@@ -31,36 +31,29 @@ pub fn build(b: *std.Build) !void {
3131 .optimize = optimize ,
3232 }).module ("ziglua" );
3333
34- // const zmesh_pkg = zmesh.package(b, target, optimize, .{});
3534 const zstbi_pkg = zstbi .package (b , target , optimize , .{});
36- // const zaudio_pkg = zaudio.package(b, target, optimize, .{});
37-
3835 const zmesh = b .dependency ("zmesh" , .{});
3936 const zaudio = b .dependency ("zaudio" , .{});
4037
4138 const sokol_item = .{ .module = dep_sokol .module ("sokol" ), .name = "sokol" };
4239 const ziglua_item = .{ .module = ziglua_mod , .name = "ziglua" };
4340 const zmesh_item = .{ .module = zmesh .module ("root" ), .name = "zmesh" };
44- // const zmesh_options_item = .{ .module = zmesh_pkg.zmesh_options, .name = "zmesh_options" };
4541 const zstbi_item = .{ .module = zstbi_pkg .zstbi , .name = "zstbi" };
4642 const zaudio_item = .{ .module = zaudio .module ("root" ), .name = "zaudio" };
4743 const delve_module_imports = [_ ]ModuleImport {
4844 sokol_item ,
4945 ziglua_item ,
5046 zmesh_item ,
51- // zmesh_options_item,
5247 zstbi_item ,
5348 zaudio_item ,
5449 };
5550 const link_libraries = [_ ]* Build.Step.Compile {
56- // zmesh_pkg.zmesh_c_cpp,
5751 zmesh .artifact ("zmesh" ),
5852 zstbi_pkg .zstbi_c_cpp ,
5953 zaudio .artifact ("miniaudio" ),
60- // zaudio_pkg.zaudio_c_cpp,
6154 };
6255
63- var build_collection : BuildCollection = .{
56+ const build_collection : BuildCollection = .{
6457 .add_imports = & delve_module_imports ,
6558 .link_libraries = & link_libraries ,
6659 };
@@ -79,17 +72,15 @@ pub fn build(b: *std.Build) !void {
7972 delve_mod .linkLibrary (lib );
8073 }
8174
82- // create new list with delve included
83- const app_module_imports = [_ ]ModuleImport {
84- sokol_item ,
85- ziglua_item ,
86- zmesh_item ,
87- // zmesh_options_item,
88- zstbi_item ,
89- zaudio_item ,
90- .{ .module = delve_mod , .name = "delve" },
91- };
92- build_collection .add_imports = & app_module_imports ;
75+ // Delve Static Library artifact
76+ const delve_lib = b .addStaticLibrary (.{
77+ .target = target ,
78+ .optimize = optimize ,
79+ .name = "delve" ,
80+ .root_source_file = .{ .path = "src/framework/delve.zig" },
81+ });
82+
83+ b .installArtifact (delve_lib );
9384
9485 // collection of all examples
9586 const examples = [_ ][]const u8 {
@@ -112,8 +103,8 @@ pub fn build(b: *std.Build) !void {
112103 "stresstest" ,
113104 };
114105
115- inline for (examples ) | example_item | {
116- try buildExample (b , example_item , build_collection );
106+ for (examples ) | example_item | {
107+ try buildExample (b , example_item , delve_mod , delve_lib );
117108 }
118109
119110 // TESTS
@@ -127,9 +118,10 @@ pub fn build(b: *std.Build) !void {
127118 test_step .dependOn (& exe_tests .step );
128119}
129120
130- fn buildExample (b : * std.Build , comptime example : []const u8 , build_collection : BuildCollection ) ! void {
121+ fn buildExample (b : * std.Build , example : []const u8 , delve_module : * Build.Module , delve_lib : * Build.Step.Compile ) ! void {
131122 const name : []const u8 = example ;
132- const root_source_file : []const u8 = "src/examples/" ++ example ++ ".zig" ;
123+ var root_source_buffer = [_ ]u8 {undefined } ** 256 ;
124+ const root_source_file = try std .fmt .bufPrint (& root_source_buffer , "src/examples/{s}.zig" , .{name });
133125
134126 var app : * Build.Step.Compile = undefined ;
135127 // special case handling for native vs web build
@@ -149,14 +141,12 @@ fn buildExample(b: *std.Build, comptime example: []const u8, build_collection: B
149141 });
150142 }
151143
152- for (build_collection .add_imports ) | build_import | {
153- app .root_module .addImport (build_import .name , build_import .module );
154- }
155- for (build_collection .link_libraries ) | lib | {
156- app .linkLibrary (lib );
157- }
144+ app .root_module .addImport ("delve" , delve_module );
145+ app .linkLibrary (delve_lib );
158146
159147 if (target .result .isWasm ()) {
148+ // TODO: Still sorting out WASM builds
149+ //
160150 // create a build step which invokes the Emscripten linker
161151 // const emsdk = dep_sokol.builder.dependency("emsdk", .{});
162152 // const link_step = try sokol.emLinkStep(b, .{
@@ -169,10 +159,16 @@ fn buildExample(b: *std.Build, comptime example: []const u8, build_collection: B
169159 // .use_filesystem = false,
170160 // .shell_file_path = dep_sokol.path("3rdparty/sokol-zig/web/shell.html").getPath(b),
171161 // });
172- // // ...and a special run step to start the web build output via 'emrun'
173- // const run = sokol.emRunStep(b, .{ .name = example[0], .emsdk = emsdk });
162+ //
163+ // const dep_sokol = b.dependency("sokol", .{
164+ // .target = target,
165+ // .optimize = optimize,
166+ // });
167+ //
168+ // // // ...and a special run step to start the web build output via 'emrun'
169+ // const run = sokol.emRunStep(b, .{ .name = example, .emsdk = emsdk });
174170 // run.step.dependOn(&link_step.step);
175-
171+ //
176172 // var option_buffer = [_]u8{undefined} ** 100;
177173 // const run_name = try std.fmt.bufPrint(&option_buffer, "run-{s}", .{name});
178174 // var description_buffer = [_]u8{undefined} ** 200;
0 commit comments