Remove emscript example building with Zig again

This commit is contained in:
Not-Nik 2023-01-31 20:52:30 +01:00
parent 1e1108be1d
commit 63dffa7f2d
2 changed files with 19 additions and 27 deletions

View File

@ -126,7 +126,7 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
endif endif
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
# Define default C compiler: CC # Define default C compiler: CC
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
@ -547,7 +547,7 @@ endif
# Clean everything # Clean everything
clean: clean:
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB)) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
del *.o *.exe /s del *.o *.exe /s
endif endif
@ -567,6 +567,12 @@ endif
ifeq ($(PLATFORM),PLATFORM_DRM) ifeq ($(PLATFORM),PLATFORM_DRM)
find . -type f -executable -delete find . -type f -executable -delete
rm -fv *.o 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 endif
@echo Cleaning done @echo Cleaning done

View File

@ -2,6 +2,10 @@ const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zig.CrossTarget) !*std.build.Step { 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 // Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions(); 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 // zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue; 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.addCSourceFile(path, &[_][]const u8{});
exe.setTarget(target); exe.setTarget(target);
exe.setBuildMode(mode); 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");
exe.addIncludePath("../src/external/glfw/include"); exe.addIncludePath("../src/external/glfw/include");
switch (exe.target.toTarget().os.tag) { switch (target.getOsTag()) {
.windows => { .windows => {
exe.linkSystemLibrary("winmm"); exe.linkSystemLibrary("winmm");
exe.linkSystemLibrary("gdi32"); 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); 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 => { else => {
@panic("Unsupported OS"); @panic("Unsupported OS");
}, },
@ -86,12 +74,10 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
exe.setOutputDir(module); exe.setOutputDir(module);
if (exe.target.toTarget().os.tag != std.Target.Os.Tag.emscripten) { var run = exe.run();
var run = exe.run(); run.step.dependOn(&b.addInstallArtifact(exe).step);
run.step.dependOn(&b.addInstallArtifact(exe).step); run.cwd = module;
run.cwd = module; b.step(name, name).dependOn(&run.step);
b.step(name, name).dependOn(&run.step);
}
all.dependOn(&exe.step); all.dependOn(&exe.step);
} }
return all; return all;