working version and not working steamParser
This commit is contained in:
parent
b38a3b7bda
commit
182b7d3f21
1 changed files with 348 additions and 323 deletions
88
build.zig
88
build.zig
|
|
@ -20,12 +20,8 @@ pub fn build(b: *std.Build) void {
|
|||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const translate_c = b.addTranslateC(.{
|
||||
.root_source_file = b.path("src/c.h"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
translate_c.linkSystemLibrary("gl", .{ .needed = true, .preferred_link_mode = .static });
|
||||
const prebuilt = b.option([]const u8, "prebuilt", "Path to prebuilt deps (for nix, can be used outside if you need to)");
|
||||
const glfw_lib = b.option([]const u8, "glfw-lib", "Path to glfw lib dir");
|
||||
|
||||
const cimgui_dep = b.dependency("cimgui_zig", .{
|
||||
.target = target,
|
||||
|
|
@ -37,10 +33,51 @@ pub fn build(b: *std.Build) void {
|
|||
// .no_platform = true, // Default value: false. Comment `platforms` field if you use this one
|
||||
});
|
||||
|
||||
const cimgui_lib = cimgui_dep.artifact("cimgui");
|
||||
addIncludePathsToTranslateC(translate_c, cimgui_lib);
|
||||
const c_module = translate_c.createModule();
|
||||
c_module.linkLibrary(cimgui_lib);
|
||||
const cimgui_artifact = cimgui_dep.artifact("cimgui");
|
||||
|
||||
// --- cimgui-only step (used by Nix to build the prebuilt derivation) ---
|
||||
const cimgui_only_step = b.step("cimgui-only", "Build only the cimgui library");
|
||||
const install_cimgui = b.addInstallLibFile(
|
||||
cimgui_artifact.getEmittedBin(),
|
||||
"libcimgui.a",
|
||||
);
|
||||
const install_headers = b.addInstallDirectory(.{
|
||||
.source_dir = cimgui_artifact.getEmittedIncludeTree(),
|
||||
.install_dir = .{ .custom = "include" },
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
cimgui_only_step.dependOn(&install_cimgui.step);
|
||||
cimgui_only_step.dependOn(&install_headers.step);
|
||||
|
||||
// --- translate-c-only step (used by Nix to cache the translate-c output) ---
|
||||
const translate_c = b.addTranslateC(.{
|
||||
.root_source_file = b.path("src/c.h"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
translate_c.linkSystemLibrary("gl", .{ .needed = true, .preferred_link_mode = .static });
|
||||
addIncludePathsToTranslateC(translate_c, cimgui_artifact);
|
||||
|
||||
const translate_c_only_step = b.step("translate-c-only", "Only run translate-c, used by Nix");
|
||||
const install_translated = b.addInstallFile(translate_c.getOutput(), "c.zig");
|
||||
translate_c_only_step.dependOn(&install_translated.step);
|
||||
|
||||
// --- c_module and exe ---
|
||||
const c_module = if (prebuilt) |p| blk: {
|
||||
const mod = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = .{ .cwd_relative = b.pathJoin(&.{ p, "c.zig" }) },
|
||||
});
|
||||
mod.linkSystemLibrary("GL", .{});
|
||||
mod.linkSystemLibrary("cimgui", .{});
|
||||
break :blk mod;
|
||||
} else blk: {
|
||||
const mod = translate_c.createModule();
|
||||
mod.linkLibrary(cimgui_artifact);
|
||||
break :blk mod;
|
||||
};
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "emu_ui",
|
||||
|
|
@ -51,19 +88,30 @@ pub fn build(b: *std.Build) void {
|
|||
.imports = &.{
|
||||
.{ .name = "imgui", .module = c_module },
|
||||
},
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
|
||||
if (prebuilt) |p| {
|
||||
exe.root_module.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ p, "lib" }) });
|
||||
exe.root_module.linkSystemLibrary("cimgui", .{});
|
||||
exe.root_module.linkSystemLibrary("stdc++", .{});
|
||||
if (glfw_lib) |g| {
|
||||
exe.root_module.addLibraryPath(.{ .cwd_relative = g });
|
||||
}
|
||||
exe.root_module.linkSystemLibrary("glfw", .{});
|
||||
}
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
const run_step = b.step("run", "Run the app");
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
const steamParser = b.addExecutable(.{
|
||||
.name = "steamParser",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/steamParser.zig"),
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
}),
|
||||
});
|
||||
const steamParserStep = b.step("steamParser", "build the steam parser");
|
||||
steamParserStep.dependOn(&b.addInstallArtifact(steamParser, .{}).step);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue