tangled
alpha
login
or
join now
altagos.dev
/
factorio-toolbox
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
build: setup imgui
altagos.dev
5 months ago
5500e1f4
32f1a8e6
verified
This commit was signed with the committer's
known signature
.
altagos.dev
SSH Key Fingerprint:
SHA256:UbTjEcCZlc6GzQWLCuDK3D//HESWD2xFPkzue9XMras=
+68
-26
3 changed files
expand all
collapse all
unified
split
.tangled
workflows
build.yml
build.zig
build.zig.zon
+1
-1
.tangled/workflows/build.yml
reviewed
···
18
18
mise exec zig -- zig build test --summary all
19
19
- name: Build ReleaseSafe
20
20
command: |
21
21
-
mise exec zig -- zig build -Doptimize=ReleaseSafe
21
21
+
mise exec zig -- zig build -Doptimize=ReleaseSafe -Ddocking
+63
-25
build.zig
reviewed
···
1
1
const std = @import("std");
2
2
const Build = std.Build;
3
3
+
3
4
const sokol = @import("sokol");
5
5
+
const cimgui = @import("cimgui");
4
6
5
7
const Options = struct {
6
6
-
mod: *Build.Module,
8
8
+
mod_ft: *Build.Module,
9
9
+
mod_exe: *Build.Module,
7
10
dep_sokol: *Build.Dependency,
11
11
+
dep_cimgui: *Build.Dependency,
12
12
+
cimgui_clib_name: []const u8,
8
13
};
9
14
10
15
pub fn build(b: *std.Build) !void {
11
16
const target = b.standardTargetOptions(.{});
12
17
const optimize = b.standardOptimizeOption(.{});
18
18
+
19
19
+
const opt_docking = b.option(bool, "docking", "Build with docking support") orelse false;
20
20
+
21
21
+
const cimgui_conf = cimgui.getConfig(opt_docking);
13
22
14
23
const dep_sokol = b.dependency("sokol", .{
15
24
.target = target,
16
25
.optimize = optimize,
26
26
+
.with_sokol_imgui = true,
27
27
+
});
28
28
+
const dep_cimgui = b.dependency("cimgui", .{
29
29
+
.target = target,
30
30
+
.optimize = optimize,
17
31
});
18
32
19
19
-
const mod = b.addModule("ft", .{
33
33
+
dep_sokol.artifact("sokol_clib").addIncludePath(dep_cimgui.path(cimgui_conf.include_dir));
34
34
+
35
35
+
const mod_ft = b.addModule("ft", .{
20
36
.root_source_file = b.path("src/root.zig"),
21
37
.target = target,
22
38
});
···
26
42
.target = target,
27
43
.optimize = optimize,
28
44
.imports = &.{
29
29
-
.{ .name = "ft", .module = mod },
30
30
-
.{ .name = "sokol", .module = dep_sokol.module("sokol") },
45
45
+
.{ .name = "ft", .module = mod_ft },
46
46
+
.{
47
47
+
.name = "sokol",
48
48
+
.module = dep_sokol.module("sokol"),
49
49
+
},
50
50
+
.{
51
51
+
.name = cimgui_conf.module_name,
52
52
+
.module = dep_cimgui.module(cimgui_conf.module_name),
53
53
+
},
31
54
// .{ .name = "shader", .module = try createShaderModule(b, dep_sokol) },
32
55
},
33
56
});
34
57
35
35
-
const opts = Options{ .mod = mod_exe, .dep_sokol = dep_sokol };
58
58
+
const options_mod_exe = b.addOptions();
59
59
+
options_mod_exe.addOption(bool, "docking", opt_docking);
60
60
+
mod_exe.addOptions("build_options", options_mod_exe);
61
61
+
62
62
+
const opts = Options{
63
63
+
.mod_ft = mod_ft,
64
64
+
.mod_exe = mod_exe,
65
65
+
.dep_sokol = dep_sokol,
66
66
+
.dep_cimgui = dep_cimgui,
67
67
+
.cimgui_clib_name = cimgui_conf.clib_name,
68
68
+
};
36
69
if (target.result.cpu.arch.isWasm()) {
37
70
try buildWeb(b, opts);
38
71
} else {
39
72
try buildNative(b, opts);
40
40
-
41
41
-
const mod_tests = b.addTest(.{
42
42
-
.name = "mod tests",
43
43
-
.root_module = mod,
44
44
-
});
45
45
-
const run_mod_tests = b.addRunArtifact(mod_tests);
46
46
-
47
47
-
const exe_tests = b.addTest(.{
48
48
-
.name = "exe tests",
49
49
-
.root_module = mod_exe,
50
50
-
});
51
51
-
const run_exe_tests = b.addRunArtifact(exe_tests);
52
52
-
53
53
-
const test_step = b.step("test", "Run tests");
54
54
-
test_step.dependOn(&run_mod_tests.step);
55
55
-
test_step.dependOn(&run_exe_tests.step);
56
73
}
57
74
}
58
75
59
76
fn buildNative(b: *Build, opts: Options) !void {
60
77
const exe = b.addExecutable(.{
61
78
.name = "factorio_toolbox",
62
62
-
.root_module = opts.mod,
79
79
+
.root_module = opts.mod_exe,
63
80
});
64
81
65
82
b.installArtifact(exe);
···
73
90
if (b.args) |args| {
74
91
run_cmd.addArgs(args);
75
92
}
93
93
+
94
94
+
const mod_tests = b.addTest(.{
95
95
+
.name = "mod tests",
96
96
+
.root_module = opts.mod_ft,
97
97
+
});
98
98
+
const run_mod_tests = b.addRunArtifact(mod_tests);
99
99
+
100
100
+
const exe_tests = b.addTest(.{
101
101
+
.name = "exe tests",
102
102
+
.root_module = opts.mod_exe,
103
103
+
});
104
104
+
const run_exe_tests = b.addRunArtifact(exe_tests);
105
105
+
106
106
+
const test_step = b.step("test", "Run tests");
107
107
+
test_step.dependOn(&run_mod_tests.step);
108
108
+
test_step.dependOn(&run_exe_tests.step);
76
109
}
77
110
78
111
fn buildWeb(b: *Build, opts: Options) !void {
79
112
const lib = b.addLibrary(.{
80
113
.name = "factorio_toolbox",
81
81
-
.root_module = opts.mod,
114
114
+
.root_module = opts.mod_exe,
82
115
});
83
116
84
117
const emsdk = opts.dep_sokol.builder.dependency("emsdk", .{});
118
118
+
119
119
+
const emsdk_incl_path = emsdk.path("upstream/emscripten/cache/sysroot/include");
120
120
+
opts.dep_cimgui.artifact(opts.cimgui_clib_name).addSystemIncludePath(emsdk_incl_path);
121
121
+
opts.dep_cimgui.artifact(opts.cimgui_clib_name).step.dependOn(&opts.dep_sokol.artifact("sokol_clib").step);
122
122
+
85
123
const link_step = try sokol.emLinkStep(b, .{
86
124
.lib_main = lib,
87
87
-
.target = opts.mod.resolved_target.?,
88
88
-
.optimize = opts.mod.optimize.?,
125
125
+
.target = opts.mod_exe.resolved_target.?,
126
126
+
.optimize = opts.mod_exe.optimize.?,
89
127
.emsdk = emsdk,
90
128
.use_webgl2 = true,
91
129
.use_emmalloc = true,
+4
build.zig.zon
reviewed
···
8
8
.url = "git+https://github.com/floooh/sokol-zig.git#76d4afd25adfae9666d76a0d324cdb70ad178a88",
9
9
.hash = "sokol-0.1.0-pb1HK3TYLgCx8lOxdLVWIVDcAzacxO8YDfyw2Er-_2nN",
10
10
},
11
11
+
.cimgui = .{
12
12
+
.url = "git+https://github.com/floooh/dcimgui.git#d5fb4e3d27b79062dc5981db3631dadc4f204654",
13
13
+
.hash = "cimgui-0.1.0-44Clkd6YlAAYULKHDwsDX9EPmka-VAVEjUl-o6ve307E",
14
14
+
},
11
15
},
12
16
.paths = .{
13
17
"build.zig",