Skip to content

Commit

Permalink
Fix build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tindy2013 committed Dec 10, 2023
1 parent 844989d commit 275f77a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Publish Docker Image
on:
push:
branches: [ master ]
branches:
- '**'
tags:
- '**'

Expand Down
6 changes: 3 additions & 3 deletions scripts/build.alpine.release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.macos.release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.windows.release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
54 changes: 54 additions & 0 deletions xmake/quickjspp.lua
Original file line number Diff line number Diff line change
@@ -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 <iostream>
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", "<input>", 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)

0 comments on commit 275f77a

Please sign in to comment.