saving
This commit is contained in:
parent
13d73418f8
commit
2176977c4c
|
|
@ -1,28 +1,24 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const core = @import("core").MakeModLib;
|
||||||
|
|
||||||
|
const depList = [_][]const u8{
|
||||||
|
"core",
|
||||||
|
"packer",
|
||||||
|
};
|
||||||
|
|
||||||
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(.{});
|
||||||
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("assets", .{
|
const engineMod = core.MakeModLib(b, .{
|
||||||
|
.name = "assets",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.root_source_file = b.path("src/assets.zig"),
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
const core_dep = b.dependency(
|
engineMod.linkModLibs(&depList);
|
||||||
"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"));
|
|
||||||
|
|
||||||
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(.{
|
||||||
|
|
@ -33,7 +29,7 @@ pub fn build(b: *std.Build) void {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.root_module.addImport("assets", mod);
|
tests.root_module.addImport("assets", engineMod);
|
||||||
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,4 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const core = @import("core").MakeModLib;
|
||||||
|
|
||||||
const depList = [_][]const u8{
|
const depList = [_][]const u8{
|
||||||
"miniaudio",
|
"miniaudio",
|
||||||
|
|
@ -11,17 +12,14 @@ 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("audio", .{
|
const engineMod = core.MakeModLib(b, .{
|
||||||
|
.name = "audio",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.root_source_file = b.path("src/audio.zig"),
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (depList) |depName| {
|
engineMod.linkModLibs(&depList);
|
||||||
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
|
||||||
|
|
||||||
mod.addImport(depName, dep.module(depName));
|
|
||||||
}
|
|
||||||
|
|
||||||
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(.{
|
||||||
|
|
@ -32,7 +30,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);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,14 @@ 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 core = MakeModLib();
|
const engineMod = MakeModLib(b, .{
|
||||||
|
.name = "core",
|
||||||
const mod = b.addModule("core", .{
|
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.root_source_file = b.path("src/core.zig"),
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (dependencyList) |depName| {
|
engineMod.linkModLibs(&dependencyList);
|
||||||
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
|
||||||
mod.addImport(depName, dep.module(depName));
|
|
||||||
}
|
|
||||||
|
|
||||||
const test_step = b.step("test", "run unit tests for core");
|
const test_step = b.step("test", "run unit tests for core");
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
|
|
@ -48,7 +44,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.linkage = .dynamic,
|
.linkage = .dynamic,
|
||||||
.name = "external",
|
.name = "external",
|
||||||
});
|
});
|
||||||
sampleGameExtern.root_module.addImport("core", mod);
|
sampleGameExtern.root_module.addImport("core", engineMod.mod);
|
||||||
|
|
||||||
const installExtern = b.addInstallArtifact(sampleGameExtern, .{
|
const installExtern = b.addInstallArtifact(sampleGameExtern, .{
|
||||||
.dest_dir = .{ .override = .{ .custom = "modules" } },
|
.dest_dir = .{ .override = .{ .custom = "modules" } },
|
||||||
|
|
@ -56,7 +52,7 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
b.getInstallStep().dependOn(&installExtern.step);
|
b.getInstallStep().dependOn(&installExtern.step);
|
||||||
|
|
||||||
tests.root_module.addImport("core", mod);
|
tests.root_module.addImport("core", engineMod.mod);
|
||||||
const runArtifact = b.addRunArtifact(tests);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
runArtifact.step.dependOn(b.getInstallStep());
|
runArtifact.step.dependOn(b.getInstallStep());
|
||||||
|
|
|
||||||
|
|
@ -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" },
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const core = @import("core");
|
||||||
|
|
||||||
const dependencyList = [_][]const u8{
|
const dependencyList = [_][]const u8{
|
||||||
"core",
|
"core",
|
||||||
|
|
@ -13,17 +14,14 @@ 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("imgui", .{
|
const engineMod = core.MakeModLib(b, .{
|
||||||
|
.name = "imgui",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.root_source_file = b.path("src/imgui.zig"),
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (dependencyList) |depName| {
|
engineMod.linkModLibs(&dependencyList);
|
||||||
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(.{
|
||||||
|
|
@ -35,7 +33,7 @@ pub fn build(b: *std.Build) void {
|
||||||
});
|
});
|
||||||
const test_step = b.step("test", "run unit tests for imgui");
|
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);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const core = @import("core");
|
||||||
|
|
||||||
const depList = [_][]const u8{
|
const depList = [_][]const u8{
|
||||||
"core",
|
"core",
|
||||||
|
|
@ -10,17 +11,14 @@ 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("net", .{
|
const engineMod = core.MakeModLib(b, .{
|
||||||
|
.name = "imgui",
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.root_source_file = b.path("src/net.zig"),
|
.static_build = static_build,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (depList) |depName| {
|
engineMod.linkModLibs(&depList);
|
||||||
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
|
|
||||||
|
|
||||||
mod.addImport(depName, dep.module(depName));
|
|
||||||
}
|
|
||||||
|
|
||||||
const test_step = b.step("test", "run unit tests for net");
|
const test_step = b.step("test", "run unit tests for net");
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
|
|
@ -31,7 +29,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);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
b.installArtifact(tests);
|
b.installArtifact(tests);
|
||||||
|
|
|
||||||
|
|
@ -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,18 +11,23 @@ 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 engineMod = core.MakeModLib(b, .{
|
||||||
|
.name = "papyrus",
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
.static_build = static_build,
|
||||||
|
});
|
||||||
|
|
||||||
|
engineMod.linkModLibs(&depList);
|
||||||
|
engineMod.addIncludePath("src/");
|
||||||
|
engineMod.lib.addCSourceFile(b.path("src/compat.cpp"));
|
||||||
|
|
||||||
const mod = b.addModule("papyrus", .{
|
const mod = b.addModule("papyrus", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
.root_source_file = b.path("src/papyrus.zig"),
|
.root_source_file = b.path("src/papyrus.zig"),
|
||||||
});
|
});
|
||||||
mod.addIncludePath(b.path("src/"));
|
|
||||||
mod.addCSourceFile(.{ .file = b.path("src/compat.cpp") });
|
|
||||||
|
|
||||||
const core_dep = b.dependency("core", .{ .target = target, .optimize = optimize, .static_build = static_build });
|
|
||||||
|
|
||||||
mod.addImport("core", core_dep.module("core"));
|
|
||||||
|
|
||||||
// Creates a step for unit testing.
|
// Creates a step for unit testing.
|
||||||
const main_tests = b.addTest(.{
|
const main_tests = b.addTest(.{
|
||||||
|
|
@ -29,7 +39,6 @@ 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", mod);
|
||||||
main_tests.root_module.addIncludePath(b.path("src/"));
|
main_tests.root_module.addIncludePath(b.path("src/"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ pub const TextEntrySystem = @import("TextEntrySystem.zig");
|
||||||
pub const DrawCommand = @import("DrawCommand.zig");
|
pub const DrawCommand = @import("DrawCommand.zig");
|
||||||
pub const DrawList = std.ArrayList(DrawCommand);
|
pub const DrawList = std.ArrayList(DrawCommand);
|
||||||
|
|
||||||
const core = @import("core");
|
pub const core = @import("core");
|
||||||
const colors = core.colors;
|
const colors = core.colors;
|
||||||
pub const Color = colors.Color;
|
pub const Color = colors.Color;
|
||||||
pub const ColorRGBA8 = colors.RGBA8;
|
pub const ColorRGBA8 = colors.RGBA8;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const grapvizDotToPng = utils.grapvizDotToPng;
|
||||||
const BmpRenderer = papyrus.BmpRenderer;
|
const BmpRenderer = papyrus.BmpRenderer;
|
||||||
const BmpWriter = BmpRenderer.BmpWriter;
|
const BmpWriter = BmpRenderer.BmpWriter;
|
||||||
|
|
||||||
const core = @import("core");
|
const core = papyrus.core;
|
||||||
const colors = core.colors;
|
const colors = core.colors;
|
||||||
const Color = colors.Color;
|
const Color = colors.Color;
|
||||||
const ColorRGBA8 = colors.ColorRGBA8;
|
const ColorRGBA8 = colors.ColorRGBA8;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ pub const ModLib = struct {
|
||||||
lib: *std.Build.Step.Compile,
|
lib: *std.Build.Step.Compile,
|
||||||
mod: *std.Build.Module,
|
mod: *std.Build.Module,
|
||||||
|
|
||||||
|
target: std.Build.ResolvedTarget,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
static_build: bool,
|
||||||
|
|
||||||
pub fn install(self: @This()) void {
|
pub fn install(self: @This()) void {
|
||||||
self.b.installArtifact(self.lib);
|
self.b.installArtifact(self.lib);
|
||||||
}
|
}
|
||||||
|
|
@ -13,6 +17,19 @@ pub const ModLib = struct {
|
||||||
self.lib.addIncludePath(self.b.path(path));
|
self.lib.addIncludePath(self.b.path(path));
|
||||||
self.mod.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 {
|
pub const ModLibOptions = struct {
|
||||||
|
|
@ -50,6 +67,9 @@ pub fn MakeModlib(b: *std.Build, o: ModLibOptions) ModLib {
|
||||||
.b = b,
|
.b = b,
|
||||||
.lib = lib,
|
.lib = lib,
|
||||||
.mod = mod,
|
.mod = mod,
|
||||||
|
.target = o.target,
|
||||||
|
.optimize = o.optimize,
|
||||||
|
.static_build = o.static_build,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue