118 lines
3.8 KiB
Zig
118 lines
3.8 KiB
Zig
pub const AddProgramOptions = struct {
|
|
name: []const u8,
|
|
opt: bh.Options,
|
|
root_source_file: std.Build.LazyPath,
|
|
};
|
|
|
|
pub const GameModule = struct {
|
|
name: []const u8,
|
|
enabled: bool = true,
|
|
};
|
|
|
|
pub const Program = struct {
|
|
name: []const u8,
|
|
opts: bh.Options,
|
|
|
|
// root_path: not used yet, we will create a second module that dynamically loads in to that root_path
|
|
|
|
gameModules: std.ArrayListUnmanaged(GameModule) = .{},
|
|
buildSystem: *backlog.BuildSystem,
|
|
iconPath: ?std.Build.LazyPath = null,
|
|
allocator: std.mem.Allocator, // just set this to the build allocator
|
|
|
|
pub fn setIconPath(self: *@This(), path: []const u8) void {
|
|
if (self.iconPath != null) {
|
|
return;
|
|
}
|
|
|
|
self.iconPath = self.buildSystem.generateRc(self.name, path) catch return;
|
|
}
|
|
|
|
pub fn compileInstall(self: *@This()) *std.Build.Step.Compile {
|
|
const bEngine = self.buildSystem.bEngine;
|
|
const b = self.buildSystem.b;
|
|
const core = self.buildSystem.nwdep.module("core");
|
|
|
|
const trampoline = b.createModule(.{
|
|
.target = self.opts.target,
|
|
.optimize = self.opts.optimize,
|
|
.root_source_file = b.path("test-trampoline.zig"),
|
|
});
|
|
trampoline.addImport("core", core);
|
|
|
|
// 1. create the loader
|
|
const exe = bEngine.addExecutable(.{
|
|
.name = self.name,
|
|
.root_module = bEngine.createModule(.{
|
|
.target = self.opts.target,
|
|
.optimize = self.opts.optimize,
|
|
.root_source_file = bEngine.path("engine/main2.zig"), // this path sould be generated by generateTrampoline.zig
|
|
}),
|
|
});
|
|
|
|
exe.root_module.addImport("core", core);
|
|
exe.root_module.addImport("trampoline", trampoline);
|
|
exe.root_module.addOptions("BacklogOptions", self.buildSystem.options);
|
|
|
|
// link core
|
|
|
|
// 2. create the actual library that the loader will try to load
|
|
|
|
// 3. set up linking, if static then we will link against the loader
|
|
|
|
self.buildSystem.b.installArtifact(exe);
|
|
|
|
// return the actual library not the loader
|
|
return exe;
|
|
}
|
|
|
|
// const b = self.b;
|
|
|
|
// const exe = self.nw_builder.addExecutable(.{
|
|
// .name = opts.name,
|
|
// .target = self.target,
|
|
// .optimize = self.optimize,
|
|
// .root_source_file = self.nw_builder.path("engine/main.zig"),
|
|
// });
|
|
|
|
// b.installArtifact(exe);
|
|
// const runArtifact = b.addRunArtifact(exe);
|
|
// if (b.args) |args| {
|
|
// runArtifact.addArgs(args);
|
|
// }
|
|
// const run_exe = b.step(self.b.fmt("run-{s}", .{opts.name}), opts.desc);
|
|
// run_exe.dependOn(&runArtifact.step);
|
|
|
|
// // main path = name/main.zig
|
|
// const mod = b.addModule(opts.name, .{
|
|
// .target = self.target,
|
|
// .optimize = self.optimize,
|
|
// .root_source_file = opts.root_source_file,
|
|
// .imports = opts.imports,
|
|
// });
|
|
|
|
// exe.root_module.addImport("main", mod);
|
|
// // todo.. remove this one and see what happens
|
|
// exe.root_module.addImport("core", self.nwdep.module("core"));
|
|
// // mod.addImport("Backlog", self.nw_mod);
|
|
// exe.root_module.addOptions("BacklogOptions", self.options);
|
|
|
|
// if (self.cookShaders) {
|
|
// const cookShadersScript = b.fmt("{s}/tools/scripts/cookShaders.py", .{self.backlogRoot});
|
|
// const cookShadersCommand = b.addSystemCommand(&[_][]const u8{"python"});
|
|
// cookShadersCommand.addArg(cookShadersScript);
|
|
|
|
// run_exe.dependOn(&cookShadersCommand.step);
|
|
// }
|
|
|
|
// b.getInstallStep().dependOn(self.nw_builder.getInstallStep());
|
|
|
|
// // run_exe.dependOn(b.getInstallStep());
|
|
|
|
// return mod;
|
|
};
|
|
|
|
const std = @import("std");
|
|
const bh = @import("bh");
|
|
const backlog = @import("../build.zig");
|