Skip to content

Commit

Permalink
build(examples): minor update Zig build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jul 11, 2023
1 parent 3bae658 commit e0fe047
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
35 changes: 32 additions & 3 deletions examples/zig-canvas/build.zig
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
// IMPORTANT: This build file is more complicated than needed due to being part of this monorepo
// IMPORTANT: Due to being part of this monorepo, this version of the build file is
// slighty more complicated than needed...
//
// Please consult the thi.ng/wasm-api README for details!
// Outside the umbrella monorepo, the import path for that file will be (usually):
// node_modules/@thi.ng/wasm-api/zig/build.zig
b.installArtifact(@import("wasm-api-build.zig").wasmLib(b, .{
const lib = @import("wasm-api-build.zig").wasmLib(b, .{
// Only needed for this monorepo!!
.base = "../../node_modules",
// Declare extra WASM API module to use
Expand All @@ -14,5 +16,32 @@ pub fn build(b: *std.Build) void {
},
// build mode override
.optimize = .ReleaseSmall,
}));
});

b.installArtifact(lib);

// Alternatively, instead of calling WASM post-processing steps separately,
// invoke them here instead (the above line needs to be removed then)...

// const install = b.addInstallArtifact(lib);
// install.step.dependOn(&lib.step);

// const optimize = b.addSystemCommand(&.{
// "wasm-opt",
// "-o",
// "foo/opt.wasm",
// "-O3",
// });
// optimize.addFileSourceArg(lib.getOutputSource());
// optimize.step.dependOn(&install.step);

// const disasm = b.addSystemCommand(&.{
// "wasm-dis",
// "-o",
// "foo/opt.wast",
// "foo/opt.wasm",
// });
// disasm.step.dependOn(&optimize.step);

// b.getInstallStep().dependOn(&disasm.step);
}
4 changes: 3 additions & 1 deletion examples/zig-cellular/build.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
// IMPORTANT: This build file is more complicated than needed due to being part of this monorepo
// IMPORTANT: Due to being part of this monorepo, this version of the build file is
// slighty more complicated than needed...
//
// Please consult the thi.ng/wasm-api README for details!
// Outside the umbrella monorepo, the import path for that file will be (usually):
// node_modules/@thi.ng/wasm-api/zig/build.zig
Expand Down
4 changes: 3 additions & 1 deletion examples/zig-counter/build.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
// IMPORTANT: This build file is more complicated than needed due to being part of this monorepo
// IMPORTANT: Due to being part of this monorepo, this version of the build file is
// slighty more complicated than needed...
//
// Please consult the thi.ng/wasm-api README for details!
// Outside the umbrella monorepo, the import path for that file will be (usually):
// node_modules/@thi.ng/wasm-api/zig/build.zig
Expand Down
4 changes: 3 additions & 1 deletion examples/zig-todo-list/build.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
// IMPORTANT: This build file is more complicated than needed due to being part of this monorepo
// IMPORTANT: Due to being part of this monorepo, this version of the build file is
// slighty more complicated than needed...
//
// Please consult the thi.ng/wasm-api README for details!
// Outside the umbrella monorepo, the import path for that file will be (usually):
// node_modules/@thi.ng/wasm-api/zig/build.zig
Expand Down

0 comments on commit e0fe047

Please sign in to comment.