From b6362be60e71d1c321228ffcfa83d5b3d31e0e65 Mon Sep 17 00:00:00 2001 From: BeRealQueally <129683130+BeRealQueally@users.noreply.github.com> Date: Sun, 16 Jun 2024 00:55:17 +0800 Subject: [PATCH] docs: fix WoA build script [skip ci] --- docs/DEVELOPERS.md | 10 +++++-- scripts/build-woa.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100755 scripts/build-woa.sh diff --git a/docs/DEVELOPERS.md b/docs/DEVELOPERS.md index 3154438..8bf219c 100644 --- a/docs/DEVELOPERS.md +++ b/docs/DEVELOPERS.md @@ -24,11 +24,15 @@ If you want to get a Deb package, run `cmake -DCPACK_GENERATOR=DEB` then `make`. Same as normal Debian/Ubuntu, however, in order to build the GBinder backends, you will need `libgbinder-dev`, `glib2.0-dev`, and you will have to pass `-DLPAC_WITH_APDU_GBINDER=ON` when invoking `cmake`. +--- + ### macOS Install [Homebrew](https://brew.sh/). Run `cmake` and `make`, compiled output will be in `output` directory. +--- + ### Windows(x86_64) Windows need libcurl.dll to run. @@ -51,6 +55,8 @@ Require `gcc-core` `gcc-g++` `make` `cmake` `unzip` `wget` installed. To run it outside Cygwin shell, you need copy `cygwin1.dll` to the program folder to distribute. `cygwin1.dll` is located in `C:\cygwin64\bin\cygwin1.dll` (Default Cygwin installation location) +--- + ### Windows on ARM #### Cross compile on Windows/Linux host(arm64,x86_64 and more architecture) with zig @@ -60,7 +66,7 @@ Install [zig](https://ziglang.org/download/) ```bash # clone this repo in the top-level folder -./scripts/build-ci.sh woa-zig +./scripts/build-woa.sh woa-zig ``` #### Cross compile on Linux x86_64 host(GNU toolchain) @@ -68,7 +74,7 @@ Install [zig](https://ziglang.org/download/) ```bash # clone this repo in the top-level folder -./scripts/build-ci.sh woa-mingw +./scripts/build-woa.sh woa-mingw ``` #### Build on Native Windows on ARM(MSYS2) diff --git a/scripts/build-woa.sh b/scripts/build-woa.sh new file mode 100755 index 0000000..473ddd2 --- /dev/null +++ b/scripts/build-woa.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -euo pipefail +WORKSPACE="$(pwd)" +CURL_VERSION="8.6.0_1" +WOA_TOOLCHAIN_VERSION="2024-02-08" +MINGW_CURL_WIN64A_BLOB="https://curl.se/windows/dl-$CURL_VERSION/curl-$CURL_VERSION-win64a-mingw.zip" +MINGW32_TOOLCHAIN_BLOB="https://github.com/Windows-on-ARM-Experiments/mingw-woarm64-build/releases/download/$WOA_TOOLCHAIN_VERSION/aarch64-w64-mingw32-msvcrt-toolchain.tar.gz" + + +function download { + URL="$1" + SAVED_PATH="$(mktemp)" + SAVED_DIR="$(mktemp -d)" + wget --no-verbose "$URL" -O "$SAVED_PATH" + case "$URL" in + *.zip) + unzip -q -d "$SAVED_DIR" "$SAVED_PATH" + rm "$SAVED_PATH" + echo "$SAVED_DIR" + ;; + *.tar.gz) + tar -C "$SAVED_DIR" --gzip --extract --file="$SAVED_PATH" + rm "$SAVED_PATH" + echo "$SAVED_DIR" + ;; + *) + echo "$SAVED_PATH" + ;; + esac +} + +set -x + +BUILD="$(mktemp -d)" +cd "$BUILD" || exit 1 + + +case "${1:-}" in +woa-mingw) + TOOLCHAIN="$(download "$MINGW32_TOOLCHAIN_BLOB")" + cmake "$WORKSPACE" -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64-woa.cmake "-DTOOLCHAIN_BIN_PATH=$TOOLCHAIN/bin" + make -j + CURL="$(download "$MINGW_CURL_WIN64A_BLOB")" + cp "$CURL"/curl-*-mingw/bin/libcurl-arm64.dll output/libcurl.dll + cp "$CURL"/curl-*-mingw/COPYING.txt output/libcurl-LICENSE + cp "$WORKSPACE/src/LICENSE" output/lpac-LICENSE + cp "$WORKSPACE/euicc/LICENSE" output/libeuicc-LICENSE + cp "$WORKSPACE/cjson/LICENSE" output/cjson-LICENSE + cp "$WORKSPACE/dlfcn-win32/LICENSE" output/dlfcn-win32-LICENSE + ;; +woa-zig) + cmake "$WORKSPACE" -DCMAKE_TOOLCHAIN_FILE=./cmake/aarch64-windows-zig.cmake + make -j + CURL="$(download "$MINGW_CURL_WIN64A_BLOB")" + cp "$CURL"/curl-*-mingw/bin/libcurl-arm64.dll output/libcurl.dll + cp "$CURL"/curl-*-mingw/COPYING.txt output/libcurl-LICENSE + cp "$WORKSPACE/src/LICENSE" output/lpac-LICENSE + cp "$WORKSPACE/euicc/LICENSE" output/libeuicc-LICENSE + cp "$WORKSPACE/cjson/LICENSE" output/cjson-LICENSE + cp "$WORKSPACE/dlfcn-win32/LICENSE" output/dlfcn-win32-LICENSE + ;; +*) + echo "Usage: $0 {woa-mingw,woa-zig}" + exit 1 + ;; +esac + +rm -rf "$BUILD"