Compare commits
5 Commits
dev/varian
...
dev/parall
| Author | SHA1 | Date |
|---|---|---|
|
|
b0d1a81d84 | |
|
|
2176977c4c | |
|
|
13d73418f8 | |
|
|
fdb23323fe | |
|
|
fc8165eb83 |
31
CLAUDE.md
31
CLAUDE.md
|
|
@ -96,6 +96,37 @@ The shader compilation system automatically discovers `.hlsl` files in `engine/*
|
|||
- The build system generates API wrappers automatically for enabled modules
|
||||
- Content directory location is determined by `content.txt` file pointing to `projects/content/`
|
||||
|
||||
### MakeModLib Build Helper
|
||||
|
||||
The project uses a custom `MakeModLib` helper function (defined in `lib/bh/build.zig`) to create library modules with consistent patterns:
|
||||
|
||||
```zig
|
||||
const mylib = bh.MakeModLib(b, .{
|
||||
.name = "mylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/mylib.zig"),
|
||||
});
|
||||
```
|
||||
|
||||
**What MakeModLib creates:**
|
||||
- A Zig module (`.mod`) for compile-time imports
|
||||
- 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
|
||||
|
||||
**Usage pattern:**
|
||||
All libraries using `MakeModLib` follow this pattern in their test executables:
|
||||
```zig
|
||||
tests.root_module.addImport("mylib", mylib.mod); // Import the module
|
||||
tests.root_module.linkLibrary(mylib.lib); // Link the library
|
||||
```
|
||||
|
||||
**Libraries using MakeModLib:**
|
||||
- `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.
|
||||
|
||||
## Common Development Tasks
|
||||
|
||||
- Adding new engine modules: Create in `engine/` with `build.zig` and add to `engineDepList`
|
||||
|
|
|
|||
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 } = &.{
|
||||
.{ .dep = "sdl3", .artifact = "SDL3" },
|
||||
.{ .dep = "spng", .artifact = "spng_c" },
|
||||
.{ .dep = "lua", .artifact = "luac" },
|
||||
.{ .dep = "miniaudio", .artifact = "miniaudio_c" },
|
||||
.{ .dep = "zphysics", .artifact = "joltc" },
|
||||
.{ .dep = "spng", .artifact = "spng" },
|
||||
.{ .dep = "lua", .artifact = "lua" },
|
||||
.{ .dep = "miniaudio", .artifact = "miniaudio" },
|
||||
.{ .dep = "zphysics", .artifact = "zphysics" },
|
||||
// .{ .dep = "enet", .artifact = "enet_c" },
|
||||
.{ .dep = "ozz", .artifact = "ozz_cpp" },
|
||||
.{ .dep = "ozz", .artifact = "ozz" },
|
||||
};
|
||||
|
||||
// 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);
|
||||
modFwd.addImport("module", dep.module(depName));
|
||||
|
||||
b.installArtifact(dep.artifact(depName));
|
||||
|
||||
// mod.addImport(depName, dep.module(depName));
|
||||
}
|
||||
|
||||
|
|
@ -561,7 +563,7 @@ pub fn build(b: *std.Build) void {
|
|||
.optimize = optimize,
|
||||
.static_build = static_build,
|
||||
});
|
||||
const lib = dep.module("SDL3");
|
||||
const lib = dep.module("sdl3");
|
||||
|
||||
mod.addImport("sdl3_fwd", lib);
|
||||
}
|
||||
|
|
@ -594,6 +596,7 @@ pub fn generateApi(self: *@This(), programName: []const u8, moduleList: []const
|
|||
});
|
||||
for (moduleList) |modName| {
|
||||
mod.addImport(modName, self.nwdep.module(modName));
|
||||
mod.linkLibrary(self.nwdep.artifact(modName));
|
||||
}
|
||||
|
||||
const loadStatics = self.generateInstallStaticResources(programName, "content/_shaders") catch unreachable;
|
||||
|
|
|
|||
|
|
@ -1,28 +1,25 @@
|
|||
const std = @import("std");
|
||||
const core = @import("core");
|
||||
|
||||
const depList = [_][]const u8{
|
||||
"core",
|
||||
"packer",
|
||||
};
|
||||
|
||||
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", .{
|
||||
const engineMod = core.MakeModLib(b, .{
|
||||
.name = "assets",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/assets.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
const core_dep = b.dependency(
|
||||
"core",
|
||||
.{ .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, .static_build = static_build },
|
||||
);
|
||||
|
||||
mod.addImport("packer", packer_dep.module("packer"));
|
||||
engineMod.linkModLibs(&depList);
|
||||
engineMod.install();
|
||||
|
||||
const test_step = b.step("test", "run unit tests for assets");
|
||||
const tests = b.addTest(.{
|
||||
|
|
@ -33,7 +30,7 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
tests.root_module.addImport("assets", mod);
|
||||
tests.root_module.addImport("assets", engineMod.mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const core = @import("core");
|
||||
|
||||
const depList = [_][]const u8{
|
||||
"miniaudio",
|
||||
|
|
@ -11,17 +12,15 @@ pub fn build(b: *std.Build) void {
|
|||
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", .{
|
||||
const engineMod = core.MakeModLib(b, .{
|
||||
.name = "audio",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/audio.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
for (depList) |depName| {
|
||||
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
||||
|
||||
mod.addImport(depName, dep.module(depName));
|
||||
}
|
||||
engineMod.linkModLibs(&depList);
|
||||
engineMod.install();
|
||||
|
||||
const test_step = b.step("test", "run unit tests for audio");
|
||||
const tests = b.addTest(.{
|
||||
|
|
@ -32,7 +31,7 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
tests.root_module.addImport("audio", mod);
|
||||
tests.root_module.addImport("audio", engineMod.mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
const std = @import("std");
|
||||
pub const bh = @import("bh");
|
||||
|
||||
pub const ModLib = bh.ModLib;
|
||||
pub const MakeModLib = bh.MakeModLib;
|
||||
|
||||
const dependencyList = [_][]const u8{
|
||||
"p2",
|
||||
|
|
@ -7,21 +11,35 @@ const dependencyList = [_][]const u8{
|
|||
"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 {
|
||||
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", .{
|
||||
const engineMod = MakeModLib(b, .{
|
||||
.name = "core",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/core.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
for (dependencyList) |depName| {
|
||||
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
||||
mod.addImport(depName, dep.module(depName));
|
||||
}
|
||||
engineMod.install();
|
||||
engineMod.linkModLibs(&dependencyList);
|
||||
|
||||
const test_step = b.step("test", "run unit tests for core");
|
||||
const tests = b.addTest(.{
|
||||
|
|
@ -42,7 +60,7 @@ pub fn build(b: *std.Build) void {
|
|||
.linkage = .dynamic,
|
||||
.name = "external",
|
||||
});
|
||||
sampleGameExtern.root_module.addImport("core", mod);
|
||||
sampleGameExtern.root_module.addImport("core", engineMod.mod);
|
||||
|
||||
const installExtern = b.addInstallArtifact(sampleGameExtern, .{
|
||||
.dest_dir = .{ .override = .{ .custom = "modules" } },
|
||||
|
|
@ -50,7 +68,7 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
b.getInstallStep().dependOn(&installExtern.step);
|
||||
|
||||
tests.root_module.addImport("core", mod);
|
||||
tests.root_module.addImport("core", engineMod.mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
runArtifact.step.dependOn(b.getInstallStep());
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
// with -Dtracy = false, this one pulls in no C dependencies
|
||||
.tracy = .{ .path = "../../lib/tracy" },
|
||||
.bh = .{ .path = "../../lib/bh" },
|
||||
|
||||
// these are zig only
|
||||
.zmath = .{ .path = "../../lib/zmath" },
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const core = @import("core");
|
||||
|
||||
const dependencyList = [_][]const u8{
|
||||
"core",
|
||||
|
|
@ -13,17 +14,15 @@ pub fn build(b: *std.Build) void {
|
|||
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", .{
|
||||
const engineMod = core.MakeModLib(b, .{
|
||||
.name = "imgui",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/imgui.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
engineMod.install();
|
||||
engineMod.linkModLibs(&dependencyList);
|
||||
|
||||
// ========== tests ==========
|
||||
const tests = b.addTest(.{
|
||||
|
|
@ -35,7 +34,7 @@ pub fn build(b: *std.Build) void {
|
|||
});
|
||||
const test_step = b.step("test", "run unit tests for imgui");
|
||||
|
||||
tests.root_module.addImport("platform", mod);
|
||||
tests.root_module.addImport("platform", engineMod.mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const core = @import("core");
|
||||
|
||||
const depList = [_][]const u8{
|
||||
"core",
|
||||
|
|
@ -10,17 +11,15 @@ pub fn build(b: *std.Build) void {
|
|||
const optimize = b.standardOptimizeOption(.{});
|
||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||
|
||||
const mod = b.addModule("net", .{
|
||||
const engineMod = core.MakeModLib(b, .{
|
||||
.name = "net",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/net.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
for (depList) |depName| {
|
||||
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
||||
|
||||
mod.addImport(depName, dep.module(depName));
|
||||
}
|
||||
engineMod.install();
|
||||
engineMod.linkModLibs(&depList);
|
||||
|
||||
const test_step = b.step("test", "run unit tests for net");
|
||||
const tests = b.addTest(.{
|
||||
|
|
@ -31,7 +30,7 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
tests.root_module.addImport("net", mod);
|
||||
tests.root_module.addImport("net", engineMod.mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
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
|
||||
pub fn build(b: *std.Build) void {
|
||||
|
|
@ -6,18 +11,18 @@ pub fn build(b: *std.Build) void {
|
|||
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", .{
|
||||
const engineMod = core.MakeModLib(b, .{
|
||||
.name = "papyrus",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.root_source_file = b.path("src/papyrus.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
mod.addIncludePath(b.path("src/"));
|
||||
mod.addCSourceFile(.{ .file = b.path("src/compat.cpp") });
|
||||
engineMod.lib.linkLibC();
|
||||
|
||||
const core_dep = b.dependency("core", .{ .target = target, .optimize = optimize, .static_build = static_build });
|
||||
|
||||
mod.addImport("core", core_dep.module("core"));
|
||||
engineMod.install();
|
||||
engineMod.linkModLibs(&depList);
|
||||
engineMod.addIncludePath("src/");
|
||||
engineMod.lib.addCSourceFile(.{ .file = b.path("src/compat.cpp"), .flags = &.{} });
|
||||
|
||||
// Creates a step for unit testing.
|
||||
const main_tests = b.addTest(.{
|
||||
|
|
@ -29,10 +34,9 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
main_tests.root_module.addImport("core", core_dep.module("core"));
|
||||
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.linkLibrary(engineMod.lib);
|
||||
main_tests.linkLibC();
|
||||
main_tests.linkLibCpp();
|
||||
const run_tests = b.addRunArtifact(main_tests);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
const papyrus = @import("papyrus.zig");
|
||||
const Context = papyrus.Context;
|
||||
|
||||
const core = @import("core");
|
||||
const core = papyrus.core;
|
||||
const Vector2i = core.Vector2i;
|
||||
const Vector2 = core.Vector2;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
const core = @import("core");
|
||||
const core = @import("papyrus.zig").core;
|
||||
const Vector2i = core.Vector2i;
|
||||
const Vector2f = core.Vector2f;
|
||||
const Name = core.Name;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const c = @cImport({
|
||||
pub const c = @cImport({
|
||||
@cInclude("stb_ttf.h");
|
||||
});
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ pub const TextEntrySystem = @import("TextEntrySystem.zig");
|
|||
pub const DrawCommand = @import("DrawCommand.zig");
|
||||
pub const DrawList = std.ArrayList(DrawCommand);
|
||||
|
||||
const core = @import("core");
|
||||
pub const core = @import("core");
|
||||
const colors = core.colors;
|
||||
pub const Color = colors.Color;
|
||||
pub const ColorRGBA8 = colors.RGBA8;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ const std = @import("std");
|
|||
const papyrus = @import("papyrus");
|
||||
const localization = papyrus.localization;
|
||||
const utils = papyrus.utils;
|
||||
const c = @cImport({
|
||||
@cInclude("stb_ttf.h");
|
||||
});
|
||||
|
||||
const c = papyrus.c;
|
||||
const PapyrusContext = papyrus.Context;
|
||||
const PapyrusNode = papyrus.Node;
|
||||
const MakeText = localization.MakeText;
|
||||
|
|
@ -14,7 +11,7 @@ const grapvizDotToPng = utils.grapvizDotToPng;
|
|||
const BmpRenderer = papyrus.BmpRenderer;
|
||||
const BmpWriter = BmpRenderer.BmpWriter;
|
||||
|
||||
const core = @import("core");
|
||||
const core = papyrus.core;
|
||||
const colors = core.colors;
|
||||
const Color = colors.Color;
|
||||
const ColorRGBA8 = colors.ColorRGBA8;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
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
|
||||
pub fn build(b: *std.Build) void {
|
||||
|
|
@ -6,25 +11,24 @@ pub fn build(b: *std.Build) void {
|
|||
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", .{
|
||||
const engineMod = core.MakeModLib(b, .{
|
||||
.name = "physics",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.root_source_file = b.path("src/physics.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
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", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.enable_cross_platform_determinism = false,
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
mod.addImport("core", core_dep.module("core"));
|
||||
mod.addImport("zphysics", zphysics_dep.module("root"));
|
||||
mod.linkLibrary(zphysics_dep.artifact("joltc"));
|
||||
engineMod.mod.addImport("zphysics", zphysics_dep.module("root"));
|
||||
engineMod.lib.linkLibrary(zphysics_dep.artifact("zphysics"));
|
||||
|
||||
const test_step = b.step("test", "run unit tests for physics");
|
||||
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);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const std = @import("std");
|
||||
const sdl3 = @import("sdl3");
|
||||
const core = @import("core");
|
||||
|
||||
const dependencyList = [_][]const u8{
|
||||
"core",
|
||||
|
|
@ -13,12 +14,16 @@ pub fn build(b: *std.Build) void {
|
|||
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,
|
||||
const engineMod = core.MakeModLib(b, .{
|
||||
.name = "platform",
|
||||
.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(.{
|
||||
.root_module = b.createModule(.{
|
||||
.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");
|
||||
tests.root_module.addImport("platform", engineMod.mod);
|
||||
tests.linkLibrary(engineMod.lib);
|
||||
|
||||
tests.root_module.addImport("platform", mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const core = @import("core");
|
||||
pub const core = @import("core");
|
||||
const test_vert = @import("test.vert");
|
||||
|
||||
pub const nfd = @import("nfd");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const core = @import("core");
|
||||
const platform = @import("platform");
|
||||
const core = @import("platform").core;
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const std = @import("std");
|
||||
const sdl3 = @import("sdl3");
|
||||
const core = @import("core");
|
||||
|
||||
const dependencyList = [_][]const u8{
|
||||
"core",
|
||||
|
|
@ -19,38 +20,47 @@ pub fn build(b: *std.Build) void {
|
|||
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", .{
|
||||
const engineMod = core.MakeModLib(b, .{
|
||||
.name = "rend",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/rend.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
engineMod.linkModLibs(&dependencyList);
|
||||
engineMod.install();
|
||||
|
||||
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);
|
||||
// const mod = b.addModule("rend", .{
|
||||
// .target = target,
|
||||
// .optimize = optimize,
|
||||
// .root_source_file = b.path("src/rend.zig"),
|
||||
// });
|
||||
|
||||
if (std.mem.eql(u8, depName, "ozz")) {
|
||||
mod.linkLibrary(dep.artifact("ozz_cpp"));
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
|
||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "sample.vert", b.path("shaders/sample.vert.json"));
|
||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "meshes.vert", b.path("shaders/meshes.vert.json"));
|
||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "lit_mesh.frag", b.path("shaders/lit_mesh.frag.json"));
|
||||
// if (std.mem.eql(u8, depName, "ozz")) {
|
||||
// mod.linkLibrary(dep.artifact("ozz_cpp"));
|
||||
// }
|
||||
// }
|
||||
|
||||
sdl3.shaderDefintion(b, mod, "../../lib/sdl3", target, optimize, "debug.frag", b.path("shaders/debug.frag.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, "sample.vert", b.path("shaders/sample.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, mod, "../../lib/sdl3", target, optimize, "skybox.vert", b.path("shaders/skybox.vert.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, "postProc.frag", b.path("shaders/postProc.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.frag", b.path("shaders/skybox.frag.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 ==========
|
||||
const tests = b.addTest(.{
|
||||
|
|
|
|||
|
|
@ -1,38 +1,27 @@
|
|||
const std = @import("std");
|
||||
const sdl3 = @import("sdl3");
|
||||
const core = @import("core");
|
||||
|
||||
const dependencyList = [_][]const u8{
|
||||
"core",
|
||||
};
|
||||
|
||||
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("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);
|
||||
}
|
||||
const engineMod = core.MakeEngineMod(b, "sys");
|
||||
engineMod.linkModLibs(&dependencyList);
|
||||
engineMod.install();
|
||||
|
||||
// ========== tests ==========
|
||||
const tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.target = engineMod.target,
|
||||
.optimize = engineMod.optimize,
|
||||
.root_source_file = b.path("tests/tests.zig"),
|
||||
}),
|
||||
});
|
||||
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);
|
||||
b.installArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ pub const SubprocessTask = struct {
|
|||
allocator: std.mem.Allocator,
|
||||
|
||||
child: ?std.process.Child = null,
|
||||
completed: bool = false,
|
||||
success: bool = false,
|
||||
completed: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
|
||||
success: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
|
||||
|
||||
workingDir: ?[]const u8 = null,
|
||||
|
||||
|
|
@ -76,29 +76,29 @@ pub const SubprocessTask = struct {
|
|||
}
|
||||
|
||||
pub fn destroy(self: *@This()) void {
|
||||
self.mutex.lock();
|
||||
// self.mutex.lock();
|
||||
self.argsArena.deinit();
|
||||
self.argsOwned.deinit(self.allocator);
|
||||
if (self.child) |*child| {
|
||||
_ = child;
|
||||
core.engine_log("destroying child process", .{});
|
||||
}
|
||||
self.mutex.unlock();
|
||||
// self.mutex.unlock();
|
||||
self.stdout.deinit(self.allocator);
|
||||
self.stderr.deinit(self.allocator);
|
||||
self.allocator.destroy(self);
|
||||
}
|
||||
|
||||
pub fn checkComplete(self: *@This()) bool {
|
||||
return self.completed;
|
||||
return self.completed.load(.monotonic);
|
||||
}
|
||||
|
||||
pub fn wait(self: *@This()) void {
|
||||
var completed: bool = self.completed;
|
||||
var completed: bool = self.completed.load(.monotonic);
|
||||
while (completed == false) {
|
||||
std.Thread.sleep(1 * 1000 * 1000);
|
||||
self.mutex.lock();
|
||||
completed = self.completed;
|
||||
completed = self.completed.load(.monotonic);
|
||||
self.mutex.unlock();
|
||||
}
|
||||
debugPrint("task completed", .{});
|
||||
|
|
@ -117,7 +117,7 @@ pub const SubprocessTask = struct {
|
|||
|
||||
switch (term) {
|
||||
.Exited => |m| {
|
||||
if (m == 0) self.success = true;
|
||||
if (m == 0) self.success.store(true, .release);
|
||||
},
|
||||
.Signal => |m| {
|
||||
core.engine_log("process Signaled {d}", .{m});
|
||||
|
|
@ -132,8 +132,8 @@ pub const SubprocessTask = struct {
|
|||
|
||||
self.mutex.lock();
|
||||
self.child = null;
|
||||
self.completed = true;
|
||||
self.mutex.unlock();
|
||||
self.completed.store(true, .release);
|
||||
}
|
||||
|
||||
pub fn runCommand(allocator: std.mem.Allocator, argv: []const []const u8, cwd: ?[]const u8) !*@This() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const std = @import("std");
|
||||
const sdl3 = @import("sdl3");
|
||||
const core = @import("core");
|
||||
|
||||
const dependencyList = [_][]const u8{
|
||||
"core",
|
||||
|
|
@ -11,28 +12,18 @@ 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,
|
||||
.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);
|
||||
}
|
||||
const engineMod = core.MakeEngineMod(b, "ui");
|
||||
engineMod.linkModLibs(&dependencyList);
|
||||
engineMod.install();
|
||||
const target = engineMod.target;
|
||||
const optimize = engineMod.optimize;
|
||||
|
||||
// shaders
|
||||
sdl3.shaderDefintion(b, 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.vert", b.path("shaders/rect.vert.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, mod, "../../lib/sdl3", target, optimize, "text.frag", b.path("shaders/text.frag.json"));
|
||||
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "text.vert", b.path("shaders/text.vert.json"));
|
||||
sdl3.shaderDefintion(b, engineMod.mod, "../../lib/sdl3", target, optimize, "text.frag", b.path("shaders/text.frag.json"));
|
||||
|
||||
// ========== tests ==========
|
||||
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");
|
||||
|
||||
tests.root_module.addImport("ui", mod);
|
||||
tests.root_module.addImport("ui", engineMod.mod);
|
||||
tests.root_module.linkLibrary(engineMod.lib);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,31 @@ pub const ModLib = struct {
|
|||
lib: *std.Build.Step.Compile,
|
||||
mod: *std.Build.Module,
|
||||
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
static_build: bool,
|
||||
|
||||
pub fn install(self: @This()) void {
|
||||
self.b.installArtifact(self.lib);
|
||||
}
|
||||
|
||||
pub fn addIncludePath(self: @This(), path: []const u8) void {
|
||||
self.lib.addIncludePath(self.b.path(path));
|
||||
self.mod.addIncludePath(self.b.path(path));
|
||||
}
|
||||
|
||||
pub fn linkModLibs(self: @This(), list: []const []const u8) void {
|
||||
for (list) |depName| {
|
||||
const dep = self.b.dependency(depName, .{
|
||||
.target = self.target,
|
||||
.optimize = self.optimize,
|
||||
.static_build = self.static_build,
|
||||
});
|
||||
|
||||
self.mod.addImport(depName, dep.module(depName));
|
||||
self.lib.linkLibrary(dep.artifact(depName));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const ModLibOptions = struct {
|
||||
|
|
@ -22,11 +44,11 @@ pub const ModLibOptions = struct {
|
|||
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, .{
|
||||
.target = o.target,
|
||||
.optimize = o.optimize,
|
||||
.root_source_file = if (o.root != null) o.root.? else b.path(b.fmt("src/{s}", .{o.name})),
|
||||
.root_source_file = if (o.root != null) o.root.? else b.path(b.fmt("src/{s}.zig", .{o.name})),
|
||||
});
|
||||
|
||||
const empty_file = b.addWriteFile("stubs", "");
|
||||
|
|
@ -45,6 +67,9 @@ pub fn MakeModlib(b: *std.Build, o: ModLibOptions) ModLib {
|
|||
.b = b,
|
||||
.lib = lib,
|
||||
.mod = mod,
|
||||
.target = o.target,
|
||||
.optimize = o.optimize,
|
||||
.static_build = o.static_build,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +78,7 @@ pub fn build(b: *std.Build) void {
|
|||
const optimize = b.standardOptimizeOption(.{});
|
||||
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",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
|
|
|
|||
|
|
@ -1,45 +1,39 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
// very tiny, not intended to build anything just to run tests linked with libc
|
||||
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", .{
|
||||
const cimgui = bh.MakeModLib(b, .{
|
||||
.name = "cimgui",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.root_source_file = b.path("src/cimgui.zig"),
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
mod.addIncludePath(b.path("cimgui/imgui"));
|
||||
mod.addIncludePath(b.path("cimgui/SDL/include"));
|
||||
mod.addIncludePath(b.path("cimplot"));
|
||||
mod.addIncludePath(b.path("cimplot/implot"));
|
||||
cimgui.install();
|
||||
|
||||
const cimgui = b.addLibrary(.{
|
||||
.name = "cimgui",
|
||||
.root_module = b.createModule(.{
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
}),
|
||||
});
|
||||
cimgui.mod.addIncludePath(b.path("cimgui/SDL/include"));
|
||||
cimgui.mod.addIncludePath(b.path("cimplot"));
|
||||
cimgui.mod.addIncludePath(b.path("cimgui/imgui"));
|
||||
cimgui.mod.addIncludePath(b.path("cimplot/implot"));
|
||||
|
||||
cimgui.linkLibC();
|
||||
cimgui.lib.linkLibC();
|
||||
|
||||
if (target.result.abi != .msvc)
|
||||
cimgui.linkLibCpp();
|
||||
cimgui.lib.linkLibCpp();
|
||||
|
||||
cimgui.addIncludePath(b.path("cimgui"));
|
||||
cimgui.addIncludePath(b.path("cimplot"));
|
||||
cimgui.addIncludePath(b.path("cimgui/imgui"));
|
||||
cimgui.addIncludePath(b.path("cimgui/imgui/backends"));
|
||||
cimgui.addIncludePath(b.path("cimgui/imgui/backends"));
|
||||
cimgui.addIncludePath(b.path("cimgui/SDL/include/"));
|
||||
cimgui.lib.addIncludePath(b.path("cimgui"));
|
||||
cimgui.lib.addIncludePath(b.path("cimplot"));
|
||||
cimgui.lib.addIncludePath(b.path("cimgui/imgui"));
|
||||
cimgui.lib.addIncludePath(b.path("cimgui/imgui/backends"));
|
||||
cimgui.lib.addIncludePath(b.path("cimgui/imgui/backends"));
|
||||
cimgui.lib.addIncludePath(b.path("cimgui/SDL/include/"));
|
||||
|
||||
cimgui.addCSourceFiles(.{
|
||||
cimgui.lib.addCSourceFiles(.{
|
||||
.root = b.path("cimgui/imgui"),
|
||||
.files = &[_][]const u8{
|
||||
"cimgui.cpp",
|
||||
|
|
@ -54,7 +48,7 @@ pub fn build(b: *std.Build) void {
|
|||
},
|
||||
});
|
||||
|
||||
cimgui.addCSourceFiles(.{
|
||||
cimgui.lib.addCSourceFiles(.{
|
||||
.root = b.path("cimplot"),
|
||||
.files = &[_][]const u8{
|
||||
"cimplot.cpp",
|
||||
|
|
@ -64,8 +58,6 @@ pub fn build(b: *std.Build) void {
|
|||
},
|
||||
});
|
||||
|
||||
mod.linkLibrary(cimgui);
|
||||
|
||||
// I could've made cimgui a seperate lib,
|
||||
// I can seperate it out later if needed.
|
||||
const test_step = b.step("test", "run unit tests for imgui");
|
||||
|
|
@ -77,7 +69,9 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
tests.root_module.addImport("cimgui", mod);
|
||||
tests.root_module.addImport("cimgui", cimgui.mod);
|
||||
tests.root_module.linkLibrary(cimgui.lib);
|
||||
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
const cimgui = @import("cimgui");
|
||||
|
||||
test "huh" {}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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;
|
||||
|
||||
// am i good to always have enet as static?
|
||||
// const enet = if (true) b.addStaticLibrary(.{
|
||||
|
|
@ -17,18 +17,18 @@ pub fn build(b: *std.Build) void {
|
|||
// .optimize = optimize,
|
||||
// });
|
||||
|
||||
const enet = b.addLibrary(.{
|
||||
.name = "enet_c",
|
||||
.linkage = .static,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
}),
|
||||
const enet = bh.MakeModLib(b, .{
|
||||
.name = "enet",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.static_build = static_build,
|
||||
});
|
||||
|
||||
enet.linkLibC();
|
||||
enet.install();
|
||||
|
||||
enet.addCSourceFiles(.{
|
||||
enet.lib.linkLibC();
|
||||
|
||||
enet.lib.addCSourceFiles(.{
|
||||
.root = b.path("enet-1.3.18"),
|
||||
.files = &.{
|
||||
"callbacks.c",
|
||||
|
|
@ -43,14 +43,13 @@ pub fn build(b: *std.Build) void {
|
|||
},
|
||||
.flags = &.{"-DHAS_OFFSETOF=1"},
|
||||
});
|
||||
|
||||
enet.addIncludePath(b.path("enet-1.3.18/include"));
|
||||
enet.addIncludePath("enet-1.3.18/include");
|
||||
|
||||
// Platform-specific configuration
|
||||
switch (target.result.os.tag) {
|
||||
.windows => {
|
||||
enet.linkSystemLibrary("ws2_32");
|
||||
enet.linkSystemLibrary("winmm");
|
||||
enet.lib.linkSystemLibrary("ws2_32");
|
||||
enet.lib.linkSystemLibrary("winmm");
|
||||
// Use .def file to control exports and avoid CRT symbol conflicts
|
||||
},
|
||||
.linux, .macos => {
|
||||
|
|
@ -59,18 +58,6 @@ pub fn build(b: *std.Build) void {
|
|||
else => {},
|
||||
}
|
||||
|
||||
b.installArtifact(enet);
|
||||
|
||||
const mod = b.addModule("enet", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/enet.zig"),
|
||||
.link_libc = true,
|
||||
});
|
||||
|
||||
mod.linkLibrary(enet);
|
||||
mod.addIncludePath(b.path("enet-1.3.18/include/"));
|
||||
|
||||
const test_step = b.step("test", "run unit tests for enet");
|
||||
const tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
|
|
@ -81,7 +68,8 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
tests.root_module.addImport("enet", mod);
|
||||
tests.linkLibrary(enet.lib);
|
||||
tests.root_module.addImport("enet", enet.mod);
|
||||
tests.root_module.addIncludePath(b.path("enet-1.3.18/include/"));
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
|
|
@ -95,7 +83,7 @@ pub fn build(b: *std.Build) void {
|
|||
.optimize = optimize,
|
||||
}),
|
||||
});
|
||||
test_server.root_module.addImport("enet", mod);
|
||||
test_server.root_module.addImport("enet", enet.mod);
|
||||
test_server.linkLibC();
|
||||
|
||||
// Test client executable
|
||||
|
|
@ -107,7 +95,7 @@ pub fn build(b: *std.Build) void {
|
|||
.optimize = optimize,
|
||||
}),
|
||||
});
|
||||
test_client.root_module.addImport("enet", mod);
|
||||
test_client.root_module.addImport("enet", enet.mod);
|
||||
test_client.linkLibC();
|
||||
|
||||
// Install test programs
|
||||
|
|
@ -135,6 +123,12 @@ pub fn build(b: *std.Build) void {
|
|||
const build_tests_step = b.step("build-tests", "Build test server and client programs");
|
||||
build_tests_step.dependOn(&install_test_server.step);
|
||||
build_tests_step.dependOn(&install_test_client.step);
|
||||
|
||||
test_server.linkLibrary(enet.lib);
|
||||
test_client.linkLibrary(enet.lib);
|
||||
|
||||
b.installArtifact(test_server);
|
||||
b.installArtifact(test_client);
|
||||
}
|
||||
|
||||
// Custom step to run server and client concurrently for loopback testing
|
||||
|
|
|
|||
|
|
@ -1,30 +1,28 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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", .{
|
||||
const lua = bh.MakeModLib(b, .{
|
||||
.name = "lua",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/lua.zig"),
|
||||
.link_libc = true,
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/lua.zig"),
|
||||
});
|
||||
|
||||
const luac = b.addLibrary(.{
|
||||
.name = "luac",
|
||||
.linkage = if (static_build) .static else .dynamic,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
lua.install();
|
||||
|
||||
b.installArtifact(luac);
|
||||
// Add include paths to module (for Zig @cImport)
|
||||
lua.addIncludePath("lua/src/");
|
||||
lua.addIncludePath("src/");
|
||||
|
||||
luac.addCSourceFiles(.{
|
||||
// Configure library
|
||||
lua.lib.linkLibC();
|
||||
lua.lib.addCSourceFiles(.{
|
||||
.root = b.path("lua/src/"),
|
||||
.files = &.{
|
||||
"lapi.c",
|
||||
|
|
@ -62,25 +60,16 @@ pub fn build(b: *std.Build) void {
|
|||
},
|
||||
});
|
||||
|
||||
luac.addCSourceFile(.{ .file = b.path("src/limited_io.c") });
|
||||
lua.lib.addCSourceFile(.{ .file = b.path("src/limited_io.c") });
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
luac.addCSourceFile(.{ .file = b.path("src/minidumpsetup.cpp") });
|
||||
lua.lib.addCSourceFile(.{ .file = b.path("src/minidumpsetup.cpp") });
|
||||
if (target.result.abi != .msvc)
|
||||
luac.linkLibCpp();
|
||||
luac.linkLibC();
|
||||
lua.lib.linkLibCpp();
|
||||
} else {
|
||||
luac.addCSourceFile(.{ .file = b.path("src/minidumpstub.cpp") });
|
||||
lua.lib.addCSourceFile(.{ .file = b.path("src/minidumpstub.cpp") });
|
||||
}
|
||||
|
||||
luac.addIncludePath(b.path("lua/src/"));
|
||||
luac.addIncludePath(b.path("src/"));
|
||||
|
||||
mod.addIncludePath(b.path("lua/src/"));
|
||||
mod.addIncludePath(b.path("src/"));
|
||||
|
||||
mod.linkLibrary(luac);
|
||||
|
||||
const run_step = b.step("test", "");
|
||||
const tests = b.addExecutable(.{
|
||||
.name = "run-lua",
|
||||
|
|
@ -92,7 +81,9 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
tests.root_module.addImport("lua", mod);
|
||||
tests.root_module.addImport("lua", lua.mod);
|
||||
tests.root_module.linkLibrary(lua.lib);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
run_step.dependOn(&runArtifact.step);
|
||||
b.installArtifact(tests);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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.addLibrary(.{
|
||||
.name = "miniaudio_c",
|
||||
.linkage = if (static_build) .static else .dynamic,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
}),
|
||||
const miniaudio = bh.MakeModLib(b, .{
|
||||
.name = "miniaudio",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/miniaudio.zig"),
|
||||
});
|
||||
|
||||
b.installArtifact(miniaudio_c);
|
||||
miniaudio_c.addCSourceFile(.{ .file = b.path("src/miniaudio.cpp"), .flags = &.{"-fno-sanitize=all"}, .language = .c });
|
||||
miniaudio_c.addIncludePath(b.path("include"));
|
||||
miniaudio.install();
|
||||
|
||||
const mod = b.addModule("miniaudio", .{ .target = target, .optimize = optimize, .root_source_file = b.path("src/miniaudio.zig") });
|
||||
// Add include paths to module (for Zig @cImport)
|
||||
miniaudio.addIncludePath("./include");
|
||||
|
||||
mod.linkLibrary(miniaudio_c);
|
||||
mod.addIncludePath(b.path("./include"));
|
||||
// Configure library
|
||||
miniaudio.lib.linkLibC();
|
||||
|
||||
miniaudio.lib.addCSourceFile(.{ .file = b.path("src/miniaudio.cpp"), .flags = &.{"-fno-sanitize=all"}, .language = .c });
|
||||
|
||||
// ======== tests ============
|
||||
const test_step = b.step("test", "");
|
||||
|
|
@ -36,7 +36,8 @@ pub fn build(b: *std.Build) void {
|
|||
});
|
||||
tests.addIncludePath(b.path("./include"));
|
||||
|
||||
tests.root_module.addImport("miniaudio", mod);
|
||||
tests.root_module.addImport("miniaudio", miniaudio.mod);
|
||||
tests.root_module.linkLibrary(miniaudio.lib);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,56 +1,63 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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", .{
|
||||
const nfd = bh.MakeModLib(b, .{
|
||||
.name = "nfd",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/nfd.zig"),
|
||||
.link_libc = true,
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/nfd.zig"),
|
||||
});
|
||||
|
||||
mod.addCSourceFile(.{
|
||||
nfd.install();
|
||||
|
||||
// Add include paths to module (for Zig @cImport)
|
||||
nfd.addIncludePath("include");
|
||||
|
||||
// Configure library
|
||||
nfd.lib.linkLibC();
|
||||
nfd.lib.addCSourceFile(.{
|
||||
.file = b.path("src/nfd_common.c"),
|
||||
.flags = &.{},
|
||||
});
|
||||
|
||||
mod.addIncludePath(b.path("include"));
|
||||
|
||||
if (target.result.os.tag == .macos) {
|
||||
mod.addCSourceFile(.{
|
||||
nfd.lib.addCSourceFile(.{
|
||||
.file = b.path("src/nfd_cocoa.m"),
|
||||
.flags = &.{},
|
||||
});
|
||||
mod.linkFramework("AppKit", .{});
|
||||
nfd.lib.linkFramework("AppKit");
|
||||
} else if (target.result.os.tag == .windows) {
|
||||
mod.addCSourceFile(.{
|
||||
nfd.lib.addCSourceFile(.{
|
||||
.file = b.path("src/nfd_win.cpp"),
|
||||
.flags = &.{},
|
||||
});
|
||||
mod.linkSystemLibrary("ole32", .{});
|
||||
nfd.lib.linkSystemLibrary("ole32");
|
||||
} else if (target.result.os.tag == .linux) {
|
||||
// mod.addCSourceFile(.{
|
||||
// nfd.lib.addCSourceFile(.{
|
||||
// .file = b.path("src/nfd_gtk.c"),
|
||||
// .flags = &.{},
|
||||
// });
|
||||
mod.addCSourceFile(.{
|
||||
nfd.lib.addCSourceFile(.{
|
||||
.file = b.path("src/nfd_null.c"),
|
||||
.flags = &.{},
|
||||
});
|
||||
// mod.linkSystemLibrary("gdk-3", .{});
|
||||
// mod.linkSystemLibrary("atk-1.0", .{});
|
||||
// mod.linkSystemLibrary("gtk-3", .{});
|
||||
// mod.linkSystemLibrary("glib-2.0", .{});
|
||||
// mod.linkSystemLibrary("gobject-2.0", .{});
|
||||
// nfd.lib.linkSystemLibrary("gdk-3", .{});
|
||||
// nfd.lib.linkSystemLibrary("atk-1.0", .{});
|
||||
// nfd.lib.linkSystemLibrary("gtk-3", .{});
|
||||
// nfd.lib.linkSystemLibrary("glib-2.0", .{});
|
||||
// nfd.lib.linkSystemLibrary("gobject-2.0", .{});
|
||||
}
|
||||
|
||||
const p2dep = b.dependency("p2", .{ .target = target, .optimize = optimize, .static_build = static_build });
|
||||
|
||||
const p2mod = p2dep.module("p2");
|
||||
mod.addImport("p2", p2mod);
|
||||
nfd.mod.addImport("p2", p2mod);
|
||||
|
||||
const test_step = b.step("test", "");
|
||||
const tests = b.addTest(.{
|
||||
|
|
@ -63,7 +70,8 @@ pub fn build(b: *std.Build) void {
|
|||
});
|
||||
tests.addIncludePath(b.path("./include"));
|
||||
|
||||
tests.root_module.addImport("nfd", mod);
|
||||
tests.root_module.addImport("nfd", nfd.mod);
|
||||
tests.root_module.linkLibrary(nfd.lib);
|
||||
tests.root_module.addImport("p2", p2mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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", .{
|
||||
const objLoader = bh.MakeModLib(b, .{
|
||||
.name = "objLoader",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/obj_loader.zig"),
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/obj_loader.zig"),
|
||||
});
|
||||
|
||||
objLoader.install();
|
||||
|
||||
const test_step = b.step("test", "");
|
||||
const tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
|
|
@ -22,7 +26,8 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
tests.root_module.addImport("objLoader", mod);
|
||||
tests.root_module.addImport("objLoader", objLoader.mod);
|
||||
tests.root_module.linkLibrary(objLoader.lib);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ pub const GltfToOzz = struct {
|
|||
});
|
||||
|
||||
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.addIncludePath(b.path("ozz-animation/include"));
|
||||
|
|
@ -148,7 +148,7 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
const ozz_cpp = b.addLibrary(.{
|
||||
.linkage = if (static_build) .static else .dynamic,
|
||||
.name = "ozz_cpp",
|
||||
.name = "ozz",
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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 true;
|
||||
_ = static_build;
|
||||
|
||||
const mod = b.addModule("p2", .{
|
||||
const p2 = bh.MakeModLib(b, .{
|
||||
.name = "p2",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/p2.zig"),
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/p2.zig"),
|
||||
});
|
||||
|
||||
p2.install();
|
||||
|
||||
const test_step = b.step("test", "test p2");
|
||||
const tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
|
|
@ -22,7 +26,8 @@ pub fn build(b: *std.Build) void {
|
|||
// .link_libc = true,
|
||||
});
|
||||
|
||||
tests.root_module.addImport("p2", mod);
|
||||
tests.root_module.addImport("p2", p2.mod);
|
||||
tests.root_module.linkLibrary(p2.lib);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
if (b.args) |args| {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ pub const IndexPool = index_pool.IndexPool;
|
|||
|
||||
pub const concurrent_queue = @import("structures/concurrent-queue.zig");
|
||||
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");
|
||||
|
||||
|
|
|
|||
|
|
@ -14,13 +14,11 @@ pub const ConcurrentQueueError = error{
|
|||
QueueIsFull,
|
||||
};
|
||||
|
||||
pub fn ConcurrentQueueU(comptime T: type) type {
|
||||
return ConcurrentQueueUnmanagedAdvanced(T, .{});
|
||||
pub fn ConcurrentQueue(comptime T: type) type {
|
||||
return ConcurrentQueueAdvanced(T, .{});
|
||||
}
|
||||
|
||||
pub fn ConcurrentQueueAssert(comptime T: type) type {
|
||||
return ConcurrentQueueUnmanagedAdvanced(T, .{ .allowAsserts = true });
|
||||
}
|
||||
pub const ConcurrentQueueU = ConcurrentQueue;
|
||||
|
||||
// lock-free concurrent queue, fixed capacity,
|
||||
// will never resize.
|
||||
|
|
@ -33,7 +31,7 @@ pub const ConcurrentStatus = packed struct(usize) {
|
|||
generation: u63 = 0,
|
||||
};
|
||||
|
||||
pub fn ConcurrentQueueUnmanagedAdvanced(comptime T: type, comptime opts: struct {
|
||||
pub fn ConcurrentQueueAdvanced(comptime T: type, comptime opts: struct {
|
||||
allowAsserts: bool = false,
|
||||
debug: bool = false,
|
||||
}) type {
|
||||
|
|
@ -142,7 +140,7 @@ test "concurrent queue basic correctness test" {
|
|||
|
||||
const allocator = std.testing.allocator;
|
||||
|
||||
var y = try ConcurrentQueueUnmanagedAdvanced(Info, .{ .allowAsserts = true, .debug = true }).initCapacity(allocator, 420);
|
||||
var y = try ConcurrentQueueAdvanced(Info, .{ .allowAsserts = true, .debug = true }).initCapacity(allocator, 420);
|
||||
defer y.deinit(allocator);
|
||||
|
||||
try y.push(.{});
|
||||
|
|
@ -158,7 +156,7 @@ test "concurrent queue basic correctness test" {
|
|||
|
||||
try utils.assertf(y.count() == 0, "expected there to be {d} elements in queue, we saw {d}", .{ 0, y.count() });
|
||||
|
||||
var x = try ConcurrentQueueU(Info).initCapacity(allocator, 12);
|
||||
var x = try ConcurrentQueue(Info).initCapacity(allocator, 12);
|
||||
defer x.deinit(allocator);
|
||||
|
||||
try x.push(.{ .x = 0 });
|
||||
|
|
@ -189,7 +187,7 @@ test "concurrent queue multiple producer single consumer" {
|
|||
arb: [4096]u8 = undefined,
|
||||
};
|
||||
|
||||
const QueueType = ConcurrentQueueUnmanagedAdvanced(Payload, .{ .debug = false, .allowAsserts = true });
|
||||
const QueueType = ConcurrentQueueAdvanced(Payload, .{ .debug = false, .allowAsserts = true });
|
||||
|
||||
const Wrap = struct {
|
||||
pub fn threadFunc(queueRef: *QueueType, id: i64, exitSignal: *Atomic(bool), pushedCountResults: *Atomic(i64)) void {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
|
|
@ -6,16 +7,20 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
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", .{
|
||||
const packer = bh.MakeModLib(b, .{
|
||||
.name = "packer",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/packer.zig"),
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/packer.zig"),
|
||||
});
|
||||
|
||||
packer.install();
|
||||
|
||||
const p2dep = b.dependency("p2", .{ .target = target, .optimize = optimize, .static_build = static_build });
|
||||
|
||||
const p2mod = p2dep.module("p2");
|
||||
mod.addImport("p2", p2mod);
|
||||
packer.mod.addImport("p2", p2mod);
|
||||
|
||||
const test_exe = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
|
|
@ -24,7 +29,8 @@ pub fn build(b: *std.Build) void {
|
|||
.root_source_file = b.path("tests/test.zig"),
|
||||
}),
|
||||
});
|
||||
test_exe.root_module.addImport("packer", mod);
|
||||
test_exe.root_module.addImport("packer", packer.mod);
|
||||
test_exe.root_module.linkLibrary(packer.lib);
|
||||
test_exe.root_module.addImport("p2", p2mod);
|
||||
|
||||
const test_step = b.step("test", "runs sample unit tests for packer");
|
||||
|
|
|
|||
|
|
@ -62,14 +62,18 @@ pub fn build(b: *std.Build) void {
|
|||
});
|
||||
|
||||
const sdl3_lib = sdl_dep.artifact("SDL3");
|
||||
b.installArtifact(sdl3_lib);
|
||||
|
||||
const sdl3_fwd = b.addModule("SDL3", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/sdl3_lib_fwd.zig"),
|
||||
const sdl3_fwd = b.addLibrary(.{
|
||||
.name = "sdl3",
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/sdl3_lib_fwd.zig"),
|
||||
}),
|
||||
});
|
||||
|
||||
sdl3_fwd.linkLibrary(sdl3_lib);
|
||||
b.installArtifact(sdl3_fwd);
|
||||
|
||||
const mod = b.addModule("sdl3", .{
|
||||
.target = target,
|
||||
|
|
@ -84,7 +88,7 @@ pub fn build(b: *std.Build) void {
|
|||
mod.addImport("shaderTypes", shaderTypes.module("shaderTypes"));
|
||||
|
||||
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 tests2 = b.addExecutable(.{
|
||||
|
|
@ -134,7 +138,6 @@ pub fn build(b: *std.Build) void {
|
|||
test_step2.dependOn(&runArtifact2.step);
|
||||
|
||||
b.installArtifact(hello_window_exe);
|
||||
b.installArtifact(sdl3_lib);
|
||||
b.installArtifact(tests);
|
||||
b.installArtifact(tests2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,5 +13,15 @@ pub fn build(b: *std.Build) void {
|
|||
.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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
|
|
@ -6,34 +7,26 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||
|
||||
const spng_c = b.addLibrary(.{
|
||||
.linkage = if (static_build) .static else .dynamic,
|
||||
.name = "spng_c",
|
||||
.root_module = b.createModule(.{
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
|
||||
spng_c.addCSourceFile(.{ .file = b.path("spng/spng.c") });
|
||||
spng_c.addCSourceFile(.{ .file = b.path("miniz.c") });
|
||||
spng_c.addIncludePath(b.path("spng"));
|
||||
spng_c.addIncludePath(b.path("./"));
|
||||
|
||||
spng_c.root_module.addCMacro("SPNG_USE_MINIZ", "1");
|
||||
|
||||
const mod = b.addModule("spng", .{
|
||||
const spng = bh.MakeModLib(b, .{
|
||||
.name = "spng",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/spng.zig"),
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/spng.zig"),
|
||||
});
|
||||
|
||||
mod.addIncludePath(b.path("spng"));
|
||||
mod.addIncludePath(b.path("./"));
|
||||
mod.linkLibrary(spng_c);
|
||||
spng.install();
|
||||
|
||||
b.installArtifact(spng_c);
|
||||
spng.addIncludePath("spng");
|
||||
spng.addIncludePath("./");
|
||||
|
||||
// Configure library
|
||||
spng.lib.linkLibC();
|
||||
|
||||
spng.lib.addCSourceFile(.{ .file = b.path("spng/spng.c") });
|
||||
spng.lib.addCSourceFile(.{ .file = b.path("miniz.c") });
|
||||
|
||||
spng.lib.root_module.addCMacro("SPNG_USE_MINIZ", "1");
|
||||
|
||||
const test_step = b.step("test", "run unit tests for spng");
|
||||
const tests = b.addTest(.{
|
||||
|
|
@ -44,9 +37,12 @@ pub fn build(b: *std.Build) void {
|
|||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
tests.root_module.linkLibrary(spng_c);
|
||||
tests.root_module.addImport("spng", spng.mod);
|
||||
tests.root_module.linkLibrary(spng.lib);
|
||||
|
||||
tests.root_module.addIncludePath(b.path("spng"));
|
||||
tests.root_module.addIncludePath(b.path("./"));
|
||||
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
const tracy_path = "tracy-0.10/public";
|
||||
const tracy_path_include = tracy_path ++ "/tracy";
|
||||
|
|
@ -7,7 +8,6 @@ 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;
|
||||
|
||||
|
|
@ -17,17 +17,26 @@ pub fn build(b: *std.Build) void {
|
|||
// }
|
||||
// std.debug.print("tracy enabled {s}\n", .{if (tracy_enabled) "true" else "false"});
|
||||
|
||||
const mod = b.addModule("tracy", .{
|
||||
const tracy = bh.MakeModLib(b, .{
|
||||
.name = "tracy",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("tracy.zig"),
|
||||
.link_libc = tracy_enabled,
|
||||
.link_libcpp = tracy_enabled,
|
||||
.static_build = static_build,
|
||||
.root = b.path("tracy.zig"),
|
||||
});
|
||||
|
||||
tracy.install();
|
||||
|
||||
if (tracy_enabled) {
|
||||
mod.addIncludePath(b.path(tracy_path_include));
|
||||
mod.addCSourceFile(.{
|
||||
// Add include paths to module (for Zig @cImport)
|
||||
tracy.mod.addIncludePath(b.path(tracy_path_include));
|
||||
|
||||
// Configure library
|
||||
tracy.lib.linkLibC();
|
||||
tracy.lib.linkLibCpp();
|
||||
|
||||
tracy.lib.addIncludePath(b.path(tracy_path_include));
|
||||
tracy.lib.addCSourceFile(.{
|
||||
.file = b.path(tracy_path ++ "/TracyClient.cpp"),
|
||||
.flags = &[_][]const u8{
|
||||
"-DTRACY_ENABLE",
|
||||
|
|
@ -40,16 +49,16 @@ pub fn build(b: *std.Build) void {
|
|||
});
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
mod.linkSystemLibrary("Advapi32", .{});
|
||||
mod.linkSystemLibrary("User32", .{});
|
||||
mod.linkSystemLibrary("Ws2_32", .{});
|
||||
mod.linkSystemLibrary("DbgHelp", .{});
|
||||
tracy.lib.linkSystemLibrary("Advapi32");
|
||||
tracy.lib.linkSystemLibrary("User32");
|
||||
tracy.lib.linkSystemLibrary("Ws2_32");
|
||||
tracy.lib.linkSystemLibrary("DbgHelp");
|
||||
}
|
||||
}
|
||||
|
||||
const opts = b.addOptions();
|
||||
opts.addOption(bool, "tracy_enabled", tracy_enabled);
|
||||
mod.addOptions("build_options", opts);
|
||||
tracy.mod.addOptions("build_options", opts);
|
||||
|
||||
// ========== tests =============
|
||||
const test_step = b.step("test", "run unit tests for tracy");
|
||||
|
|
@ -60,7 +69,8 @@ pub fn build(b: *std.Build) void {
|
|||
.root_source_file = b.path("tracy_test.zig"),
|
||||
}),
|
||||
});
|
||||
tests.root_module.addImport("tracy", mod);
|
||||
tests.root_module.addImport("tracy", tracy.mod);
|
||||
tests.root_module.linkLibrary(tracy.lib);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,37 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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("watcher", .{
|
||||
const watcher = bh.MakeModLib(b, .{
|
||||
.name = "watcher",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/watcher.zig"),
|
||||
.link_libc = true,
|
||||
.link_libcpp = true,
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/watcher.zig"),
|
||||
});
|
||||
|
||||
mod.addCSourceFile(.{ .file = b.path("src/watcher.cpp") });
|
||||
watcher.install();
|
||||
|
||||
// Add include paths to module (for Zig @cImport)
|
||||
watcher.mod.addIncludePath(b.path("src/include"));
|
||||
|
||||
// Configure library
|
||||
watcher.lib.linkLibC();
|
||||
watcher.lib.linkLibCpp();
|
||||
|
||||
watcher.lib.addIncludePath(b.path("src/include"));
|
||||
watcher.lib.addCSourceFile(.{ .file = b.path("src/watcher.cpp") });
|
||||
|
||||
if (target.result.os.tag == .macos) {
|
||||
mod.linkFramework("CoreFoundation", .{});
|
||||
mod.linkFramework("CoreServices", .{});
|
||||
watcher.lib.linkFramework("CoreFoundation");
|
||||
watcher.lib.linkFramework("CoreServices");
|
||||
}
|
||||
|
||||
mod.addIncludePath(b.path("src/include"));
|
||||
|
||||
const test_exe = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
|
|
@ -31,7 +39,8 @@ pub fn build(b: *std.Build) void {
|
|||
.root_source_file = b.path("tests/test.zig"),
|
||||
}),
|
||||
});
|
||||
test_exe.root_module.addImport("watcher", mod);
|
||||
test_exe.root_module.addImport("watcher", watcher.mod);
|
||||
test_exe.root_module.linkLibrary(watcher.lib);
|
||||
|
||||
const test_step = b.step("test", "runs sample unit tests for watcher");
|
||||
test_step.dependOn(&b.addRunArtifact(test_exe).step);
|
||||
|
|
|
|||
|
|
@ -1,21 +1,31 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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("zgltf", .{
|
||||
.root_source_file = b.path("src/zgltf.zig"),
|
||||
const zgltf = bh.MakeModLib(b, .{
|
||||
.name = "zgltf",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.static_build = static_build,
|
||||
.root = b.path("src/zgltf.zig"),
|
||||
});
|
||||
|
||||
zgltf.install();
|
||||
|
||||
const tests = b.addTest(.{
|
||||
.root_module = mod,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/zgltf.zig"),
|
||||
}),
|
||||
});
|
||||
tests.root_module.addImport("zgltf", zgltf.mod);
|
||||
tests.root_module.linkLibrary(zgltf.lib);
|
||||
b.installArtifact(tests);
|
||||
|
||||
var run_tests = b.addRunArtifact(tests);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
const std = @import("std");
|
||||
const bh = @import("bh");
|
||||
|
||||
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", .{
|
||||
const zmath = bh.MakeModLib(b, .{
|
||||
.name = "zmath",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("zmath.zig"),
|
||||
.static_build = static_build,
|
||||
.root = b.path("zmath.zig"),
|
||||
});
|
||||
|
||||
zmath.install();
|
||||
|
||||
const test_step = b.step("test", "runs tests for zmath");
|
||||
const tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
|
|
@ -22,7 +26,8 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
|
||||
tests.root_module.addImport("zmath", mod);
|
||||
tests.root_module.addImport("zmath", zmath.mod);
|
||||
tests.root_module.linkLibrary(zmath.lib);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ pub fn build(b: *std.Build) void {
|
|||
zjolt.addIncludePath(b.path("libs/JoltC"));
|
||||
|
||||
const joltc = b.addLibrary(.{
|
||||
.name = "joltc",
|
||||
.name = "zphysics",
|
||||
.linkage = if (!static_build) .dynamic else .static,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ pub fn build(b: *std.Build) void {
|
|||
.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("audio", true);
|
||||
sampleGame.setModuleEnabled("physics", true);
|
||||
|
|
@ -51,26 +55,26 @@ pub fn build(b: *std.Build) void {
|
|||
newProjectMaker.setIconPath("icons/NewProject.ico");
|
||||
_ = newProjectMaker.compileInstall();
|
||||
|
||||
const toolbox = blbuild.program(.{
|
||||
.name = "toolbox",
|
||||
.desc = "graphical toolbox for random stuff",
|
||||
.root_source_file = b.path("tools/toolbox.zig"),
|
||||
});
|
||||
// const toolbox = blbuild.program(.{
|
||||
// .name = "toolbox",
|
||||
// .desc = "graphical toolbox for random stuff",
|
||||
// .root_source_file = b.path("tools/toolbox.zig"),
|
||||
// });
|
||||
|
||||
toolbox.setModuleEnabled("imgui", true);
|
||||
toolbox.setModuleEnabled("audio", false);
|
||||
toolbox.setModuleEnabled("sys", true);
|
||||
toolbox.setModuleEnabled("net", false);
|
||||
toolbox.addExtraModule("gameExtras");
|
||||
// toolbox.setModuleEnabled("imgui", true);
|
||||
// toolbox.setModuleEnabled("audio", false);
|
||||
// toolbox.setModuleEnabled("sys", true);
|
||||
// toolbox.setModuleEnabled("net", false);
|
||||
// toolbox.addExtraModule("gameExtras");
|
||||
|
||||
const toolboxExe = toolbox.compileInstall();
|
||||
// const toolboxExe = toolbox.compileInstall();
|
||||
// Add Windows icon resource for toolbox
|
||||
if (target.result.os.tag == .windows) {
|
||||
toolboxExe.addWin32ResourceFile(.{
|
||||
.file = b.path("tools/toolbox.rc"),
|
||||
.flags = &.{},
|
||||
});
|
||||
}
|
||||
// if (target.result.os.tag == .windows) {
|
||||
// toolboxExe.addWin32ResourceFile(.{
|
||||
// .file = b.path("tools/toolbox.rc"),
|
||||
// .flags = &.{},
|
||||
// });
|
||||
// }
|
||||
|
||||
const headless = blbuild.program(.{
|
||||
.name = "headless",
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ pub fn start_module(args: core.ModuleLoaderArgs) !void {
|
|||
core.PatchOrCreateObject(imgui.utils.ConsoleWindow, .{});
|
||||
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;
|
||||
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,
|
||||
reloadMapInput: ?*core.ActionBinding = null,
|
||||
|
||||
recompileStart: f64 = 0.0,
|
||||
|
||||
volume: f32 = 100.0,
|
||||
volume2: f32 = 100.0,
|
||||
|
||||
|
|
@ -403,6 +405,8 @@ pub const ExternGameObject = struct {
|
|||
pub fn recompileComplete(ctx: ?*anyopaque) void {
|
||||
const self = core.cast(*@This(), ctx.?);
|
||||
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 {
|
||||
|
|
@ -417,6 +421,7 @@ pub const ExternGameObject = struct {
|
|||
const self = core.cast(*@This(), ctx.?);
|
||||
|
||||
if (!self.recompiling) {
|
||||
self.recompileStart = core.getEngineTime();
|
||||
self.recompiling = true;
|
||||
const x = core.EngineObject(sys.SystemRunner).get();
|
||||
x.commandQueue.pushLocked(.{
|
||||
|
|
@ -487,8 +492,6 @@ pub const ExternGameObject = struct {
|
|||
_ = dt;
|
||||
//self.time += @floatCast(dt);
|
||||
|
||||
//core.debugSphere(.{ .y = 10 + std.math.sin(self.time) }, 5, .{});
|
||||
|
||||
if (core.getEngineObject(imgui.utils.TopBar)) |topbar| {
|
||||
topbar.menuOpen = platform.context().isCursorEnabled();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue