chore: update run step
This commit is contained in:
parent
ca64dae639
commit
ff3260ab6d
2 changed files with 24 additions and 16 deletions
|
|
@ -20,14 +20,13 @@ pub fn build(b: *std.Build) !void {
|
|||
mod.addImport("temporal_rs", temporal.module("temporal_rs"));
|
||||
|
||||
// --- Zig Executable: temporalz --- //
|
||||
const exe_root = if (is_wasm_freestanding)
|
||||
b.path("example/src/wasm.zig")
|
||||
else
|
||||
b.path("example/src/main.zig");
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "temporalz",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = exe_root,
|
||||
.root_source_file = if (is_wasm_freestanding)
|
||||
b.path("example/src/wasm.zig")
|
||||
else
|
||||
b.path("example/src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.imports = &.{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const std = @import("std");
|
|||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const is_wasm = target.result.cpu.arch.isWasm();
|
||||
const is_wasm_freestanding = target.result.cpu.arch.isWasm() and target.result.os.tag == .freestanding;
|
||||
|
||||
const temporalz = b.dependency("temporalz", .{
|
||||
.target = target,
|
||||
|
|
@ -12,7 +12,7 @@ pub fn build(b: *std.Build) void {
|
|||
const exe = b.addExecutable(.{
|
||||
.name = "temporalz",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path(if (is_wasm) "src/wasm.zig" else "src/main.zig"),
|
||||
.root_source_file = b.path(if (is_wasm_freestanding) "src/wasm.zig" else "src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.imports = &.{},
|
||||
|
|
@ -22,14 +22,23 @@ pub fn build(b: *std.Build) void {
|
|||
b.installArtifact(exe);
|
||||
|
||||
const run_step = b.step("run", "Run the app");
|
||||
if (is_wasm) {
|
||||
switch (target.result.os.tag) {
|
||||
.freestanding => {
|
||||
const run_cmd = b.addSystemCommand(&.{ "node", "src/main.mjs" });
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
} else {
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
},
|
||||
.wasi => {
|
||||
const run_cmd = b.addSystemCommand(&.{"wasmtime"});
|
||||
run_cmd.addFileArg(exe.getEmittedBin());
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
},
|
||||
else => {
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
if (b.args) |args| run_cmd.addArgs(args);
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue