removing more cruft from p2

This commit is contained in:
Peterino2 2026-11-20 18:19:38 -07:00
parent eae1737b66
commit f74c6cc6c2
7 changed files with 7 additions and 186 deletions

View File

@ -1,155 +0,0 @@
const std = @import("std");
pub const ModLib = struct {
b: *std.Build,
lib: *std.Build.Step.Compile,
mod: *std.Build.Module,
pub fn install(self: @This()) void {
self.b.installArtifact(self.lib);
}
};
pub const ModLibOptions = struct {
name: []const u8,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
monolithic: bool,
allow_dynamic: bool = false,
link_libc: bool = false,
link_libcpp: bool = false,
root: ?std.Build.LazyPath = null,
stub: ?std.Build.LazyPath = null,
};
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})),
});
const empty_file = b.addWriteFile("stubs", "");
const lib = b.addLibrary(.{
.name = o.name,
.linkage = if (o.allow_dynamic and !o.monolithic) .dynamic else .static,
.root_module = b.createModule(.{
.root_source_file = empty_file.add("stubc.zig", ""),
.target = o.target,
.optimize = o.optimize,
}),
});
return .{
.b = b,
.lib = lib,
.mod = mod,
};
}
pub const Options = struct {
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
monolithic: bool,
tracy: bool,
renderer: []const u8,
box3d_validate: ?bool = null,
};
// standard set of options that all riblab modules and dependenices shall use.
pub fn declareOptions(b: *std.Build) Options {
return .{
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
.monolithic = b.option(bool, "monolithic", "builds RibLab dependencies for static linking") orelse false,
.tracy = b.option(bool, "tracy", "builds with tracy support") orelse false,
.renderer = b.option([]const u8, "renderer", "renderer backend: sgpu_main, gl_low_spec, headless") orelse "sgpu_main",
.box3d_validate = b.option(bool, "box3d-validate", "enable heavy Box3D validation"),
};
}
pub fn dependency(b: *std.Build, name: []const u8, opts: Options) *std.Build.Dependency {
if (std.mem.eql(u8, name, "physics")) {
return b.dependency(name, .{
.target = opts.target,
.optimize = opts.optimize,
.monolithic = opts.monolithic,
.tracy = opts.tracy,
.renderer = opts.renderer,
.@"box3d-validate" = opts.box3d_validate,
});
}
if (isEngineDependency(name)) {
return b.dependency(name, .{
.target = opts.target,
.optimize = opts.optimize,
.monolithic = opts.monolithic,
.tracy = opts.tracy,
.renderer = opts.renderer,
});
}
return b.dependency(name, .{
.target = opts.target,
.optimize = opts.optimize,
.monolithic = opts.monolithic,
.tracy = opts.tracy,
});
}
pub fn isEngineDependency(name: []const u8) bool {
const engine_deps = [_][]const u8{
"assets",
"audio",
"cook",
"core",
"desktopKit",
"devkit",
"editorkit",
"net",
"netgame",
"nav",
"bsp",
"papyrus",
"platform",
"rend",
"ui",
"physics",
"sys",
};
for (engine_deps) |dep_name| {
if (std.mem.eql(u8, dep_name, name)) return true;
}
return false;
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const monolithic = b.option(bool, "monolithic", "builds RibLab dependencies for static linking") orelse false;
const r = MakeModlib(b, .{
.name = "bh",
.target = target,
.optimize = optimize,
.monolithic = monolithic,
});
b.installArtifact(r.lib);
const test_step = b.step("test", "run unit tests for enet");
const tests = b.addTest(.{
.root_module = b.createModule(.{
.link_libc = true,
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/tests.zig"),
}),
});
const runArtifact = b.addRunArtifact(tests);
test_step.dependOn(&runArtifact.step);
}

View File

@ -1,10 +0,0 @@
.{
.name = .bh,
.version = "0.0.0",
.dependencies = .{
},
.paths = .{
"",
},
.fingerprint = 0x557bf2b094ba1492,
}

View File

@ -1,12 +1,12 @@
const std = @import("std");
const bh = @import("bh");
pub fn build(b: *std.Build) void {
const opts = bh.declareOptions(b);
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("p2", .{
.target = opts.target,
.optimize = opts.optimize,
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/p2.zig"),
});
@ -15,8 +15,8 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "test p2");
const tests = b.addTest(.{
.root_module = b.createModule(.{
.target = opts.target,
.optimize = opts.optimize,
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/p2.zig"),
}),
.use_llvm = b.option(bool, "llvm", "compiles the tests with llvm "),
@ -30,16 +30,4 @@ pub fn build(b: *std.Build) void {
test_step.dependOn(&runArtifact.step);
runArtifact.addPassthruArgs();
b.installArtifact(tests);
const benchmark = b.addExecutable(.{
.name = "queue-benchmark",
.root_module = b.createModule(.{
.target = opts.target,
.optimize = opts.optimize,
.root_source_file = b.path("src/queue-benchmark.zig"),
}),
});
const runBenchmark = b.addRunArtifact(benchmark);
runBenchmark.addPassthruArgs();
b.step("bench-queues", "Compare one-producer/many-consumer queue throughput").dependOn(&runBenchmark.step);
}

View File

@ -1,9 +1,7 @@
.{
.name = .p2,
.version = "0.0.0",
.dependencies = .{
.bh = .{ .path = "../bh" },
},
.dependencies = .{},
.paths = .{
"",
},