diff --git a/.gitignore b/.gitignore index edb258c..7429489 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ zig-cache/ zig-out/ bin/ doc/ -imgui.ini \ No newline at end of file +imgui.ini +.build_config/ diff --git a/.gitmodules b/.gitmodules index 0fc3ea0..15089b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,3 @@ [submodule "lib/zgui"] path = lib/zgui url = https://git.musuka.dev/paoda/zgui -[submodule "lib/arm32"] - path = lib/arm32 - url = https://git.musuka.dev/paoda/arm32.git -[submodule "lib/zba-gdbstub"] - path = lib/zba-gdbstub - url = https://git.musuka.dev/paoda/zba-gdbstub diff --git a/build.zig b/build.zig index 10e4ee3..2e14bc1 100644 --- a/build.zig +++ b/build.zig @@ -2,8 +2,6 @@ const std = @import("std"); const Sdk = @import("lib/SDL.zig/build.zig"); const zgui = @import("lib/zgui/build.zig"); -const arm32 = @import("lib/arm32/build.zig"); -const gdbstub = @import("lib/zba-gdbstub/build.zig"); // Although this function looks imperative, note that its job is to // declaratively construct a build graph that will be executed by an external @@ -29,21 +27,22 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); - exe.addModule("arm32", arm32.module(b)); - exe.addModule("gdbstub", gdbstub.module(b)); - exe.addModule("zig-clap", b.dependency("zig-clap", .{}).module("clap")); + exe.root_module.addImport("arm32", b.dependency("arm32", .{}).module("arm32")); + exe.root_module.addImport("gdbstub", b.dependency("zba-gdbstub", .{}).module("gdbstub")); + exe.root_module.addImport("zig-clap", b.dependency("zig-clap", .{}).module("clap")); - exe.addAnonymousModule("bitfield", .{ .source_file = .{ .path = "lib/bitfield.zig" } }); // https://github.com/FlorenceOS/ - exe.addAnonymousModule("gl", .{ .source_file = .{ .path = "lib/gl.zig" } }); // https://github.com/MasterQ32/zig-opengl + exe.root_module.addAnonymousImport("bitfield", .{ .root_source_file = .{ .path = "lib/bitfield.zig" } }); // https://github.com/FlorenceOS/ + exe.root_module.addAnonymousImport("gl", .{ .root_source_file = .{ .path = "lib/gl.zig" } }); // https://github.com/MasterQ32/zig-opengl // https://github.com/MasterQ32/SDL.zig const sdk = Sdk.init(b, null); - sdk.link(exe, .dynamic); - exe.addModule("sdl2", sdk.getNativeModule()); + sdk.link(exe, .static); + 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, .shared = true } }); + sdk.link(zgui_pkg.zgui_c_cpp, .static); zgui_pkg.link(exe); // This declares intent for the executable to be installed into the diff --git a/build.zig.zon b/build.zig.zon index 676982c..ca4cdec 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,15 +1,25 @@ .{ .name = "turbo", .version = "0.1.0", + .paths = .{ + "lib/bitfield.zig", + "lib/gl.zig", + "src", + "build.zig", + "build.zig.zon", + }, .dependencies = .{ .@"zig-clap" = .{ - .url = "https://github.com/Hejsil/zig-clap/archive/f49b94700e0761b7514abdca0e4f0e7f3f938a93.tar.gz", - .hash = "1220f48518ce22882e102255ed3bcdb7aeeb4891f50b2cdd3bd74b5b2e24d3149ba2", + .url = "https://github.com/Hejsil/zig-clap/archive/4267b0b60ef6f87cccf3ee6ed481e6d0759180c6.tar.gz", + .hash = "12202fa30d679d821292bcd953458b9e76097a5d16999489125a206db63a53392833", }, - .@"zba-util" = .{ - // Necessary to use paoda/arm32 as a git submodule - .url = "https://git.musuka.dev/paoda/zba-util/archive/322c798e384a0d24cc84ffcfa2e4a3ca807798a0.tar.gz", - .hash = "12209ce0e729460b997706e47a53a32f1842672cd120189e612f4871731780a30ed0", + .@"zba-gdbstub" = .{ + .url = "https://git.musuka.dev/paoda/zba-gdbstub/archive/8d2c76e410357166f092008ff5c7f7f097a043a7.tar.gz", + .hash = "1220a171c7e14769386e3f4aab6aed53b5e176d654bdf1428a15b972effed750bf30", + }, + .arm32 = .{ + .url = "https://git.musuka.dev/paoda/arm32/archive/6f0e27136072610e6dba97ff8aaf5e2ec86e2c09.tar.gz", + .hash = "122047d0affe12b9e9e9c655a7ba6d51b311f02d688e9f1c9a91394a03103f1c0cd5", }, }, } diff --git a/dl_sdl2.ps1 b/dl_sdl2.ps1 new file mode 100644 index 0000000..88cc6e9 --- /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": "SDL2\\include", + "libs": "SDL2\\lib", + "bin": "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 diff --git a/lib/SDL.zig b/lib/SDL.zig index 80e7409..6d42434 160000 --- a/lib/SDL.zig +++ b/lib/SDL.zig @@ -1 +1 @@ -Subproject commit 80e7409e21ebbf0bd182b34b6e0206cc26e5ca05 +Subproject commit 6d42434c4d92efb1199d58f821edb7f701812f7e diff --git a/lib/arm32 b/lib/arm32 deleted file mode 160000 index bdc4bfc..0000000 --- a/lib/arm32 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bdc4bfc6423f173e28d1ee8a4608d0d90e1da3f3 diff --git a/lib/zba-gdbstub b/lib/zba-gdbstub deleted file mode 160000 index eb8e517..0000000 --- a/lib/zba-gdbstub +++ /dev/null @@ -1 +0,0 @@ -Subproject commit eb8e5175bd9738e92d10c47f75abb174f3624082 diff --git a/lib/zgui b/lib/zgui index ca27a47..1fff275 160000 --- a/lib/zgui +++ b/lib/zgui @@ -1 +1 @@ -Subproject commit ca27a472249a70dd1e94fb94f05f26dd931363fb +Subproject commit 1fff275f8d322d44355a08f2eac3e7c4905fc382