Automatically include Emscripten headers (#173)
* add emscripten headers * update func to return error
This commit is contained in:
parent
606d9bb9ba
commit
de8c2d4585
4 changed files with 10 additions and 5 deletions
9
emcc.zig
9
emcc.zig
|
|
@ -39,19 +39,24 @@ pub fn compileForEmscripten(
|
|||
root_source_file: []const u8,
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.Mode,
|
||||
) *std.Build.Step.Compile {
|
||||
) !*std.Build.Step.Compile {
|
||||
// TODO: It might be a good idea to create a custom compile step, that does
|
||||
// both the compile to static library and the link with emcc by overidding
|
||||
// the make function of the step. However it might also be a bad idea since
|
||||
// it messes with the build system itself.
|
||||
|
||||
// The project is built as a library and linked later.
|
||||
return b.addStaticLibrary(.{
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = name,
|
||||
.root_source_file = b.path(root_source_file),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const emscripten_headers = try std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" });
|
||||
defer b.allocator.free(emscripten_headers);
|
||||
lib.addIncludePath(.{ .cwd_relative = emscripten_headers });
|
||||
return lib;
|
||||
}
|
||||
|
||||
// Links a set of items together using emscripten.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue