Skip to content

Commit b123f41

Browse files
committed
WIP: Editor & Runner
1 parent e70146c commit b123f41

File tree

120 files changed

+2960
-1252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+2960
-1252
lines changed

.generate_ide.zon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
.{
22
.launchers = .{
3+
.{ .name = "CETech1 unit tests", .program = .{ .path = "zig-out/bin/cetech1_test" }, .args = .{} },
34
.{ .name = "CETech1 no asset root", .args = .{} },
45
.{ .name = "CETech1 max 5 tick", .args = .{ "--max-kernel-tick", "5", "--asset-root", "fixtures/test_asset/" } },
56
.{ .name = "CETech1 --headless", .args = .{ "--max-kernel-tick", "5", "--asset-root", "fixtures/test_asset/", "--headless" } },
6-
.{ .name = "CETech1 Tests", .program = "zig-out/bin/cetech1_test", .args = .{} },
77
.{ .name = "CETech1 Tests UI", .args = .{"--test-ui"} },
88
.{ .name = "CETech1 Tests UI (headless)", .args = .{ "--test-ui", "--headless", "--test-ui-junit", "./result.xml" } },
99
.{ .name = "CETech1 (Vulkan)", .args = .{ "--asset-root", "fixtures/test_asset/", "--renderer", "bgfx_vulkan" } },
10+
.{ .name = "CETech1 runner world", .program = .runner, .args = .{ "--asset-root", "fixtures/test_graph/", "--simulate", "0198d6b0-9580-74d8-b06f-e4df9723720a", "--simulate-ui" } },
11+
.{ .name = "CETech1 runner explode", .program = .runner, .args = .{ "--asset-root", "fixtures/test_graph/", "--simulate", "0191e6d1-830a-73d8-992a-aa6f9add6d1e", "--simulate-explode", "100", "--simulate-ui" } },
1012
},
1113
}

.github/workflows/test.yaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ jobs:
9898
# uses: pyvista/setup-headless-display-action@v2
9999

100100
- name: Test headless standalone
101-
run: zig-out/bin/cetech1 --headless --max-kernel-tick 5
101+
run: zig-out/bin/cetech1_editor --headless --max-kernel-tick 5
102102

103103
- name: Test headless standalone with asset root
104-
run: zig-out/bin/cetech1 --headless --max-kernel-tick 5 --asset-root fixtures/test_asset/
104+
run: zig-out/bin/cetech1_editor --headless --max-kernel-tick 5 --asset-root fixtures/test_asset/
105105

106106
- name: Test UI headless
107-
run: zig-out/bin/cetech1 --headless --test-ui --test-ui-junit ./result.xml
107+
run: zig-out/bin/cetech1_editor --headless --test-ui --test-ui-junit ./result.xml
108108

109109
- name: Publish Test Report
110110
uses: mikepenz/action-junit-report@v4
@@ -150,13 +150,13 @@ jobs:
150150
#run: kcov --include-pattern=/cetech1/src/,/cetech/public/ kcov-output zig-out/bin/cetech1_test
151151

152152
- name: Test headless standalone
153-
run: zig-out/bin/cetech1 --headless --max-kernel-tick 5
153+
run: zig-out/bin/cetech1_editor --headless --max-kernel-tick 5
154154

155155
- name: Test headless standalone with asset root
156-
run: zig-out/bin/cetech1 --headless --max-kernel-tick 5 --asset-root fixtures/test_asset/
156+
run: zig-out/bin/cetech1_editor --headless --max-kernel-tick 5 --asset-root fixtures/test_asset/
157157

158158
- name: Test UI headless
159-
run: zig-out/bin/cetech1 --headless --test-ui --test-ui-junit ./result.xml
159+
run: zig-out/bin/cetech1_editor --headless --test-ui --test-ui-junit ./result.xml
160160

161161
- name: Publish Test Report
162162
uses: mikepenz/action-junit-report@v4
@@ -204,17 +204,15 @@ jobs:
204204
run: zig-out/bin/cetech1_test
205205

206206
# FIXME: Windows
207-
- name: Test headless standalone
208-
shell: bash
209-
run: zig-out/bin/cetech1 --headless --max-kernel-tick 5
210-
211-
- name: Test headless standalone with asset root
212-
shell: bash
213-
run: zig-out/bin/cetech1 --headless --max-kernel-tick 5 --asset-root fixtures/test_asset/
214-
215-
- name: Test UI headless
216-
shell: bash
217-
run: zig-out/bin/cetech1 --headless --test-ui --test-ui-junit ./result.xml
207+
# - name: Test headless standalone
208+
# shell: bash
209+
# run: zig-out/bin/cetech1_editor --headless --max-kernel-tick 5
210+
# - name: Test headless standalone with asset root
211+
# shell: bash
212+
# run: zig-out/bin/cetech1_editor --headless --max-kernel-tick 5 --asset-root fixtures/test_asset/
213+
# - name: Test UI headless
214+
# shell: bash
215+
# run: zig-out/bin/cetech1_editor --headless --test-ui --test-ui-junit ./result.xml
218216

219217
- name: Publish Test Report
220218
uses: mikepenz/action-junit-report@v4

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ _static.zig
3737
.vscode/launch.json
3838
.vscode/settings.json
3939

40-
# Fleet
41-
.fleet/settings.json
42-
.fleet/run.json
43-
4440
# Idea
4541
.idea/
4642
Zig.iml

build.zig

Lines changed: 106 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,18 @@ pub fn updateCectechStep(
119119
pub fn createKernelExe(
120120
b: *std.Build,
121121
comptime bin_name: []const u8,
122+
comptime run_name: []const u8,
123+
comptime run_description: []const u8,
122124
runner_main: std.Build.LazyPath,
123125
cetech1_kernel: *std.Build.Module,
124126
cetech1_kernel_lib: *std.Build.Step.Compile,
125127
versionn: std.SemanticVersion,
128+
static_modules: []const []const u8,
126129
target: std.Build.ResolvedTarget,
127130
optimize: std.builtin.OptimizeMode,
128-
) *std.Build.Step.Compile {
131+
ignored_modules: ?[]const []const u8,
132+
ignored_modules_prefix: ?[]const []const u8,
133+
) !*std.Build.Step.Compile {
129134
const exe = b.addExecutable(.{
130135
.name = bin_name,
131136
.version = versionn,
@@ -141,11 +146,74 @@ pub fn createKernelExe(
141146
exe.linkLibrary(cetech1_kernel_lib);
142147
b.installArtifact(exe);
143148
useSystemSDK(b, target, exe);
144-
createRunStep(b, exe, "run", "Run Forest run");
149+
createRunStep(b, exe, run_name, run_description);
150+
try linkStaticModules(b, exe, target, optimize, static_modules);
151+
152+
const options_step = b.addOptions();
153+
options_step.addOption(?[]const []const u8, "ignored_modules", ignored_modules);
154+
options_step.addOption(?[]const []const u8, "ignored_modules_prefix", ignored_modules_prefix);
155+
const options_module = options_step.createModule();
145156

157+
exe.root_module.addImport("kernel_options", options_module);
146158
return exe;
147159
}
148160

161+
pub fn createEditorExe(
162+
b: *std.Build,
163+
comptime base_bin_name: []const u8,
164+
root_source: std.Build.LazyPath,
165+
cetech1_kernel: *std.Build.Module,
166+
cetech1_kernel_lib: *std.Build.Step.Compile,
167+
versionn: std.SemanticVersion,
168+
static_modules: []const []const u8,
169+
target: std.Build.ResolvedTarget,
170+
optimize: std.builtin.OptimizeMode,
171+
) !*std.Build.Step.Compile {
172+
return try createKernelExe(
173+
b,
174+
base_bin_name ++ "_editor",
175+
"editor",
176+
"Run editor",
177+
root_source,
178+
cetech1_kernel,
179+
cetech1_kernel_lib,
180+
versionn,
181+
static_modules,
182+
target,
183+
optimize,
184+
&.{"runner"},
185+
&.{"runner_"},
186+
);
187+
}
188+
189+
pub fn createRunnerExe(
190+
b: *std.Build,
191+
comptime base_bin_name: []const u8,
192+
root_source: std.Build.LazyPath,
193+
cetech1_kernel: *std.Build.Module,
194+
cetech1_kernel_lib: *std.Build.Step.Compile,
195+
versionn: std.SemanticVersion,
196+
static_modules: []const []const u8,
197+
target: std.Build.ResolvedTarget,
198+
optimize: std.builtin.OptimizeMode,
199+
) !*std.Build.Step.Compile {
200+
return try createKernelExe(
201+
b,
202+
base_bin_name,
203+
"run",
204+
"Run Forest Run!",
205+
root_source,
206+
cetech1_kernel,
207+
cetech1_kernel_lib,
208+
versionn,
209+
static_modules,
210+
target,
211+
optimize,
212+
&.{"editor"},
213+
&.{"editor_"},
214+
);
215+
}
216+
149217
pub fn build(b: *std.Build) !void {
150218
try ensureZigVersion();
151219

@@ -159,6 +227,7 @@ pub fn build(b: *std.Build) !void {
159227
// Modules
160228
.enable_samples = b.option(bool, "with_samples", "build with sample modules.") orelse true,
161229
.enable_editor = b.option(bool, "with_editor", "build with editor modules.") orelse true,
230+
.enable_runner = b.option(bool, "with_runner", "build with editor modules.") orelse true,
162231

163232
.modules = b.option([]const []const u8, "with_module", "build with this modules."),
164233
.static_modules = b.option(bool, "static_modules", "build all modules in static mode.") orelse false,
@@ -317,6 +386,10 @@ pub fn build(b: *std.Build) !void {
317386

318387
// Modules
319388
const ModulesSet = std.StringArrayHashMapUnmanaged(void);
389+
390+
var internal_modules = std.ArrayListUnmanaged([]const u8){};
391+
defer internal_modules.deinit(b.allocator);
392+
320393
var module_set = ModulesSet{};
321394
defer module_set.deinit(b.allocator);
322395
for (all_modules) |module| {
@@ -333,6 +406,7 @@ pub fn build(b: *std.Build) !void {
333406

334407
if (options.enable_samples) try enabled_modules.appendSlice(b.allocator, &samples_modules);
335408
if (options.enable_editor) try enabled_modules.appendSlice(b.allocator, &editor_modules);
409+
if (options.enable_runner) try enabled_modules.appendSlice(b.allocator, &runner_modules);
336410
}
337411

338412
// Static modules.
@@ -446,6 +520,9 @@ pub fn build(b: *std.Build) !void {
446520
var buff: [256:0]u8 = undefined;
447521
for (dynamic_modules.keys()) |m| {
448522
const artifact_name = try std.fmt.bufPrintZ(&buff, "ct_{s}", .{m});
523+
524+
if (!module_set.contains(m)) continue;
525+
449526
const art = b.lazyDependency(m, .{
450527
.target = target,
451528
.optimize = optimize,
@@ -526,21 +603,36 @@ pub fn build(b: *std.Build) !void {
526603
});
527604

528605
//
529-
// CETech1 kernel standalone exe
606+
// CETech1 editor standalone exe
530607
//
531-
const exe = createKernelExe(
608+
const editor_exe = try createEditorExe(
532609
b,
533610
"cetech1",
534611
b.path("src/main.zig"),
535612
kernel_module,
536613
kernel_lib,
537614
cetech1_version,
615+
static_modules.keys(),
538616
target,
539617
optimize,
540618
);
541-
try linkStaticModules(b, exe, target, optimize, static_modules.keys());
542-
// Make exe depends on generated files.
543-
exe.step.dependOn(&generated_files.step);
619+
editor_exe.step.dependOn(&generated_files.step);
620+
621+
//
622+
// CETech1 runner standalone exe
623+
//
624+
const runner_exe = try createRunnerExe(
625+
b,
626+
"cetech1",
627+
b.path("src/main.zig"),
628+
kernel_module,
629+
kernel_lib,
630+
cetech1_version,
631+
static_modules.keys(),
632+
target,
633+
optimize,
634+
);
635+
runner_exe.step.dependOn(&generated_files.step);
544636

545637
//
546638
// CETech1 kernel standalone tests
@@ -557,17 +649,17 @@ pub fn build(b: *std.Build) !void {
557649
});
558650
useSystemSDK(b, target, tests);
559651
b.installArtifact(tests);
652+
try linkStaticModules(b, tests, target, optimize, static_modules.keys());
560653
tests.linkLibC();
561654
tests.linkLibrary(kernel_lib);
562655
tests.step.dependOn(&generated_files.step);
563-
try linkStaticModules(b, tests, target, optimize, static_modules.keys());
564656

565657
const run_unit_tests = b.addRunArtifact(tests);
566658
run_unit_tests.step.dependOn(b.getInstallStep());
567659
const test_step = b.step("test", "Run unit tests");
568660
test_step.dependOn(&run_unit_tests.step);
569661

570-
const run_tests_ui = b.addRunArtifact(exe);
662+
const run_tests_ui = b.addRunArtifact(editor_exe);
571663
run_tests_ui.addArgs(&.{ "--test-ui", "--headless" });
572664
run_tests_ui.step.dependOn(b.getInstallStep());
573665
const testui_step = b.step("test-ui", "Run UI headless test");
@@ -636,6 +728,10 @@ pub const editor_modules = [_][]const u8{
636728
"editor_renderer",
637729
};
638730

731+
pub const runner_modules = [_][]const u8{
732+
"runner",
733+
};
734+
639735
pub const core_modules = [_][]const u8{
640736
"gpu_bgfx",
641737
"graphvm",
@@ -668,4 +764,4 @@ pub const samples_modules = [_][]const u8{
668764
"editor_foo_viewport_tab",
669765
};
670766

671-
pub const all_modules = editor_modules ++ core_modules ++ samples_modules;
767+
pub const all_modules = editor_modules ++ runner_modules ++ core_modules ++ samples_modules;

build.zig.zon

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
.dependencies = .{
2222
//
23-
// Public cetech1 API
23+
// Public API for modules
2424
//
2525
.cetech1 = .{ .path = "public/" },
2626

@@ -47,6 +47,9 @@
4747
.editor_simulation = .{ .path = "modules/editor/simulation", .lazy = true },
4848
.editor_renderer = .{ .path = "modules/editor/renderer", .lazy = true },
4949

50+
// RUNNER
51+
.runner = .{ .path = "modules/runner/runner", .lazy = true },
52+
5053
// PHYSICS
5154
.physics = .{ .path = "modules/physics/physics", .lazy = true },
5255

@@ -66,12 +69,16 @@
6669
.vertex_system = .{ .path = "modules/rendering/vertex_system", .lazy = true },
6770
.instance_system = .{ .path = "modules/rendering/instance_system", .lazy = true },
6871
.renderer_nodes = .{ .path = "modules/rendering/renderer_nodes", .lazy = true },
69-
.renderer = .{ .path = "modules/rendering/renderer", .lazy = true },
7072
.visibility_flags = .{ .path = "modules/rendering/visibility_flags", .lazy = true },
7173
.light_component = .{ .path = "modules/rendering/light_component", .lazy = true },
7274
.light_system = .{ .path = "modules/rendering/light_system", .lazy = true },
7375
.gpu_bgfx = .{ .path = "modules/rendering/gpu_bgfx", .lazy = true },
7476

77+
// Examples
78+
.foo = .{ .path = "modules/examples/foo", .lazy = true },
79+
.editor_foo_tab = .{ .path = "modules/examples/editor_foo_tab", .lazy = true },
80+
.editor_foo_viewport_tab = .{ .path = "modules/examples/editor_foo_viewport_tab", .lazy = true },
81+
7582
//
7683
// Externals
7784
//
@@ -90,12 +97,5 @@
9097
.zflecs = .{ .path = "externals/shared/lib/zflecs" },
9198
.ztracy = .{ .path = "externals/shared/lib/ztracy" },
9299
.zgui = .{ .path = "externals/shared/lib/zgui" },
93-
94-
//
95-
// CETech1 examples
96-
//
97-
.foo = .{ .path = "examples/foo", .lazy = true },
98-
.editor_foo_tab = .{ .path = "examples/editor_foo_tab", .lazy = true },
99-
.editor_foo_viewport_tab = .{ .path = "examples/editor_foo_viewport_tab", .lazy = true },
100100
},
101101
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
zig-out/bin/cetech1_test && zig-out/bin/cetech1 --asset-root fixtures/test_asset/
1+
zig-out/bin/cetech1_test && zig-out/bin/cetech1_editor --asset-root fixtures/test_asset/
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Desktop mode
2-
zig-out/bin/cetech1_test && zig-out/bin/cetech1 --asset-root fixtures/test_asset/
2+
zig-out/bin/cetech1_test && zig-out/bin/cetech1_editor --asset-root fixtures/test_asset/
33

44
# Standalone
5-
zig-out/bin/cetech1 --fullscreen --asset-root fixtures/test_asset/
5+
zig-out/bin/cetech1_editor --fullscreen --asset-root fixtures/test_asset/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
zig-out/bin/cetech1_test.exe && zig-out/bin/cetech1.exe --asset-root fixtures/test_asset/
1+
zig-out/bin/cetech1_test.exe && zig-out/bin/cetech1_editor.exe --asset-root fixtures/test_asset/

0 commit comments

Comments
 (0)