diff --git a/examples/Makefile b/examples/Makefile index b7bb161c2..3d5fe3d8b 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -126,7 +126,7 @@ ifeq ($(PLATFORM),PLATFORM_DRM) endif # Define raylib release directory for compiled library -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src +RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src # Define default C compiler: CC #------------------------------------------------------------------------------------------------ @@ -547,7 +547,7 @@ endif # Clean everything clean: -ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB)) +ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) del *.o *.exe /s endif @@ -567,6 +567,12 @@ endif ifeq ($(PLATFORM),PLATFORM_DRM) find . -type f -executable -delete rm -fv *.o +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + ifeq ($(PLATFORM_OS),WINDOWS) + del *.wasm *.html *.js *.data + else + rm -f */*.wasm */*.html */*.js */*.data + endif endif @echo Cleaning done - diff --git a/examples/build.zig b/examples/build.zig index e004e01ce..eb040fd2f 100644 --- a/examples/build.zig +++ b/examples/build.zig @@ -2,6 +2,10 @@ const std = @import("std"); const builtin = @import("builtin"); fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zig.CrossTarget) !*std.build.Step { + if (target.getOsTag() == .emscripten) { + @panic("Emscripten building via Zig unsupported"); + } + // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const mode = b.standardReleaseOptions(); @@ -18,7 +22,7 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi // zig's mingw headers do not include pthread.h if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue; - const exe = b.addSharedLibrary(name, null, std.build.LibExeObjStep.SharedLibKind.unversioned); + const exe = b.addExecutable(name, null); exe.addCSourceFile(path, &[_][]const u8{}); exe.setTarget(target); exe.setBuildMode(mode); @@ -35,7 +39,7 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi exe.addIncludePath("../src/external"); exe.addIncludePath("../src/external/glfw/include"); - switch (exe.target.toTarget().os.tag) { + switch (target.getOsTag()) { .windows => { exe.linkSystemLibrary("winmm"); exe.linkSystemLibrary("gdi32"); @@ -63,22 +67,6 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi exe.defineCMacro("PLATFORM_DESKTOP", null); }, - .emscripten => { - exe.defineCMacro("PLATFORM_WEB", null); - exe.defineCMacro("GRAPHICS_API_OPENGL_ES2", null); - - if (b.sysroot == null) { - @panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"'S"); - } - - const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory"); - defer b.allocator.free(cache_include); - - var d = std.fs.openDirAbsolute(cache_include, std.fs.Dir.OpenDirOptions{.access_sub_paths = true, .no_follow = true}) catch @panic("No emscripten cache. Generate it!"); - d.close(); - - exe.addIncludePath(cache_include); - }, else => { @panic("Unsupported OS"); }, @@ -86,12 +74,10 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi exe.setOutputDir(module); - if (exe.target.toTarget().os.tag != std.Target.Os.Tag.emscripten) { - var run = exe.run(); - run.step.dependOn(&b.addInstallArtifact(exe).step); - run.cwd = module; - b.step(name, name).dependOn(&run.step); - } + var run = exe.run(); + run.step.dependOn(&b.addInstallArtifact(exe).step); + run.cwd = module; + b.step(name, name).dependOn(&run.step); all.dependOn(&exe.step); } return all;