init
This commit is contained in:
commit
b38a3b7bda
1 changed files with 801 additions and 0 deletions
69
build.zig
Normal file
69
build.zig
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
const std = @import("std");
|
||||
|
||||
const cimgui = @import("cimgui_zig");
|
||||
const Renderer = cimgui.Renderer;
|
||||
const Platform = cimgui.Platform;
|
||||
|
||||
fn addIncludePathsToTranslateC(translate_c: *std.Build.Step.TranslateC, lib: *std.Build.Step.Compile) void {
|
||||
for (lib.root_module.include_dirs.items) |*included| {
|
||||
switch (included.*) {
|
||||
.path => translate_c.addIncludePath(included.path),
|
||||
.config_header_step => translate_c.addConfigHeader(included.config_header_step),
|
||||
.path_system => translate_c.addSystemIncludePath(included.path_system),
|
||||
.other_step => addIncludePathsToTranslateC(translate_c, included.other_step),
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 cimgui_dep = b.dependency("cimgui_zig", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.platforms = &[_]Platform{.GLFW},
|
||||
.renderers = &[_]Renderer{.OpenGL3},
|
||||
// .docking = true, // Default value: false
|
||||
// .no_renderer = true, // Default value: false. Comment `renderers` field if you use this one
|
||||
// .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 exe = b.addExecutable(.{
|
||||
.name = "emu_ui",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.imports = &.{
|
||||
.{ .name = "imgui", .module = c_module },
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue