Skip to content

Commit 8f12185

Browse files
authored
Update project (#20)
* Update CI * Update tests * Update windows CI * Update linux caching * Update CI * Simplify windows CI * Update windows CI * Extend pkgconf info * Test win * Try install * integrate * integrate install * Windows full * Dafuq? * update * copy * oida * pkgconf * aha * PWDshell * NOT * aölskd * ARG * bla * blub * bloo * asd * env * Remove other ci * win * ba * jup * Full * full build * Revert "Remove other ci" This reverts commit 5434d2a. * Try it another way * Remove wrapped * pc * Update * Flag * last try * Cleanups * Remove vs code
1 parent 538e6ac commit 8f12185

File tree

10 files changed

+80
-96
lines changed

10 files changed

+80
-96
lines changed

.github/workflows/ci-linux.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,30 @@ jobs:
1717
image: swift:${{ matrix.swift }}
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@master
21-
- name: Restore APT cache
22-
uses: actions/cache@v3
20+
uses: actions/checkout@v3.5.2
21+
22+
- name: APT cache
23+
uses: actions/cache@v3.3.1
2324
with:
2425
path: /var/cache/apt
2526
key: ${{ runner.os }}-apt
27+
2628
- name: Restore cached SPM dependencies
27-
uses: actions/cache@v3
29+
uses: actions/cache@v3.3.1
2830
with:
29-
path: |
30-
.build/repositories
31-
key: ${{ runner.os }}-spm-repos-${{ hashFiles('**/Package.resolved') }}
31+
path: .build
32+
key: swiftpm-${{ runner.os }}-${{ inputs.swift-version }}-${{ hashFiles('Package.swift') }}
3233
restore-keys: |
33-
${{ runner.os }}-spm-repos-
34+
swiftpm-${{ runner.os }}-${{ inputs.swift-version }}-
35+
swiftpm-${{ runner.os }}-
36+
3437
- name: Install dependencies
3538
run: |
3639
apt update
37-
apt-get install -y libsdl2-dev
38-
sdl2-config --version
40+
apt install -y libsdl2-dev
41+
3942
- name: Test
40-
run: make test
43+
run: swift test
44+
4145
- name: Build Release
42-
run: make build-release
46+
run: swift build -c release

.github/workflows/ci-macos.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,43 @@ on:
99

1010
jobs:
1111
macos-test-build-release-xcode:
12-
runs-on: macOS-latest
12+
runs-on: macos-latest
1313
strategy:
1414
matrix:
1515
xcode: ["14.2"]
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@master
18+
uses: actions/checkout@v3.5.2
19+
1920
- name: Select Xcode ${{ matrix.xcode }}
2021
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
22+
2123
- name: Restore cached Homebrew dependencies
22-
uses: actions/cache@v3
24+
uses: actions/cache@v3.3.1
2325
with:
2426
path: |
2527
~/Library/Caches/Homebrew/sdl2--*
2628
~/Library/Caches/Homebrew/downloads/*--sdl2-*
2729
key: ${{ runner.os }}-brew-sdl2-${{ hashFiles('.github/brew-formulae') }}
2830
restore-keys: ${{ runner.os }}-brew-sdl2-
31+
2932
- name: Restore cached SPM dependencies
30-
uses: actions/cache@v3
33+
uses: actions/cache@v3.3.1
3134
with:
3235
path: |
3336
.build/repositories
3437
key: ${{ runner.os }}-spm-repos-${{ hashFiles('**/Package.resolved') }}
3538
restore-keys: |
3639
${{ runner.os }}-spm-repos-
40+
3741
- name: Install dependencies
38-
run: |
39-
brew install sdl2
40-
sdl2-config --version
42+
run: brew install sdl2
43+
4144
- name: Test
4245
run: make test
4346
env:
4447
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
48+
4549
- name: Upload test artifacts
4650
if: failure()
4751
uses: actions/upload-artifact@v3.1.2
@@ -50,10 +54,12 @@ jobs:
5054
path: |
5155
.build/**/*.json
5256
.build/**/*.xctest
57+
5358
- name: Build Release
5459
run: make build-release
5560
env:
5661
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
62+
5763
- name: Upload build artifacts
5864
if: failure()
5965
uses: actions/upload-artifact@v3.1.2

.github/workflows/ci-windows.yml

Lines changed: 22 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,35 @@ on:
1010
jobs:
1111
windows-test-build-release:
1212
runs-on: windows-latest
13-
strategy:
14-
matrix:
15-
include:
16-
- tag: 5.7-RELEASE
17-
branch: swift-5.7-release
1813
steps:
19-
- uses: actions/checkout@master
14+
- uses: compnerd/gha-setup-swift@main
2015
with:
21-
fetch-depth: 1
22-
- uses: seanmiddleditch/gha-setup-vsdevenv@master
16+
branch: swift-5.8-release
17+
tag: 5.8-RELEASE
2318

24-
- name: Install pkg-conf
25-
shell: pwsh
26-
run: |
27-
vcpkg install --triplet x64-windows pkgconf
28-
echo "PKG_CONFIG=C:\vcpkg\installed\x64-windows\tools\pkgconf\pkgconf.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
29-
echo "PKG_CONFIG_PATH=C:\vcpkg\installed\x64-windows\lib\pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
30-
$env:Path += ";C:\vcpkg\installed\x64-windows\tools\pkgconf\"
31-
pkgconf --version
32-
33-
- name: Install SDL2 + Vulkan
34-
shell: pwsh
35-
run: vcpkg install sdl2[core,vulkan] --recurse --triplet x64-windows
19+
- name: Checkout
20+
uses: actions/checkout@v3.5.2
3621

37-
- name: Install Swift ${{ matrix.tag }}
38-
run: |
39-
Install-Binary -Url "https://swift.org/builds/${{ matrix.branch }}/windows10/swift-${{ matrix.tag }}/swift-${{ matrix.tag }}-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
40-
41-
- name: Set Environment Variables
42-
run: |
43-
echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
44-
echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
45-
46-
- name: Adjust Paths
47-
run: |
48-
echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
49-
echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
50-
51-
- name: Install Supporting Files
52-
run: |
53-
Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap"
54-
Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap"
55-
Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes"
56-
Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap"
22+
- name: Cache vcpkg
23+
uses: actions/cache@v3.3.1
24+
with:
25+
key: windows-x64-vcpkg
26+
path: C:/vcpkg/
5727

58-
- name: Generate shims
28+
- name: Build & Test
5929
shell: pwsh
6030
run: |
61-
$env:Path += ";C:\vcpkg\installed\x64-windows\tools\pkgconf\" # required to be set there!
62-
./genshim.ps1
31+
# install dependencies
32+
vcpkg install sdl2[core,vulkan] pkgconf --recurse --triplet x64-windows
33+
vcpkg integrate install
34+
35+
# setup pkgconf environment
36+
$env:Path += ";C:\vcpkg\installed\x64-windows\tools\pkgconf\"
37+
$env:PKG_CONFIG_PATH=$VCPKG_DIR+'\installed\x64-windows\tools\pkgconf\;C:\vcpkg\packages\sdl2_x64-windows\debug\lib\pkgconfig\'
6338
64-
- name: Build Debug & Release
65-
run: |
39+
# build
6640
swift build
67-
swift build -c release
68-
69-
- name: Copy libs
70-
shell: pwsh
71-
run: |
72-
$env:Path += ";C:\vcpkg\installed\x64-windows\tools\pkgconf\" # required to be set there!
73-
./copylibs.ps1
7441
75-
- name: Test
76-
run: swift test -v --skip-update --parallel --enable-test-discovery
42+
# test
43+
swift test
44+

Package.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.1
1+
// swift-tools-version:5.5
22
import PackageDescription
33

44
let package = Package(
@@ -19,11 +19,14 @@ let package = Package(
1919
.brew(["sdl2"]),
2020
.apt(["libsdl2-dev"])
2121
]),
22-
.target(name: "SDL2", dependencies: ["CSDL2Wrapped"]),
23-
// workaround for unsafeFlags from SDL <https://forums.swift.org/t/override-for-unsafeflags-in-swift-package-manager/45273/5>
24-
.target(name: "CSDL2Wrapped", dependencies: ["CSDL2"]),
25-
.target(name: "Minimal", dependencies: ["SDL2"], path: "Sources/Demos/Minimal"),
26-
.target(name: "MetalApp", dependencies: ["SDL2"], path: "Sources/Demos/MetalApp",swiftSettings: [.define("METAL_ENABLED", .when(platforms: [.macOS]))]),
22+
.target(name: "SDL2", dependencies: ["CSDL2"]),
23+
.executableTarget(name: "Minimal", dependencies: ["SDL2"], path: "Sources/Demos/Minimal"),
24+
.executableTarget(
25+
name: "MetalApp",
26+
dependencies: ["SDL2"],
27+
path: "Sources/Demos/MetalApp",
28+
swiftSettings: [.define("METAL_ENABLED", .when(platforms: [.macOS]))]
29+
),
2730
.testTarget(name: "CSDL2Tests", dependencies: ["CSDL2"])
2831
]
2932
)

Sources/CSDL2/shims.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#if __has_include("windows_generated.h")
1515
#include "windows_generated.h"
1616
#else
17-
error "windows_generated.h missing - run `genshim.ps1`"
17+
#include "windows.h"
1818
#endif
1919
#elif __linux__
2020
#include "linux.h" // linux

Sources/CSDL2/windows.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include <SDL.h>
2+
#include <SDL_vulkan.h>

Sources/CSDL2Wrapped/CSDL2Wrapped.swift

Lines changed: 0 additions & 9 deletions
This file was deleted.

Sources/Demos/Minimal/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let window = SDL_CreateWindow(
1010
"SDL2 Minimal Demo",
1111
Int32(SDL_WINDOWPOS_CENTERED_MASK), Int32(SDL_WINDOWPOS_CENTERED_MASK),
1212
800, 600,
13-
SDL_WINDOW_SHOWN.rawValue)
13+
SDL_Flag(SDL_WINDOW_SHOWN))
1414

1515
var quit = false
1616
var event = SDL_Event()

Sources/SDL2/SDL2.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
// Created by Christian Treffs on 03.11.19.
66
//
77

8-
@_exported import CSDL2Wrapped
8+
@_exported import CSDL2
99

1010
extension SDL_KeyCode: Equatable {}
1111
extension SDL_KeyCode: Hashable {}
12+
13+
14+
@_transparent
15+
public func SDL_Flag<I: FixedWidthInteger, R: RawRepresentable>(_ flag: R) -> I where R.RawValue: FixedWidthInteger {
16+
I(flag.rawValue)
17+
}

Tests/CSDL2Tests/CSDL2Tests.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ final class CSDL2Tests: XCTestCase {
1919
var linked = SDL_version()
2020
SDL_GetVersion(&linked)
2121

22-
XCTAssertEqual(compiled.major, 2)
23-
XCTAssertEqual(compiled.minor, 0)
24-
25-
XCTAssertEqual(linked.major, 2)
26-
XCTAssertEqual(linked.minor, 0)
22+
XCTAssertGreaterThanOrEqual(compiled.major, 2)
23+
XCTAssertEqual(compiled.major, linked.major)
24+
}
25+
26+
func testAPIAvailability() {
27+
XCTAssertNotNil(SDL_Init.self)
28+
XCTAssertNotNil(SDL_CreateWindow.self)
29+
XCTAssertNotNil(SDL_DestroyWindow.self)
30+
XCTAssertNotNil(SDL_Quit.self)
2731
}
2832

2933
func testKeyCodeAvailability() {

0 commit comments

Comments
 (0)