1DOLLY 82PACKAGE quickjs3REQUIRES HOST runtime@04REQUIRES HOST threads@056# QuickJS-ng from its pinned checkout, unchanged, as upstream's CMakeLists.txt7# builds it for Unix: the engine as a library (-lquickjs, <quickjs.h>) and8# upstream's qjs, the engine with its own std, os and bjson modules and nothing9# of Node. The library is compiled without -pthread, so that a program linking10# it is one thread unless it asks for more; qjs, whose os.Worker starts11# threads, is compiled with it and linked through Binaryen's cast emulation:12# upstream starts a Worker's thread through a pointer of another type13# (js_thread_create in cutils.h). os.exec fails because nothing here forks.14FROM /Dollyfile-system-tools 7dc08859cff6c590c9bf42278822be15b530cc9d18438481449469995c2bf8fe15USE /demos/tools/Dollyfile-binaryen c2aed2b9b7b56e03f139b58f6c295403d5ccab0d072d8f7bbcbe6bb0c9a8217b1617REQUIRES HEADER libc18REQUIRES TOOL   ar19REQUIRES TOOL   cc20REQUIRES TOOL   cp21REQUIRES TOOL   make22REQUIRES TOOL   mkdir23REQUIRES TOOL   tar24REQUIRES TOOL   wasm-opt2526SOURCE /dist/static/default/quickjs.tar 9fd1cf2a32d292362acf460b48b2332e1e4a8dd49e603b62ad9ba87bc1205af8 /tmp/quickjs.tar27SLOP tar -xf /tmp/quickjs.tar -C /2829FILE /tmp/quickjs.mk30    .RECIPEPREFIX := >31    SOURCE := /usr/src/quickjs32    ENGINE := dtoa libregexp libunicode quickjs33    COMMAND := qjs quickjs-libc gen/repl gen/standalone34    CFLAGS := -O2 -std=gnu11 -funsigned-char -D_GNU_SOURCE -DQUICKJS_NG_BUILD -DNDEBUG35    objects = $(addprefix $(SOURCE)/$(2)/,$(addsuffix .o,$(1)))36    all: /usr/lib/libquickjs.a /usr/bin/qjs37    $(SOURCE)/library/%.o: $(SOURCE)/%.c38    >mkdir -p $(@D)39    >cc $(CFLAGS) -c $< -o $@40    $(SOURCE)/threaded/%.o: $(SOURCE)/%.c41    >mkdir -p $(@D)42    >cc $(CFLAGS) -pthread -c $< -o $@43    /usr/lib/libquickjs.a: $(call objects,$(ENGINE),library)44    >ar rcs $@ $^45    /usr/bin/qjs: $(call objects,$(ENGINE) $(COMMAND),threaded)46    >cc -pthread --dolly-cast-emulation $^ -o $@47SLOP make -j4 -f /tmp/quickjs.mk48SLOP cp /usr/src/quickjs/quickjs.h /usr/include/quickjs.h4950SLOP test "$(qjs -e 'console.log(6 * 7)')" = 4251FILE /tmp/quickjs-worker.mjs52    import * as os from "qjs:os";53    const parent = os.Worker.parent;54    if (parent) {55      parent.onmessage = message => { parent.postMessage(message.data * 2); parent.onmessage = null; };56    } else {57      const worker = new os.Worker("/tmp/quickjs-worker.mjs");58      worker.onmessage = message => {59        const shared = new Int32Array(new SharedArrayBuffer(4));60        console.log(message.data, Atomics.add(shared, 0, 1) + Atomics.load(shared, 0));61        worker.onmessage = null;62      };63      worker.postMessage(21);64    }65SLOP test "$(qjs -m /tmp/quickjs-worker.mjs)" = "42 1"66# qjs --help ends with status 1.67SLOP qjs --help > /usr/share/man/cat1/qjs.1 || test -s /usr/share/man/cat1/qjs.16869EXPORTS TOOL   qjs70EXPORTS LIB    quickjs /usr/lib/libquickjs.a71EXPORTS HEADER quickjs /usr/include/quickjs.h72FILE /usr/share/man/cat1/qjs.173FILE /usr/share/licenses/quickjs-ng/LICENSE74