build: Add "zig build examples" command to build all examples
This commit is contained in:
@@ -10,6 +10,8 @@ pub fn build(b: *std.Build) void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const examples_step = b.step("examples", "Build all examples");
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "example",
|
||||
.root_module = b.createModule(.{
|
||||
@@ -19,7 +21,8 @@ pub fn build(b: *std.Build) void {
|
||||
}),
|
||||
});
|
||||
exe.root_module.addImport("zigmulator", zigmulator);
|
||||
b.installArtifact(exe);
|
||||
const install_exe = b.addInstallArtifact(exe, .{});
|
||||
examples_step.dependOn(&install_exe.step);
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
if (b.args) |args| {
|
||||
@@ -28,4 +31,16 @@ pub fn build(b: *std.Build) void {
|
||||
|
||||
const run_step = b.step("run", "Run the example");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
const open_file_exe = b.addExecutable(.{
|
||||
.name = "open_file",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("examples/open_file.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
}),
|
||||
});
|
||||
open_file_exe.root_module.addImport("zigmulator", zigmulator);
|
||||
const install_open_file_exe = b.addInstallArtifact(open_file_exe, .{});
|
||||
examples_step.dependOn(&install_open_file_exe.step);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user