Compare commits

...

2 Commits

Author SHA1 Message Date
nothke
f032509b12 Added note about running wasm but doesnt build 2024-07-04 17:08:10 +02:00
nothke
2a10ffc55c Now switches on target set to wasm 2024-07-04 16:57:48 +02:00
2 changed files with 3 additions and 12 deletions

View File

@ -3,15 +3,13 @@ const sokol = @import("sokol");
const title = "sok"; const title = "sok";
const buildForWeb = false;
pub fn build(b: *std.Build) void { pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const dep_sokol = b.dependency("sokol", .{ .target = target, .optimize = optimize }); const dep_sokol = b.dependency("sokol", .{ .target = target, .optimize = optimize });
if (!buildForWeb) { if (!target.result.isWasm()) {
// Native exe // Native exe
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
@ -96,12 +94,3 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Run unit tests"); const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_unit_tests.step); test_step.dependOn(&run_exe_unit_tests.step);
} }
// for web builds, the Zig code needs to be built into a library and linked with the Emscripten linker
fn buildWeb(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.Build.OptimizeMode, dep_sokol: *std.Build.Dependency) !void {
_ = b; // autofix
_ = target; // autofix
_ = optimize; // autofix
_ = dep_sokol; // autofix
}

View File

@ -10,6 +10,8 @@ The goal of this project is not fixed, and is just to try out some sokol feature
To build, you need to have zig master (you can use [zvm](https://www.zvm.app/) to help you with this). Then just `zig build run` and that should be it! To build, you need to have zig master (you can use [zvm](https://www.zvm.app/) to help you with this). Then just `zig build run` and that should be it!
To build for wasm, use `zig build -Dtarget=wasm32-emscripten run`
Note that if you change shaders, you have to recompile them manually - run compile_shaders.bat. Note that if you change shaders, you have to recompile them manually - run compile_shaders.bat.
### Live error checking ### Live error checking