Skip to content

Instantly share code, notes, and snippets.

View meheleventyone's full-sized avatar

Charles Palmer meheleventyone

View GitHub Profile
interface Value<T> {
kind: "value";
value: T;
}
interface Error<T> {
kind: "error";
error: T;
}
export type Result<T, E> = Value<T> | Error<E>;
export type Optional<T> = T | undefined;
const Builder = @import("std").build.Builder;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("main", "src/main.zig");
exe.setBuildMode(mode);
exe.setTarget(.wasm32, .freestanding, .none);
b.default_step.dependOn(&exe.step);
}
@meheleventyone
meheleventyone / build.zig
Created November 20, 2018 20:48
Build a Zig lib to WASM.
const Builder = @import("std").build.Builder;
const builtin = @import("builtin");
const wasmLink : []const []const u8 = []const []const u8 {"wasm-ld", "./zig-cache/wasmtest.o", "-o", "./zig-cache/wasmtest.wasm", "-O2", "--no-entry", "--allow-undefined"};
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const obj = b.addObject("wasmtest", "src/main.zig");
obj.setBuildMode(mode);
obj.setTarget(builtin.Arch.wasm32, builtin.Os.freestanding, builtin.Environ.unknown);