@@ -119,13 +119,18 @@ pub fn updateCectechStep(
119119pub 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+
149217pub 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+
639735pub 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 ;
0 commit comments