From f71aaafe4141fd87820e4d4a7a5158ac41fb61d2 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 10 Feb 2024 15:08:27 -0600 Subject: [PATCH] ci: get windows and ubuntu builds working again --- .github/workflows/main.yml | 21 ++++++++++----------- .gitmodules | 2 +- build.zig | 4 ++-- build.zig.zon | 4 ++-- dl_sdl2.ps1 | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 dl_sdl2.ps1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5eac398..3a31f28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,7 @@ on: push: paths: - "**.zig" + - "dl_sdl2.ps1" branches: - main schedule: @@ -15,12 +16,16 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - # os: [ubuntu-latest, windows-latest] runs-on: ${{matrix.os}} steps: - uses: goto-bus-stop/setup-zig@v2 with: - version: 0.11.0 + version: 0.12.0-dev.2063+804cee3b9 + - run: | + git config --global core.autocrlf false + - uses: actions/checkout@v3 + with: + submodules: recursive - name: prepare-linux if: runner.os == 'Linux' run: | @@ -29,16 +34,11 @@ jobs: - name: prepare-windows if: runner.os == 'Windows' run: | - vcpkg integrate install - vcpkg install sdl2:x64-windows - git config --global core.autocrlf false + .\dl_sdl2.ps1 - name: prepare-macos if: runner.os == 'macOS' run: | brew install sdl2 - - uses: actions/checkout@v3 - with: - submodules: recursive - name: build run: zig build -Doptimize=ReleaseSafe -Dcpu=baseline - name: prepare-executable @@ -57,6 +57,5 @@ jobs: submodules: recursive - uses: goto-bus-stop/setup-zig@v2 with: - version: 0.11.0-dev.3395+1e7dcaa3a - - run: zig fmt src/**/*.zig - \ No newline at end of file + version: 0.12.0-dev.2063+804cee3b9 + - run: zig fmt --check {src,lib}/**/*.zig build.zig build.zig.zon diff --git a/.gitmodules b/.gitmodules index 15089b6..fb0fe3f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "lib/SDL.zig"] path = lib/SDL.zig - url = https://github.com/MasterQ32/SDL.zig + url = https://github.com/paoda/SDL.zig [submodule "lib/zgui"] path = lib/zgui url = https://git.musuka.dev/paoda/zgui diff --git a/build.zig b/build.zig index 93a7d69..256ceb4 100644 --- a/build.zig +++ b/build.zig @@ -39,14 +39,14 @@ pub fn build(b: *std.Build) void { // https://github.com/MasterQ32/SDL.zig const sdk = Sdk.init(b, null); - sdk.link(exe, .static); + sdk.link(exe, .dynamic); exe.root_module.addImport("sdl2", sdk.getNativeModule()); // https://git.musuka.dev/paoda/zgui // .shared option should stay in sync with SDL.zig call above where true == .dynamic, and false == .static const zgui_pkg = zgui.package(b, target, optimize, .{ .options = .{ .backend = .sdl2_opengl3 } }); zgui_pkg.link(exe); - sdk.link(zgui_pkg.zgui_c_cpp, .static); + sdk.link(zgui_pkg.zgui_c_cpp, .dynamic); b.installArtifact(exe); diff --git a/build.zig.zon b/build.zig.zon index ff1eca8..7d512db 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -30,8 +30,8 @@ .hash = "12207da7e1f5d6180666db9575f84373055b230cb4259a4b6310562293338dc10b9d", }, .@"zba-gdbstub" = .{ - .url = "https://git.musuka.dev/paoda/zba-gdbstub/archive/8c3a166a5daa453c3627dda42bc169c20a470c68.tar.gz", - .hash = "12201dd0f0ae0c9efc8928aedd6970738f146675b2b9cbe8190177e37d1d849a6b6d", + .url = "https://git.musuka.dev/paoda/zba-gdbstub/archive/8d2c76e410357166f092008ff5c7f7f097a043a7.tar.gz", + .hash = "1220a171c7e14769386e3f4aab6aed53b5e176d654bdf1428a15b972effed750bf30", }, .tomlz = .{ .url = "https://github.com/paoda/tomlz/archive/f0aebccc31d48a131e57108cb05c8acfe4991eb8.tar.gz", diff --git a/dl_sdl2.ps1 b/dl_sdl2.ps1 new file mode 100644 index 0000000..f6737a0 --- /dev/null +++ b/dl_sdl2.ps1 @@ -0,0 +1,32 @@ +$SDL2Version = "2.30.0" +$ArchiveFile = ".\SDL2-devel-mingw.zip" +$Json = @" +{ + "x86_64-windows-gnu": { + "include": ".build_config\\SDL2\\include", + "libs": ".build_config\\SDL2\\lib", + "bin": ".build_config\\SDL2\\bin" + } +} +"@ + +New-Item -Force -ItemType Directory -Path .\.build_config +Set-Location -Path .build_config -PassThru + +if (!(Test-Path -PathType Leaf $ArchiveFile)) { + Invoke-WebRequest "https://github.com/libsdl-org/SDL/releases/download/release-$SDL2Version/SDL2-devel-$SDL2Version-mingw.zip" -OutFile $ArchiveFile +} + +Expand-Archive $ArchiveFile + +if (Test-Path -PathType Leaf .\SDL2) { + Remove-Item -Recurse .\SDL2 +} + +New-Item -Force -ItemType Directory -Path .\SDL2 +Get-ChildItem -Path ".\SDL2-devel-mingw\SDL2-$SDL2Version\x86_64-w64-mingw32" | Move-Item -Destination .\SDL2 + +New-Item -Force .\sdl.json -Value $Json + +Remove-Item -Recurse .\SDL2-devel-mingw +Set-Location -Path .. -PassThru