Skip to content

Commit

Permalink
ci: use docker to cross compile
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed May 7, 2024
1 parent d1ef346 commit 33f34ed
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 74 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ jobs:
key: ${{ runner.os }}-externals-${{ hashFiles('scripts/prepare-*.ps1') }}
- name: Install dependencies
run: yarn install
- name: Prepare (Windows)
- name: Prepare & build (Windows)
if: runner.os == 'Windows'
run: powershell ./scripts/prepare-windows.ps1
- name: Build (Windows)
if: runner.os == 'Windows'
run: powershell ./scripts/build-windows.ps1
- name: Prepare (Linux)
run: |
powershell ./scripts/prepare-windows.ps1
powershell ./scripts/build-windows.ps1
- name: Prepare & build (Linux x86_64)
if: runner.os == 'Linux'
run: bash ./scripts/prepare-linux.sh
- name: Build (Linux)
run: |
bash ./scripts/prepare-linux.sh
bash ./scripts/build-linux.sh
- name: Prepare & build (Linux arm64)
if: runner.os == 'Linux'
run: bash ./scripts/build-linux.sh
run: |
docker run --rm --volume $(pwd):/app --workdir /app -t arm64v8/ubuntu bash -c "./scripts/prepare-linux.sh && ./scripts/build-linux.sh"
- name: Build (macOS)
if: runner.os == 'macOS'
run: bash ./scripts/build-macos.sh
Expand Down
8 changes: 5 additions & 3 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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 --CDVULKAN_SDK="$(realpath 'externals/arm64-Vulkan-SDK')"
if [ $(uname -m) == "x86_64" ]; then
yarn clean && yarn build-native --CDLLAMA_VULKAN=1
else
yarn clean && yarn build-native --CDLLAMA_VULKAN=1 --CDVULKAN_SDK="$(realpath 'externals/arm64-Vulkan-SDK')"
fi
131 changes: 69 additions & 62 deletions scripts/prepare-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,82 @@

set -e

DISTRO=$(lsb_release -c -s)

wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.3.280-$DISTRO.list https://packages.lunarg.com/vulkan/1.3.280/lunarg-vulkan-1.3.280-$DISTRO.list

cat <<EOL | sudo tee /etc/apt/sources.list.d/arm64.list
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $DISTRO main
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $DISTRO-updates main
EOL

sudo apt-get update
sudo apt-get install -qy \
binutils-aarch64-linux-gnu \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
vulkan-sdk \
libx11-dev:arm64
function run_as_root() {
if [ $UID -ne 0 ]; then
sudo -E $@
else
$@
fi
}

# Install SDK for arm64 by building from source
if [ $(uname -m) == "x86_64" ]; then
DISTRO=$(lsb_release -c -s)
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | run_as_root tee /etc/apt/trusted.gpg.d/lunarg.asc
run_as_root wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.3.280-$DISTRO.list https://packages.lunarg.com/vulkan/1.3.280/lunarg-vulkan-1.3.280-$DISTRO.list
run_as_root apt-get update
run_as_root apt-get install -qy vulkan-sdk
else
run_as_root apt-get update
run_as_root apt-get install -qy curl gnupg2

mkdir externals || true
cd externals
if ! command -v node &> /dev/null; then
curl -fsSL https://deb.nodesource.com/setup_20.x | run_as_root bash -
run_as_root apt-get install -qy nodejs
npm install -g yarn
fi

if [ ! -d OpenCL-SDK-source ]; then
# clone KhronosGroup/OpenCL-SDK tag v2023.12.14
git clone https://github.com/KhronosGroup/OpenCL-SDK.git OpenCL-SDK-source --recursive
cd OpenCL-SDK-source
git checkout v2023.12.14
cd ..
fi
run_as_root apt-get install -qy git build-essential libx11-xcb-dev libxkbcommon-dev libwayland-dev libxrandr-dev

if [ ! -d CLBlast-source ]; then
# clone CNugteren/CLBlast tag 1.6.2
git clone https://github.com/CNugteren/CLBlast.git CLBlast-source --recursive
cd CLBlast-source
git checkout 1.6.2
cd ..
fi
mkdir externals || true
cd externals

# build Vulkan SDK from source for arm64

if [ ! -d arm64-Vulkan-SDK ]; then
VULKAN_ROOT=$(realpath ./arm64-Vulkan-SDK)
if [ ! -d Vulkan-Headers-source ]; then
git clone "https://github.com/KhronosGroup/Vulkan-Headers.git" "Vulkan-Headers-source"
cd "Vulkan-Headers-source"
git checkout "sdk-1.3.261"
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ cmake -B build
cmake --build build --config Release
cmake --install build --prefix $VULKAN_ROOT
if [ ! -d OpenCL-SDK-source ]; then
git clone https://github.com/KhronosGroup/OpenCL-SDK.git OpenCL-SDK-source --recursive
cd OpenCL-SDK-source
git checkout v2023.12.14
cd ..
fi
if [ ! -d Vulkan-Loader-source ]; then
git clone "https://github.com/KhronosGroup/Vulkan-Loader.git" "Vulkan-Loader-source"
cd "Vulkan-Loader-source"
git checkout "sdk-1.3.261"
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ cmake -B build -DVULKAN_HEADERS_INSTALL_DIR="$VULKAN_ROOT" -DUSE_MASM=OFF
cmake --build build --config Release
cmake --install build --prefix $VULKAN_ROOT
cd ".."

if [ ! -d CLBlast-source ]; then
# clone CNugteren/CLBlast tag 1.6.2
git clone https://github.com/CNugteren/CLBlast.git CLBlast-source --recursive
cd CLBlast-source
git checkout 1.6.2
cd ..
fi
if [ ! -d Vulkan-Hpp-source ]; then
git clone "https://github.com/KhronosGroup/Vulkan-Hpp.git" "Vulkan-Hpp-source"
cd "Vulkan-Hpp-source"
git checkout "v1.3.261"
git submodule update --init --recursive
cmake -B build -DVULKAN_HPP_INSTALL=ON -DVULKAN_HPP_RUN_GENERATOR=ON
cmake --build build --config Release
cmake --install build --prefix $VULKAN_ROOT
cd ".."

# build Vulkan SDK from source for arm64

if [ ! -d arm64-Vulkan-SDK ]; then
VULKAN_ROOT=$(realpath ./arm64-Vulkan-SDK)
if [ ! -d Vulkan-Headers-source ]; then
git clone "https://github.com/KhronosGroup/Vulkan-Headers.git" "Vulkan-Headers-source"
cd "Vulkan-Headers-source"
git checkout "sdk-1.3.261"
cmake -B build
cmake --build build --config Release
cmake --install build --prefix $VULKAN_ROOT
cd ..
fi
if [ ! -d Vulkan-Loader-source ]; then
git clone "https://github.com/KhronosGroup/Vulkan-Loader.git" "Vulkan-Loader-source"
cd "Vulkan-Loader-source"
git checkout "sdk-1.3.261"
cmake -B build -DVULKAN_HEADERS_INSTALL_DIR="$VULKAN_ROOT" -DUSE_MASM=OFF
cmake --build build --config Release
cmake --install build --prefix $VULKAN_ROOT
cd ".."
fi
if [ ! -d Vulkan-Hpp-source ]; then
git clone "https://github.com/KhronosGroup/Vulkan-Hpp.git" "Vulkan-Hpp-source"
cd "Vulkan-Hpp-source"
git checkout "v1.3.261"
git submodule update --init --recursive
cmake -B build -DVULKAN_HPP_INSTALL=ON -DVULKAN_HPP_RUN_GENERATOR=ON
cmake --build build --config Release
cmake --install build --prefix $VULKAN_ROOT
cd ".."
fi
fi

fi

0 comments on commit 33f34ed

Please sign in to comment.