Skip to content

Commit 0cfe4b6

Browse files
committed
CI Linux SDL: consolidate
add all to one script with deps/build_install/install_cached actions - yml - use action @main - cache: do not depend .github/scripts/Linux/prepare.sh, just the catch-all SDL install file - build SDL,SDL_ttf without entering the dir (as fluidsynth already does)
1 parent 4466594 commit 0cfe4b6

File tree

5 files changed

+61
-42
lines changed

5 files changed

+61
-42
lines changed

.github/scripts/Linux/common.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# $2 - pattern to exclude; separate packates with '\|' (BRE alternation)
2+
get_build_deps_excl() {
3+
apt-cache showsrc "$1" | sed -n "/^Build-Depends:/\
4+
{s/Build-Depends://;p;q}" | tr ',' '\n' | cut -f 2 -d\ | grep -v "$2"
5+
}
6+

.github/scripts/Linux/download_build_sdl.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,49 @@
11
#!/bin/sh -eu
22

3-
cd /var/tmp/sdl
4-
sudo cmake --install SDL/build
5-
sudo cmake --install SDL_ttf/build
6-
sudo cmake --install fluidsynth/build
3+
dir=$(dirname "$0")
4+
# shellcheck source=/dev/null
5+
. "$dir/common.sh" # for get_build_deps_excl
76

7+
# build dir that will be restored from cache
8+
cache_dir=/var/tmp/sdl
9+
10+
# install the deps - runs always (regardless the cache)
11+
deps() {
12+
sudo apt build-dep libsdl2
13+
fluidsynth_build_dep=$(get_build_deps_excl libfluidsynth3 libsdl2-dev)
14+
sdl2_ttf_build_dep=$(get_build_deps_excl libsdl2-ttf libsdl2-dev)
15+
# shellcheck disable=SC2086 # intentional
16+
sudo apt install $fluidsynth_build_dep $sdl2_ttf_build_dep
17+
}
18+
19+
# build SDL, SDL_ttf and fluidsynth and also install them
20+
build_install() {
21+
mkdir -p $cache_dir
22+
cd $cache_dir
23+
24+
git clone --depth 1 https://github.com/libsdl-org/SDL
25+
cmake -S SDL -B SDL/build
26+
cmake --build SDL/build -j "$(nproc)"
27+
sudo cmake --install SDL/build
28+
29+
git clone --depth 1 https://github.com/libsdl-org/SDL_ttf
30+
cmake -S SDL_ttf -B SDL_ttf/build
31+
cmake --build SDL_ttf/build -j "$(nproc)"
32+
sudo cmake --install SDL_ttf/build
33+
34+
git clone --recurse-submodules --depth 1\
35+
https://github.com/Fluidsynth/fluidsynth
36+
cmake -S fluidsynth -B fluidsynth/build
37+
cmake --build fluidsynth/build -j "$(nproc)"
38+
sudo cmake --install fluidsynth/build
39+
}
40+
41+
# if cache is successfully restored, just install the builds
42+
install_cached() {
43+
cd $cache_dir
44+
sudo cmake --install SDL/build
45+
sudo cmake --install SDL_ttf/build
46+
sudo cmake --install fluidsynth/build
47+
}
48+
49+
"${1?action required!}"

.github/scripts/Linux/prepare.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash -eux
22

3+
dir=$(dirname "$0")
4+
# shellcheck source=/dev/null
5+
. "$dir/common.sh" # for get_build_deps_excl
6+
37
export PKG_CONFIG_PATH=/usr/local/qt/lib/pkgconfig:/usr/local/lib/pkgconfig
48
export LIBRARY_PATH=/usr/local/lib:/usr/local/qt/lib
59
printf "%b" "\
@@ -33,15 +37,7 @@ sudo apt install libopencv-core-dev libopencv-imgproc-dev
3337
sudo apt install libcurl4-openssl-dev # for RTSP client (vidcap)
3438
sudo apt install i965-va-driver-shaders libva-dev # instead of i965-va-driver
3539

36-
get_build_deps_excl() { # $2 - pattern to exclude; separate packates with '\|' (BRE alternation)
37-
apt-cache showsrc "$1" | sed -n '/^Build-Depends:/{s/Build-Depends://;p;q}' | tr ',' '\n' | cut -f 2 -d\ | grep -v "$2"
38-
}
39-
40-
sudo apt build-dep libsdl2
41-
fluidsynth_build_dep=$(get_build_deps_excl libfluidsynth3 libsdl2-dev)
42-
sdl2_ttf_build_dep=$(get_build_deps_excl libsdl2-ttf libsdl2-dev)
43-
# shellcheck disable=SC2086 # intentional
44-
sudo apt install $fluidsynth_build_dep $sdl2_ttf_build_dep
40+
"$dir/install_sdl.sh" deps
4541

4642
ffmpeg_build_dep=$(get_build_deps_excl ffmpeg 'libsdl')
4743
# shellcheck disable=SC2086 # intentional

.github/workflows/ccpp.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ jobs:
9393
run: .github/scripts/Linux/install_ffmpeg.sh
9494
- name: Cache SDL
9595
id: cache-sdl
96-
uses: actions/cache@v3
96+
uses: actions/cache@main
9797
with:
9898
path: '/var/tmp/sdl'
99-
key: cache-sdl-${{ runner.os }}-${{ hashFiles( '.github/scripts/Linux/prepare.sh', '.github/scripts/Linux/download_build_sdl.sh' ) }}
99+
key: cache-sdl-${{ runner.os }}-${{ hashFiles( '.github/scripts/Linux/install_sdl.sh' ) }}
100100
- name: Build SDL
101101
if: steps.cache-sdl.outputs.cache-hit != 'true'
102-
run: .github/scripts/Linux/download_build_sdl.sh
102+
run: .github/scripts/Linux/install_sdl.sh build_install
103103
- name: Install Cached SDL
104104
if: steps.cache-sdl.outputs.cache-hit == 'true'
105-
run: .github/scripts/Linux/install_sdl.sh
105+
run: .github/scripts/Linux/install_sdl.sh install_cached
106106
- name: configure
107107
run: "./autogen.sh $FEATURES || { RC=$?; cat config.log; exit $RC; }"
108108
- name: make

0 commit comments

Comments
 (0)