split between zig and c libraries complete
This commit is contained in:
parent
2176977c4c
commit
b0d1a81d84
12
CLAUDE.md
12
CLAUDE.md
|
|
@ -96,12 +96,12 @@ The shader compilation system automatically discovers `.hlsl` files in `engine/*
|
||||||
- The build system generates API wrappers automatically for enabled modules
|
- The build system generates API wrappers automatically for enabled modules
|
||||||
- Content directory location is determined by `content.txt` file pointing to `projects/content/`
|
- Content directory location is determined by `content.txt` file pointing to `projects/content/`
|
||||||
|
|
||||||
### MakeModlib Build Helper
|
### MakeModLib Build Helper
|
||||||
|
|
||||||
The project uses a custom `MakeModlib` helper function (defined in `lib/bh/build.zig`) to create library modules with consistent patterns:
|
The project uses a custom `MakeModLib` helper function (defined in `lib/bh/build.zig`) to create library modules with consistent patterns:
|
||||||
|
|
||||||
```zig
|
```zig
|
||||||
const mylib = bh.MakeModlib(b, .{
|
const mylib = bh.MakeModLib(b, .{
|
||||||
.name = "mylib",
|
.name = "mylib",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
@ -110,19 +110,19 @@ const mylib = bh.MakeModlib(b, .{
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
**What MakeModlib creates:**
|
**What MakeModLib creates:**
|
||||||
- A Zig module (`.mod`) for compile-time imports
|
- A Zig module (`.mod`) for compile-time imports
|
||||||
- A library artifact (`.lib`) for linking (static or dynamic based on `static_build` flag)
|
- A library artifact (`.lib`) for linking (static or dynamic based on `static_build` flag)
|
||||||
- The library uses an empty stub source file and is intended to carry C dependencies
|
- The library uses an empty stub source file and is intended to carry C dependencies
|
||||||
|
|
||||||
**Usage pattern:**
|
**Usage pattern:**
|
||||||
All libraries using `MakeModlib` follow this pattern in their test executables:
|
All libraries using `MakeModLib` follow this pattern in their test executables:
|
||||||
```zig
|
```zig
|
||||||
tests.root_module.addImport("mylib", mylib.mod); // Import the module
|
tests.root_module.addImport("mylib", mylib.mod); // Import the module
|
||||||
tests.root_module.linkLibrary(mylib.lib); // Link the library
|
tests.root_module.linkLibrary(mylib.lib); // Link the library
|
||||||
```
|
```
|
||||||
|
|
||||||
**Libraries using MakeModlib:**
|
**Libraries using MakeModLib:**
|
||||||
- `bh`, `cimgui`, `enet`, `lua`, `miniaudio`, `nfd`, `objLoader`, `p2`, `packer`, `spng`, `tracy`, `watcher`, `zgltf`, `zmath`
|
- `bh`, `cimgui`, `enet`, `lua`, `miniaudio`, `nfd`, `objLoader`, `p2`, `packer`, `spng`, `tracy`, `watcher`, `zgltf`, `zmath`
|
||||||
|
|
||||||
This pattern separates Zig code (in the module) from C/C++ dependencies (in the library), allowing for flexible static/dynamic linking while maintaining consistent module interfaces.
|
This pattern separates Zig code (in the module) from C/C++ dependencies (in the library), allowing for flexible static/dynamic linking while maintaining consistent module interfaces.
|
||||||
|
|
|
||||||
15
build.zig
15
build.zig
|
|
@ -243,12 +243,12 @@ pub fn addDependencyInstalls(self: *BuildSystem, b: *std.Build, optimize: std.bu
|
||||||
|
|
||||||
const DynamicDepList: []const struct { dep: []const u8, artifact: []const u8 } = &.{
|
const DynamicDepList: []const struct { dep: []const u8, artifact: []const u8 } = &.{
|
||||||
.{ .dep = "sdl3", .artifact = "SDL3" },
|
.{ .dep = "sdl3", .artifact = "SDL3" },
|
||||||
.{ .dep = "spng", .artifact = "spng_c" },
|
.{ .dep = "spng", .artifact = "spng" },
|
||||||
.{ .dep = "lua", .artifact = "luac" },
|
.{ .dep = "lua", .artifact = "lua" },
|
||||||
.{ .dep = "miniaudio", .artifact = "miniaudio_c" },
|
.{ .dep = "miniaudio", .artifact = "miniaudio" },
|
||||||
.{ .dep = "zphysics", .artifact = "joltc" },
|
.{ .dep = "zphysics", .artifact = "zphysics" },
|
||||||
// .{ .dep = "enet", .artifact = "enet_c" },
|
// .{ .dep = "enet", .artifact = "enet_c" },
|
||||||
.{ .dep = "ozz", .artifact = "ozz_cpp" },
|
.{ .dep = "ozz", .artifact = "ozz" },
|
||||||
};
|
};
|
||||||
|
|
||||||
// all other modules are disabled by default
|
// all other modules are disabled by default
|
||||||
|
|
@ -551,6 +551,8 @@ pub fn build(b: *std.Build) void {
|
||||||
mod.addImport(b.fmt("{s}", .{depName}), modFwd);
|
mod.addImport(b.fmt("{s}", .{depName}), modFwd);
|
||||||
modFwd.addImport("module", dep.module(depName));
|
modFwd.addImport("module", dep.module(depName));
|
||||||
|
|
||||||
|
b.installArtifact(dep.artifact(depName));
|
||||||
|
|
||||||
// mod.addImport(depName, dep.module(depName));
|
// mod.addImport(depName, dep.module(depName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -561,7 +563,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.static_build = static_build,
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
const lib = dep.module("SDL3");
|
const lib = dep.module("sdl3");
|
||||||
|
|
||||||
mod.addImport("sdl3_fwd", lib);
|
mod.addImport("sdl3_fwd", lib);
|
||||||
}
|
}
|
||||||
|
|
@ -594,6 +596,7 @@ pub fn generateApi(self: *@This(), programName: []const u8, moduleList: []const
|
||||||
});
|
});
|
||||||
for (moduleList) |modName| {
|
for (moduleList) |modName| {
|
||||||
mod.addImport(modName, self.nwdep.module(modName));
|
mod.addImport(modName, self.nwdep.module(modName));
|
||||||
|
mod.linkLibrary(self.nwdep.artifact(modName));
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadStatics = self.generateInstallStaticResources(programName, "content/_shaders") catch unreachable;
|
const loadStatics = self.generateInstallStaticResources(programName, "content/_shaders") catch unreachable;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const core = @import("core").MakeModLib;
|
const core = @import("core");
|
||||||
|
|
||||||
const depList = [_][]const u8{
|
const depList = [_][]const u8{
|
||||||
"core",
|
"core",
|
||||||
|
|
@ -19,6 +19,7 @@ pub fn build(b: *std.Build) void {
|
||||||
});
|
});
|
||||||
|
|
||||||
engineMod.linkModLibs(&depList);
|
engineMod.linkModLibs(&depList);
|
||||||
|
engineMod.install();
|
||||||
|
|
||||||
const test_step = b.step("test", "run unit tests for assets");
|
const test_step = b.step("test", "run unit tests for assets");
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
|
|
@ -29,7 +30,7 @@ pub fn build(b: *std.Build) void {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.root_module.addImport("assets", engineMod);
|
tests.root_module.addImport("assets", engineMod.mod);
|
||||||
const runArtifact = b.addRunArtifact(tests);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const core = @import("core").MakeModLib;
|
const core = @import("core");
|
||||||
|
|
||||||
const depList = [_][]const u8{
|
const depList = [_][]const u8{
|
||||||
"miniaudio",
|
"miniaudio",
|
||||||
|
|
@ -20,6 +20,7 @@ pub fn build(b: *std.Build) void {
|
||||||
});
|
});
|
||||||
|
|
||||||
engineMod.linkModLibs(&depList);
|
engineMod.linkModLibs(&depList);
|
||||||
|
engineMod.install();
|
||||||
|
|
||||||
const test_step = b.step("test", "run unit tests for audio");
|
const test_step = b.step("test", "run unit tests for audio");
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,21 @@ const dependencyList = [_][]const u8{
|
||||||
"packer", // packer no longer has C deps.
|
"packer", // packer no longer has C deps.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub fn MakeEngineMod(b: *std.Build, name: []const u8) ModLib {
|
||||||
|
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 engineMod = MakeModLib(b, .{
|
||||||
|
.name = name,
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
.static_build = static_build,
|
||||||
|
});
|
||||||
|
|
||||||
|
return engineMod;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
@ -23,6 +38,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.static_build = static_build,
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
engineMod.install();
|
||||||
engineMod.linkModLibs(&dependencyList);
|
engineMod.linkModLibs(&dependencyList);
|
||||||
|
|
||||||
const test_step = b.step("test", "run unit tests for core");
|
const test_step = b.step("test", "run unit tests for core");
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
// with -Dtracy = false, this one pulls in no C dependencies
|
// with -Dtracy = false, this one pulls in no C dependencies
|
||||||
.tracy = .{ .path = "../../lib/tracy" },
|
.tracy = .{ .path = "../../lib/tracy" },
|
||||||
.bh = .{.path = "../../lib/bh" },
|
.bh = .{ .path = "../../lib/bh" },
|
||||||
|
|
||||||
// these are zig only
|
// these are zig only
|
||||||
.zmath = .{ .path = "../../lib/zmath" },
|
.zmath = .{ .path = "../../lib/zmath" },
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.static_build = static_build,
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
engineMod.install();
|
||||||
engineMod.linkModLibs(&dependencyList);
|
engineMod.linkModLibs(&dependencyList);
|
||||||
|
|
||||||
// ========== tests ==========
|
// ========== tests ==========
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,13 @@ pub fn build(b: *std.Build) void {
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const engineMod = core.MakeModLib(b, .{
|
const engineMod = core.MakeModLib(b, .{
|
||||||
.name = "imgui",
|
.name = "net",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.static_build = static_build,
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
engineMod.install();
|
||||||
engineMod.linkModLibs(&depList);
|
engineMod.linkModLibs(&depList);
|
||||||
|
|
||||||
const test_step = b.step("test", "run unit tests for net");
|
const test_step = b.step("test", "run unit tests for net");
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,12 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.static_build = static_build,
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
engineMod.lib.linkLibC();
|
||||||
|
|
||||||
|
engineMod.install();
|
||||||
engineMod.linkModLibs(&depList);
|
engineMod.linkModLibs(&depList);
|
||||||
engineMod.addIncludePath("src/");
|
engineMod.addIncludePath("src/");
|
||||||
engineMod.lib.addCSourceFile(b.path("src/compat.cpp"));
|
engineMod.lib.addCSourceFile(.{ .file = b.path("src/compat.cpp"), .flags = &.{} });
|
||||||
|
|
||||||
const mod = b.addModule("papyrus", .{
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
.link_libc = true,
|
|
||||||
.root_source_file = b.path("src/papyrus.zig"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Creates a step for unit testing.
|
// Creates a step for unit testing.
|
||||||
const main_tests = b.addTest(.{
|
const main_tests = b.addTest(.{
|
||||||
|
|
@ -39,9 +34,9 @@ pub fn build(b: *std.Build) void {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
main_tests.root_module.addImport("papyrus", mod);
|
main_tests.root_module.addImport("papyrus", engineMod.mod);
|
||||||
main_tests.root_module.addIncludePath(b.path("src/"));
|
main_tests.root_module.addIncludePath(b.path("src/"));
|
||||||
|
main_tests.linkLibrary(engineMod.lib);
|
||||||
main_tests.linkLibC();
|
main_tests.linkLibC();
|
||||||
main_tests.linkLibCpp();
|
main_tests.linkLibCpp();
|
||||||
const run_tests = b.addRunArtifact(main_tests);
|
const run_tests = b.addRunArtifact(main_tests);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
||||||
const papyrus = @import("papyrus.zig");
|
const papyrus = @import("papyrus.zig");
|
||||||
const Context = papyrus.Context;
|
const Context = papyrus.Context;
|
||||||
|
|
||||||
const core = @import("core");
|
const core = papyrus.core;
|
||||||
const Vector2i = core.Vector2i;
|
const Vector2i = core.Vector2i;
|
||||||
const Vector2 = core.Vector2;
|
const Vector2 = core.Vector2;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c.zig").c;
|
const c = @import("c.zig").c;
|
||||||
|
|
||||||
const core = @import("core");
|
const core = @import("papyrus.zig").core;
|
||||||
const Vector2i = core.Vector2i;
|
const Vector2i = core.Vector2i;
|
||||||
const Vector2f = core.Vector2f;
|
const Vector2f = core.Vector2f;
|
||||||
const Name = core.Name;
|
const Name = core.Name;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @cImport({
|
pub const c = @cImport({
|
||||||
@cInclude("stb_ttf.h");
|
@cInclude("stb_ttf.h");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,7 @@ const std = @import("std");
|
||||||
const papyrus = @import("papyrus");
|
const papyrus = @import("papyrus");
|
||||||
const localization = papyrus.localization;
|
const localization = papyrus.localization;
|
||||||
const utils = papyrus.utils;
|
const utils = papyrus.utils;
|
||||||
const c = @cImport({
|
const c = papyrus.c;
|
||||||
@cInclude("stb_ttf.h");
|
|
||||||
});
|
|
||||||
|
|
||||||
const PapyrusContext = papyrus.Context;
|
const PapyrusContext = papyrus.Context;
|
||||||
const PapyrusNode = papyrus.Node;
|
const PapyrusNode = papyrus.Node;
|
||||||
const MakeText = localization.MakeText;
|
const MakeText = localization.MakeText;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const core = @import("core");
|
||||||
|
|
||||||
|
const depList = [_][]const u8{
|
||||||
|
"core",
|
||||||
|
};
|
||||||
|
|
||||||
// very tiny, not intended to build anything just to run tests linked with libc
|
// very tiny, not intended to build anything just to run tests linked with libc
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
|
|
@ -6,25 +11,24 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const mod = b.addModule("physics", .{
|
const engineMod = core.MakeModLib(b, .{
|
||||||
|
.name = "physics",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.link_libc = true,
|
.static_build = static_build,
|
||||||
.root_source_file = b.path("src/physics.zig"),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const core_dep = b.dependency("core", .{ .target = target, .optimize = optimize, .static_build = static_build });
|
engineMod.install();
|
||||||
|
engineMod.linkModLibs(&depList);
|
||||||
|
|
||||||
const zphysics_dep = b.dependency("zphysics", .{
|
const zphysics_dep = b.dependency("zphysics", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.enable_cross_platform_determinism = false,
|
|
||||||
.static_build = static_build,
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
mod.addImport("core", core_dep.module("core"));
|
engineMod.mod.addImport("zphysics", zphysics_dep.module("root"));
|
||||||
mod.addImport("zphysics", zphysics_dep.module("root"));
|
engineMod.lib.linkLibrary(zphysics_dep.artifact("zphysics"));
|
||||||
mod.linkLibrary(zphysics_dep.artifact("joltc"));
|
|
||||||
|
|
||||||
const test_step = b.step("test", "run unit tests for physics");
|
const test_step = b.step("test", "run unit tests for physics");
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
|
|
@ -35,7 +39,8 @@ pub fn build(b: *std.Build) void {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.root_module.addImport("physics", mod);
|
tests.root_module.addImport("physics", engineMod.mod);
|
||||||
|
tests.root_module.linkLibrary(zphysics_dep.artifact("zphysics"));
|
||||||
const runArtifact = b.addRunArtifact(tests);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const sdl3 = @import("sdl3");
|
const sdl3 = @import("sdl3");
|
||||||
|
const core = @import("core");
|
||||||
|
|
||||||
const dependencyList = [_][]const u8{
|
const dependencyList = [_][]const u8{
|
||||||
"core",
|
"core",
|
||||||
|
|
@ -13,12 +14,16 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const mod = b.addModule("platform", .{
|
const engineMod = core.MakeModLib(b, .{
|
||||||
.target = target,
|
.name = "platform",
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.root_source_file = b.path("src/platform.zig"),
|
.target = target,
|
||||||
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
engineMod.linkModLibs(&dependencyList);
|
||||||
|
engineMod.install();
|
||||||
|
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|
@ -27,16 +32,10 @@ pub fn build(b: *std.Build) void {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
for (dependencyList) |depName| {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
const test_step = b.step("test", "run unit tests for platform");
|
const test_step = b.step("test", "run unit tests for platform");
|
||||||
|
tests.root_module.addImport("platform", engineMod.mod);
|
||||||
|
tests.linkLibrary(engineMod.lib);
|
||||||
|
|
||||||
tests.root_module.addImport("platform", mod);
|
|
||||||
const runArtifact = b.addRunArtifact(tests);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const core = @import("core");
|
pub const core = @import("core");
|
||||||
const test_vert = @import("test.vert");
|
const test_vert = @import("test.vert");
|
||||||
|
|
||||||
pub const nfd = @import("nfd");
|
pub const nfd = @import("nfd");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const core = @import("core");
|
|
||||||
const platform = @import("platform");
|
const platform = @import("platform");
|
||||||
|
const core = @import("platform").core;
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const sdl3 = @import("sdl3");
|
const sdl3 = @import("sdl3");
|
||||||
|
const core = @import("core");
|
||||||
|
|
||||||
const dependencyList = [_][]const u8{
|
const dependencyList = [_][]const u8{
|
||||||
"core",
|
"core",
|
||||||
|
|
@ -19,38 +20,47 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const mod = b.addModule("rend", .{
|
const engineMod = core.MakeModLib(b, .{
|
||||||
|
.name = "rend",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.root_source_file = b.path("src/rend.zig"),
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
engineMod.linkModLibs(&dependencyList);
|
||||||
|
engineMod.install();
|
||||||
|
|
||||||
for (dependencyList) |depName| {
|
// const mod = b.addModule("rend", .{
|
||||||
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
// .target = target,
|
||||||
const dep_mod = dep.module(depName);
|
// .optimize = optimize,
|
||||||
mod.addImport(depName, dep_mod);
|
// .root_source_file = b.path("src/rend.zig"),
|
||||||
|
// });
|
||||||
|
|
||||||
if (std.mem.eql(u8, depName, "ozz")) {
|
// for (dependencyList) |depName| {
|
||||||
mod.linkLibrary(dep.artifact("ozz_cpp"));
|
// const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
||||||
}
|
// const dep_mod = dep.module(depName);
|
||||||
}
|
// mod.addImport(depName, dep_mod);
|
||||||
|
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "sample.vert", b.path("shaders/sample.vert.json"));
|
// if (std.mem.eql(u8, depName, "ozz")) {
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "meshes.vert", b.path("shaders/meshes.vert.json"));
|
// mod.linkLibrary(dep.artifact("ozz_cpp"));
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "lit_mesh.frag", b.path("shaders/lit_mesh.frag.json"));
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "debug.frag", b.path("shaders/debug.frag.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "sample.vert", b.path("shaders/sample.vert.json"));
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "debug.vert", b.path("shaders/debug.vert.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "meshes.vert", b.path("shaders/meshes.vert.json"));
|
||||||
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "lit_mesh.frag", b.path("shaders/lit_mesh.frag.json"));
|
||||||
|
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "depthOnly.frag", b.path("shaders/depthOnly.frag.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "debug.frag", b.path("shaders/debug.frag.json"));
|
||||||
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "debug.vert", b.path("shaders/debug.vert.json"));
|
||||||
|
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "skybox.frag", b.path("shaders/skybox.frag.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "depthOnly.frag", b.path("shaders/depthOnly.frag.json"));
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "skybox.vert", b.path("shaders/skybox.vert.json"));
|
|
||||||
|
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "postProc.frag", b.path("shaders/postProc.frag.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "skybox.frag", b.path("shaders/skybox.frag.json"));
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "postProc.vert", b.path("shaders/postProc.vert.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "skybox.vert", b.path("shaders/skybox.vert.json"));
|
||||||
|
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "ssao.frag", b.path("shaders/ssao.frag.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "postProc.frag", b.path("shaders/postProc.frag.json"));
|
||||||
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "postProc.vert", b.path("shaders/postProc.vert.json"));
|
||||||
|
|
||||||
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "ssao.frag", b.path("shaders/ssao.frag.json"));
|
||||||
|
|
||||||
// ========== tests ==========
|
// ========== tests ==========
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,27 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const sdl3 = @import("sdl3");
|
const sdl3 = @import("sdl3");
|
||||||
|
const core = @import("core");
|
||||||
|
|
||||||
const dependencyList = [_][]const u8{
|
const dependencyList = [_][]const u8{
|
||||||
"core",
|
"core",
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const engineMod = core.MakeEngineMod(b, "sys");
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
engineMod.linkModLibs(&dependencyList);
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
engineMod.install();
|
||||||
|
|
||||||
const mod = b.addModule("sys", .{
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
.root_source_file = b.path("src/sys.zig"),
|
|
||||||
});
|
|
||||||
|
|
||||||
for (dependencyList) |depName| {
|
|
||||||
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 ==========
|
// ========== tests ==========
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.target = target,
|
.target = engineMod.target,
|
||||||
.optimize = optimize,
|
.optimize = engineMod.optimize,
|
||||||
.root_source_file = b.path("tests/tests.zig"),
|
.root_source_file = b.path("tests/tests.zig"),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const test_step = b.step("test", "run unit tests for ui");
|
const test_step = b.step("test", "run unit tests for ui");
|
||||||
|
|
||||||
tests.root_module.addImport("sys", mod);
|
tests.root_module.addImport("sys", engineMod.mod);
|
||||||
const runArtifact = b.addRunArtifact(tests);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ pub const SubprocessTask = struct {
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
|
|
||||||
child: ?std.process.Child = null,
|
child: ?std.process.Child = null,
|
||||||
completed: bool = false,
|
completed: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
|
||||||
success: bool = false,
|
success: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
|
||||||
|
|
||||||
workingDir: ?[]const u8 = null,
|
workingDir: ?[]const u8 = null,
|
||||||
|
|
||||||
|
|
@ -76,29 +76,29 @@ pub const SubprocessTask = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn destroy(self: *@This()) void {
|
pub fn destroy(self: *@This()) void {
|
||||||
self.mutex.lock();
|
// self.mutex.lock();
|
||||||
self.argsArena.deinit();
|
self.argsArena.deinit();
|
||||||
self.argsOwned.deinit(self.allocator);
|
self.argsOwned.deinit(self.allocator);
|
||||||
if (self.child) |*child| {
|
if (self.child) |*child| {
|
||||||
_ = child;
|
_ = child;
|
||||||
core.engine_log("destroying child process", .{});
|
core.engine_log("destroying child process", .{});
|
||||||
}
|
}
|
||||||
self.mutex.unlock();
|
// self.mutex.unlock();
|
||||||
self.stdout.deinit(self.allocator);
|
self.stdout.deinit(self.allocator);
|
||||||
self.stderr.deinit(self.allocator);
|
self.stderr.deinit(self.allocator);
|
||||||
self.allocator.destroy(self);
|
self.allocator.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checkComplete(self: *@This()) bool {
|
pub fn checkComplete(self: *@This()) bool {
|
||||||
return self.completed;
|
return self.completed.load(.monotonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait(self: *@This()) void {
|
pub fn wait(self: *@This()) void {
|
||||||
var completed: bool = self.completed;
|
var completed: bool = self.completed.load(.monotonic);
|
||||||
while (completed == false) {
|
while (completed == false) {
|
||||||
std.Thread.sleep(1 * 1000 * 1000);
|
std.Thread.sleep(1 * 1000 * 1000);
|
||||||
self.mutex.lock();
|
self.mutex.lock();
|
||||||
completed = self.completed;
|
completed = self.completed.load(.monotonic);
|
||||||
self.mutex.unlock();
|
self.mutex.unlock();
|
||||||
}
|
}
|
||||||
debugPrint("task completed", .{});
|
debugPrint("task completed", .{});
|
||||||
|
|
@ -117,7 +117,7 @@ pub const SubprocessTask = struct {
|
||||||
|
|
||||||
switch (term) {
|
switch (term) {
|
||||||
.Exited => |m| {
|
.Exited => |m| {
|
||||||
if (m == 0) self.success = true;
|
if (m == 0) self.success.store(true, .release);
|
||||||
},
|
},
|
||||||
.Signal => |m| {
|
.Signal => |m| {
|
||||||
core.engine_log("process Signaled {d}", .{m});
|
core.engine_log("process Signaled {d}", .{m});
|
||||||
|
|
@ -132,8 +132,8 @@ pub const SubprocessTask = struct {
|
||||||
|
|
||||||
self.mutex.lock();
|
self.mutex.lock();
|
||||||
self.child = null;
|
self.child = null;
|
||||||
self.completed = true;
|
|
||||||
self.mutex.unlock();
|
self.mutex.unlock();
|
||||||
|
self.completed.store(true, .release);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn runCommand(allocator: std.mem.Allocator, argv: []const []const u8, cwd: ?[]const u8) !*@This() {
|
pub fn runCommand(allocator: std.mem.Allocator, argv: []const []const u8, cwd: ?[]const u8) !*@This() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const sdl3 = @import("sdl3");
|
const sdl3 = @import("sdl3");
|
||||||
|
const core = @import("core");
|
||||||
|
|
||||||
const dependencyList = [_][]const u8{
|
const dependencyList = [_][]const u8{
|
||||||
"core",
|
"core",
|
||||||
|
|
@ -11,28 +12,18 @@ const dependencyList = [_][]const u8{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const engineMod = core.MakeEngineMod(b, "ui");
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
engineMod.linkModLibs(&dependencyList);
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
engineMod.install();
|
||||||
|
const target = engineMod.target;
|
||||||
const mod = b.addModule("ui", .{
|
const optimize = engineMod.optimize;
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
.root_source_file = b.path("src/ui.zig"),
|
|
||||||
});
|
|
||||||
|
|
||||||
for (dependencyList) |depName| {
|
|
||||||
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
|
||||||
const dep_mod = dep.module(depName);
|
|
||||||
mod.addImport(depName, dep_mod);
|
|
||||||
}
|
|
||||||
|
|
||||||
// shaders
|
// shaders
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "rect.vert", b.path("shaders/rect.vert.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "rect.vert", b.path("shaders/rect.vert.json"));
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "rect.frag", b.path("shaders/rect.frag.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "rect.frag", b.path("shaders/rect.frag.json"));
|
||||||
|
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "text.vert", b.path("shaders/text.vert.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "text.vert", b.path("shaders/text.vert.json"));
|
||||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "text.frag", b.path("shaders/text.frag.json"));
|
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "text.frag", b.path("shaders/text.frag.json"));
|
||||||
|
|
||||||
// ========== tests ==========
|
// ========== tests ==========
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
|
|
@ -44,7 +35,8 @@ pub fn build(b: *std.Build) void {
|
||||||
});
|
});
|
||||||
const test_step = b.step("test", "run unit tests for ui");
|
const test_step = b.step("test", "run unit tests for ui");
|
||||||
|
|
||||||
tests.root_module.addImport("ui", mod);
|
tests.root_module.addImport("ui", engineMod.mod);
|
||||||
|
tests.root_module.linkLibrary(engineMod.lib);
|
||||||
const runArtifact = b.addRunArtifact(tests);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ pub const ModLib = struct {
|
||||||
self.mod.addIncludePath(self.b.path(path));
|
self.mod.addIncludePath(self.b.path(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkModLibs(self: *@This(), list: []const []const u8) void {
|
pub fn linkModLibs(self: @This(), list: []const []const u8) void {
|
||||||
for (list) |depName| {
|
for (list) |depName| {
|
||||||
const dep = self.b.dependency(depName, .{
|
const dep = self.b.dependency(depName, .{
|
||||||
.target = self.target,
|
.target = self.target,
|
||||||
|
|
@ -44,7 +44,7 @@ pub const ModLibOptions = struct {
|
||||||
stub: ?std.Build.LazyPath = null,
|
stub: ?std.Build.LazyPath = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn MakeModlib(b: *std.Build, o: ModLibOptions) ModLib {
|
pub fn MakeModLib(b: *std.Build, o: ModLibOptions) ModLib {
|
||||||
const mod = b.addModule(o.name, .{
|
const mod = b.addModule(o.name, .{
|
||||||
.target = o.target,
|
.target = o.target,
|
||||||
.optimize = o.optimize,
|
.optimize = o.optimize,
|
||||||
|
|
@ -78,7 +78,7 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const r = MakeModlib(b, .{
|
const r = MakeModLib(b, .{
|
||||||
.name = "bh",
|
.name = "bh",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const cimgui = bh.MakeModlib(b, .{
|
const cimgui = bh.MakeModLib(b, .{
|
||||||
.name = "cimgui",
|
.name = "cimgui",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
|
||||||
// .optimize = optimize,
|
// .optimize = optimize,
|
||||||
// });
|
// });
|
||||||
|
|
||||||
const enet = bh.MakeModlib(b, .{
|
const enet = bh.MakeModLib(b, .{
|
||||||
.name = "enet",
|
.name = "enet",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const lua = bh.MakeModlib(b, .{
|
const lua = bh.MakeModLib(b, .{
|
||||||
.name = "lua",
|
.name = "lua",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const miniaudio = bh.MakeModlib(b, .{
|
const miniaudio = bh.MakeModLib(b, .{
|
||||||
.name = "miniaudio",
|
.name = "miniaudio",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const nfd = bh.MakeModlib(b, .{
|
const nfd = bh.MakeModLib(b, .{
|
||||||
.name = "nfd",
|
.name = "nfd",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const objLoader = bh.MakeModlib(b, .{
|
const objLoader = bh.MakeModLib(b, .{
|
||||||
.name = "objLoader",
|
.name = "objLoader",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ pub const GltfToOzz = struct {
|
||||||
});
|
});
|
||||||
|
|
||||||
const dep = b.dependency(opts.importName, .{});
|
const dep = b.dependency(opts.importName, .{});
|
||||||
const ozz_mod = dep.artifact("ozz_cpp");
|
const ozz_mod = dep.artifact("ozz");
|
||||||
exe.root_module.linkLibrary(ozz_mod);
|
exe.root_module.linkLibrary(ozz_mod);
|
||||||
|
|
||||||
exe.root_module.addIncludePath(b.path("ozz-animation/include"));
|
exe.root_module.addIncludePath(b.path("ozz-animation/include"));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse true;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse true;
|
||||||
|
|
||||||
const p2 = bh.MakeModlib(b, .{
|
const p2 = bh.MakeModLib(b, .{
|
||||||
.name = "p2",
|
.name = "p2",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ pub const IndexPool = index_pool.IndexPool;
|
||||||
|
|
||||||
pub const concurrent_queue = @import("structures/concurrent-queue.zig");
|
pub const concurrent_queue = @import("structures/concurrent-queue.zig");
|
||||||
pub const ConcurrentQueueU = concurrent_queue.ConcurrentQueueU;
|
pub const ConcurrentQueueU = concurrent_queue.ConcurrentQueueU;
|
||||||
pub const ConcurrentQueueUnmanagedAdvanced = concurrent_queue.ConcurrentQueueUnmanagedAdvanced;
|
pub const ConcurrentQueueAdvanced = concurrent_queue.ConcurrentQueueAdvanced;
|
||||||
|
|
||||||
pub const string_pool = @import("structures/string-pool.zig");
|
pub const string_pool = @import("structures/string-pool.zig");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const packer = bh.MakeModlib(b, .{
|
const packer = bh.MakeModLib(b, .{
|
||||||
.name = "packer",
|
.name = "packer",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -62,14 +62,18 @@ pub fn build(b: *std.Build) void {
|
||||||
});
|
});
|
||||||
|
|
||||||
const sdl3_lib = sdl_dep.artifact("SDL3");
|
const sdl3_lib = sdl_dep.artifact("SDL3");
|
||||||
|
b.installArtifact(sdl3_lib);
|
||||||
|
|
||||||
const sdl3_fwd = b.addModule("SDL3", .{
|
const sdl3_fwd = b.addLibrary(.{
|
||||||
.target = target,
|
.name = "sdl3",
|
||||||
.optimize = optimize,
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/sdl3_lib_fwd.zig"),
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
.root_source_file = b.path("src/sdl3_lib_fwd.zig"),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
sdl3_fwd.linkLibrary(sdl3_lib);
|
sdl3_fwd.linkLibrary(sdl3_lib);
|
||||||
|
b.installArtifact(sdl3_fwd);
|
||||||
|
|
||||||
const mod = b.addModule("sdl3", .{
|
const mod = b.addModule("sdl3", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|
@ -84,7 +88,7 @@ pub fn build(b: *std.Build) void {
|
||||||
mod.addImport("shaderTypes", shaderTypes.module("shaderTypes"));
|
mod.addImport("shaderTypes", shaderTypes.module("shaderTypes"));
|
||||||
|
|
||||||
mod.addIncludePath(b.path("SDL/include"));
|
mod.addIncludePath(b.path("SDL/include"));
|
||||||
mod.linkLibrary(sdl3_lib);
|
mod.linkLibrary(sdl_dep.artifact("SDL3"));
|
||||||
|
|
||||||
const test_step2 = b.step("test", "run unit tests for sdl3");
|
const test_step2 = b.step("test", "run unit tests for sdl3");
|
||||||
const tests2 = b.addExecutable(.{
|
const tests2 = b.addExecutable(.{
|
||||||
|
|
@ -134,7 +138,6 @@ pub fn build(b: *std.Build) void {
|
||||||
test_step2.dependOn(&runArtifact2.step);
|
test_step2.dependOn(&runArtifact2.step);
|
||||||
|
|
||||||
b.installArtifact(hello_window_exe);
|
b.installArtifact(hello_window_exe);
|
||||||
b.installArtifact(sdl3_lib);
|
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
b.installArtifact(tests2);
|
b.installArtifact(tests2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,15 @@ pub fn build(b: *std.Build) void {
|
||||||
.root_source_file = b.path("shaderTypes.zig"),
|
.root_source_file = b.path("shaderTypes.zig"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const lib = b.addLibrary(.{
|
||||||
|
.name = "shaderTypes",
|
||||||
|
.root_module = b.createModule(.{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
.root_source_file = b.path("stubc.zig"),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
b.installArtifact(lib);
|
||||||
_ = mod;
|
_ = mod;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const spng = bh.MakeModlib(b, .{
|
const spng = bh.MakeModLib(b, .{
|
||||||
.name = "spng",
|
.name = "spng",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
|
||||||
// }
|
// }
|
||||||
// std.debug.print("tracy enabled {s}\n", .{if (tracy_enabled) "true" else "false"});
|
// std.debug.print("tracy enabled {s}\n", .{if (tracy_enabled) "true" else "false"});
|
||||||
|
|
||||||
const tracy = bh.MakeModlib(b, .{
|
const tracy = bh.MakeModLib(b, .{
|
||||||
.name = "tracy",
|
.name = "tracy",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const watcher = bh.MakeModlib(b, .{
|
const watcher = bh.MakeModLib(b, .{
|
||||||
.name = "watcher",
|
.name = "watcher",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const zgltf = bh.MakeModlib(b, .{
|
const zgltf = bh.MakeModLib(b, .{
|
||||||
.name = "zgltf",
|
.name = "zgltf",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||||
|
|
||||||
const zmath = bh.MakeModlib(b, .{
|
const zmath = bh.MakeModLib(b, .{
|
||||||
.name = "zmath",
|
.name = "zmath",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ pub fn build(b: *std.Build) void {
|
||||||
zjolt.addIncludePath(b.path("libs/JoltC"));
|
zjolt.addIncludePath(b.path("libs/JoltC"));
|
||||||
|
|
||||||
const joltc = b.addLibrary(.{
|
const joltc = b.addLibrary(.{
|
||||||
.name = "joltc",
|
.name = "zphysics",
|
||||||
.linkage = if (!static_build) .dynamic else .static,
|
.linkage = if (!static_build) .dynamic else .static,
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ pub fn build(b: *std.Build) void {
|
||||||
.root_source_file = b.path("sampleGame/main.zig"),
|
.root_source_file = b.path("sampleGame/main.zig"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// new paradigm has all engine modules be zig modules,
|
||||||
|
// in that way zig modules act as headers.
|
||||||
|
//
|
||||||
|
// due to conditional compiling, we do NOT need to do any special linking against them
|
||||||
sampleGame.setModuleEnabled("imgui", true);
|
sampleGame.setModuleEnabled("imgui", true);
|
||||||
sampleGame.setModuleEnabled("audio", true);
|
sampleGame.setModuleEnabled("audio", true);
|
||||||
sampleGame.setModuleEnabled("physics", true);
|
sampleGame.setModuleEnabled("physics", true);
|
||||||
|
|
@ -51,26 +55,26 @@ pub fn build(b: *std.Build) void {
|
||||||
newProjectMaker.setIconPath("icons/NewProject.ico");
|
newProjectMaker.setIconPath("icons/NewProject.ico");
|
||||||
_ = newProjectMaker.compileInstall();
|
_ = newProjectMaker.compileInstall();
|
||||||
|
|
||||||
const toolbox = blbuild.program(.{
|
// const toolbox = blbuild.program(.{
|
||||||
.name = "toolbox",
|
// .name = "toolbox",
|
||||||
.desc = "graphical toolbox for random stuff",
|
// .desc = "graphical toolbox for random stuff",
|
||||||
.root_source_file = b.path("tools/toolbox.zig"),
|
// .root_source_file = b.path("tools/toolbox.zig"),
|
||||||
});
|
// });
|
||||||
|
|
||||||
toolbox.setModuleEnabled("imgui", true);
|
// toolbox.setModuleEnabled("imgui", true);
|
||||||
toolbox.setModuleEnabled("audio", false);
|
// toolbox.setModuleEnabled("audio", false);
|
||||||
toolbox.setModuleEnabled("sys", true);
|
// toolbox.setModuleEnabled("sys", true);
|
||||||
toolbox.setModuleEnabled("net", false);
|
// toolbox.setModuleEnabled("net", false);
|
||||||
toolbox.addExtraModule("gameExtras");
|
// toolbox.addExtraModule("gameExtras");
|
||||||
|
|
||||||
const toolboxExe = toolbox.compileInstall();
|
// const toolboxExe = toolbox.compileInstall();
|
||||||
// Add Windows icon resource for toolbox
|
// Add Windows icon resource for toolbox
|
||||||
if (target.result.os.tag == .windows) {
|
// if (target.result.os.tag == .windows) {
|
||||||
toolboxExe.addWin32ResourceFile(.{
|
// toolboxExe.addWin32ResourceFile(.{
|
||||||
.file = b.path("tools/toolbox.rc"),
|
// .file = b.path("tools/toolbox.rc"),
|
||||||
.flags = &.{},
|
// .flags = &.{},
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const headless = blbuild.program(.{
|
const headless = blbuild.program(.{
|
||||||
.name = "headless",
|
.name = "headless",
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ pub fn start_module(args: core.ModuleLoaderArgs) !void {
|
||||||
core.PatchOrCreateObject(imgui.utils.ConsoleWindow, .{});
|
core.PatchOrCreateObject(imgui.utils.ConsoleWindow, .{});
|
||||||
core.PatchOrCreateObject(@import("fpgame/fpgame.zig"), .{});
|
core.PatchOrCreateObject(@import("fpgame/fpgame.zig"), .{});
|
||||||
|
|
||||||
core.engine_log("this change definitely happened :^) ", .{});
|
const dt = core.getEngineTime() - core.get(ExternGameObject).recompileStart;
|
||||||
|
|
||||||
core.engine_log("this change definitely happened :^) ", .{});
|
core.engine_log("recompile time: {d}", .{dt});
|
||||||
|
|
||||||
_ = args;
|
_ = args;
|
||||||
core.logDisplay("externGame", "accessing old object at {x} same object? {d}", .{ @intFromPtr(core.EngineObject(ExternGameObject).get()), @sizeOf(ExternGameObject) });
|
core.logDisplay("externGame", "accessing old object at {x} same object? {d}", .{ @intFromPtr(core.EngineObject(ExternGameObject).get()), @sizeOf(ExternGameObject) });
|
||||||
|
|
@ -120,6 +120,8 @@ pub const ExternGameObject = struct {
|
||||||
openSpawner: ?*core.ActionBinding = null,
|
openSpawner: ?*core.ActionBinding = null,
|
||||||
reloadMapInput: ?*core.ActionBinding = null,
|
reloadMapInput: ?*core.ActionBinding = null,
|
||||||
|
|
||||||
|
recompileStart: f64 = 0.0,
|
||||||
|
|
||||||
volume: f32 = 100.0,
|
volume: f32 = 100.0,
|
||||||
volume2: f32 = 100.0,
|
volume2: f32 = 100.0,
|
||||||
|
|
||||||
|
|
@ -403,6 +405,8 @@ pub const ExternGameObject = struct {
|
||||||
pub fn recompileComplete(ctx: ?*anyopaque) void {
|
pub fn recompileComplete(ctx: ?*anyopaque) void {
|
||||||
const self = core.cast(*@This(), ctx.?);
|
const self = core.cast(*@This(), ctx.?);
|
||||||
self.recompiling = false;
|
self.recompiling = false;
|
||||||
|
const duration = core.getEngineTime() - self.recompileStart;
|
||||||
|
core.engine_log("recompile time {d}s", .{duration});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn onOpenSpawner(ctx: ?*anyopaque, _: core.ActionEvent) void {
|
pub fn onOpenSpawner(ctx: ?*anyopaque, _: core.ActionEvent) void {
|
||||||
|
|
@ -417,6 +421,7 @@ pub const ExternGameObject = struct {
|
||||||
const self = core.cast(*@This(), ctx.?);
|
const self = core.cast(*@This(), ctx.?);
|
||||||
|
|
||||||
if (!self.recompiling) {
|
if (!self.recompiling) {
|
||||||
|
self.recompileStart = core.getEngineTime();
|
||||||
self.recompiling = true;
|
self.recompiling = true;
|
||||||
const x = core.EngineObject(sys.SystemRunner).get();
|
const x = core.EngineObject(sys.SystemRunner).get();
|
||||||
x.commandQueue.pushLocked(.{
|
x.commandQueue.pushLocked(.{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue