@@ -119,13 +119,16 @@ 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+ ) ! * std.Build.Step.Compile {
129132 const exe = b .addExecutable (.{
130133 .name = bin_name ,
131134 .version = versionn ,
@@ -141,11 +144,63 @@ pub fn createKernelExe(
141144 exe .linkLibrary (cetech1_kernel_lib );
142145 b .installArtifact (exe );
143146 useSystemSDK (b , target , exe );
144- createRunStep (b , exe , "run" , "Run Forest run" );
145-
147+ createRunStep (b , exe , run_name , run_description );
148+ try linkStaticModules ( b , exe , target , optimize , static_modules );
146149 return exe ;
147150}
148151
152+ pub fn createEditorExe (
153+ b : * std.Build ,
154+ comptime base_bin_name : []const u8 ,
155+ root_source : std.Build.LazyPath ,
156+ cetech1_kernel : * std.Build.Module ,
157+ cetech1_kernel_lib : * std.Build.Step.Compile ,
158+ versionn : std.SemanticVersion ,
159+ static_modules : []const []const u8 ,
160+ target : std.Build.ResolvedTarget ,
161+ optimize : std.builtin.OptimizeMode ,
162+ ) ! * std.Build.Step.Compile {
163+ return try createKernelExe (
164+ b ,
165+ base_bin_name ++ "_editor" ,
166+ "editor" ,
167+ "Run editor" ,
168+ root_source ,
169+ cetech1_kernel ,
170+ cetech1_kernel_lib ,
171+ versionn ,
172+ static_modules ,
173+ target ,
174+ optimize ,
175+ );
176+ }
177+
178+ pub fn createRunnerExe (
179+ b : * std.Build ,
180+ comptime base_bin_name : []const u8 ,
181+ root_source : std.Build.LazyPath ,
182+ cetech1_kernel : * std.Build.Module ,
183+ cetech1_kernel_lib : * std.Build.Step.Compile ,
184+ versionn : std.SemanticVersion ,
185+ static_modules : []const []const u8 ,
186+ target : std.Build.ResolvedTarget ,
187+ optimize : std.builtin.OptimizeMode ,
188+ ) ! * std.Build.Step.Compile {
189+ return try createKernelExe (
190+ b ,
191+ base_bin_name ,
192+ "run" ,
193+ "Run Forest Run!" ,
194+ root_source ,
195+ cetech1_kernel ,
196+ cetech1_kernel_lib ,
197+ versionn ,
198+ static_modules ,
199+ target ,
200+ optimize ,
201+ );
202+ }
203+
149204pub fn build (b : * std.Build ) ! void {
150205 try ensureZigVersion ();
151206
@@ -317,6 +372,10 @@ pub fn build(b: *std.Build) !void {
317372
318373 // Modules
319374 const ModulesSet = std .StringArrayHashMapUnmanaged (void );
375+
376+ var internal_modules = std .ArrayListUnmanaged ([]const u8 ){};
377+ defer internal_modules .deinit (b .allocator );
378+
320379 var module_set = ModulesSet {};
321380 defer module_set .deinit (b .allocator );
322381 for (all_modules ) | module | {
@@ -403,7 +462,7 @@ pub fn build(b: *std.Build) !void {
403462 gen_ide .addArgs (&.{ "--ide" , @tagName (options .ide ) });
404463
405464 gen_ide .addArg ("--bin-path" );
406- gen_ide .addDirectoryArg (b .path ("zig-out/bin/cetech1 " ));
465+ gen_ide .addDirectoryArg (b .path ("zig-out/bin/cetech1_editor " ));
407466
408467 gen_ide .addArg ("--project-path" );
409468 gen_ide .addDirectoryArg (b .path ("" ));
@@ -446,6 +505,9 @@ pub fn build(b: *std.Build) !void {
446505 var buff : [256 :0 ]u8 = undefined ;
447506 for (dynamic_modules .keys ()) | m | {
448507 const artifact_name = try std .fmt .bufPrintZ (& buff , "ct_{s}" , .{m });
508+
509+ if (! module_set .contains (m )) continue ;
510+
449511 const art = b .lazyDependency (m , .{
450512 .target = target ,
451513 .optimize = optimize ,
@@ -526,21 +588,36 @@ pub fn build(b: *std.Build) !void {
526588 });
527589
528590 //
529- // CETech1 kernel standalone exe
591+ // CETech1 editor standalone exe
592+ //
593+ const editor_exe = try createEditorExe (
594+ b ,
595+ "cetech1" ,
596+ b .path ("src/editor/editor.zig" ),
597+ kernel_module ,
598+ kernel_lib ,
599+ cetech1_version ,
600+ static_modules .keys (),
601+ target ,
602+ optimize ,
603+ );
604+ editor_exe .step .dependOn (& generated_files .step );
605+
606+ //
607+ // CETech1 runner standalone exe
530608 //
531- const exe = createKernelExe (
609+ const runner_exe = try createRunnerExe (
532610 b ,
533611 "cetech1" ,
534- b .path ("src/main .zig" ),
612+ b .path ("src/runner/runner .zig" ),
535613 kernel_module ,
536614 kernel_lib ,
537615 cetech1_version ,
616+ static_modules .keys (),
538617 target ,
539618 optimize ,
540619 );
541- try linkStaticModules (b , exe , target , optimize , static_modules .keys ());
542- // Make exe depends on generated files.
543- exe .step .dependOn (& generated_files .step );
620+ runner_exe .step .dependOn (& generated_files .step );
544621
545622 //
546623 // CETech1 kernel standalone tests
@@ -557,17 +634,17 @@ pub fn build(b: *std.Build) !void {
557634 });
558635 useSystemSDK (b , target , tests );
559636 b .installArtifact (tests );
637+ try linkStaticModules (b , tests , target , optimize , static_modules .keys ());
560638 tests .linkLibC ();
561639 tests .linkLibrary (kernel_lib );
562640 tests .step .dependOn (& generated_files .step );
563- try linkStaticModules (b , tests , target , optimize , static_modules .keys ());
564641
565642 const run_unit_tests = b .addRunArtifact (tests );
566643 run_unit_tests .step .dependOn (b .getInstallStep ());
567644 const test_step = b .step ("test" , "Run unit tests" );
568645 test_step .dependOn (& run_unit_tests .step );
569646
570- const run_tests_ui = b .addRunArtifact (exe );
647+ const run_tests_ui = b .addRunArtifact (editor_exe );
571648 run_tests_ui .addArgs (&.{ "--test-ui" , "--headless" });
572649 run_tests_ui .step .dependOn (b .getInstallStep ());
573650 const testui_step = b .step ("test-ui" , "Run UI headless test" );
0 commit comments