| 123456789101112131415161718192021222324252627282930313233 |
- #!/bin/sh
- # Build the vendored QuickJS interpreter (`qjs`) for the JS test harness
- # (tests/markdown/run.sh). Only the 8 C files the interpreter needs are
- # vendored, so we compile them directly rather than driving upstream's
- # Makefile (whose default target also builds qjsc, run-test262, examples
- # and a qjsc-generated repl.c rule we have no sources for).
- #
- # The build is skipped when a system `qjs` is already available; set
- # FORCE_BUILD_QJS=1 to build anyway.
- set -e
- cd "$(dirname "$0")"
- if command -v qjs >/dev/null 2>&1 && [ -z "$FORCE_BUILD_QJS" ]; then
- echo "[qjs] using system qjs: $(command -v qjs)"
- exit 0
- fi
- VERSION=$(cat VERSION)
- # The quotes are consumed by the shell: gcc ends up seeing the macro value
- # wrapped in literal double quotes, i.e. a valid C string literal.
- VERDEF='-DCONFIG_VERSION="'"$VERSION"'"'
- CFLAGS="-g -Wall -Wno-array-bounds -Wno-format-truncation -Wno-infinite-recursion -fwrapv -D_GNU_SOURCE $VERDEF -DHAVE_CLOSEFROM -O2"
- OBJS="quickjs dtoa libregexp libunicode cutils quickjs-libc qjs repl"
- rm -rf .obj
- mkdir -p .obj
- for base in $OBJS; do
- echo "[qjs] CC $base.c"
- gcc $CFLAGS -c -o ".obj/$base.o" "$base.c"
- done
- echo "[qjs] LD qjs"
- gcc -rdynamic -o qjs $(for base in $OBJS; do echo ".obj/$base.o"; done) -lm -lpthread -ldl
- echo "[qjs] built $(pwd)/qjs"
|