make it heavy handed, but not THAT heavy handed...
All checks were successful
Generic zig build / build (push) Successful in 1m32s
All checks were successful
Generic zig build / build (push) Successful in 1m32s
This commit is contained in:
parent
1eea692a24
commit
0581221c11
|
@ -47,7 +47,7 @@ pub fn build(b: *std.Build) void {
|
|||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
const deploy_cmd = CloudflareDeployStep.create(b, "zigwasi", .{ .path = "index.js" }, .{});
|
||||
const deploy_cmd = CloudflareDeployStep.create(b, "zigwasi", .{ .path = "index.js" }, .{ .compile_target = exe });
|
||||
|
||||
// This creates a build step. It will be visible in the `zig build --help` menu,
|
||||
// and can be selected like this: `zig build run`
|
||||
|
@ -78,10 +78,6 @@ pub fn build(b: *std.Build) void {
|
|||
}
|
||||
|
||||
pub fn configureBuild(b: *std.Build, cs: *std.Build.Step.Compile, function_name: []const u8) !void {
|
||||
if (cs.rootModuleTarget().os.tag != .wasi) {
|
||||
std.log.err("Error: Cloudflare builds require compilation with -Dtarget=wasm32-wasi", .{});
|
||||
return error.WasiCompilationRequired;
|
||||
}
|
||||
const script = @embedFile("index.js");
|
||||
const wasm_name = try std.fmt.allocPrint(b.allocator, "{s}.wasm", .{cs.name});
|
||||
const deploy_cmd = CloudflareDeployStep.create(
|
||||
|
@ -95,6 +91,7 @@ pub fn configureBuild(b: *std.Build, cs: *std.Build.Step.Compile, function_name:
|
|||
.replace = wasm_name,
|
||||
},
|
||||
.wasm_dir = b.getInstallPath(.bin, "."),
|
||||
.compile_target = cs,
|
||||
},
|
||||
);
|
||||
deploy_cmd.step.dependOn(b.getInstallStep());
|
||||
|
|
|
@ -23,6 +23,9 @@ pub const Options = struct {
|
|||
|
||||
/// When set, the directory specified will be used rather than the current directory
|
||||
wasm_dir: ?[]const u8 = null,
|
||||
|
||||
/// Compilation target for this step
|
||||
compile_target: *std.Build.Step.Compile,
|
||||
};
|
||||
|
||||
pub fn create(
|
||||
|
@ -53,6 +56,11 @@ fn make(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
|
|||
const b = step.owner;
|
||||
const self = @as(*CloudflareDeployStep, @fieldParentPtr("step", step));
|
||||
|
||||
if (self.options.compile_target.rootModuleTarget().os.tag != .wasi) {
|
||||
std.log.err("Error: Cloudflare builds require compilation with -Dtarget=wasm32-wasi", .{});
|
||||
return error.WasiCompilationRequired;
|
||||
}
|
||||
|
||||
var client = std.http.Client{ .allocator = b.allocator };
|
||||
try client.initDefaultProxies(b.allocator);
|
||||
defer client.deinit();
|
||||
|
|
Loading…
Reference in New Issue
Block a user