forked from thedmd/imgui-node-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
90 lines (74 loc) · 3.14 KB
/
build.zig
File metadata and controls
90 lines (74 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const std = @import("std");
const zcc = @import("compile_commands");
const sokol = @import("sokol");
const cimgui = @import("cimgui");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
var cflags_buf: [16][]const u8 = undefined;
var cflags = std.ArrayListUnmanaged([]const u8).initBuffer(&cflags_buf);
try cflags.appendBounded("-fno-sanitize=undefined");
const examples_step = b.step("examples", "Build examples");
var targets = std.ArrayListUnmanaged(*std.Build.Step.Compile){};
const lazy_dep_cimgui = b.lazyDependency("cimgui", .{
.target = target,
.optimize = optimize,
});
const lazy_dep_sokol = b.lazyDependency("sokol", .{
.target = target,
.optimize = optimize,
.with_sokol_imgui = true,
.with_tracing = true,
});
const mod_imgui_node_editor = b.addModule("imgui-node-editor", .{
.link_libc = true,
.link_libcpp = true,
.target = target,
.optimize = optimize,
.root_source_file = b.path("node_editor.zig"),
});
if (lazy_dep_cimgui) |dep_cimgui| {
mod_imgui_node_editor.addIncludePath(dep_cimgui.path("src"));
}
mod_imgui_node_editor.addIncludePath(b.path("."));
mod_imgui_node_editor.addCSourceFiles(.{
.flags = cflags.items,
.language = .cpp,
.root = b.path("."),
.files = &[_][]const u8{
"crude_json.cpp",
"imgui_canvas.cpp",
"imgui_node_editor.cpp",
"imgui_node_editor_api.cpp",
},
});
const lib_imgui_node_editor = b.addLibrary(.{
.name = "lib_imgui-node-editor",
.root_module = mod_imgui_node_editor,
});
targets.append(b.allocator, lib_imgui_node_editor) catch @panic("OOM");
b.installArtifact(lib_imgui_node_editor);
if (lazy_dep_cimgui) |dep_cimgui| {
mod_imgui_node_editor.linkLibrary(dep_cimgui.artifact("cimgui_clib"));
if (lazy_dep_sokol) |dep_sokol| {
dep_sokol.artifact("sokol_clib").addIncludePath(dep_cimgui.path("src"));
dep_sokol.artifact("sokol_clib").linkLibrary(dep_cimgui.artifact("cimgui_clib"));
const exe = b.addExecutable(.{
.name = "simple-example",
.root_module = b.addModule("simple-example", .{
.root_source_file = b.path("examples/sokol-simple-example/sokol-simple-example.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "sokol", .module = dep_sokol.module("sokol") },
.{ .name = "cimgui", .module = dep_cimgui.module("cimgui") },
.{ .name = "node-editor", .module = mod_imgui_node_editor },
},
}),
});
examples_step.dependOn(&b.addInstallArtifact(exe, .{}).step);
b.step("run-simple", "Run demo").dependOn(&b.addRunArtifact(exe).step);
}
}
_ = zcc.createStep(b, "compile_commands", targets.toOwnedSlice(b.allocator) catch @panic("OOM"));
}