Skip to content

Commit 56738d8

Browse files
authored
Add Cygwin compatibility
1 parent 9c2614c commit 56738d8

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,39 @@ jobs:
350350
emmake make -C build qjs_wasm -j$(getconf _NPROCESSORS_ONLN)
351351
- name: result
352352
run: ls -lh build
353+
354+
cygwin:
355+
runs-on: windows-latest
356+
defaults:
357+
run:
358+
shell: C:\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
359+
steps:
360+
- name: Set up Cygwin
361+
uses: cygwin/cygwin-install-action@master
362+
with:
363+
packages: make cmake gcc-g++ bash
364+
365+
- uses: actions/checkout@v3
366+
367+
- name: build
368+
369+
# Plain `make` fails here with this error:
370+
# No rule to make target '/cygdrive/d/a/quickjs-ng/quickjs-ng/cutils.c',
371+
# needed by 'CMakeFiles/qjs.dir/cutils.c.o'. Stop.
372+
#
373+
# For some reason, making the build directory then `make`ing in there
374+
# fixes it.
375+
run: |
376+
cd $GITHUB_WORKSPACE
377+
make build/CMakeCache.txt
378+
make --directory build
379+
380+
- name: stats
381+
run: |
382+
cd $GITHUB_WORKSPACE
383+
make --debug stats
384+
385+
- name: test
386+
run: |
387+
cd $GITHUB_WORKSPACE
388+
make --debug test

qjs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <time.h>
3737
#if defined(__APPLE__)
3838
#include <malloc/malloc.h>
39-
#elif defined(__linux__)
39+
#elif defined(__linux__) || defined(__CYGWIN__)
4040
#include <malloc.h>
4141
#endif
4242

@@ -259,7 +259,7 @@ static const JSMallocFunctions trace_mf = {
259259
(size_t (*)(const void *))_msize,
260260
#elif defined(EMSCRIPTEN)
261261
NULL,
262-
#elif defined(__linux__)
262+
#elif defined(__linux__) || defined(__CYGWIN__)
263263
(size_t (*)(const void *))malloc_usable_size,
264264
#else
265265
/* change this to `NULL,` if compilation fails */

quickjs-libc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,6 +3582,8 @@ void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt))
35823582
#define OS_PLATFORM "darwin"
35833583
#elif defined(EMSCRIPTEN)
35843584
#define OS_PLATFORM "js"
3585+
#elif defined(__CYGWIN__)
3586+
#define OS_PLATFORM "cygwin"
35853587
#else
35863588
#define OS_PLATFORM "linux"
35873589
#endif

quickjs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <math.h>
3939
#if defined(__APPLE__)
4040
#include <malloc/malloc.h>
41-
#elif defined(__linux__)
41+
#elif defined(__linux__) || defined(__CYGWIN__)
4242
#include <malloc.h>
4343
#elif defined(__FreeBSD__)
4444
#include <malloc_np.h>
@@ -1722,7 +1722,7 @@ static const JSMallocFunctions def_malloc_funcs = {
17221722
(size_t (*)(const void *))_msize,
17231723
#elif defined(EMSCRIPTEN)
17241724
NULL,
1725-
#elif defined(__linux__)
1725+
#elif defined(__linux__) || defined (__CYGWIN__)
17261726
(size_t (*)(const void *))malloc_usable_size,
17271727
#else
17281728
/* change this to `NULL,` if compilation fails */

run-test262.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ int run_test(const char *filename, int index)
16681668
/* XXX: should extract the phase */
16691669
char *q = find_tag(p, "type:", &state);
16701670
if (q) {
1671-
while (isspace(*q))
1671+
while (isspace((unsigned char)*q))
16721672
q++;
16731673
error_type = strdup_len(q, strcspn(q, " \n"));
16741674
}
@@ -2089,7 +2089,7 @@ int main(int argc, char **argv)
20892089
update_exclude_dirs();
20902090

20912091
if (is_dir_list) {
2092-
if (optind < argc && !isdigit(argv[optind][0])) {
2092+
if (optind < argc && !isdigit((unsigned char)argv[optind][0])) {
20932093
filename = argv[optind++];
20942094
namelist_load(&test_list, filename);
20952095
}

tests/test_builtin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ function test_number()
345345
assert(Number.isNaN(Number("-")));
346346
assert(Number.isNaN(Number("\x00a")));
347347

348-
// TODO: Fix rounding errors on Windows.
349-
if (os.platform === 'win32') {
348+
// TODO: Fix rounding errors on Windows/Cygwin.
349+
if (['win32', 'cygwin'].includes(os.platform)) {
350350
return;
351351
}
352352

0 commit comments

Comments
 (0)