diff --git a/build.zig b/build.zig index bb5ddb2..946e97e 100755 --- a/build.zig +++ b/build.zig @@ -221,7 +221,7 @@ pub fn emscriptenRunStep(b: *std.Build) !*std.Build.Step.Run { } //Creates the static library to build a project for Emscripten -fn compileForEmscripten(b: *std.Build, name: []const u8, root_source_file: []const u8, target: std.zig.CrossTarget, optimize: std.builtin.Mode) *std.Build.Step.Compile { +pub fn compileForEmscripten(b: *std.Build, name: []const u8, root_source_file: []const u8, target: std.zig.CrossTarget, optimize: std.builtin.Mode) *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, @@ -249,7 +249,7 @@ fn compileForEmscripten(b: *std.Build, name: []const u8, root_source_file: []con // TODO: test if shared libraries are accepted, I don't remember if emcc can link a shared library with a project or not // TODO: add a way to convert from an input path to the output path, if emscripten even allows such a thing. // TODO: add a parameter that allows a custom output directory -fn linkWithEmscripten(b: *std.Build, itemsToLink: []const *std.Build.Step.Compile, filesToInclude: []const std.Build.LazyPath) !*std.Build.Step.Run { +pub fn linkWithEmscripten(b: *std.Build, itemsToLink: []const *std.Build.Step.Compile, filesToInclude: []const std.Build.LazyPath) !*std.Build.Step.Run { //Raylib uses --sysroot in order to find emscripten, so do the same here if (b.sysroot == null) { @panic("Pass '--sysroot \"[path to emsdk installation]/upstream/emscripten\"'"); diff --git a/project_setup.sh b/project_setup.sh index 4b6f37d..7e921a4 100755 --- a/project_setup.sh +++ b/project_setup.sh @@ -19,17 +19,17 @@ pub fn build(b: *std.Build) !void { var raylib_math = rl.math.getModule(b, "raylib-zig"); //web exports are completely separate if (target.getOsTag() == .emscripten) { - const exe_lib = compileForEmscripten(b, '$PROJECT_NAME', "src/main.zig", target, optimize); + const exe_lib = rl.compileForEmscripten(b, "'$PROJECT_NAME'", "src/main.zig", target, optimize); exe_lib.addModule("raylib", raylib); exe_lib.addModule("raylib-math", raylib_math); const raylib_artifact = rl.getArtifact(b, target, optimize); - // Note that raylib itself isn't actually added to the exe_lib output file, so it also needs to be linked with emscripten. + // Note that raylib itself is not actually added to the exe_lib output file, so it also needs to be linked with emscripten. exe_lib.linkLibrary(raylib_artifact); - const link_step = try linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_artifact }, &[_]std.Build.LazyPath{.{ .path = "resources/" }}); + const link_step = try rl.linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_artifact }, &[_]std.Build.LazyPath{.{ .path = "resources/" }}); link_step.step.dependOn(&raylib_artifact.step); link_step.step.dependOn(&exe_lib.step); - b.getInstallStep.dependOn(&link_step.step); - const run_step = try emscriptenRunStep(b); + b.getInstallStep().dependOn(&link_step.step); + const run_step = try rl.emscriptenRunStep(b); run_step.step.dependOn(&link_step.step); const run_option = b.step("run", "Run '$PROJECT_NAME'"); run_option.dependOn(&run_step.step);