Skip to content

Commit 34eeac5

Browse files
authored
general: add fallback and SDL3 support via pkg-config in setup.vsh (#1020) (#1034)
* ci: bump macos sdl2 version to `2.32.6`
1 parent dba9c2c commit 34eeac5

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
runs-on: macos-13
8282
timeout-minutes: 60
8383
env:
84-
SDL2_VERSION: 2.32.4
84+
SDL2_VERSION: 2.32.6
8585
CFLAGS: -fpermissive -std=c99
8686
steps:
8787
- name: Checkout V

setup.vsh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,36 @@ import os
22

33
os.chdir(os.dir(os.executable()))!
44

5-
res := os.execute('sdl2-config --version')
5+
mut res := os.execute('sdl2-config --version')
66
if res.exit_code != 0 {
7-
println('sdl2-config is missing')
8-
exit(1)
7+
println('sdl2-config is missing. Trying pkg-config...')
8+
pkgconf := os.find_abs_path_of_executable('pkg-config') or { '' }
9+
if !os.is_executable(pkgconf) {
10+
println('pkg-config not found. Giving up')
11+
exit(1)
12+
}
13+
res = os.execute('pkg-config --modversion sdl2')
14+
if res.exit_code != 0 {
15+
println('SDL2 is missing. Trying SDL3...')
16+
res = os.execute('pkg-config --modversion sdl3')
17+
if res.exit_code != 0 {
18+
println('SDL3 is missing. Giving up')
19+
exit(1)
20+
}
21+
}
922
}
1023
system_version := res.output.trim_space()
1124
println('Your version is ${system_version}')
1225

1326
remotes := os.execute('git branch -r --list')
1427
if remotes.exit_code != 0 {
15-
println('git is missing')
28+
println('git is missing. Giving up')
1629
exit(1)
1730
}
18-
mut supported_versions := remotes.output.split_into_lines().map(it.trim_space()).filter(it.starts_with('origin/2')).map(it.all_after('origin/'))
19-
supported_versions.insert(0, '2.0.8') // master
31+
supported_versions := remotes.output.split_into_lines().map(it.trim_space()).filter(
32+
it.starts_with('origin/2') || it.starts_with('origin/3')).map(it.all_after('origin/'))
2033
println('The SDL module officially supports these versions of SDL:\n ${supported_versions}')
2134

22-
if system_version == '2.0.8' {
23-
println('Setting up the repository to branch master, that exactly matches your system SDL version 2.0.8')
24-
os.system('git checkout master')
25-
exit(0)
26-
}
27-
2835
if system_version in supported_versions {
2936
println('Setting up the repository to branch ${system_version} that exactly matches your system SDL version')
3037
os.system('git checkout ${system_version}')

0 commit comments

Comments
 (0)