Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QuickJS as a Javascript engine option #5052

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[fixup] no lto for freebsd
  • Loading branch information
nickva committed May 12, 2024
commit 4408d4c2414f8e6dc246c5e54a91abba147e9e75
24 changes: 18 additions & 6 deletions src/couch_quickjs/rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Msys = "msys2_shell.cmd -defterm -no-start -ucrt64 -here -lc ".

PreHooks = [
{"(linux|darwin)", compile, "make CONFIG_LTO=y -C quickjs -j8 libquickjs.lto.a qjsc"},
{"freebsd", compile, "gmake CONFIG_LTO=y -C quickjs -j8 libquickjs.lto.a qjsc"},
{"freebsd", compile, "gmake -C quickjs -j8 libquickjs.a qjsc"},
{"win32", compile, Msys ++ "'make -C quickjs qjsc'"},
{"(linux|darwin|freebsd|win32)", compile, "escript build_js.escript compile"}
].
Expand All @@ -29,15 +29,25 @@ PostHooks = [
{"(linux|darwin|freebsd|win32)", clean, "escript build_js.escript clean"}
].

UnixEnv = [
{"CFLAGS", "$CFLAGS -flto -g -Wall -DCONFIG_LTO=y -O2 -Iquickjs"},
{"LDFLAGS", "$LDFLAGS -flto -lm quickjs/libquickjs.lto.a"},
% We're not building a driver just an executable so we don't
% need all the Erlang/OTP headers and libraries
ResetFlags = [
{"ERL_CFLAGS", ""},
{"ERL_LDFLAGS", ""},
{"EXE_CFLAGS", ""},
{"EXE_LDFLAGS", ""}
].

LinuxDarwinEnv = [
{"CFLAGS", "$CFLAGS -flto -g -Wall -DCONFIG_LTO=y -O2 -Iquickjs"},
{"LDFLAGS", "$LDFLAGS -flto -lm quickjs/libquickjs.lto.a"}
] ++ ResetFlags.

FreeBSDEnv = [
{"CFLAGS", "$CFLAGS -g -Wall -O2 -Iquickjs"},
{"LDFLAGS", "$LDFLAGS -lm -lpthread quickjs/libquickjs.a"}
] ++ ResetFlags.

WindowsEnv = [
{"CFLAGS", "-D_GNU_SOURCE -DCONFIG_BIGNUM -O2 -fwrapv -DCONFIG_VERSION=\\\"0\\\" -Iquickjs"},
{"EXE_CC_TEMPLATE", "gcc.exe -g -c $CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
Expand All @@ -62,8 +72,10 @@ WindowsMainjsSrc = WindowsBaseSrc ++ UnixMainjsSrc.
WindowsCoffeeSrc = WindowsBaseSrc ++ UnixCoffeeSrc.

PortSpecs = [
{"(linux|darwin|freebsd)", "priv/couchjs_mainjs", UnixMainjsSrc, [{env, UnixEnv}]},
{"(linux|darwin|freebsd)", "priv/couchjs_coffee", UnixCoffeeSrc, [{env, UnixEnv}]},
{"(linux|darwin)", "priv/couchjs_mainjs", UnixMainjsSrc, [{env, LinuxDarwinEnv}]},
{"(linux|darwin)", "priv/couchjs_coffee", UnixCoffeeSrc, [{env, LinuxDarwinEnv}]},
{"freebsd", "priv/couchjs_mainjs", UnixMainjsSrc, [{env, FreeBSDEnv}]},
{"freebsd", "priv/couchjs_coffee", UnixCoffeeSrc, [{env, FreeBSDEnv}]},
{"win32", "priv/couchjs_mainjs.exe", WindowsMainjsSrc, [{env, WindowsEnv}]},
{"win32", "priv/couchjs_coffee.exe", WindowsCoffeeSrc, [{env, WindowsEnv}]}
].
Expand Down