From fafd9bdcabf15d243ea331096f8eac7f0ff5f455 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 28 Oct 2020 00:46:37 +0800 Subject: [PATCH 1/3] add cross for zlib --- .github/workflows/cross_musl.yml | 30 ++++++++++++++++++++++++++++++ packages/z/zlib/xmake.lua | 2 +- scripts/packages.lua | 2 +- scripts/test.lua | 30 +++++++++++++++++------------- 4 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/cross_musl.yml diff --git a/.github/workflows/cross_musl.yml b/.github/workflows/cross_musl.yml new file mode 100644 index 000000000..0a7ba48ad --- /dev/null +++ b/.github/workflows/cross_musl.yml @@ -0,0 +1,30 @@ +name: Cross (Musl) + +on: + pull_request: + push: + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest] + arch: [arm, aarch64] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v1 + - uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: branch@dev + + - name: Installation + run: | + wget https://musl.cc/${{ matrix.arch }}-linux-musleabi-cross.tgz + tar -xvf ${{ matrix.arch }}-linux-musleabi-cross.tgz + + - name: Tests + run: | + xmake l ./scripts/test.lua -D -k ${{ matrix.kind }} -p cross --sdk=`pwd`/${{ matrix.arch }}-linux-musleabi-cross + diff --git a/packages/z/zlib/xmake.lua b/packages/z/zlib/xmake.lua index 19ce3891e..876c69467 100644 --- a/packages/z/zlib/xmake.lua +++ b/packages/z/zlib/xmake.lua @@ -30,7 +30,7 @@ package("zlib") import("package.tools.autoconf").install(package, {"--static"}) end) - on_install("iphoneos", "android@linux,macosx", "mingw@linux,macosx", function (package) + on_install("iphoneos", "android@linux,macosx", "mingw@linux,macosx", "cross", function (package) import("package.tools.autoconf").configure(package, {host = "", "--static"}) io.gsub("Makefile", "\nAR=.-\n", "\nAR=" .. (package:build_getenv("ar") or "") .. "\n") io.gsub("Makefile", "\nARFLAGS=.-\n", "\nARFLAGS=cr\n") diff --git a/scripts/packages.lua b/scripts/packages.lua index 91ab4b1ca..68b49d266 100644 --- a/scripts/packages.lua +++ b/scripts/packages.lua @@ -60,7 +60,7 @@ function main(opt) local packagefile = path.join(packagedir, "xmake.lua") local instance = package.load_from_repository(packagename, nil, packagedir, packagefile) if instance then - for _, plat in ipairs({"windows", "linux", "macosx", "iphoneos", "android", "mingw", "msys", "bsd"}) do + for _, plat in ipairs({"windows", "linux", "macosx", "iphoneos", "android", "mingw", "msys", "bsd", "cross"}) do local archs = platform.archs(plat) if archs then local package_archs = {} diff --git a/scripts/test.lua b/scripts/test.lua index 20c433a31..5c0a433f8 100644 --- a/scripts/test.lua +++ b/scripts/test.lua @@ -6,19 +6,20 @@ import("packages", {alias = "get_packages"}) -- the options local options = { - {'v', "verbose", "k", nil, "Enable verbose information." } -, {'D', "diagnosis", "k", nil, "Enable diagnosis information." } -, {nil, "shallow", "k", nil, "Only install the root packages." } -, {'k', "kind", "kv", nil, "Enable static/shared library." } -, {'p', "plat", "kv", nil, "Set the given platform." } -, {'a', "arch", "kv", nil, "Set the given architecture." } -, {'m', "mode", "kv", nil, "Set the given mode." } -, {nil, "cflags", "kv", nil, "Set the cflags." } -, {nil, "cxxflags", "kv", nil, "Set the cxxflags." } -, {nil, "ldflags", "kv", nil, "Set the ldflags." } -, {nil, "ndk", "kv", nil, "Set the android NDK directory." } -, {nil, "mingw", "kv", nil, "Set the MingW directory." } -, {nil, "packages", "vs", nil, "The package list." } + {'v', "verbose", "k", nil, "Enable verbose information." } +, {'D', "diagnosis", "k", nil, "Enable diagnosis information." } +, {nil, "shallow", "k", nil, "Only install the root packages." } +, {'k', "kind", "kv", nil, "Enable static/shared library." } +, {'p', "plat", "kv", nil, "Set the given platform." } +, {'a', "arch", "kv", nil, "Set the given architecture." } +, {'m', "mode", "kv", nil, "Set the given mode." } +, {nil, "cflags", "kv", nil, "Set the cflags." } +, {nil, "cxxflags", "kv", nil, "Set the cxxflags." } +, {nil, "ldflags", "kv", nil, "Set the ldflags." } +, {nil, "ndk", "kv", nil, "Set the android NDK directory." } +, {nil, "sdk", "kv", nil, "Set the SDK directory of cross toolchain." } +, {nil, "mingw", "kv", nil, "Set the MingW directory." } +, {nil, "packages", "vs", nil, "The package list." } } -- require packages @@ -42,6 +43,9 @@ function _require_packages(argv, packages) if argv.ndk then table.insert(config_argv, "--ndk=" .. argv.ndk) end + if argv.sdk then + table.insert(config_argv, "--sdk=" .. argv.sdk) + end if argv.mingw then table.insert(config_argv, "--mingw=" .. argv.mingw) end From 67c50ae05fc26ce5c07c33b1754fe16e74983643 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 28 Oct 2020 00:49:46 +0800 Subject: [PATCH 2/3] fix cross yml --- .github/workflows/cross_musl.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cross_musl.yml b/.github/workflows/cross_musl.yml index 0a7ba48ad..8c73d1451 100644 --- a/.github/workflows/cross_musl.yml +++ b/.github/workflows/cross_musl.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - arch: [arm, aarch64] + cross: [arm-linux-musleabi, aarch64-linux-musl] runs-on: ${{ matrix.os }} @@ -21,10 +21,10 @@ jobs: - name: Installation run: | - wget https://musl.cc/${{ matrix.arch }}-linux-musleabi-cross.tgz - tar -xvf ${{ matrix.arch }}-linux-musleabi-cross.tgz + wget https://musl.cc/${{ matrix.cross }}-cross.tgz + tar -xvf ${{ matrix.cross }}-cross.tgz - name: Tests run: | - xmake l ./scripts/test.lua -D -k ${{ matrix.kind }} -p cross --sdk=`pwd`/${{ matrix.arch }}-linux-musleabi-cross + xmake l ./scripts/test.lua -D -p cross --sdk=`pwd`/${{ matrix.cross }}-cross From 0b4738c1adb5061fe93f71c6dc731849d5f0e5f4 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 30 Oct 2020 22:42:00 +0800 Subject: [PATCH 3/3] add cross for openssl --- packages/o/openssl/xmake.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/o/openssl/xmake.lua b/packages/o/openssl/xmake.lua index f9e2c31c9..2d07f3438 100644 --- a/packages/o/openssl/xmake.lua +++ b/packages/o/openssl/xmake.lua @@ -14,10 +14,27 @@ package("openssl") add_versions("github:1.0.2", "b61942861405c634f86ca2b8dd1a34687e24b5036598d0fa971fac02405fdb1a") add_versions("github:1.0.0", "9b67e5ad1a4234c1170ada75b66321e914da4f3ebaeaef6b28400173aaa6b378") + add_links("ssl", "crypto") + on_install("linux", "macosx", function (package) os.vrun("./config %s --prefix=\"%s\"", package:debug() and "--debug" or "", package:installdir()) - os.vrun("make -j4") - os.vrun("make install") + import("package.tools.make").install(package) + end) + + on_install("cross", function (package) + local target = "linux-generic32" + if package:is_os("linux") then + if package:is_arch("arm64") then + target = "linux-aarch64" + else + target = "linux-armv4" + end + end + local configs = {target, "-DOPENSSL_NO_HEARTBEATS", "no-shared", "no-threads", "--prefix=" .. package:installdir()} + local buildenvs = import("package.tools.autoconf").buildenvs(package) + os.vrunv("./Configure", configs, {envs = buildenvs}) + local makeconfigs = {CFLAGS = buildenvs.CFLAGS, ASFLAGS = buildenvs.ASFLAGS} + import("package.tools.make").install(package, makeconfigs) end) on_test(function (package)