diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f624e396a..79b98156a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,7 +1,8 @@ name: Publish Docker Image on: push: - branches: [ master ] + branches: + - '**' tags: - '**' diff --git a/scripts/build.alpine.release.sh b/scripts/build.alpine.release.sh index a8c602338..50998fa8f 100644 --- a/scripts/build.alpine.release.sh +++ b/scripts/build.alpine.release.sh @@ -47,13 +47,13 @@ set -xe ## shellcheck disable=SC2046 #g++ -o base/subconverter $(find CMakeFiles/subconverter.dir/src/ -name "*.o") -static -lpcre2-8 -lyaml-cpp -L/usr/lib64 -lcurl -lmbedtls -lmbedcrypto -lmbedx509 -lz -l:quickjs/libquickjs.a -llibcron -O3 -s -apk add git g++ build-base linux-headers cmake python3 curl unzip p7zip +apk add git g++ build-base linux-headers cmake python3 curl unzip p7zip perl apk add lua5.4-dev luajit-dev mbedtls-dev mbedtls-static zlib-dev curl -fsSL https://xmake.io/shget.text | bash source "$HOME/.xmake/profile" -xmake f --root --static=true -m release -y -xmake --root subconverter +xmake f --root --static=true -m release -y -v +xmake --root -v subconverter cp "$(find build -name subconverter -type f)" base/subconverter python3 -m ensurepip diff --git a/scripts/build.macos.release.sh b/scripts/build.macos.release.sh index ec124ca1a..df447faa2 100644 --- a/scripts/build.macos.release.sh +++ b/scripts/build.macos.release.sh @@ -57,8 +57,8 @@ set -xe brew reinstall xmake rapidjson pkgconfig -xmake f --root -m release -y -xmake --root subconverter +xmake f --root -m release -y -v +xmake --root -v subconverter cp "$(find build -name subconverter -type f)" base/subconverter python -m ensurepip diff --git a/scripts/build.windows.release.sh b/scripts/build.windows.release.sh index 9fbf305da..167f54309 100644 --- a/scripts/build.windows.release.sh +++ b/scripts/build.windows.release.sh @@ -51,8 +51,8 @@ set -xe ## shellcheck disable=SC2046 #g++ $(find CMakeFiles/subconverter.dir/src -name "*.obj") curl/lib/libcurl.a -o base/subconverter.exe -static -lbcrypt -lpcre2-8 -l:quickjs/libquickjs.a -llibcron -lyaml-cpp -liphlpapi -lcrypt32 -lws2_32 -lwsock32 -lz -s -xmake f --root --static=true -m release -y -xmake --root subconverter +xmake f --root --static=true -m release -y -v +xmake --root -v subconverter cp "$(find build -name subconverter -type f)" base/subconverter python -m ensurepip diff --git a/xmake.lua b/xmake.lua index de0865b08..be390d082 100644 --- a/xmake.lua +++ b/xmake.lua @@ -7,11 +7,13 @@ option("static") set_description("Build static binary.") option_end() -add_requires("libcurl >=8.4.0", "pcre2", "yaml-cpp", "rapidjson", "toml11", "quickjspp") +add_requires("libcurl >=8.4.0", "pcre2", "yaml-cpp", "rapidjson", "toml11") includes("xmake/libcron.lua") includes("xmake/yaml-cpp-static.lua") +includes("xmake/quickjspp.lua") add_requires("libcron", {system = false}) add_requires("yaml-cpp-static", {system = false}) +add_requires("quickjspp", {system = false}) target("subconverter") set_kind("binary") diff --git a/xmake/quickjspp.lua b/xmake/quickjspp.lua new file mode 100644 index 000000000..292fbb3c8 --- /dev/null +++ b/xmake/quickjspp.lua @@ -0,0 +1,54 @@ +package("quickjspp") + + set_homepage("https://github.com/ftk/quickjspp") + set_description("QuickJS C++ wrapper") + + add_urls("https://github.com/ftk/quickjspp.git") + add_versions("2022.7.22", "9cee4b4d27271d54b95f6f42bfdc534ebeaaeb72") + + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + + add_includedirs("include", "include/quickjs") + add_linkdirs("lib/quickjs") + add_links("quickjs") + + add_deps("cmake") + + if is_plat("linux") then + add_syslinks("pthread", "dl", "m") + end + + on_install("linux", "macosx", "windows", function (package) + local configs = {"-DBUILD_TESTING=OFF"} + -- TODO, disable lto, maybe we need do it better + io.replace("CMakeLists.txt", "set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)", "", {plain = true}) + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + import("package.tools.cmake").install(package, configs, {}) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + void test() { + using namespace qjs; + Runtime runtime; + Context context(runtime); + auto rt = runtime.rt; + auto ctx = context.ctx; + js_std_init_handlers(rt); + js_init_module_std(ctx, "std"); + js_init_module_os(ctx, "os"); + context.eval(R"xxx( + import * as std from 'std'; + import * as os from 'os'; + globalThis.std = std; + globalThis.os = os; + )xxx", "", JS_EVAL_TYPE_MODULE); + + js_std_loop(ctx); + js_std_free_handlers(rt); + + } + ]]}, {configs = {languages = "c++17"}, + includes = {"quickjspp.hpp","quickjs/quickjs-libc.h"}})) + end) \ No newline at end of file