Skip to content

Commit e76554c

Browse files
authored
compat.quickjs-ng 0.17.0 on macOS and Windows (#582)
* compat.quickjs-ng 0.17.0 on macOS and Windows The descriptor declared Linux only. Upstream builds the same four sources with the same flags on all three platforms, and openmui's TypeScript binding embeds the engine on every desktop. macOS needs nothing more (libSystem has libm and pthreads). Windows adds _CRT_SECURE_NO_WARNINGS, as upstream's CMake does for MSVC-ABI builds. The test is no longer gated to Linux, so it now evaluates the same JavaScript on macOS and Windows. Checked locally on x86_64-linux-gnu, and for x86_64-windows-gnu under wine. * tests/examples/quickjs-ng: the dependency in the form the candidate check rewrites
1 parent cf56364 commit e76554c

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

‎pkgs/c/compat.quickjs-ng.lua‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
-- keeps its assertions and its debug-dump code (quickjs.c:84-86); upstream's
4747
-- default build type (Release) would define it.
4848
--
49-
-- LINUX ONLY. Built and tested with llvm 22.1.8 on x86_64-linux-gnu, and in an
50-
-- openkal graph for x86_64-linux-gnu. Upstream supports macOS and Windows, but
51-
-- nothing here has built the package there, so those sections are not declared.
49+
-- PLATFORMS. Linux (llvm 22.1.8 on x86_64-linux-gnu, and in an openkal graph),
50+
-- macOS and Windows: the same four sources and flags, as upstream's own CI
51+
-- builds them on all three (clang and MSVC-ABI clang on Windows).
5252
--
5353
-- NO CN MIRROR. The url is upstream's tag archive as a plain string, the
5454
-- fallback docs/cn-mirror.md describes for a contributor without mcpp-res write
@@ -82,6 +82,18 @@ package = {
8282
sha256 = "559bc4c420475e55c7ab4510adbc562f55d7524d75e8e89d79ce4bb02f5687d9",
8383
},
8484
},
85+
macosx = {
86+
["0.17.0"] = {
87+
url = "https://github.com/quickjs-ng/quickjs/archive/refs/tags/v0.17.0.tar.gz",
88+
sha256 = "559bc4c420475e55c7ab4510adbc562f55d7524d75e8e89d79ce4bb02f5687d9",
89+
},
90+
},
91+
windows = {
92+
["0.17.0"] = {
93+
url = "https://github.com/quickjs-ng/quickjs/archive/refs/tags/v0.17.0.tar.gz",
94+
sha256 = "559bc4c420475e55c7ab4510adbc562f55d7524d75e8e89d79ce4bb02f5687d9",
95+
},
96+
},
8597
},
8698

8799
mcpp = {
@@ -111,6 +123,11 @@ package = {
111123
-- the C driver, which adds no libm, and quickjs.c's Math functions then
112124
-- fail to link. libdl is left out: only quickjs-libc.c calls dlopen.
113125
linux = { ldflags = { "-lm", "-lpthread" } },
126+
-- libSystem carries libm and pthreads: nothing to add on macOS.
127+
-- Windows: upstream's CMake adds _CRT_SECURE_NO_WARNINGS for MSVC-ABI
128+
-- builds (CMakeLists.txt, `if(MSVC)`), and quickjs.c's thread-safe
129+
-- atomics need nothing beyond the CRT.
130+
windows = { cflags = { "-D_CRT_SECURE_NO_WARNINGS" } },
114131
targets = { ["quickjs-ng"] = { kind = "lib" } },
115132
deps = { },
116133
},
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# QuickJS-ng test project: evaluate JavaScript through the engine and assert
2-
# the values it computes, one group per compiled source file.
3-
#
4-
# compat.quickjs-ng carries a `linux` section only (see the descriptor's
5-
# header), so the dependency is gated and the test compiles to a no-op main()
6-
# elsewhere, the same shape as tests/examples/libaio and tests/examples/wamr.
2+
# the values it computes, one group per compiled source file, on Linux, macOS
3+
# and Windows.
74
[package]
85
name = "quickjs-ng-tests"
96
version = "0.1.0"
107

11-
[target.'cfg(linux)'.dependencies.compat]
8+
[dependencies.compat]
129
quickjs-ng = "0.17.0"

‎tests/examples/quickjs-ng/tests/engine.cpp‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// JS_FreeRuntime asserts that no object is still alive (quickjs.c:2699) and an
1717
// object this test forgot to free aborts it.
1818

19-
#ifdef __linux__
20-
2119
#include <quickjs.h>
2220

2321
#include <cstdio>
@@ -131,9 +129,3 @@ int main() {
131129
}
132130
return 0;
133131
}
134-
135-
#else
136-
137-
int main() { return 0; } // compat.quickjs-ng declares linux only; nothing to assert here.
138-
139-
#endif

0 commit comments

Comments
 (0)