From d0b90830afc008534812f4297f64edc066140297 Mon Sep 17 00:00:00 2001 From: Hans Date: Sun, 5 May 2024 13:06:39 +0800 Subject: [PATCH] ci: move build commands to scripts --- .github/workflows/release.yml | 36 +++++++++-------------------------- scripts/build-linux.sh | 8 ++++++++ scripts/build-macos.sh | 7 +++++++ scripts/build-windows.sh | 17 +++++++++++++++++ scripts/prepare-linux.sh | 13 +++++++++++++ scripts/prepare-windows.sh | 2 ++ 6 files changed, 56 insertions(+), 27 deletions(-) create mode 100755 scripts/build-linux.sh create mode 100755 scripts/build-macos.sh create mode 100755 scripts/build-windows.sh create mode 100755 scripts/prepare-linux.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 35c98df..dbbfb99 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,43 +29,25 @@ jobs: with: path: externals key: ${{ runner.os }}-externals - - name: Prepare Toolchain (Linux) - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - - name: Prepare Vulkan SDK - if: runner.os == 'Linux' - uses: humbletim/setup-vulkan-sdk@v1.2.0 - with: - vulkan-query-version: 1.3.204.0 - vulkan-components: Vulkan-Headers, Vulkan-Loader - vulkan-use-cache: true - name: Install dependencies run: yarn install - - name: Build (Linux) - if: runner.os == 'Linux' - run: | - yarn clean && yarn build-native -a x86_64 --CDLLAMA_VULKAN=1 - yarn clean && yarn build-native -a aarch64 --cc aarch64-linux-gnu-gcc --cxx aarch64-linux-gnu-g++ - - name: Prepare SDK (Windows) + - name: Prepare (Windows) if: runner.os == 'Windows' shell: bash run: bash ./scripts/prepare-windows.sh - name: Build (Windows) if: runner.os == 'Windows' shell: bash - run: | - yarn clean && yarn build-native -a x86_64 - yarn clean && yarn build-native -a arm64 - X64_SDK_ROOT=$(python -c "import os,sys; print(os.path.abspath(sys.argv[1]))" "externals/win32-x64/SDK") - ARM64_SDK_ROOT=$(python -c "import os,sys; print(os.path.abspath(sys.argv[1]))" "externals/win32-arm64/SDK") - yarn clean && yarn build-native -a x86_64 --CDVARIANT=opencl --CDLLAMA_CLBLAST=ON --CDCMAKE_PREFIX_PATH=$X64_SDK_ROOT/lib/cmake/CLBlast - yarn clean && yarn build-native -a arm64 --CDVARIANT=opencl --CDLLAMA_CLBLAST=ON --CDCMAKE_PREFIX_PATH=$ARM64_SDK_ROOT/lib/cmake/CLBlast + run: bash ./scripts/build-windows.sh + - name: Prepare (Linux) + if: runner.os == 'Linux' + run: bash ./scripts/prepare-linux.sh + - name: Build (Linux) + if: runner.os == 'Linux' + run: bash ./scripts/build-linux.sh - name: Build (macOS) if: runner.os == 'macOS' - run: | - yarn clean && yarn build-native + run: bash ./scripts/build-macos.sh - name: Upload build artifacts uses: actions/upload-artifact@v4 with: diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh new file mode 100755 index 0000000..dd5d9be --- /dev/null +++ b/scripts/build-linux.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +# General + +yarn clean && yarn build-native -a x86_64 --CDLLAMA_VULKAN=1 +yarn clean && yarn build-native -a aarch64 --cc aarch64-linux-gnu-gcc --cxx aarch64-linux-gnu-g++ --CDLLAMA_VULKAN=1 diff --git a/scripts/build-macos.sh b/scripts/build-macos.sh new file mode 100755 index 0000000..aac941a --- /dev/null +++ b/scripts/build-macos.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# General + +yarn clean && yarn build-native diff --git a/scripts/build-windows.sh b/scripts/build-windows.sh new file mode 100755 index 0000000..c58bac3 --- /dev/null +++ b/scripts/build-windows.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +function resolve_path { + python -c "import os,sys; print(os.path.abspath(sys.argv[1]))" "$1" +} + +# General + +yarn clean && yarn build-native -a x86_64 +yarn clean && yarn build-native -a arm64 + +# build with CLBlast + +yarn clean && yarn build-native -a x86_64 --CDVARIANT=opencl --CDLLAMA_CLBLAST=ON --CDCMAKE_PREFIX_PATH="$(resolve_path 'externals/win32-x64/SDK/lib/cmake/CLBlast')" +yarn clean && yarn build-native -a arm64 --CDVARIANT=opencl --CDLLAMA_CLBLAST=ON --CDCMAKE_PREFIX_PATH="$(resolve_path 'externals/win32-arm64/SDK/lib/cmake/CLBlast')" diff --git a/scripts/prepare-linux.sh b/scripts/prepare-linux.sh new file mode 100755 index 0000000..2199718 --- /dev/null +++ b/scripts/prepare-linux.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +sudo apt-get update +sudo apt-get install -qy \ + binutils-aarch64-linux-gnu \ + gcc-aarch64-linux-gnu \ + g++-aarch64-linux-gnu \ + vulkan-sdk \ + libvulkan-dev:arm64 + + diff --git a/scripts/prepare-windows.sh b/scripts/prepare-windows.sh index c1811b1..7ef46c8 100755 --- a/scripts/prepare-windows.sh +++ b/scripts/prepare-windows.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + mkdir externals || true cd externals