Skip to content

Commit

Permalink
try again - imgui
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Apr 21, 2024
1 parent 38649cc commit 1d1fc58
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,21 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep {
.flags = cflags,
});
}
// FIXME: missing 'assert.h'
if (!lib.rootModuleTarget().isWasm()) {
lib.addCSourceFile(.{
.file = .{ .path = csrc_root ++ "sokol_imgui.c" },
.flags = cflags,
});
const cimgui = try buildImgui(b, .{
.target = options.target,
.optimize = options.optimize,
.emsdk = options.emsdk,
});
for (cimgui.root_module.include_dirs.items) |dir| {
try lib.root_module.include_dirs.append(b.allocator, dir);
}
lib.linkLibrary(cimgui);

lib.addCSourceFile(.{
.file = .{ .path = csrc_root ++ "sokol_imgui.c" },
.flags = cflags,
});
const cimgui = try buildImgui(b, .{
.target = options.target,
.optimize = options.optimize,
.emsdk = options.emsdk,
});
for (cimgui.root_module.include_dirs.items) |dir| {
try lib.root_module.include_dirs.append(b.allocator, dir);
}
lib.linkLibrary(cimgui);

if (sharedlib)
b.installArtifact(lib);
return lib;
Expand Down Expand Up @@ -240,8 +239,6 @@ pub fn build(b: *Build) !void {
};

inline for (examples) |example| {
if (lib_sokol.rootModuleTarget().isWasm() and std.mem.eql(u8, example, "imgui"))
return; // FIXME: cimgui need 'assert.h'.
const ldc = try ldcBuildStep(b, .{
.name = example,
.artifact = lib_sokol,
Expand Down Expand Up @@ -519,14 +516,8 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep {

try cmds.append(b.fmt("-mtriple={s}", .{mtriple}));

// cpu model (e.g. "baseline")
if (options.target.query.isNative()) {
const cpu_model = if (options.target.result.isDarwin())
builtin.cpu.model.llvm_name orelse "generic"
else
builtin.cpu.model.name;
try cmds.append(b.fmt("-mcpu={s}", .{cpu_model}));
}
const cpu_model = options.target.result.cpu.model.llvm_name orelse "generic";
try cmds.append(b.fmt("-mcpu={s}", .{cpu_model}));

const outputDir = switch (options.kind) {
.lib => "lib",
Expand Down

0 comments on commit 1d1fc58

Please sign in to comment.