Skip to content

Commit

Permalink
remove examples backend and redundances
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Jan 10, 2024
1 parent 0f33ed0 commit ae79928
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub const LibSokolOptions = struct {
backend: Backend = .auto,
force_egl: bool = false,
enable_x11: bool = true,
enable_wgpu: bool = false,
enable_wayland: bool = false,
sysroot: ?[]const u8 = null,
package: ?*Build.Dependency = null,
Expand All @@ -49,7 +48,6 @@ pub fn build(b: *Build) void {
.backend = if (force_gl) .gl else .auto,
.enable_wayland = b.option(bool, "wayland", "Compile with wayland-support (default: false)") orelse false,
.enable_x11 = b.option(bool, "x11", "Compile with x11-support (default: true)") orelse true,
.enable_wgpu = b.option(bool, "wgpu", "Compile with wgpu-support for Wasm (default: false)") orelse false,
.force_egl = b.option(bool, "egl", "Use EGL instead of GLX if possible (default: false)") orelse false,
}) catch |err| {
std.log.err("buildLibSokol return with error {}", .{err});
Expand Down Expand Up @@ -84,7 +82,6 @@ pub fn build(b: *Build) void {
.lib_sokol = lib_sokol,
.mod_sokol = mod_sokol,
.package = b.dependency("emsdk", .{}),
.backend = if (force_gl) .gl else .auto,
});
}
buildShaders(b);
Expand All @@ -95,7 +92,6 @@ const ExampleOptions = struct {
optimize: OptimizeMode,
lib_sokol: *CompileStep,
mod_sokol: *Module,
backend: Backend = .auto,
package: ?*Build.Dependency = null,

fn packagePath(self: ExampleOptions, b: *Build) ?[]const u8 {
Expand Down Expand Up @@ -178,8 +174,6 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep {
_backend = .d3d11;
} else if (lib.rootModuleTarget().isWasm()) {
_backend = .gles3;
} else if (lib.rootModuleTarget().isWasm() and options.enable_wgpu) {
_backend = .wgpu;
} else if (lib.rootModuleTarget().abi == .android) {
_backend = .gles3;
} else {
Expand Down Expand Up @@ -307,8 +301,6 @@ fn buildExample(b: *Build, comptime name: []const u8, options: ExampleOptions) v
var run: ?*RunStep = null;
if (e.rootModuleTarget().isWasm()) {
run = buildWasm(b, e, options) catch |err| @panic(@errorName(err));
run.?.addArtifactArg(e);
run.?.addArtifactArg(options.lib_sokol);
} else {
b.installArtifact(e);
run = b.addRunArtifact(e);
Expand Down Expand Up @@ -391,14 +383,14 @@ fn buildWasm(b: *Build, example: *CompileStep, options: ExampleOptions) !*RunSte
try emcc_cmds.append("-sERROR_ON_UNDEFINED_SYMBOLS=0");

// TODO: fix undefined references
switch (options.backend) {
.wgpu => {
try emcc_cmds.append("-sUSE_WEBGPU=1");
},
else => {
try emcc_cmds.append("-sUSE_WEBGL2=1");
},
}
// switch (options.backend) {
// .wgpu => {
// try emcc_cmds.append("-sUSE_WEBGPU=1");
// },
// else => {
try emcc_cmds.append("-sUSE_WEBGL2=1");
// },
// }
try emcc_cmds.append("-sEXPORTED_FUNCTIONS=['_malloc','_free','_main']");

const emcc = b.addSystemCommand(emcc_cmds.items);
Expand Down

0 comments on commit ae79928

Please sign in to comment.