Improve Web example building
This commit is contained in:
parent
d1733e60cc
commit
1e1108be1d
|
|
@ -67,8 +67,8 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
|
# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
|
||||||
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
||||||
# ifeq ($(UNAME),Msys) -> Windows
|
# ifeq ($(UNAME),Msys) -> Windows
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
|
|
@ -128,16 +128,6 @@ 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
|
||||||
|
|
||||||
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)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define default C compiler: CC
|
# Define default C compiler: CC
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
@ -557,7 +547,7 @@ endif
|
||||||
|
|
||||||
# Clean everything
|
# Clean everything
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
del *.o *.exe /s
|
del *.o *.exe /s
|
||||||
endif
|
endif
|
||||||
|
|
@ -577,9 +567,6 @@ 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)
|
|
||||||
del *.o *.html *.js
|
|
||||||
endif
|
endif
|
||||||
@echo Cleaning done
|
@echo Cleaning done
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,8 @@ 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.addExecutable(name, null);
|
const exe = b.addSharedLibrary(name, null, std.build.LibExeObjStep.SharedLibKind.unversioned);
|
||||||
exe.addCSourceFile(path, switch (target.getOsTag()) {
|
exe.addCSourceFile(path, &[_][]const u8{});
|
||||||
.windows => &[_][]const u8{},
|
|
||||||
.linux => &[_][]const u8{},
|
|
||||||
.macos => &[_][]const u8{"-DPLATFORM_DESKTOP"},
|
|
||||||
else => @panic("Unsupported OS"),
|
|
||||||
});
|
|
||||||
exe.setTarget(target);
|
exe.setTarget(target);
|
||||||
exe.setBuildMode(mode);
|
exe.setBuildMode(mode);
|
||||||
exe.linkLibC();
|
exe.linkLibC();
|
||||||
|
|
@ -32,6 +27,7 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
||||||
.windows => "../src/raylib.lib",
|
.windows => "../src/raylib.lib",
|
||||||
.linux => "../src/libraylib.a",
|
.linux => "../src/libraylib.a",
|
||||||
.macos => "../src/libraylib.a",
|
.macos => "../src/libraylib.a",
|
||||||
|
.emscripten => "../src/libraylib.a",
|
||||||
else => @panic("Unsupported OS"),
|
else => @panic("Unsupported OS"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -45,6 +41,8 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
||||||
exe.linkSystemLibrary("gdi32");
|
exe.linkSystemLibrary("gdi32");
|
||||||
exe.linkSystemLibrary("opengl32");
|
exe.linkSystemLibrary("opengl32");
|
||||||
exe.addIncludePath("external/glfw/deps/mingw");
|
exe.addIncludePath("external/glfw/deps/mingw");
|
||||||
|
|
||||||
|
exe.defineCMacro("PLATFORM_DESKTOP", null);
|
||||||
},
|
},
|
||||||
.linux => {
|
.linux => {
|
||||||
exe.linkSystemLibrary("GL");
|
exe.linkSystemLibrary("GL");
|
||||||
|
|
@ -52,6 +50,8 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
||||||
exe.linkSystemLibrary("dl");
|
exe.linkSystemLibrary("dl");
|
||||||
exe.linkSystemLibrary("m");
|
exe.linkSystemLibrary("m");
|
||||||
exe.linkSystemLibrary("X11");
|
exe.linkSystemLibrary("X11");
|
||||||
|
|
||||||
|
exe.defineCMacro("PLATFORM_DESKTOP", null);
|
||||||
},
|
},
|
||||||
.macos => {
|
.macos => {
|
||||||
exe.linkFramework("Foundation");
|
exe.linkFramework("Foundation");
|
||||||
|
|
@ -60,6 +60,24 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
||||||
exe.linkFramework("CoreAudio");
|
exe.linkFramework("CoreAudio");
|
||||||
exe.linkFramework("CoreVideo");
|
exe.linkFramework("CoreVideo");
|
||||||
exe.linkFramework("IOKit");
|
exe.linkFramework("IOKit");
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
@ -68,10 +86,12 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
||||||
|
|
||||||
exe.setOutputDir(module);
|
exe.setOutputDir(module);
|
||||||
|
|
||||||
var run = exe.run();
|
if (exe.target.toTarget().os.tag != std.Target.Os.Tag.emscripten) {
|
||||||
run.step.dependOn(&b.addInstallArtifact(exe).step);
|
var run = exe.run();
|
||||||
run.cwd = module;
|
run.step.dependOn(&b.addInstallArtifact(exe).step);
|
||||||
b.step(name, name).dependOn(&run.step);
|
run.cwd = module;
|
||||||
|
b.step(name, name).dependOn(&run.step);
|
||||||
|
}
|
||||||
all.dependOn(&exe.step);
|
all.dependOn(&exe.step);
|
||||||
}
|
}
|
||||||
return all;
|
return all;
|
||||||
|
|
|
||||||
0
examples/shapes/resources/.gitkeep
Normal file
0
examples/shapes/resources/.gitkeep
Normal file
|
|
@ -81,7 +81,7 @@ pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.
|
||||||
raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
|
raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
|
||||||
|
|
||||||
if (b.sysroot == null) {
|
if (b.sysroot == null) {
|
||||||
@panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"' or '--sysroot \"/usr/local/opt/emscripten/libexec\"' on macOS");
|
@panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"'");
|
||||||
}
|
}
|
||||||
|
|
||||||
const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory");
|
const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user