From 4d57518bc04ec199a7f6b12d6973c82278f564ae Mon Sep 17 00:00:00 2001 From: peterino2 Date: Sun, 8 Jun 2025 11:25:44 -0700 Subject: [PATCH] updated build scripts --- build.zig | 111 ++++++++++++++++------- engine/assets/build.zig | 5 +- engine/audio/build.zig | 3 +- engine/core/build.zig | 3 +- engine/core/src/extern/externModule.zig | 13 ++- engine/imgui/build.zig | 3 +- engine/papyrus/build.zig | 3 +- engine/physics/build.zig | 5 +- engine/platform/build.zig | 3 +- engine/rend/build.zig | 3 +- engine/ui/build.zig | 3 +- lib/cimgui/build.zig | 2 + lib/lua/build.zig | 8 +- lib/miniaudio/build.zig | 8 +- lib/nfd/build.zig | 3 +- lib/objLoader/build.zig | 2 + lib/ozz/build.zig | 18 ++-- lib/p2/build.zig | 2 + lib/packer/build.zig | 4 +- lib/sdl3/SDL/build.zig | 3 + lib/sdl3/build.zig | 18 +--- lib/sdl3/shaderTypes/build.zig | 3 + lib/spirv-reflect-zig/build.zig | 2 + lib/spng/build.zig | 28 ++++-- lib/tracy/build.zig | 2 + lib/zgltf/build.zig | 2 + lib/zmath/build.zig | 2 + lib/zphysics/build.zig | 7 +- projects/build.zig | 12 +++ projects/minimal/Saved/Session_Log.txt | 112 ------------------------ 30 files changed, 201 insertions(+), 192 deletions(-) delete mode 100644 projects/minimal/Saved/Session_Log.txt diff --git a/build.zig b/build.zig index a5c90ac..9cfb70f 100644 --- a/build.zig +++ b/build.zig @@ -14,6 +14,8 @@ backlogRoot: []const u8, // content/_shaders/def reflectShaderPathList: [][]u8 = undefined, +staticBuild: bool = false, + const engineDepList = [_][]const u8{ "assets", "audio", @@ -37,14 +39,24 @@ const ozz = @import("ozz"); pub const InitOptions = struct { import_name: []const u8 = "Backlog", backlogRoot: []const u8 = "./BacklogEngine", + staticBuild: bool = false, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, }; pub fn init(b: *std.Build, opts: InitOptions) BuildSystem { + var buildOpts = declareBuildOptions(b); + + if (opts.target.result.os.tag == .linux) { + // using a static build for linux... object loading hell is not fun + std.debug.print("Important! only supporting static builds for linux", .{}); + buildOpts.static_build = true; + } + const nwdep = b.dependency(opts.import_name, .{ .target = opts.target, .optimize = opts.optimize, + .static_build = buildOpts.static_build, }); const self = BuildSystem{ @@ -55,9 +67,11 @@ pub fn init(b: *std.Build, opts: InitOptions) BuildSystem { .nw_mod = nwdep.module("Backlog"), .backlogRoot = opts.backlogRoot, .spirvReflect = SpirvReflect.SpirvGenerator2.init(nwdep.builder, .{}), - .options = createGameOptions(b), + .options = createGameOptions(b, buildOpts), .gltf2ozz = ozz.GltfToOzz.init(nwdep.builder, .{}), .cookShaders = b.option(bool, "cookShaders", "generates shaders and updates .json files before running the build. (needs to be done whenever shaders are updated, this just runs tools/scripts/cook-shaders.py)") orelse false, + + .staticBuild = buildOpts.static_build, }; const exeList = [2]*std.Build.Step.Compile{ self.gltf2ozz.exe, self.spirvReflect.reflect }; @@ -147,57 +161,81 @@ pub fn addProgram(self: *BuildSystem, opts: AddProgramOptions) *std.Build.Module return mod; } -pub fn createGameOptions(b: *std.Build) *std.Build.Step.Options { +pub const BuildOptions = struct { + mutex_job_queue: bool, + static_build: bool, + zero_logging: bool, + slow_logging: bool, + force_mailbox: bool, +}; + +pub fn declareBuildOptions(b: *std.Build) BuildOptions { + return .{ + .mutex_job_queue = b.option(bool, "mutex_job_queue", "temporary test, reverts to old mutex based queue behaviour in jobs.zig:JobManager") orelse false, + .static_build = b.option(bool, "static_build", "builds the entire game as a single executable") orelse false, + .zero_logging = b.option(bool, "zero_logging", "disables all logging, only intended for use on job dispatch testing") orelse false, + .slow_logging = b.option(bool, "slow_logging", "Disables buffered logging, takes a hit to performance but gain timing information on logging") orelse false, + .force_mailbox = b.option(bool, "force_mailbox", "forces mailbox mode for present mode. unlocks framerate to irresponsible levels") orelse false, + }; +} + +pub fn createGameOptions(b: *std.Build, options: BuildOptions) *std.Build.Step.Options { const opts = b.addOptions(); + inline for (@typeInfo(BuildOptions).@"struct".fields) |field| { + opts.addOption(bool, field.name, @field(options, field.name)); + } + // build options for core.zig - opts.addOption( - bool, - "mutex_job_queue", - b.option(bool, "mutex_job_queue", "temporary test, reverts to old mutex based queue behaviour in jobs.zig:JobManager") orelse false, - ); - opts.addOption( - bool, - "zero_logging", - b.option(bool, "zero_logging", "disables all logging, only intended for use on job dispatch testing") orelse false, - ); - opts.addOption( - bool, - "slow_logging", - b.option(bool, "slow_logging", "Disables buffered logging, takes a hit to performance but gain timing information on logging") orelse false, - ); - opts.addOption( - bool, - "force_mailbox", - b.option(bool, "force_mailbox", "forces mailbox mode for present mode. unlocks framerate to irresponsible levels") orelse false, - ); - opts.addOption( - bool, - "use_renderthread", - true, - ); + // opts.addOption( + // bool, + // "mutex_job_queue", + // ); + + // opts.addOption( + // bool, + // "static_build", + // ); + + // opts.addOption( + // bool, + // "zero_logging", + // ); + // opts.addOption( + // bool, + // "slow_logging", + // ); + // opts.addOption( + // bool, + // "force_mailbox", + // ); return opts; } pub fn addExtraModule(self: *BuildSystem, mod: *std.Build.Module, moduleName: []const u8) void { - const dep = self.b.dependency(moduleName, .{ .target = self.target, .optimize = self.optimize }); + const dep = self.b.dependency(moduleName, .{ .target = self.target, .optimize = self.optimize, .static_build = self.staticBuild }); mod.addImport(moduleName, dep.module(moduleName)); } pub fn addDependencyInstalls(self: *BuildSystem, b: *std.Build, optimize: std.builtin.OptimizeMode) void { - // b.installArtifact(b.dependency("sdl3_lib", .{ .target = self.target, .optimize = optimize }).artifact("SDL3")); + if (self.staticBuild) { + return; + } - for (cDependencyList) |d| { + inline for (cDependencyList) |d| { b.installArtifact(b.dependency( d.dep, - .{ .target = self.target, .optimize = optimize }, + .{ .target = self.target, .optimize = optimize, .static_build = self.staticBuild }, ).artifact(d.artifact)); } + b.installArtifact(b.dependency( + "sdl3_lib", + .{ .target = self.target, .optimize = optimize, .static_build = self.staticBuild, .preferred_linkage = .dynamic }, + ).artifact("SDL3")); } const cDependencyList: []const struct { dep: []const u8, artifact: []const u8 } = &.{ - .{ .dep = "sdl3_lib", .artifact = "SDL3" }, .{ .dep = "spng", .artifact = "spng_c" }, .{ .dep = "lua", .artifact = "luac" }, .{ .dep = "miniaudio", .artifact = "miniaudio_c" }, @@ -210,10 +248,12 @@ const cDependencyList: []const struct { dep: []const u8, artifact: []const u8 } pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const spirvDep = b.dependency("SpirvReflect", .{ .target = target, .optimize = optimize, + .static_build = static_build, }); _ = spirvDep; @@ -230,6 +270,7 @@ pub fn build(b: *std.Build) void { .{ .target = target, .optimize = optimize, + .static_build = static_build, }, ); mod.addImport(depName, dep.module(depName)); @@ -237,7 +278,11 @@ pub fn build(b: *std.Build) void { // link in large platform support functions { - const dep = b.dependency("sdl3", .{ .target = target, .optimize = optimize }); + const dep = b.dependency("sdl3", .{ + .target = target, + .optimize = optimize, + .static_build = static_build, + }); const lib = dep.module("sdl3_lib"); mod.addImport("sdl3_fwd", lib); diff --git a/engine/assets/build.zig b/engine/assets/build.zig index 3fc5f4b..ea8790f 100644 --- a/engine/assets/build.zig +++ b/engine/assets/build.zig @@ -3,6 +3,7 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("assets", .{ .target = target, @@ -12,13 +13,13 @@ pub fn build(b: *std.Build) void { const core_dep = b.dependency( "core", - .{ .target = target, .optimize = optimize }, + .{ .target = target, .optimize = optimize, .static_build = static_build }, ); mod.addImport("core", core_dep.module("core")); const packer_dep = b.dependency( "packer", - .{ .target = target, .optimize = optimize }, + .{ .target = target, .optimize = optimize, .static_build = static_build }, ); mod.addImport("packer", packer_dep.module("packer")); diff --git a/engine/audio/build.zig b/engine/audio/build.zig index b4ec609..eacaa60 100644 --- a/engine/audio/build.zig +++ b/engine/audio/build.zig @@ -9,6 +9,7 @@ const depList = [_][]const u8{ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("audio", .{ .target = target, @@ -17,7 +18,7 @@ pub fn build(b: *std.Build) void { }); for (depList) |depName| { - const dep = b.dependency(depName, .{ .target = target, .optimize = optimize }); + const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build }); mod.addImport(depName, dep.module(depName)); } diff --git a/engine/core/build.zig b/engine/core/build.zig index 972136c..d289e04 100644 --- a/engine/core/build.zig +++ b/engine/core/build.zig @@ -14,6 +14,7 @@ const dependencyList = [_][]const u8{ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("core", .{ .target = target, @@ -22,7 +23,7 @@ pub fn build(b: *std.Build) void { }); for (dependencyList) |depName| { - const dep = b.dependency(depName, .{ .target = target, .optimize = optimize }); + const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build }); mod.addImport(depName, dep.module(depName)); } diff --git a/engine/core/src/extern/externModule.zig b/engine/core/src/extern/externModule.zig index 709203f..9309eac 100644 --- a/engine/core/src/extern/externModule.zig +++ b/engine/core/src/extern/externModule.zig @@ -120,6 +120,7 @@ pub const ModuleLoader = struct { backingAllocator: std.mem.Allocator, arena: std.heap.ArenaAllocator, loadedModules: std.ArrayListUnmanaged(*LoadedModule) = .{}, + watchInitialized: bool = false, pub var NeonObjectTable = core.EngineObjectVTable.from(@This(), "core.ModuleLoader"); pub fn create(allocator: std.mem.Allocator) !*@This() { @@ -130,17 +131,25 @@ pub const ModuleLoader = struct { .arena = std.heap.ArenaAllocator.init(allocator), }; - //core.fs().watchPath("zig-out/modules/"); - return self; } pub fn addModule(self: *@This(), moduleName: []const u8) !void { // modules are always looked for under zig-out/modules + if (core.BuildOption("static_build")) { + core.engine_log("[ModuleLoader]: skipping dynamic load, hot loading is not available", .{moduleName}); + return; + } + core.engine_log("[ModuleLoader]: adding module to watch '{s}'", .{moduleName}); const libFileName = try p2.sharedLibNameAlloc(self.arena.allocator(), moduleName); const loaded = try self.arena.allocator().create(LoadedModule); + if (self.watchInitialized == false) { + core.fs().watchPath("zig-out/modules/"); + self.watchInitialized = true; + } + loaded.* = LoadedModule{ .baseModulePath = try std.fmt.allocPrint(self.arena.allocator(), "zig-out/modules/{s}", .{libFileName}), .moduleName = moduleName, diff --git a/engine/imgui/build.zig b/engine/imgui/build.zig index 93467dd..48d33c6 100644 --- a/engine/imgui/build.zig +++ b/engine/imgui/build.zig @@ -11,6 +11,7 @@ const dependencyList = [_][]const u8{ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("imgui", .{ .target = target, @@ -19,7 +20,7 @@ pub fn build(b: *std.Build) void { }); for (dependencyList) |depName| { - const dep = b.dependency(depName, .{ .target = target, .optimize = optimize }); + const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build }); const dep_mod = dep.module(depName); mod.addImport(depName, dep_mod); } diff --git a/engine/papyrus/build.zig b/engine/papyrus/build.zig index 48b6334..c5ec26e 100644 --- a/engine/papyrus/build.zig +++ b/engine/papyrus/build.zig @@ -4,6 +4,7 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("papyrus", .{ .target = target, @@ -14,7 +15,7 @@ pub fn build(b: *std.Build) void { mod.addIncludePath(b.path("src/")); mod.addCSourceFile(.{ .file = b.path("src/compat.cpp") }); - const core_dep = b.dependency("core", .{ .target = target, .optimize = optimize }); + const core_dep = b.dependency("core", .{ .target = target, .optimize = optimize, .static_build = static_build }); mod.addImport("core", core_dep.module("core")); diff --git a/engine/physics/build.zig b/engine/physics/build.zig index 1189ee3..0fcf9c7 100644 --- a/engine/physics/build.zig +++ b/engine/physics/build.zig @@ -4,6 +4,7 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("physics", .{ .target = target, @@ -12,9 +13,9 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("src/physics.zig"), }); - const core_dep = b.dependency("core", .{ .target = target, .optimize = optimize }); + const core_dep = b.dependency("core", .{ .target = target, .optimize = optimize, .static_build = static_build }); - const zphysics_dep = b.dependency("zphysics", .{ .target = target, .optimize = optimize }); + const zphysics_dep = b.dependency("zphysics", .{ .target = target, .optimize = optimize, .static_build = static_build }); mod.addImport("core", core_dep.module("core")); mod.addImport("zphysics", zphysics_dep.module("root")); diff --git a/engine/platform/build.zig b/engine/platform/build.zig index 7db70b4..94c97e7 100644 --- a/engine/platform/build.zig +++ b/engine/platform/build.zig @@ -9,6 +9,7 @@ const dependencyList = [_][]const u8{ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("platform", .{ .target = target, @@ -23,7 +24,7 @@ pub fn build(b: *std.Build) void { }); for (dependencyList) |depName| { - const dep = b.dependency(depName, .{ .target = target, .optimize = optimize }); + const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build }); const dep_mod = dep.module(depName); mod.addImport(depName, dep_mod); tests.root_module.addImport(depName, dep_mod); diff --git a/engine/rend/build.zig b/engine/rend/build.zig index a107144..2f4d1b4 100644 --- a/engine/rend/build.zig +++ b/engine/rend/build.zig @@ -15,6 +15,7 @@ const dependencyList = [_][]const u8{ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("rend", .{ .target = target, @@ -23,7 +24,7 @@ pub fn build(b: *std.Build) void { }); for (dependencyList) |depName| { - const dep = b.dependency(depName, .{ .target = target, .optimize = optimize }); + const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build }); const dep_mod = dep.module(depName); mod.addImport(depName, dep_mod); diff --git a/engine/ui/build.zig b/engine/ui/build.zig index d58c829..4de2d3f 100644 --- a/engine/ui/build.zig +++ b/engine/ui/build.zig @@ -13,6 +13,7 @@ const dependencyList = [_][]const u8{ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("ui", .{ .target = target, @@ -21,7 +22,7 @@ pub fn build(b: *std.Build) void { }); for (dependencyList) |depName| { - const dep = b.dependency(depName, .{ .target = target, .optimize = optimize }); + const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build }); const dep_mod = dep.module(depName); mod.addImport(depName, dep_mod); } diff --git a/lib/cimgui/build.zig b/lib/cimgui/build.zig index 3ce85a4..2bf0985 100644 --- a/lib/cimgui/build.zig +++ b/lib/cimgui/build.zig @@ -4,6 +4,8 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + _ = static_build; const mod = b.addModule("cimgui", .{ .target = target, diff --git a/lib/lua/build.zig b/lib/lua/build.zig index e3ef5b1..066a9fd 100644 --- a/lib/lua/build.zig +++ b/lib/lua/build.zig @@ -3,6 +3,7 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("lua", .{ .target = target, @@ -11,7 +12,12 @@ pub fn build(b: *std.Build) void { .link_libc = true, }); - const luac = b.addSharedLibrary(.{ + const luac = if (static_build) b.addStaticLibrary(.{ + .name = "luac", + .target = target, + .optimize = optimize, + .link_libc = true, + }) else b.addSharedLibrary(.{ .name = "luac", .target = target, .optimize = optimize, diff --git a/lib/miniaudio/build.zig b/lib/miniaudio/build.zig index 19255dd..c8773cf 100644 --- a/lib/miniaudio/build.zig +++ b/lib/miniaudio/build.zig @@ -3,8 +3,14 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; - const miniaudio_c = b.addSharedLibrary(.{ + const miniaudio_c = if (static_build) b.addStaticLibrary(.{ + .name = "miniaudio_c", + .target = target, + .optimize = optimize, + .link_libc = true, + }) else b.addSharedLibrary(.{ .name = "miniaudio_c", .target = target, .optimize = optimize, diff --git a/lib/nfd/build.zig b/lib/nfd/build.zig index 7517ff2..4316b30 100644 --- a/lib/nfd/build.zig +++ b/lib/nfd/build.zig @@ -3,6 +3,7 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const mod = b.addModule("nfd", .{ .target = target, @@ -46,7 +47,7 @@ pub fn build(b: *std.Build) void { // mod.linkSystemLibrary("gobject-2.0", .{}); } - const p2dep = b.dependency("p2", .{ .target = target, .optimize = optimize }); + const p2dep = b.dependency("p2", .{ .target = target, .optimize = optimize, .static_build = static_build }); const p2mod = p2dep.module("p2"); mod.addImport("p2", p2mod); diff --git a/lib/objLoader/build.zig b/lib/objLoader/build.zig index ea253b5..8a9bda4 100644 --- a/lib/objLoader/build.zig +++ b/lib/objLoader/build.zig @@ -3,6 +3,8 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + _ = static_build; const mod = b.addModule("objLoader", .{ .target = target, diff --git a/lib/ozz/build.zig b/lib/ozz/build.zig index 8b00c9c..05d162b 100644 --- a/lib/ozz/build.zig +++ b/lib/ozz/build.zig @@ -140,12 +140,20 @@ pub const GltfToOzz = struct { pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const target = b.standardTargetOptions(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; - const ozz_cpp = b.addSharedLibrary(.{ - .name = "ozz_cpp", - .target = target, - .optimize = optimize, - }); + const ozz_cpp = if (static_build) + b.addStaticLibrary(.{ + .name = "ozz_cpp", + .target = target, + .optimize = optimize, + }) + else + b.addSharedLibrary(.{ + .name = "ozz_cpp", + .target = target, + .optimize = optimize, + }); b.installArtifact(ozz_cpp); diff --git a/lib/p2/build.zig b/lib/p2/build.zig index 768cc5d..43e9129 100644 --- a/lib/p2/build.zig +++ b/lib/p2/build.zig @@ -3,6 +3,8 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse unreachable; + _ = static_build; const mod = b.addModule("p2", .{ .target = target, diff --git a/lib/packer/build.zig b/lib/packer/build.zig index 420bcff..b764487 100644 --- a/lib/packer/build.zig +++ b/lib/packer/build.zig @@ -4,7 +4,9 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const p2dep = b.dependency("p2", .{ .target = target, .optimize = optimize }); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + + const p2dep = b.dependency("p2", .{ .target = target, .optimize = optimize, .static_build = static_build }); const mod = b.addModule("packer", .{ .target = target, diff --git a/lib/sdl3/SDL/build.zig b/lib/sdl3/SDL/build.zig index 5361179..da009cb 100644 --- a/lib/sdl3/SDL/build.zig +++ b/lib/sdl3/SDL/build.zig @@ -11,6 +11,9 @@ pub const revision = formatted_version ++ " (" ++ vendor_info ++ ")"; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + _ = static_build; + const preferred_linkage: std.builtin.LinkMode = b.option( std.builtin.LinkMode, "preferred_linkage", diff --git a/lib/sdl3/build.zig b/lib/sdl3/build.zig index 840eb05..a6409bd 100644 --- a/lib/sdl3/build.zig +++ b/lib/sdl3/build.zig @@ -42,23 +42,9 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - var linux = false; - var windows = false; - var macos = false; - switch (target.result.os.tag) { - .windows => { - windows = true; - }, - .linux => { - linux = true; - }, - .macos => { - macos = true; - }, - else => {}, - } + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; - const preferred_linkage: std.builtin.LinkMode = if (linux) .static else .dynamic; + const preferred_linkage: std.builtin.LinkMode = if (static_build) .static else .dynamic; const sdl_dep = b.dependency("sdl", .{ .target = target, diff --git a/lib/sdl3/shaderTypes/build.zig b/lib/sdl3/shaderTypes/build.zig index 1854e86..394be03 100644 --- a/lib/sdl3/shaderTypes/build.zig +++ b/lib/sdl3/shaderTypes/build.zig @@ -4,6 +4,9 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + _ = static_build; + const mod = b.addModule("shaderTypes", .{ .target = target, .optimize = optimize, diff --git a/lib/spirv-reflect-zig/build.zig b/lib/spirv-reflect-zig/build.zig index e3211a5..71ec234 100644 --- a/lib/spirv-reflect-zig/build.zig +++ b/lib/spirv-reflect-zig/build.zig @@ -117,6 +117,8 @@ pub const SpirvGenerator2 = struct { pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const target = b.standardTargetOptions(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + _ = static_build; const test_step = b.step("test", ""); const tests = b.addTest(.{ diff --git a/lib/spng/build.zig b/lib/spng/build.zig index 535f08f..00a6f4b 100644 --- a/lib/spng/build.zig +++ b/lib/spng/build.zig @@ -4,14 +4,26 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const spng_c = b.addSharedLibrary( - .{ - .optimize = optimize, - .target = target, - .name = "spng_c", - .link_libc = true, - }, - ); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + + const spng_c = if (static_build) + b.addStaticLibrary( + .{ + .optimize = optimize, + .target = target, + .name = "spng_c", + .link_libc = true, + }, + ) + else + b.addSharedLibrary( + .{ + .optimize = optimize, + .target = target, + .name = "spng_c", + .link_libc = true, + }, + ); spng_c.addCSourceFile(.{ .file = b.path("spng/spng.c") }); spng_c.addCSourceFile(.{ .file = b.path("miniz.c") }); diff --git a/lib/tracy/build.zig b/lib/tracy/build.zig index 5b34ac1..22925af 100644 --- a/lib/tracy/build.zig +++ b/lib/tracy/build.zig @@ -6,6 +6,8 @@ const tracy_path_include = tracy_path ++ "/tracy"; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + _ = static_build; //const tracy_enabled = b.option(bool, "tracy", "Enables tracy integration") orelse false; diff --git a/lib/zgltf/build.zig b/lib/zgltf/build.zig index 0e38f4e..f500770 100644 --- a/lib/zgltf/build.zig +++ b/lib/zgltf/build.zig @@ -3,6 +3,8 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + _ = static_build; _ = b.addModule("zgltf", .{ .root_source_file = b.path("src/main.zig"), diff --git a/lib/zmath/build.zig b/lib/zmath/build.zig index d3d2aa9..c858efc 100644 --- a/lib/zmath/build.zig +++ b/lib/zmath/build.zig @@ -3,6 +3,8 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; + _ = static_build; const mod = b.addModule("zmath", .{ .target = target, diff --git a/lib/zphysics/build.zig b/lib/zphysics/build.zig index c451e93..4d78e27 100644 --- a/lib/zphysics/build.zig +++ b/lib/zphysics/build.zig @@ -3,6 +3,7 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const target = b.standardTargetOptions(.{}); + const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false; const options = .{ .use_double_precision = b.option( @@ -42,7 +43,11 @@ pub fn build(b: *std.Build) void { }); zjolt.addIncludePath(b.path("libs/JoltC")); - const joltc = b.addSharedLibrary(.{ + const joltc = if (static_build) b.addStaticLibrary(.{ + .name = "joltc", + .target = target, + .optimize = optimize, + }) else b.addSharedLibrary(.{ .name = "joltc", .target = target, .optimize = optimize, diff --git a/projects/build.zig b/projects/build.zig index 0258f94..11b0fd6 100644 --- a/projects/build.zig +++ b/projects/build.zig @@ -17,6 +17,18 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("sampleGame/main.zig"), }); + // new build api + // + // const game:BlProgram = blbuild.addProgram(...) + // game.addExtraModule(...) + // game.setModuleEnabled("physics", true); + // game.setModuleEnabled("audio", true); + // game.setModuleEnabled("audio", true); + // + //// commits changes and adds compile steps to the builder + // const sampleGame = game.addCompileSteps(); + // + blbuild.addExtraModule(sampleGame, "gameExtras"); blbuild.addExtraModule(sampleGame, "videoplayer"); blbuild.addExtraModule(sampleGame, "doomplayer"); diff --git a/projects/minimal/Saved/Session_Log.txt b/projects/minimal/Saved/Session_Log.txt deleted file mode 100644 index 3a61517..0000000 --- a/projects/minimal/Saved/Session_Log.txt +++ /dev/null @@ -1,112 +0,0 @@ -[ENGINE ]: defining componentScene -[ENGINE ]: Component container created scene.Scene @16ed1884f98 -[ENGINE ]: creating lua metatable Scene -[ENGINE ]: module started >>>> core <<<< -[ENGINE ]: platform settings windowing.PlatformParams{ .extent = math.Vector2Type(c_int,"Vector2c"[0..8]){ .x = 1600, .y = 900 }, .windowName = { 66, 97, 99, 107, 108, 111, 103, 32, 69, 110, 103, 105, 110, 101 }, .icon = { 116, 101, 120, 116, 117, 114, 101, 115, 47, 105, 99, 111, 110, 46, 112, 110, 103 }, .hasVideo = true } -[ENGINE ]: module started >>>> platform <<<< -[ENGINE ]: allocated size: 4035286 (3.848 MiB) -[ENGINE ]: peak allocated size size: 4035414 (3.848 MiB) (76 peak allocations) -[ENGINE ]: module started >>>> assets <<<< -[ENGINE ]: sgpu device created, using shader format: .spv -[ENGINE ]: using renderer... scientist -[ENGINE ]: creating shader meshes.vert => _shaders/spv/meshes.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 } -[ENGINE ]: creating shader lit_mesh.frag => _shaders/spv/lit_mesh.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 4, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 } -[GRAPHICS ]: swapchain format: gpu.GPUTextureFormat.textureformatB8g8r8a8Unorm -[ENGINE ]: creating shader postProc.vert => _shaders/spv/postProc.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 } -[ENGINE ]: creating shader postProc.frag => _shaders/spv/postProc.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 3, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 } -[GRAPHICS ]: hdr texture format format: gpu.GPUTextureFormat.textureformatR16g16b16a16Float -[GRAPHICS ]: mesh pool created 4000k vertices, 16000k indices -[ENGINE ]: asset loader for asset type (Mesh) registered -[ENGINE ]: Texture List Added -[ENGINE ]: asset loader for asset type (Texture) registered -[ENGINE ]: creating blocky sampler -[ENGINE ]: loading asset t_default (Texture) [embedded:texture_sample.png] -[ENGINE ]: loading texture t_default -[ENGINE ]: creating mipmap level 9 -[ENGINE ]: loading asset m_default_cube (Mesh) [embedded:primitive_box.obj] -[ENGINE ]: loading mesh asset embedded:primitive_box.obj [obj] -[GRAPHICS ]: [embedded:primitive_box.obj] vertex count vertices=24 indices=36 -[ENGINE ]: [DebugDrawSystem] starting up... -[ENGINE ]: loading asset m_debug_box (Mesh) [embedded:debug_box.obj] -[ENGINE ]: loading mesh asset embedded:debug_box.obj [obj] -[GRAPHICS ]: [embedded:debug_box.obj] vertex count vertices=24 indices=36 -[ENGINE ]: loading asset m_debug_line (Mesh) [embedded:debug_line.obj] -[ENGINE ]: loading mesh asset embedded:debug_line.obj [obj] -[GRAPHICS ]: [embedded:debug_line.obj] vertex count vertices=2 indices=3 -[ENGINE ]: loading asset m_debug_sphere (Mesh) [embedded:debug_sphere.obj] -[ENGINE ]: loading mesh asset embedded:debug_sphere.obj [obj] -[GRAPHICS ]: [embedded:debug_sphere.obj] vertex count vertices=240 indices=336 -[ENGINE ]: [DebugDrawSystem] registering to renderer... -[ENGINE ]: creating shader debug.vert => _shaders/spv/debug.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 } -[ENGINE ]: creating shader debug.frag => _shaders/spv/debug.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 } -[ENGINE ]: creating shader meshes.vert => _shaders/spv/meshes.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 } -[ENGINE ]: creating shader depthOnly.frag => _shaders/spv/depthOnly.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 } -[ENGINE ]: loading asset m_skybox (Mesh) [embedded:skybox_mesh.obj] -[ENGINE ]: loading mesh asset embedded:skybox_mesh.obj [obj] -[GRAPHICS ]: [embedded:skybox_mesh.obj] vertex count vertices=24 indices=36 -[ENGINE ]: creating shader skybox.vert => _shaders/spv/skybox.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 } -[ENGINE ]: creating shader skybox.frag => _shaders/spv/skybox.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 1, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 } -[ENGINE ]: loading asset m_plane (Mesh) [embedded:plane.obj] -[ENGINE ]: loading mesh asset embedded:plane.obj [obj] -[GRAPHICS ]: [embedded:plane.obj] vertex count vertices=4 indices=6 -[ENGINE ]: loading asset m_screenPlane (Mesh) [embedded:screenPlane.obj] -[ENGINE ]: loading mesh asset embedded:screenPlane.obj [obj] -[GRAPHICS ]: [embedded:screenPlane.obj] vertex count vertices=4 indices=6 -[ENGINE ]: creating ssao pipeline -[ENGINE ]: creating shader postProc.vert => _shaders/spv/postProc.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 } -[ENGINE ]: creating shader ssao.frag => _shaders/spv/ssao.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 3, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 } -[ENGINE ]: defining component_MeshComponent -[ENGINE ]: Component container created meshes.MeshComponent @16e88766338 -[ENGINE ]: creating lua metatable Mesh -[ENGINE ]: defining component_CameraComponent -[ENGINE ]: Component container created camera.CameraComponent @16ed3fef308 -[ENGINE ]: creating lua metatable Camera -[ENGINE ]: module started >>>> rend <<<< -[GRAPHICS ]: imgui startup -[ENGINE ]: module started >>>> imgui <<<< -[ENGINE ]: UI module started -[ENGINE ]: [Fontcache] loading font cache for default font -[ENGINE ]: [Fontcache] loading font cache for monospace font -[ENGINE ]: [Fontcache] loading font cache for bitmap font -[GRAPHICS ]: imgui startup -[ENGINE ]: module started >>>> ui <<<< -[ENGINE ]: creating Game context -[ENGINE ]: calling gEngine.run -[ENGINE ]: engine loop started -[ENGINE ]: program ready -[ENGINE ]: uploading mesh => m_default_cube -[GRAPHICS ]: uploading 24 vertices and 36 indices -[ENGINE ]: install mesh by name 16 -[ENGINE ]: uploading mesh => m_debug_box -[GRAPHICS ]: uploading 24 vertices and 36 indices -[ENGINE ]: install mesh by name 20 -[ENGINE ]: uploading mesh => m_debug_line -[GRAPHICS ]: uploading 2 vertices and 3 indices -[ENGINE ]: install mesh by name 21 -[ENGINE ]: uploading mesh => m_debug_sphere -[GRAPHICS ]: uploading 240 vertices and 336 indices -[ENGINE ]: install mesh by name 22 -[ENGINE ]: uploading mesh => m_skybox -[GRAPHICS ]: uploading 24 vertices and 36 indices -[ENGINE ]: install mesh by name 30 -[ENGINE ]: uploading mesh => m_plane -[GRAPHICS ]: uploading 4 vertices and 6 indices -[ENGINE ]: install mesh by name 37 -[ENGINE ]: uploading mesh => m_screenPlane -[GRAPHICS ]: uploading 4 vertices and 6 indices -[ENGINE ]: install mesh by name 38 -[ENGINE ]: Processing exit signals -[ENGINE ]: checking everything is ready to exit -[ENGINE ]: checking everything is ready to exit engineObject.InterfaceRef2(engineObject.EngineObjectVTable){ .ptr = anyopaque@16ed18a2458, .vtable = engineObject.EngineObjectVTable{ .typeName = { 119, 105, 110, 100, 111, 119, 105, 110, 103, 46, 80, 108, 97, 116, 102, 111, 114, 109, 73, 110, 115, 116, 97, 110, 99, 101 }, .typeSize = 112, .typeAlign = 8, .singletonName = { 112, 108, 97, 116, 102, 111, 114, 109, 46, 73, 110, 115, 116, 97, 110, 99, 101 }, .init_func = fn (mem.Allocator) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!*anyopaque@7ff7f0769030, .tick_func = null, .engineDraw_func = null, .preTick_func = null, .deinit_func = fn (*anyopaque) void@7ff7f0769290, .postInit_func = null, .processEvents = null, .exitSignal_func = fn (*anyopaque) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!void@7ff7f0769170, .readyToExit_func = fn (*anyopaque) bool@7ff7f07691f0, .prepare_func = null, .fieldListHash = null, .fieldList = null, .slackSize = null } } -[ENGINE ]: exiting -[ENGINE ]: module shutting down >>>> ui <<<< -[ENGINE ]: module shutting down >>>> imgui <<<< -[ENGINE ]: module shutting down >>>> rend <<<< -[ENGINE ]: undefining component meshes.MeshComponent -[ENGINE ]: undefining component camera.CameraComponent -[ENGINE ]: module shutting down >>>> assets <<<< -[ENGINE ]: module shutting down >>>> platform <<<< -[ENGINE ]: module shutting down >>>> core <<<< -[ENGINE ]: allocated size: 3064738 (2.923 MiB) -[ENGINE ]: peak allocated size size: 9418782 (8.982 MiB) (190 peak allocations) -[ENGINE ]: undefining component scene.Scene