diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/Makefile | 29 | ||||
| -rw-r--r-- | examples/build.zig | 20 | ||||
| -rw-r--r-- | examples/shapes/resources/.gitkeep | 0 |
3 files changed, 30 insertions, 19 deletions
diff --git a/examples/Makefile b/examples/Makefile index bc2c8d71..dce02218 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -67,8 +67,8 @@ ifeq ($(PLATFORM),PLATFORM_RPI) endif endif -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) +# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB)) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! # ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) @@ -126,16 +126,18 @@ ifeq ($(PLATFORM),PLATFORM_DRM) endif # Define raylib release directory for compiled library -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src +RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten - CLANG_PATH = $(EMSDK_PATH)/upstream/bin - PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit - NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH) + ifeq ($(PLATFORM_OS),WINDOWS) + # Emscripten required variables + EMSDK_PATH ?= C:/emsdk + EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten + CLANG_PATH = $(EMSDK_PATH)/upstream/bin + PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit + NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin + export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH) + endif endif # Define default C compiler: CC @@ -579,7 +581,10 @@ ifeq ($(PLATFORM),PLATFORM_DRM) rm -fv *.o endif ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js + 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 cb211aef..eb040fd2 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(); @@ -19,12 +23,7 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue; const exe = b.addExecutable(name, null); - exe.addCSourceFile(path, switch (target.getOsTag()) { - .windows => &[_][]const u8{}, - .linux => &[_][]const u8{}, - .macos => &[_][]const u8{"-DPLATFORM_DESKTOP"}, - else => @panic("Unsupported OS"), - }); + exe.addCSourceFile(path, &[_][]const u8{}); exe.setTarget(target); exe.setBuildMode(mode); exe.linkLibC(); @@ -32,6 +31,7 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi .windows => "../src/raylib.lib", .linux => "../src/libraylib.a", .macos => "../src/libraylib.a", + .emscripten => "../src/libraylib.a", else => @panic("Unsupported OS"), }); @@ -39,12 +39,14 @@ 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"); exe.linkSystemLibrary("opengl32"); exe.addIncludePath("external/glfw/deps/mingw"); + + exe.defineCMacro("PLATFORM_DESKTOP", null); }, .linux => { exe.linkSystemLibrary("GL"); @@ -52,6 +54,8 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi exe.linkSystemLibrary("dl"); exe.linkSystemLibrary("m"); exe.linkSystemLibrary("X11"); + + exe.defineCMacro("PLATFORM_DESKTOP", null); }, .macos => { exe.linkFramework("Foundation"); @@ -60,6 +64,8 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi exe.linkFramework("CoreAudio"); exe.linkFramework("CoreVideo"); exe.linkFramework("IOKit"); + + exe.defineCMacro("PLATFORM_DESKTOP", null); }, else => { @panic("Unsupported OS"); diff --git a/examples/shapes/resources/.gitkeep b/examples/shapes/resources/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/examples/shapes/resources/.gitkeep |
