Merge f1dc83603c into 71643d8cda
This commit is contained in:
commit
25b517e6c8
2 changed files with 18 additions and 18 deletions
30
build.zig
30
build.zig
|
|
@ -63,21 +63,18 @@ pub const emsdk = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emccStep(b: *std.Build, raylib: *std.Build.Step.Compile, wasm: *std.Build.Step.Compile, options: zemscripten.StepOptions) *std.Build.Step {
|
pub fn emccStep(b: *std.Build, raylib: *std.Build.Step.Compile, wasm: *std.Build.Step.Compile, options: zemscripten.StepOptions) *std.Build.Step {
|
||||||
const activate_emsdk_step = zemscripten.activateEmsdkStep(b);
|
|
||||||
|
|
||||||
const emsdk_dep = b.dependency("emsdk", .{});
|
const emsdk_dep = b.dependency("emsdk", .{});
|
||||||
raylib.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
|
raylib.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
|
||||||
wasm.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
|
wasm.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
|
||||||
|
|
||||||
const emcc_step = zemscripten.emccStep(b, wasm, options);
|
const emcc_step = zemscripten.emccStep(b, &.{}, &.{wasm}, options);
|
||||||
emcc_step.dependOn(activate_emsdk_step);
|
|
||||||
|
|
||||||
return emcc_step;
|
return emcc_step;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emrunStep(
|
pub fn emrunStep(
|
||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
html_path: []const u8,
|
html_path: std.Build.LazyPath,
|
||||||
extra_args: []const []const u8,
|
extra_args: []const []const u8,
|
||||||
) *std.Build.Step {
|
) *std.Build.Step {
|
||||||
return zemscripten.emrunStep(b, html_path, extra_args);
|
return zemscripten.emrunStep(b, html_path, extra_args);
|
||||||
|
|
@ -92,7 +89,7 @@ pub fn linkWindows(mod: *std.Build.Module, opengl: bool, comptime shcore: bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn findWaylandScanner(b: *std.Build) void {
|
fn findWaylandScanner(b: *std.Build) void {
|
||||||
_ = b.findProgram(&.{"wayland-scanner"}, &.{}) catch {
|
_ = b.findProgram(.{ .names = &.{"wayland-scanner"} }) orelse {
|
||||||
std.log.err(
|
std.log.err(
|
||||||
\\ `wayland-scanner` may not be installed on the system.
|
\\ `wayland-scanner` may not be installed on the system.
|
||||||
\\ You can switch to X11 in your `build.zig` by changing `Options.linux_display_backend`
|
\\ You can switch to X11 in your `build.zig` by changing `Options.linux_display_backend`
|
||||||
|
|
@ -649,7 +646,7 @@ fn addExamples(
|
||||||
const all = b.step(module, "All " ++ module ++ " examples");
|
const all = b.step(module, "All " ++ module ++ " examples");
|
||||||
const module_subpath = b.pathJoin(&.{ "examples", module });
|
const module_subpath = b.pathJoin(&.{ "examples", module });
|
||||||
|
|
||||||
var dir = try b.build_root.handle.openDir(b.graph.io, module_subpath, .{ .iterate = true });
|
var dir = try b.root.openDir(b.graph.io, module_subpath, .{ .iterate = true });
|
||||||
defer dir.close(b.graph.io);
|
defer dir.close(b.graph.io);
|
||||||
|
|
||||||
var iter = dir.iterate();
|
var iter = dir.iterate();
|
||||||
|
|
@ -699,7 +696,7 @@ fn addExamples(
|
||||||
exe_mod.addCMacro("PLATFORM_WEB", "");
|
exe_mod.addCMacro("PLATFORM_WEB", "");
|
||||||
|
|
||||||
const wasm = b.addLibrary(.{
|
const wasm = b.addLibrary(.{
|
||||||
.name = filename,
|
.name = b.fmt("{s}.html", .{filename}),
|
||||||
.root_module = exe_mod,
|
.root_module = exe_mod,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -707,9 +704,10 @@ fn addExamples(
|
||||||
const emcc_flags = emsdk.emccDefaultFlags(b.allocator, .{ .optimize = optimize });
|
const emcc_flags = emsdk.emccDefaultFlags(b.allocator, .{ .optimize = optimize });
|
||||||
const emcc_settings = emsdk.emccDefaultSettings(b.allocator, .{ .optimize = optimize });
|
const emcc_settings = emsdk.emccDefaultSettings(b.allocator, .{ .optimize = optimize });
|
||||||
|
|
||||||
const EmccExamplesPreloadMap = std.static_string_map.StaticStringMap([]const emsdk.zemscripten.EmccFilePath);
|
const EmccExamplesPreloadMap = std.static_string_map.StaticStringMap([]const emsdk.zemscripten.ResourceFile);
|
||||||
const EmccExamplesPreloadKV = struct { []const u8, []const emsdk.zemscripten.EmccFilePath };
|
const EmccExamplesPreloadKV = struct { []const u8, []const emsdk.zemscripten.ResourceFile };
|
||||||
const emcc_examples_preloads: []const EmccExamplesPreloadKV = @import("examples/example_resources.zon");
|
const emcc_examples_preloads_ = @import("examples/example_resources.zon");
|
||||||
|
const emcc_examples_preloads: []const EmccExamplesPreloadKV = @ptrCast(@alignCast(&emcc_examples_preloads_));
|
||||||
const emcc_examples_preloads_map = EmccExamplesPreloadMap.initComptime(emcc_examples_preloads);
|
const emcc_examples_preloads_map = EmccExamplesPreloadMap.initComptime(emcc_examples_preloads);
|
||||||
|
|
||||||
const emcc_step = emsdk.emccStep(b, raylib, wasm, .{
|
const emcc_step = emsdk.emccStep(b, raylib, wasm, .{
|
||||||
|
|
@ -719,12 +717,15 @@ fn addExamples(
|
||||||
.preload_paths = emcc_examples_preloads_map.get(filename) orelse &.{},
|
.preload_paths = emcc_examples_preloads_map.get(filename) orelse &.{},
|
||||||
.shell_file_path = b.path("src/shell.html"),
|
.shell_file_path = b.path("src/shell.html"),
|
||||||
.install_dir = install_dir,
|
.install_dir = install_dir,
|
||||||
|
.out_file_name = wasm.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
const html_filename = try std.fmt.allocPrint(b.allocator, "{s}.html", .{wasm.name});
|
|
||||||
const emrun_step = emsdk.emrunStep(
|
const emrun_step = emsdk.emrunStep(
|
||||||
b,
|
b,
|
||||||
b.getInstallPath(install_dir, html_filename),
|
b.graph.path(.install_prefix, b.fmt(
|
||||||
|
"web/{s}/{s}/{s}",
|
||||||
|
.{ module, filename, wasm.name },
|
||||||
|
)),
|
||||||
&.{},
|
&.{},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -759,7 +760,7 @@ fn waylandGenerate(
|
||||||
comptime waylandDir: []const u8,
|
comptime waylandDir: []const u8,
|
||||||
comptime source: bool,
|
comptime source: bool,
|
||||||
) !void {
|
) !void {
|
||||||
const dir = try b.build_root.handle.openDir(b.graph.io, waylandDir, .{ .iterate = true });
|
const dir = try b.root.openDir(b.graph.io, waylandDir, .{ .iterate = true });
|
||||||
defer dir.close(b.graph.io);
|
defer dir.close(b.graph.io);
|
||||||
|
|
||||||
var iter = dir.iterate();
|
var iter = dir.iterate();
|
||||||
|
|
@ -793,4 +794,3 @@ fn waylandGenerate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
.{
|
.{
|
||||||
.name = .raylib,
|
.name = .raylib,
|
||||||
.version = "6.0.0",
|
.version = "6.0.0",
|
||||||
.minimum_zig_version = "0.16.0",
|
.minimum_zig_version = "0.17.0-dev.1426+58a94eaae",
|
||||||
|
|
||||||
.fingerprint = 0x13035e5cb8bc1ac2, // Changing this has security and trust implications.
|
.fingerprint = 0x13035e5cb8bc1ac2, // Changing this has security and trust implications.
|
||||||
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
.hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ",
|
.hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ",
|
||||||
},
|
},
|
||||||
.zemscripten = .{
|
.zemscripten = .{
|
||||||
.url = "git+https://github.com/zig-gamedev/zemscripten#3fa4b778852226c7346bdcc3c1486e875a9a6d02",
|
.url = "git+https://github.com/Yinameah/zemscripten#06d49243789d638ba10d4af004c46df4da83579c",
|
||||||
.hash = "zemscripten-0.2.0-dev-sRlDqApRAACspTbAZnuNKWIzfWzSYgYkb2nWAXZ-tqqt",
|
.hash = "zemscripten-0.2.0-dev-sRlDqKFRAAAXl8aICu541O6PiY70v4HIr3FTmCg--WqM",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue