Skip to content

Commit 15105a3

Browse files
committed
Add CI builds
1 parent 433c3ea commit 15105a3

File tree

6 files changed

+155
-7
lines changed

6 files changed

+155
-7
lines changed

.github/workflows/build.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build (macOS & Windows)
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
build-macos:
11+
runs-on: macos-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install build dependencies
16+
run: |
17+
brew install cmake pkg-config nasm
18+
19+
- name: Build SDL 2.32.10 for macOS universal
20+
run: |
21+
bash tools/build_sdl_macos.sh
22+
23+
- name: Build macOS (x86_64 + arm64)
24+
run: |
25+
cd MacOS
26+
make clean
27+
make
28+
29+
- name: Verify dylib linking
30+
run: |
31+
cd MacOS
32+
make check-dylibs
33+
34+
- name: Upload macOS build artifact
35+
uses: actions/upload-artifact@v4
36+
if: success()
37+
with:
38+
name: Kiwi8-macOS
39+
path: MacOS/release/Kiwi8.app
40+
retention-days: 7
41+
42+
build-windows:
43+
runs-on: windows-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Install CMake
48+
run: |
49+
choco install cmake -y
50+
51+
- name: Setup MSVC
52+
uses: microsoft/setup-msbuild@v1.1
53+
54+
- name: Build SDL 2.32.10 for Windows x64
55+
shell: pwsh
56+
run: |
57+
cd ${{ github.workspace }}
58+
.\tools\build_sdl_windows.ps1
59+
60+
- name: Build Windows (x64)
61+
shell: cmd
62+
run: |
63+
cd Windows
64+
nmake clean
65+
nmake build_release
66+
67+
- name: Upload Windows build artifact
68+
uses: actions/upload-artifact@v4
69+
if: success()
70+
with:
71+
name: Kiwi8-Windows-x64
72+
path: |
73+
Windows/release/Kiwi8.exe
74+
Windows/release/SDL2.dll
75+
retention-days: 7
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Core Lint
1+
name: Lint
22

33
on:
44
pull_request: {}

MacOS/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CC = clang++
2-
CFLAGS = -std=c++11 -Wall -mmacosx-version-min=11.0 -arch x86_64 -arch arm64
2+
CFLAGS = -std=c++17 -Wall -mmacosx-version-min=11.0 -arch x86_64 -arch arm64
33
LFLAGS = -mmacosx-version-min=11.0
44
INCS = -I$(CURDIR)/frameworks/sdl/include/ \
55
-I$(CURDIR)/../frameworks/imgui/
576 Bytes
Binary file not shown.

Windows/makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
# Note: Microsoft Visual C++ Build Tools are assumed to be installed and added to PATH
66

7-
# 1) vcvarsall x86
7+
# 1) vcvarsall x64
88
# 2) nmake
99

1010
APPNAME = Kiwi8
11-
ARCH = x86
11+
ARCH = x64
1212

1313
DEBUG = /SUBSYSTEM:CONSOLE
1414
RELEASE = /SUBSYSTEM:WINDOWS
@@ -45,7 +45,7 @@ test_debug:
4545
debug\$(APPNAME).exe \
4646
"C:\Roms\CHIP-8\Games\Brix [Andreas Gustafsson, 1990].ch8"
4747

48-
test_release:
48+
test_release:
4949
release\$(APPNAME).exe \
5050

5151
# Build object files
@@ -60,5 +60,5 @@ resource: src\$(APPNAME).rc resources\$(APPNAME).ico
6060
# Clean any leftover build files
6161
clean:
6262
DEL *.exe *.obj *.res *.pdb
63-
cd debug & DEL *.exe *.dll
64-
cd release & DEL *.exe *.dll
63+
cd debug & DEL *.exe *.dll
64+
cd release & DEL *.exe *.dll

tools/build_sdl_windows.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# build_sdl_windows.ps1
2+
# Builds SDL 2.32.10 for Windows x64 and installs it into Windows/frameworks/sdl
3+
4+
param(
5+
[string]$SDL_VERSION = "2.32.10",
6+
[string]$ROOT_DIR = (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
7+
)
8+
9+
$SDL_URL = "https://github.com/libsdl-org/SDL/releases/download/release-${SDL_VERSION}/SDL2-${SDL_VERSION}.tar.gz"
10+
$TP_DIR = "$ROOT_DIR/Windows/third_party"
11+
$INSTALL_DIR = "$ROOT_DIR/Windows/frameworks/sdl"
12+
13+
# Create third_party directory
14+
New-Item -ItemType Directory -Force -Path $TP_DIR | Out-Null
15+
Push-Location $TP_DIR
16+
17+
# Download if needed
18+
$ARCHIVE = "SDL2-${SDL_VERSION}.tar.gz"
19+
if (-Not (Test-Path $ARCHIVE)) {
20+
Write-Host "Downloading SDL ${SDL_VERSION}..."
21+
Invoke-WebRequest -Uri $SDL_URL -OutFile $ARCHIVE
22+
}
23+
24+
# Extract if needed
25+
$EXTRACT_DIR = "SDL2-${SDL_VERSION}"
26+
if (-Not (Test-Path $EXTRACT_DIR)) {
27+
Write-Host "Extracting SDL..."
28+
# Use 7z if available, otherwise tar (PowerShell 7+)
29+
if (Get-Command 7z -ErrorAction SilentlyContinue) {
30+
7z x $ARCHIVE
31+
} else {
32+
tar -xzf $ARCHIVE
33+
}
34+
}
35+
36+
# Configure & build
37+
$BUILD_DIR = "$EXTRACT_DIR/build-x64"
38+
New-Item -ItemType Directory -Force -Path $BUILD_DIR | Out-Null
39+
Push-Location $BUILD_DIR
40+
41+
Write-Host "Building SDL for x64..."
42+
cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DSDL_SHARED=ON -DSDL_STATIC=ON
43+
cmake --build . --config Release -- -m
44+
45+
# Backup
46+
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
47+
$BACKUP_DIR = "$INSTALL_DIR/backups"
48+
New-Item -ItemType Directory -Force -Path $BACKUP_DIR | Out-Null
49+
if (Test-Path "$INSTALL_DIR/lib") {
50+
Copy-Item -Path "$INSTALL_DIR/lib" -Destination "$BACKUP_DIR/lib.$timestamp" -Recurse -Force
51+
}
52+
if (Test-Path "$INSTALL_DIR/include") {
53+
Copy-Item -Path "$INSTALL_DIR/include" -Destination "$BACKUP_DIR/include.$timestamp" -Recurse -Force
54+
}
55+
56+
# Create install directories
57+
New-Item -ItemType Directory -Force -Path "$INSTALL_DIR/lib/x64" | Out-Null
58+
New-Item -ItemType Directory -Force -Path "$INSTALL_DIR/include" | Out-Null
59+
60+
# Copy artifacts (Release build)
61+
$RELEASE_BUILD = "Release"
62+
Copy-Item -Path "$BUILD_DIR/$RELEASE_BUILD/SDL2.lib" -Destination "$INSTALL_DIR/lib/x64/SDL2.lib" -Force
63+
Copy-Item -Path "$BUILD_DIR/$RELEASE_BUILD/SDL2.dll" -Destination "$INSTALL_DIR/lib/x64/SDL2.dll" -Force
64+
Copy-Item -Path "$BUILD_DIR/$RELEASE_BUILD/SDL2main.lib" -Destination "$INSTALL_DIR/lib/x64/SDL2main.lib" -Force
65+
66+
# Install headers
67+
Remove-Item -Path "$INSTALL_DIR/include/SDL2" -Recurse -Force -ErrorAction SilentlyContinue
68+
Copy-Item -Path "$BUILD_DIR/include/SDL2" -Destination "$INSTALL_DIR/include/" -Recurse -Force
69+
Copy-Item -Path "$BUILD_DIR/$RELEASE_BUILD/SDL_config.h" -Destination "$INSTALL_DIR/include/SDL2/SDL_config.h" -Force
70+
71+
Write-Host "SDL ${SDL_VERSION} built and installed into ${INSTALL_DIR}"
72+
Pop-Location
73+
Pop-Location

0 commit comments

Comments
 (0)