forked from Mirrors/wasm3
Add minimal build.zig build script (#247)
* Add minimal build.zig build script The minimal `build.zig` script effectively can act as a (nicer?) alternative to CMake; however, it is minimal in the sense, it currently only includes the necessary ingredients to build `wasm3` with Zig as the build system. As an added bonus though, you get the full cross-compilation power of Zig for free. Example invocation to build for the host: ``` zig build ``` To target `wasm32-wasi`: ``` zig build -Dtarget=wasm32-wasi ``` To target `aarch64-macos` from *anywhere*: ``` zig build -Dtarget=aarch64-macos ``` * Include Zig in build instructionsopam-2.0.0
parent
cad20bb192
commit
70706ffb5b
@ -0,0 +1,42 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.build.Builder) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const wasm3 = b.addExecutable("wasm3", null);
|
||||
wasm3.setTarget(target);
|
||||
wasm3.setBuildMode(mode);
|
||||
wasm3.install();
|
||||
wasm3.linkLibC();
|
||||
|
||||
if (target.getCpuArch() == .wasm32 and target.getOsTag() == .wasi) {
|
||||
wasm3.linkSystemLibrary("wasi-emulated-process-clocks");
|
||||
}
|
||||
|
||||
wasm3.addIncludeDir("source");
|
||||
wasm3.addCSourceFiles(&.{
|
||||
"source/m3_api_libc.c",
|
||||
"source/m3_api_meta_wasi.c",
|
||||
"source/m3_api_tracer.c",
|
||||
"source/m3_api_uvwasi.c",
|
||||
"source/m3_api_wasi.c",
|
||||
"source/m3_bind.c",
|
||||
"source/m3_code.c",
|
||||
"source/m3_compile.c",
|
||||
"source/m3_core.c",
|
||||
"source/m3_emit.c",
|
||||
"source/m3_env.c",
|
||||
"source/m3_exec.c",
|
||||
"source/m3_function.c",
|
||||
"source/m3_info.c",
|
||||
"source/m3_module.c",
|
||||
"source/m3_optimize.c",
|
||||
"source/m3_parse.c",
|
||||
"source/extensions/m3_extensions.c",
|
||||
"platforms/app/main.c",
|
||||
}, &.{
|
||||
"-Dd_m3HasWASI",
|
||||
"-fno-sanitize=undefined", // TODO investigate UB sites in the codebase, then delete this line.
|
||||
});
|
||||
}
|
Loading…
Reference in new issue