Skip to content

Commit d692bb5

Browse files
committed
move to a bash script
1 parent 72efc86 commit d692bb5

File tree

2 files changed

+108
-120
lines changed

2 files changed

+108
-120
lines changed

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

0 commit comments

Comments
 (0)