mirror of
https://github.com/estkme-group/lpac
synced 2024-07-02 14:56:39 +02:00
improve build.sh (#52)
This commit is contained in:
parent
695b72f183
commit
77ca2683da
75
.github/workflows/build.yaml
vendored
75
.github/workflows/build.yaml
vendored
|
@ -9,59 +9,58 @@ on:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-linux:
|
build:
|
||||||
name: Build on Linux
|
name: Build for ${{ matrix.build.name }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
build:
|
||||||
|
- {variant: make, name: Linux, artifact: linux-x64}
|
||||||
|
- {variant: debian, name: Debian, artifact: debian-x64}
|
||||||
|
- {variant: mingw, name: Windows with MinGW, artifact: windows-x64}
|
||||||
|
- {variant: woa-mingw, name: Windows on ARM with MinGW, artifact: windows-arm64}
|
||||||
|
include:
|
||||||
|
- os: macos-14
|
||||||
|
build: {variant: make, name: macOS, artifact: macos-universal}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Toolchain
|
- name: Setup Toolchain
|
||||||
run: ./scripts/setup-linux.sh
|
run: ./scripts/setup-debian.sh
|
||||||
- name: Build for Linux
|
if: runner.os == 'Linux'
|
||||||
run: ./scripts/build.sh linux
|
- name: Build for ${{ matrix.build.name }}
|
||||||
- name: Build for Debian
|
run: ./scripts/build.sh ${{ matrix.build.variant }}
|
||||||
run: ./scripts/build.sh debian
|
- name: Upload ${{ matrix.build.name }} to Artifact
|
||||||
- name: Build for Windows with MinGW
|
|
||||||
run: ./scripts/build.sh mingw
|
|
||||||
- name: Build for Windows on ARM with MinGW
|
|
||||||
run: ./scripts/build.sh woa-mingw
|
|
||||||
- name: Build for Windows on ARM with Zig
|
|
||||||
run: ./scripts/build.sh woa-zig
|
|
||||||
- name: Upload Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: artifact-linux
|
name: ${{ matrix.build.artifact }}
|
||||||
path: |
|
path: lpac-*.*
|
||||||
lpac-*.deb
|
|
||||||
lpac-*.zip
|
|
||||||
build-macos:
|
|
||||||
name: Build on macOS
|
|
||||||
runs-on: macos-14
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Build for macOS
|
|
||||||
run: ./scripts/build.sh macos
|
|
||||||
- name: Upload Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: artifact-macos
|
|
||||||
path: lpac-*.zip
|
|
||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
needs: [build-linux, build-macos]
|
needs: build
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Download Artifact
|
- name: Download Artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
pattern: artifact-*
|
merge-multiple: true
|
||||||
|
pattern: '*'
|
||||||
|
- name: Run SHA1SUM
|
||||||
|
id: checksum
|
||||||
|
run: |
|
||||||
|
echo 'sha1sum<<EOF' >> $GITHUB_OUTPUT
|
||||||
|
sha1sum * >> $GITHUB_OUTPUT
|
||||||
|
echo 'EOF' >> $GITHUB_OUTPUT
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: |
|
body: |
|
||||||
lpac-*.deb
|
```plain
|
||||||
lpac-*.zip
|
${{ steps.checksum.outputs.sha1sum }}
|
||||||
|
```
|
||||||
|
append_body: true
|
||||||
|
files: '*'
|
||||||
|
|
|
@ -33,7 +33,7 @@ lpac is dynamic-linked, Release is built by Github action, if you can't run it y
|
||||||
sudo apt install build-essential cmake git g++ libpcsclite-dev libcurl4-openssl-dev
|
sudo apt install build-essential cmake git g++ libpcsclite-dev libcurl4-openssl-dev
|
||||||
git clone --depth=1 https://github.com/estkme-group/lpac
|
git clone --depth=1 https://github.com/estkme-group/lpac
|
||||||
cd lpac
|
cd lpac
|
||||||
./scripts/build.sh linux
|
./scripts/build.sh make
|
||||||
```
|
```
|
||||||
|
|
||||||
then execute `./output/lpac` to use.
|
then execute `./output/lpac` to use.
|
||||||
|
@ -52,7 +52,7 @@ Same as normal Debian/Ubuntu, however, in order to build the GBinder backends, y
|
||||||
```bash
|
```bash
|
||||||
git clone --depth=1 https://github.com/estkme-group/lpac
|
git clone --depth=1 https://github.com/estkme-group/lpac
|
||||||
cd lpac
|
cd lpac
|
||||||
./scripts/build.sh macos
|
./scripts/build.sh make
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
@ -74,7 +74,7 @@ cd lpac
|
||||||
- Build on Windows(MSYS2)
|
- Build on Windows(MSYS2)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc
|
||||||
git clone --depth=1 https://github.com/estkme-group/lpac
|
git clone --depth=1 https://github.com/estkme-group/lpac
|
||||||
cd lpac
|
cd lpac
|
||||||
./scripts/build.sh mingw
|
./scripts/build.sh mingw
|
||||||
|
@ -120,7 +120,7 @@ cd lpac
|
||||||
|
|
||||||
It is possible to build on **WoA devices** with [MSYS2 ARM64 Support](https://www.msys2.org/wiki/arm64/)
|
It is possible to build on **WoA devices** with [MSYS2 ARM64 Support](https://www.msys2.org/wiki/arm64/)
|
||||||
|
|
||||||
You may need to install `mingw-w64-clang-aarch64-cmake`, `mingw-w64-clang-aarch64-ninja`,`mingw-w64-clang-aarch64-clang` and modify `cmake/linux-mingw64.cmake`(replace toolchain).
|
You may need to install `mingw-w64-clang-aarch64-cmake`, `mingw-w64-clang-aarch64-clang` and modify `cmake/linux-mingw64.cmake`(replace toolchain).
|
||||||
|
|
||||||
Download prebuilt curl dll is also needed. Refer to the previous compilation steps.
|
Download prebuilt curl dll is also needed. Refer to the previous compilation steps.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
WORKSPACE="$(pwd)"
|
WORKSPACE="$(pwd)"
|
||||||
|
KERNEL="$(uname -s)"
|
||||||
MATCHINE="$(uname -m)"
|
MATCHINE="$(uname -m)"
|
||||||
CURL_VERSION="8.6.0_1"
|
CURL_VERSION="8.6.0_1"
|
||||||
WOA_TOOLCHAIN_VERSION="2024-02-08"
|
WOA_TOOLCHAIN_VERSION="2024-02-08"
|
||||||
|
@ -8,6 +9,16 @@ MINGW_CURL_WIN64_BLOB="https://curl.se/windows/dl-$CURL_VERSION/curl-$CURL_VERSI
|
||||||
MINGW_CURL_WIN64A_BLOB="https://curl.se/windows/dl-$CURL_VERSION/curl-$CURL_VERSION-win64a-mingw.zip"
|
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"
|
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"
|
||||||
|
|
||||||
|
case "$KERNEL" in
|
||||||
|
Linux)
|
||||||
|
KERNEL="linux"
|
||||||
|
;;
|
||||||
|
Darwin)
|
||||||
|
KERNEL="darwin"
|
||||||
|
MATCHINE="universal"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
function download {
|
function download {
|
||||||
URL="$1"
|
URL="$1"
|
||||||
SAVED_PATH="$(mktemp)"
|
SAVED_PATH="$(mktemp)"
|
||||||
|
@ -32,51 +43,46 @@ function download {
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
rm -rf build
|
BUILD="$(mktemp -d)"
|
||||||
mkdir build
|
cd "$BUILD" || exit 1
|
||||||
cd build || exit 1
|
|
||||||
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
linux)
|
make)
|
||||||
cmake .. -GNinja
|
cmake "$WORKSPACE"
|
||||||
ninja
|
make -j
|
||||||
chmod +x output/lpac
|
zip -r -j "$WORKSPACE/lpac-$KERNEL-$MATCHINE.zip" output/*
|
||||||
zip -r -j "$WORKSPACE/lpac-linux-$MATCHINE.zip" output/*
|
|
||||||
;;
|
;;
|
||||||
debian)
|
debian)
|
||||||
cmake .. -GNinja -DCPACK_GENERATOR=DEB
|
cmake "$WORKSPACE" -DCPACK_GENERATOR=DEB
|
||||||
ninja package
|
make -j package
|
||||||
cp lpac-*.deb ..
|
cp lpac-*.deb "$WORKSPACE"
|
||||||
;;
|
;;
|
||||||
mingw)
|
mingw)
|
||||||
cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake
|
cmake "$WORKSPACE" -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake
|
||||||
ninja
|
make -j
|
||||||
CURL="$(download "$MINGW_CURL_WIN64_BLOB")"
|
CURL="$(download "$MINGW_CURL_WIN64_BLOB")"
|
||||||
cp "$CURL"/curl-*-mingw/bin/libcurl-x64.dll output/libcurl.dll
|
cp "$CURL"/curl-*-mingw/bin/libcurl-x64.dll output/libcurl.dll
|
||||||
zip -r -j "$WORKSPACE/lpac-windows-x86_64-mingw.zip" output/*
|
zip -r -j "$WORKSPACE/lpac-windows-x86_64-mingw.zip" output/*
|
||||||
;;
|
;;
|
||||||
woa-mingw)
|
woa-mingw)
|
||||||
TOOLCHAIN="$(download "$MINGW32_TOOLCHAIN_BLOB")"
|
TOOLCHAIN="$(download "$MINGW32_TOOLCHAIN_BLOB")"
|
||||||
cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64-woa.cmake "-DTOOLCHAIN_BIN_PATH=$TOOLCHAIN/bin"
|
cmake "$WORKSPACE" -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64-woa.cmake "-DTOOLCHAIN_BIN_PATH=$TOOLCHAIN/bin"
|
||||||
ninja
|
make -j
|
||||||
CURL="$(download "$MINGW_CURL_WIN64A_BLOB")"
|
CURL="$(download "$MINGW_CURL_WIN64A_BLOB")"
|
||||||
cp "$CURL"/curl-*-mingw/bin/libcurl-arm64.dll output/libcurl.dll
|
cp "$CURL"/curl-*-mingw/bin/libcurl-arm64.dll output/libcurl.dll
|
||||||
zip -r -j "$WORKSPACE/lpac-windows-arm64-mingw.zip" output/*
|
zip -r -j "$WORKSPACE/lpac-windows-arm64-mingw.zip" output/*
|
||||||
;;
|
;;
|
||||||
woa-zig)
|
woa-zig)
|
||||||
cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE=./cmake/aarch64-windows-zig.cmake
|
cmake "$WORKSPACE" -DCMAKE_TOOLCHAIN_FILE=./cmake/aarch64-windows-zig.cmake
|
||||||
ninja
|
make -j
|
||||||
CURL="$(download "$MINGW_CURL_WIN64A_BLOB")"
|
CURL="$(download "$MINGW_CURL_WIN64A_BLOB")"
|
||||||
cp "$CURL"/curl-*-mingw/bin/libcurl-arm64.dll output/libcurl.dll
|
cp "$CURL"/curl-*-mingw/bin/libcurl-arm64.dll output/libcurl.dll
|
||||||
zip -r -j "$WORKSPACE/lpac-windows-arm64-zig.zip" output/*
|
zip -r -j "$WORKSPACE/lpac-windows-arm64-zig.zip" output/*
|
||||||
;;
|
;;
|
||||||
macos)
|
|
||||||
cmake ..
|
|
||||||
make "-j$(sysctl -n hw.ncpu)"
|
|
||||||
chmod +x output/lpac
|
|
||||||
zip -r -j "$WORKSPACE/lpac-macos-universal.zip" output/*
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {build,debian,mingw,woa-mingw,woa-zig,macos}"
|
echo "Usage: $0 {make,debian,mingw,woa-mingw,woa-zig}"
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
rm -rf "$BUILD"
|
||||||
|
|
4
scripts/setup-debian.sh
Executable file
4
scripts/setup-debian.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -xeuo pipefail
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential libpcsclite-dev libcurl4-openssl-dev gcc-mingw-w64 g++-mingw-w64
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -xeuo pipefail
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libpcsclite-dev libcurl4-openssl-dev gcc make cmake gcc-mingw-w64 g++-mingw-w64 unzip ninja-build
|
|
||||||
sudo snap install zig --classic --beta
|
|
Loading…
Reference in a new issue