Add Cygwin compatibility

This commit is contained in:
Felipe Gasper 2023-12-03 12:15:07 -05:00 committed by GitHub
parent 9c2614c2fa
commit 56738d8b4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 8 deletions

View file

@ -350,3 +350,39 @@ jobs:
emmake make -C build qjs_wasm -j$(getconf _NPROCESSORS_ONLN)
- name: result
run: ls -lh build
cygwin:
runs-on: windows-latest
defaults:
run:
shell: C:\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
steps:
- name: Set up Cygwin
uses: cygwin/cygwin-install-action@master
with:
packages: make cmake gcc-g++ bash
- uses: actions/checkout@v3
- name: build
# Plain `make` fails here with this error:
# No rule to make target '/cygdrive/d/a/quickjs-ng/quickjs-ng/cutils.c',
# needed by 'CMakeFiles/qjs.dir/cutils.c.o'. Stop.
#
# For some reason, making the build directory then `make`ing in there
# fixes it.
run: |
cd $GITHUB_WORKSPACE
make build/CMakeCache.txt
make --directory build
- name: stats
run: |
cd $GITHUB_WORKSPACE
make --debug stats
- name: test
run: |
cd $GITHUB_WORKSPACE
make --debug test

4
qjs.c
View file

@ -36,7 +36,7 @@
#include <time.h>
#if defined(__APPLE__)
#include <malloc/malloc.h>
#elif defined(__linux__)
#elif defined(__linux__) || defined(__CYGWIN__)
#include <malloc.h>
#endif
@ -259,7 +259,7 @@ static const JSMallocFunctions trace_mf = {
(size_t (*)(const void *))_msize,
#elif defined(EMSCRIPTEN)
NULL,
#elif defined(__linux__)
#elif defined(__linux__) || defined(__CYGWIN__)
(size_t (*)(const void *))malloc_usable_size,
#else
/* change this to `NULL,` if compilation fails */

View file

@ -3582,6 +3582,8 @@ void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt))
#define OS_PLATFORM "darwin"
#elif defined(EMSCRIPTEN)
#define OS_PLATFORM "js"
#elif defined(__CYGWIN__)
#define OS_PLATFORM "cygwin"
#else
#define OS_PLATFORM "linux"
#endif

View file

@ -38,7 +38,7 @@
#include <math.h>
#if defined(__APPLE__)
#include <malloc/malloc.h>
#elif defined(__linux__)
#elif defined(__linux__) || defined(__CYGWIN__)
#include <malloc.h>
#elif defined(__FreeBSD__)
#include <malloc_np.h>
@ -1722,7 +1722,7 @@ static const JSMallocFunctions def_malloc_funcs = {
(size_t (*)(const void *))_msize,
#elif defined(EMSCRIPTEN)
NULL,
#elif defined(__linux__)
#elif defined(__linux__) || defined (__CYGWIN__)
(size_t (*)(const void *))malloc_usable_size,
#else
/* change this to `NULL,` if compilation fails */

View file

@ -1668,7 +1668,7 @@ int run_test(const char *filename, int index)
/* XXX: should extract the phase */
char *q = find_tag(p, "type:", &state);
if (q) {
while (isspace(*q))
while (isspace((unsigned char)*q))
q++;
error_type = strdup_len(q, strcspn(q, " \n"));
}
@ -2089,7 +2089,7 @@ int main(int argc, char **argv)
update_exclude_dirs();
if (is_dir_list) {
if (optind < argc && !isdigit(argv[optind][0])) {
if (optind < argc && !isdigit((unsigned char)argv[optind][0])) {
filename = argv[optind++];
namelist_load(&test_list, filename);
}

View file

@ -345,8 +345,8 @@ function test_number()
assert(Number.isNaN(Number("-")));
assert(Number.isNaN(Number("\x00a")));
// TODO: Fix rounding errors on Windows.
if (os.platform === 'win32') {
// TODO: Fix rounding errors on Windows/Cygwin.
if (['win32', 'cygwin'].includes(os.platform)) {
return;
}