Skip to content

Commit 7da7de1

Browse files
author
Kevin Pfeifer
committed
move to a bash script
1 parent 72efc86 commit 7da7de1

2 files changed

Lines changed: 109 additions & 120 deletions

File tree

.github/workflows/build.yml

Lines changed: 11 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
- { name: win-arm64, os: windows-latest, flags: -A ARM64 }
2121
- { name: linux-x64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":amd64"}
2222
- { name: linux-x86, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":i386" }
23-
- { name: linux-arm64, os: ubuntu-20.04, container: arm64v8/ubuntu }
24-
- { name: linux-arm, os: ubuntu-20.04, container: arm32v7/ubuntu }
23+
- { name: linux-arm64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":arm64", container: arm64v8/ubuntu }
24+
- { name: linux-arm, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":armhf", container: arm32v7/ubuntu }
2525
- { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" }
2626
# NOTE: macOS 11.0 is the first released supported by Apple Silicon.
2727
- { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" }
@@ -44,50 +44,16 @@ jobs:
4444
uses: addnab/docker-run-action@v3
4545
with:
4646
image: ${{ matrix.platform.container }}
47-
options: -v ${{ github.workspace }}:/workspace -e NAME=${{ matrix.platform.name }} -e BUILD_TYPE=${{ env.BUILD_TYPE }}
47+
options: >
48+
-v ${{ github.workspace }}:/workspace
49+
-e NAME=${{ matrix.platform.name }}
50+
-e TARGET_APT_ARCH=${{ matrix.platform.target_apt_arch }}
51+
-e RUNNER_OS=${{ runner.os }}
52+
-e FLAGS=${{ matrix.platform.flags }}
53+
-e BUILD_TYPE=${{ env.BUILD_TYPE }}
4854
run: |
49-
apt update -y -qq
50-
apt install -y \
51-
gcc \
52-
g++ \
53-
cmake \
54-
ninja-build \
55-
wayland-scanner++ \
56-
wayland-protocols \
57-
pkg-config \
58-
libasound2-dev \
59-
libdbus-1-dev \
60-
libegl1-mesa-dev \
61-
libgl1-mesa-dev \
62-
libgles2-mesa-dev \
63-
libglu1-mesa-dev \
64-
libibus-1.0-dev \
65-
libpulse-dev \
66-
libsndio-dev \
67-
libudev-dev \
68-
libwayland-dev \
69-
libx11-dev \
70-
libxcursor-dev \
71-
libxext-dev \
72-
libxi-dev \
73-
libxinerama-dev \
74-
libxkbcommon-dev \
75-
libxrandr-dev \
76-
libxss-dev \
77-
libxt-dev \
78-
libxv-dev \
79-
libxxf86vm-dev \
80-
libdrm-dev \
81-
libgbm-dev \
82-
libpulse-dev
83-
8455
cd /workspace
85-
cmake -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON
86-
cmake --build build/ --config Release
87-
cmake --install build/ --prefix install_output --config Release
88-
89-
mkdir -p SDL3-CS/native/$NAME
90-
cp install_output/lib/libSDL3.so SDL3-CS/native/$NAME/libSDL3.so
56+
./SDL3-CS/build.sh
9157
9258
- name: Build
9359
if: ${{ !contains(matrix.platform.container, 'arm') }}
@@ -97,82 +63,7 @@ jobs:
9763
TARGET_APT_ARCH: ${{ matrix.platform.target_apt_arch }}
9864
RUNNER_OS: ${{ runner.os }}
9965
FLAGS: ${{ matrix.platform.flags }}
100-
101-
run: |
102-
if [[ $RUNNER_OS == 'Linux' ]]; then
103-
# Setup Linux dependencies
104-
if [[ $TARGET_APT_ARCH == :i386 ]]; then
105-
sudo dpkg --add-architecture i386
106-
fi
107-
108-
sudo apt-get update -y -qq
109-
110-
if [[ $TARGET_APT_ARCH == :i386 ]]; then
111-
# Workaround GitHub's ubuntu-20.04 image issue <https://github.com/actions/virtual-environments/issues/4589>
112-
sudo apt-get install -y --allow-downgrades libpcre2-8-0=10.34-7
113-
fi
114-
115-
sudo apt-get install -y \
116-
gcc-multilib \
117-
g++-multilib \
118-
cmake \
119-
ninja-build \
120-
wayland-scanner++ \
121-
wayland-protocols \
122-
pkg-config$TARGET_APT_ARCH \
123-
libasound2-dev$TARGET_APT_ARCH \
124-
libdbus-1-dev$TARGET_APT_ARCH \
125-
libegl1-mesa-dev$TARGET_APT_ARCH \
126-
libgl1-mesa-dev$TARGET_APT_ARCH \
127-
libgles2-mesa-dev$TARGET_APT_ARCH \
128-
libglu1-mesa-dev$TARGET_APT_ARCH \
129-
libibus-1.0-dev$TARGET_APT_ARCH \
130-
libpulse-dev$TARGET_APT_ARCH \
131-
libsndio-dev$TARGET_APT_ARCH \
132-
libudev-dev$TARGET_APT_ARCH \
133-
libwayland-dev$TARGET_APT_ARCH \
134-
libx11-dev$TARGET_APT_ARCH \
135-
libxcursor-dev$TARGET_APT_ARCH \
136-
libxext-dev$TARGET_APT_ARCH \
137-
libxi-dev$TARGET_APT_ARCH \
138-
libxinerama-dev$TARGET_APT_ARCH \
139-
libxkbcommon-dev$TARGET_APT_ARCH \
140-
libxrandr-dev$TARGET_APT_ARCH \
141-
libxss-dev$TARGET_APT_ARCH \
142-
libxt-dev$TARGET_APT_ARCH \
143-
libxv-dev$TARGET_APT_ARCH \
144-
libxxf86vm-dev$TARGET_APT_ARCH \
145-
libdrm-dev$TARGET_APT_ARCH \
146-
libgbm-dev$TARGET_APT_ARCH \
147-
libpulse-dev$TARGET_APT_ARCH
148-
fi
149-
150-
# Configure CMake
151-
cmake -B build $FLAGS -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON
152-
153-
# Build
154-
cmake --build build/ --config Release
155-
156-
if [[ $RUNNER_OS == 'Windows' ]]; then
157-
# Install (Windows)
158-
cmake --install build/ --prefix install_output --config Release
159-
else
160-
# Install
161-
sudo cmake --install build/ --prefix install_output --config Release
162-
fi
163-
164-
mkdir -p SDL3-CS/native/$NAME
165-
166-
if [[ $RUNNER_OS == 'Windows' ]]; then
167-
# Prepare release (Windows)
168-
cp install_output/bin/SDL3.dll SDL3-CS/native/$NAME/SDL3.dll
169-
elif [[ $RUNNER_OS == 'Linux' ]]; then
170-
# Prepare release (Linux)
171-
cp install_output/lib/libSDL3.so SDL3-CS/native/$NAME/libSDL3.so
172-
elif [[ $RUNNER_OS == 'macOS' ]]; then
173-
# Prepare release (macOS)
174-
cp install_output/lib/libSDL3.dylib SDL3-CS/native/$NAME/libSDL3.dylib
175-
fi
66+
run: ./SDL3-CS/build.sh
17667

17768
- name: Create pull request
17869
uses: peter-evans/create-pull-request@v6

build.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/bash
2+
3+
# Check if environment variables are defined
4+
if [[ -z $NAME || -z $RUNNER_OS || -z $FLAGS ]]; then
5+
echo "One or more required environment variables are not defined."
6+
exit 1
7+
fi
8+
9+
SUDO=$(which sudo)
10+
11+
if [[ $RUNNER_OS == 'Linux' ]]; then
12+
# Setup Linux dependencies
13+
if [[ $TARGET_APT_ARCH == :i386 ]]; then
14+
$SUDO dpkg --add-architecture i386
15+
fi
16+
17+
$SUDO apt-get update -y -qq
18+
19+
if [[ $TARGET_APT_ARCH == :i386 ]]; then
20+
# Workaround GitHub's ubuntu-20.04 image issue <https://github.com/actions/virtual-environments/issues/4589>
21+
$SUDO apt-get install -y --allow-downgrades libpcre2-8-0=10.34-7
22+
fi
23+
24+
if [[ $NAME != 'linux-x86' && $NAME != 'linux-x64' ]]; then
25+
GCC="gcc"
26+
GPP="g++"
27+
else
28+
GCC="gcc-multilib"
29+
GPP="g++-multilib"
30+
fi
31+
32+
$SUDO apt-get install -y \
33+
$GCC \
34+
$GPP \
35+
cmake \
36+
ninja-build \
37+
wayland-scanner++ \
38+
wayland-protocols \
39+
pkg-config$TARGET_APT_ARCH \
40+
libasound2-dev$TARGET_APT_ARCH \
41+
libdbus-1-dev$TARGET_APT_ARCH \
42+
libegl1-mesa-dev$TARGET_APT_ARCH \
43+
libgl1-mesa-dev$TARGET_APT_ARCH \
44+
libgles2-mesa-dev$TARGET_APT_ARCH \
45+
libglu1-mesa-dev$TARGET_APT_ARCH \
46+
libibus-1.0-dev$TARGET_APT_ARCH \
47+
libpulse-dev$TARGET_APT_ARCH \
48+
libsndio-dev$TARGET_APT_ARCH \
49+
libudev-dev$TARGET_APT_ARCH \
50+
libwayland-dev$TARGET_APT_ARCH \
51+
libx11-dev$TARGET_APT_ARCH \
52+
libxcursor-dev$TARGET_APT_ARCH \
53+
libxext-dev$TARGET_APT_ARCH \
54+
libxi-dev$TARGET_APT_ARCH \
55+
libxinerama-dev$TARGET_APT_ARCH \
56+
libxkbcommon-dev$TARGET_APT_ARCH \
57+
libxrandr-dev$TARGET_APT_ARCH \
58+
libxss-dev$TARGET_APT_ARCH \
59+
libxt-dev$TARGET_APT_ARCH \
60+
libxv-dev$TARGET_APT_ARCH \
61+
libxxf86vm-dev$TARGET_APT_ARCH \
62+
libdrm-dev$TARGET_APT_ARCH \
63+
libgbm-dev$TARGET_APT_ARCH \
64+
libpulse-dev$TARGET_APT_ARCH
65+
fi
66+
67+
# Configure CMake
68+
if [[ $NAME == 'linux-x86' ]]; then
69+
FLAGS="$FLAGS -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32"
70+
elif [[ $NAME == 'linux-x64' ]]; then
71+
FLAGS="$FLAGS -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS=-m64"
72+
fi
73+
74+
cmake -B build $FLAGS -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON
75+
76+
# Build
77+
cmake --build build/ --config Release
78+
79+
if [[ $RUNNER_OS == 'Windows' ]]; then
80+
# Install (Windows)
81+
cmake --install build/ --prefix install_output --config Release
82+
else
83+
# Install
84+
$SUDO cmake --install build/ --prefix install_output --config Release
85+
fi
86+
87+
mkdir -p SDL3-CS/native/$NAME
88+
89+
if [[ $RUNNER_OS == 'Windows' ]]; then
90+
# Prepare release (Windows)
91+
cp install_output/bin/SDL3.dll SDL3-CS/native/$NAME/SDL3.dll
92+
elif [[ $RUNNER_OS == 'Linux' ]]; then
93+
# Prepare release (Linux)
94+
cp install_output/lib/libSDL3.so SDL3-CS/native/$NAME/libSDL3.so
95+
elif [[ $RUNNER_OS == 'macOS' ]]; then
96+
# Prepare release (macOS)
97+
cp install_output/lib/libSDL3.dylib SDL3-CS/native/$NAME/libSDL3.dylib
98+
fi

0 commit comments

Comments
 (0)