Skip to content

Commit bb505aa

Browse files
committed
Changed to bundle SDL2 for Linux and use macOS 15 for build
1 parent 40aeeb8 commit bb505aa

File tree

4 files changed

+36
-42
lines changed

4 files changed

+36
-42
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ jobs:
1717
arch: x86
1818

1919
- target: x86_64-apple-darwin
20-
os: macos-13
20+
os: macos-15-intel
2121
arch: x64
22+
min_macos: "10.13"
2223

2324
- target: aarch64-apple-darwin
24-
os: macos-13
25-
arch: x64
25+
os: macos-15
26+
arch: arm64
27+
min_macos: "11.0"
2628

2729
runs-on: ${{ matrix.os }}
2830
steps:
2931
- name: Check out repository
30-
uses: actions/checkout@v3
32+
uses: actions/checkout@v4
3133

3234
- name: Install Rust
3335
uses: dtolnay/rust-toolchain@stable
@@ -50,7 +52,10 @@ jobs:
5052
run: pip install -r python/requirements.txt
5153

5254
- name: Build wheel
53-
run: make TARGET=${{ matrix.target }}
55+
shell: bash
56+
run: |
57+
export MACOSX_DEPLOYMENT_TARGET=${{ matrix.min_macos }}
58+
make TARGET=${{ matrix.target }}
5459
5560
- name: Upload wheel
5661
uses: actions/upload-artifact@v4
@@ -80,7 +85,7 @@ jobs:
8085

8186
steps:
8287
- name: Check out repository
83-
uses: actions/checkout@v3
88+
uses: actions/checkout@v4
8489

8590
- name: Install Rust
8691
uses: dtolnay/rust-toolchain@stable
@@ -93,40 +98,22 @@ jobs:
9398
toolchain: nightly-2025-02-17
9499
components: rustfmt
95100

96-
- name: Install Python
97-
uses: actions/setup-python@v4
98-
with:
99-
python-version: "3.12"
100-
101101
- name: Install Python packages
102102
run: pip install -r python/requirements.txt
103103

104-
- name: Build and install SDL2
104+
- name: Install build deps (X11/ALSA headers)
105105
run: |
106-
SDL2_VERSION=2.0.10
107-
export CC=$TARGET_CC
108-
export AR=$TARGET_AR
109-
export RANLIB=$TARGET_RANLIB
110-
111-
curl -sqLO https://github.com/libsdl-org/SDL/releases/download/release-${SDL2_VERSION}/SDL2-${SDL2_VERSION}.tar.gz
112-
tar xzf SDL2-${SDL2_VERSION}.tar.gz
113-
114-
cd SDL2-${SDL2_VERSION}
115-
CFLAGS="-O3 -fPIC" ./configure \
116-
--build=x86_64-unknown-linux-gnu \
117-
--host=${{ matrix.target }} \
118-
--prefix=/usr/${{ matrix.target }}
119-
make -j4
120-
make install
121-
cd ..
122-
123-
rm -rf SDL2-${SDL2_VERSION}
106+
if command -v yum >/dev/null 2>&1; then
107+
yum install -y gcc gcc-c++ make pkgconfig \
108+
alsa-lib-devel \
109+
libX11-devel libXext-devel libXcursor-devel libXrandr-devel libXi-devel libXinerama-devel
110+
fi
124111
125112
- name: Build wheel
126113
run: |
127-
export BINDGENFLAGS="-I/usr/${{ matrix.target }}/include/SDL2 -I/usr/${{ matrix.target }}/${{ matrix.target }}/sysroot/usr/include"
128-
export RUSTFLAGS="-L/usr/${{ matrix.target }}/lib"
129-
114+
export CC=$TARGET_CC
115+
export AR=$TARGET_AR
116+
export RANLIB=$TARGET_RANLIB
130117
make TARGET=${{ matrix.target }}
131118
132119
- name: Upload wheel

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- Changed desktop OpenGL internal format to GL_R8
66
- Fixed Tilemap.data_ptr to expose full map data
7+
- Changed to bundle SDL2 for Linux
8+
- Updated the build environment version for Mac to macOS 15
79

810
## 2.5.7
911

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ WASM_TARGET = wasm32-unknown-emscripten
6363

6464
# Tool options
6565
CLIPPY_OPTS = -q -- --no-deps
66-
MATURIN_OPTS = --manylinux 2014 --auditwheel skip
66+
MATURIN_OPTS = --manylinux 2014
6767

6868
# Build options
6969
TARGET ?= $(shell rustc -vV | awk '/^host:/ {print $$2}')
@@ -73,6 +73,8 @@ ifneq (,$(findstring windows,$(TARGET)))
7373
CARGO_FEATURES = --features sdl2_bundle
7474
else ifneq (,$(findstring darwin,$(TARGET)))
7575
CARGO_FEATURES = --features sdl2_bundle
76+
else ifneq (,$(findstring linux,$(TARGET)))
77+
CARGO_FEATURES = --features sdl2_bundle
7678
else
7779
CARGO_FEATURES = --features sdl2
7880
endif

rust/pyxel-platform/build.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ impl Sdl2Bindings {
100100
let mut cfg = cmake::Config::new(&self.sdl2_dir);
101101
cfg.profile("release")
102102
.cflag("-D__FLTUSED__")
103-
.define("SDL_SHARED", "OFF")
104-
.define("SDL_STATIC", "ON")
105103
.define("SDL_MAIN_HANDLED", "ON");
106104

105+
if self.target_os == "linux-gnu" {
106+
cfg.define("SDL_SHARED", "ON").define("SDL_STATIC", "OFF");
107+
} else {
108+
cfg.define("SDL_SHARED", "OFF").define("SDL_STATIC", "ON");
109+
}
110+
107111
if self.target_os == "windows-gnu" {
108112
cfg.define("VIDEO_OPENGLES", "OFF");
109113
}
@@ -121,14 +125,9 @@ impl Sdl2Bindings {
121125

122126
fn link_sdl2(&self) {
123127
if bundle_sdl2() {
124-
println!("cargo:rustc-link-lib=static=SDL2main");
125128
if self.target_os.contains("windows") {
129+
println!("cargo:rustc-link-lib=static=SDL2main");
126130
println!("cargo:rustc-link-lib=static=SDL2-static");
127-
} else {
128-
println!("cargo:rustc-link-lib=static=SDL2");
129-
}
130-
131-
if self.target_os.contains("windows") {
132131
println!("cargo:rustc-link-lib=shell32");
133132
println!("cargo:rustc-link-lib=user32");
134133
println!("cargo:rustc-link-lib=gdi32");
@@ -142,6 +141,8 @@ impl Sdl2Bindings {
142141
println!("cargo:rustc-link-lib=dxguid");
143142
println!("cargo:rustc-link-lib=setupapi");
144143
} else if self.target_os == "darwin" {
144+
println!("cargo:rustc-link-lib=static=SDL2main");
145+
println!("cargo:rustc-link-lib=static=SDL2");
145146
println!("cargo:rustc-link-lib=framework=Cocoa");
146147
println!("cargo:rustc-link-lib=framework=IOKit");
147148
println!("cargo:rustc-link-lib=framework=Carbon");
@@ -153,6 +154,8 @@ impl Sdl2Bindings {
153154
println!("cargo:rustc-link-lib=framework=AudioToolbox");
154155
println!("cargo:rustc-link-lib=framework=Metal");
155156
println!("cargo:rustc-link-lib=iconv");
157+
} else if self.target_os == "linux-gnu" {
158+
println!("cargo:rustc-link-lib=SDL2");
156159
}
157160
} else if self.target_os != "emscripten" {
158161
println!("cargo:rustc-flags=-l SDL2");

0 commit comments

Comments
 (0)