Skip to content

Commit

Permalink
chore: refactor build script (#119)
Browse files Browse the repository at this point in the history
* refactor: build script

* docs: update build guide for WoA

---------

Co-authored-by: FakeQueally <[email protected]>
  • Loading branch information
septs and BeRealQueally authored Jun 16, 2024
1 parent b6362be commit 6e295db
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.build.artifact }}
path: ${{ github.workspace }}/action/lpac*.*
path: ${{ github.workspace }}/build/*.*
release:
name: Release
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions docs/DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ Install [zig](https://ziglang.org/download/)
```bash
# clone this repo in the top-level folder

./scripts/build-woa.sh woa-zig
./scripts/build-woa.sh zig
```

#### Cross compile on Linux x86_64 host(GNU toolchain)

```bash
# clone this repo in the top-level folder

./scripts/build-woa.sh woa-mingw
./scripts/build-woa.sh mingw
```

#### Build on Native Windows on ARM(MSYS2)
Expand Down
37 changes: 15 additions & 22 deletions scripts/build-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,35 @@ set -x

BUILD="$(mktemp -d)"
cd "$BUILD" || exit 1
mkdir "$WORKSPACE"/action

ARTIFACT="$WORKSPACE/build"

mkdir "$BUILD/output"
[ -d "$ARTIFACT" ] || mkdir "$ARTIFACT"

cp "$WORKSPACE/src/LICENSE" "$BUILD/output/lpac-LICENSE"
cp "$WORKSPACE/euicc/LICENSE" "$BUILD/output/libeuicc-LICENSE"
cp "$WORKSPACE/cjson/LICENSE" "$BUILD/output/cjson-LICENSE"
cp "$WORKSPACE/dlfcn-win32/LICENSE" "$BUILD/output/dlfcn-win32-LICENSE"

case "${1:-}" in
make)
cmake "$WORKSPACE"
make -j
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
zip -r -j "$WORKSPACE/action/lpac-$KERNEL-$MATCHINE.zip" output/*
zip -r -j "$ARTIFACT/lpac-$KERNEL-$MATCHINE.zip" output/*
;;
debian)
cmake "$WORKSPACE" -DCPACK_GENERATOR=DEB
make -j package
cp lpac_*.deb "$WORKSPACE"/action
cp lpac_*.deb "$ARTIFACT"
;;
mingw)
cmake "$WORKSPACE" -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake
make -j
CURL="$(download "$MINGW_CURL_WIN64_BLOB")"
cp "$CURL"/curl-*-mingw/bin/libcurl-x64.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
zip -r -j "$WORKSPACE/action/lpac-windows-x86_64-mingw.zip" output/*
zip -r -j "$ARTIFACT/lpac-windows-x86_64-mingw.zip" output/*
;;
woa-mingw)
TOOLCHAIN="$(download "$MINGW32_TOOLCHAIN_BLOB")"
Expand All @@ -81,23 +82,15 @@ woa-mingw)
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
zip -r -j "$WORKSPACE/action/lpac-windows-arm64-mingw.zip" output/*
zip -r -j "$ARTIFACT/lpac-windows-arm64-mingw.zip" output/*
;;
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
zip -r -j "$WORKSPACE/action/lpac-windows-arm64-zig.zip" output/*
zip -r -j "$ARTIFACT/lpac-windows-arm64-zig.zip" output/*
;;
*)
echo "Usage: $0 {make,debian,mingw,woa-mingw,woa-zig}"
Expand Down
20 changes: 8 additions & 12 deletions scripts/build-woa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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)"
Expand Down Expand Up @@ -34,33 +33,30 @@ set -x
BUILD="$(mktemp -d)"
cd "$BUILD" || exit 1

mkdir "$BUILD/output"
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

case "${1:-}" in
woa-mingw)
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)
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}"
echo "Usage: $0 {mingw,zig}"
exit 1
;;
esac
Expand Down

0 comments on commit 6e295db

Please sign in to comment.