From 49d798f4efc26d07459ee77337e2bbc5880815d5 Mon Sep 17 00:00:00 2001 From: Matheus Catarino Date: Thu, 16 May 2024 09:47:15 -0300 Subject: [PATCH 1/2] build: break changes fixed * fix includes & package path * some fixes for wasm target * fix sokol_backend * switch build (dub or zig only) * fix clear example for wasm32 (no stdout) --- .github/workflows/build.yml | 4 +- README.md | 28 +++--- build.zig | 172 ++++++++++++++++++------------------ build.zig.zon | 10 +-- dub.sdl | 42 ++++----- src/examples/clear.d | 21 +++-- 6 files changed, 144 insertions(+), 133 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d8dcd62..0513be3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: korandoru/setup-zig@v1 with: - zig-version: 0.12.0 + zig-version: master - uses: dlang-community/setup-dlang@v1 with: compiler: ldc-master @@ -42,4 +42,4 @@ jobs: - name: (Zig) Build Native run: zig build -DzigCC --summary all - name: (Zig + emsdk) Build Wasm - run: zig build -DzigCC --summary all -Dtarget=wasm32-emscripten -Doptimize=ReleaseSmall + run: zig build -DzigCC --summary all -Dtarget=wasm32-emscripten-none -Doptimize=ReleaseSmall diff --git a/README.md b/README.md index 3c64ba9..613cf19 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ Auto-generated [D](https://dlang.org) bindings for the [sokol headers](https://g #### Targets - Native -- Wasm (`-Dtarget=wasm32-emscripten`) +- Wasm (`-Dtarget=wasm32-emscripten-none`) ## BUILD **Required** - [zig](https://ziglang.org/download) v0.12.0 or master -- [ldc](https://ldc-developers.github.io) v1.36.0 or latest-CI (nightly) +- [ldc](https://ldc-developers.github.io) v1.38.0 or latest-CI (nightly) Supported platforms are: Windows, macOS, Linux (with X11) @@ -23,22 +23,22 @@ On Linux install the following packages: libglu1-mesa-dev, mesa-common-dev, xorg ```bash # build sokol library + all examples [default: static library] -zig build -Doptimize=ReleaseFast +zig build -Doptimize=ReleaseSafe # build sokol shared library + all examples -zig build -Doptimize=ReleaseFast -Dshared +zig build -Doptimize=ReleaseSafe -Dshared # Run Examples -zig build run-blend -Doptimize=ReleaseFast -zig build run-clear -Doptimize=ReleaseFast -zig build run-cube -Doptimize=ReleaseFast -zig build run-debugtext -Doptimize=ReleaseFast -zig build run-mrt -Doptimize=ReleaseFast -zig build run-saudio -Doptimize=ReleaseFast -zig build run-sgl_context -Doptimize=ReleaseFast -zig build run-sgl_points -Doptimize=ReleaseFast -zig build run-user_data -Doptimize=ReleaseFast -zig build run-triangle -Doptimize=ReleaseFast +zig build run-blend -Doptimize=ReleaseSafe +zig build run-clear -Doptimize=ReleaseSafe +zig build run-cube -Doptimize=ReleaseSafe +zig build run-debugtext -Doptimize=ReleaseSafe +zig build run-mrt -Doptimize=ReleaseSafe +zig build run-saudio -Doptimize=ReleaseSafe +zig build run-sgl_context -Doptimize=ReleaseSafe +zig build run-sgl_points -Doptimize=ReleaseSafe +zig build run-user_data -Doptimize=ReleaseSafe +zig build run-triangle -Doptimize=ReleaseSafe zig build --help # Project-Specific Options: diff --git a/build.zig b/build.zig index a039494..b236b1b 100644 --- a/build.zig +++ b/build.zig @@ -33,7 +33,9 @@ fn resolveSokolBackend(backend: SokolBackend, target: std.Target) SokolBackend { return .metal; } else if (target.os.tag == .windows) { return .d3d11; - } else if (target.isWasm() or target.isAndroid()) { + } else if (target.isWasm()) { + return .gles3; + } else if (target.isAndroid()) { return .gles3; } else { return .gl; @@ -58,7 +60,7 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep { }); lib.root_module.sanitize_c = false; lib.linkLibC(); - lib.root_module.root_source_file = .{ .path = "src/handmade/math.zig" }; + lib.root_module.root_source_file = b.path("src/handmade/math.zig"); switch (options.optimize) { .Debug, .ReleaseSafe => lib.bundle_compiler_rt = true, @@ -66,6 +68,8 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep { } if (options.target.result.isWasm()) { + if (options.optimize != .Debug) + lib.want_lto = true; // make sure we're building for the wasm32-emscripten target, not wasm32-freestanding if (lib.rootModuleTarget().os.tag != .emscripten) { std.log.err("Please build with 'zig build -Dtarget=wasm32-emscripten", .{}); @@ -76,9 +80,7 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep { lib.step.dependOn(&emsdk_setup.step); } // add the Emscripten system include seach path - const emsdk_sysroot = b.pathJoin(&.{ emSdkPath(b, options.emsdk.?), "upstream", "emscripten", "cache", "sysroot" }); - const include_path = b.pathJoin(&.{ emsdk_sysroot, "include" }); - lib.addSystemIncludePath(.{ .path = include_path }); + lib.addSystemIncludePath(emSdkLazyPath(b, options.emsdk.?, &.{ "upstream", "emscripten", "cache", "sysroot", "include" })); } // resolve .auto backend into specific backend by platform @@ -172,12 +174,10 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep { }; for (csources) |csrc| { lib.addCSourceFile(.{ - .file = .{ .path = csrc }, + .file = b.path(csrc), .flags = cflags, }); } - - b.installArtifact(lib); return lib; } @@ -188,7 +188,10 @@ pub fn build(b: *Build) !void { const opt_use_wayland = b.option(bool, "wayland", "Force Wayland (default: false, Linux only, not supported in main-line headers)") orelse false; const opt_use_egl = b.option(bool, "egl", "Force EGL (default: false, Linux only)") orelse false; const sokol_backend: SokolBackend = if (opt_use_gl) .gl else if (opt_use_wgpu) .wgpu else .auto; - + const dub_artifact = b.option(bool, "artifact", "Build artifacts (default: false)") orelse false; + // LDC-options options + const enable_betterC = b.option(bool, "betterC", "Omit generating some runtime information and helper functions (default: false)") orelse false; + const enable_zigcc = b.option(bool, "zigCC", "Use zig cc as compiler and linker (default: false)") orelse false; // ldc2 w/ druntime + phobos2 works on MSVC const target = b.standardTargetOptions(.{ .default_target = if (builtin.os.tag == .windows) try std.Target.Query.parse(.{ .arch_os_abi = "native-windows-msvc" }) else .{} }); const optimize = b.standardOptimizeOption(.{}); @@ -203,48 +206,45 @@ pub fn build(b: *Build) !void { .use_egl = opt_use_egl, .emsdk = emsdk, }); - - // LDC-options options - const enable_betterC = b.option(bool, "betterC", "Omit generating some runtime information and helper functions (default: false)") orelse false; - const enable_zigcc = b.option(bool, "zigCC", "Use zig cc as compiler and linker (default: false)") orelse false; - - // build examples - const examples = .{ - "clear", - "triangle", - "cube", - "blend", - "mrt", - "saudio", - "sgl_context", - "sgl_points", - "debugtext", - "user_data", // Need GC for user data [associative array] - }; - - inline for (examples) |example| { - const ldc = try ldcBuildStep(b, .{ - .name = example, - .artifact = lib_sokol, - .sources = &[_][]const u8{b.fmt("{s}/src/examples/{s}.d", .{ rootPath(), example })}, - .betterC = if (std.mem.eql(u8, example, "user-data")) false else enable_betterC, - .dflags = &[_][]const u8{ - "-w", // warnings as error - // more info: ldc2 -preview=help (list all specs) - "-preview=all", - }, - .d_packages = if (target.result.isWasm()) &[_][]const u8{ - b.dependency("wasmd", .{}).path("arsd-webassembly").getPath(b), - } else null, - // fixme: https://github.com/kassane/sokol-d/issues/1 - betterC works on darwin - .zig_cc = if (target.result.isDarwin() and !enable_betterC) false else enable_zigcc, - .target = target, - .optimize = optimize, - // send ldc2-obj (wasm artifact) to emcc - .kind = if (target.result.isWasm()) .obj else .exe, - .emsdk = emsdk, - }); - b.getInstallStep().dependOn(&ldc.step); + if (dub_artifact) { + b.installArtifact(lib_sokol); + } else { + // build examples + const examples = .{ + "clear", + "triangle", + "cube", + "blend", + "mrt", + "saudio", + "sgl_context", + "sgl_points", + "debugtext", + "user_data", // Need GC for user data [associative array] + }; + + inline for (examples) |example| { + const ldc = try ldcBuildStep(b, .{ + .name = example, + .artifact = lib_sokol, + .sources = &[_][]const u8{b.fmt("{s}/src/examples/{s}.d", .{ rootPath(), example })}, + .betterC = if (std.mem.eql(u8, example, "user-data")) false else enable_betterC, + .dflags = &[_][]const u8{ + "-w", // warnings as error + // more info: ldc2 -preview=help (list all specs) + "-preview=all", + }, + // fixme: https://github.com/kassane/sokol-d/issues/1 - betterC works on darwin + .zig_cc = if (target.result.isDarwin() and !enable_betterC) false else enable_zigcc, + .target = target, + .optimize = optimize, + // send ldc2-obj (wasm artifact) to emcc + .kind = if (target.result.isWasm()) .obj else .exe, + .emsdk = emsdk, + .backend = sokol_backend, + }); + b.getInstallStep().dependOn(&ldc.step); + } } buildShaders(b); @@ -357,8 +357,6 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep { // mutable state hash (ldc2 cache - llvm-ir2obj) try cmds.append(b.fmt("-cache={s}", .{b.pathJoin(&.{ path, "o", &b.graph.cache.hash.final() })})); } - // name object files uniquely (so the files don't collide) - try cmds.append("-oq"); // disable LLVM-IR verifier // https://llvm.org/docs/Passes.html#verify-module-verifier @@ -426,8 +424,8 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep { // library paths for (lib_sokol.root_module.lib_paths.items) |libpath| { - if (libpath.path.len > 0) // skip empty paths - try cmds.append(b.fmt("-L-L{s}", .{libpath.path})); + if (libpath.getPath(b).len > 0) // skip empty paths + try cmds.append(b.fmt("-L-L{s}", .{libpath.getPath(b)})); } // link system libs @@ -490,9 +488,9 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep { // ldc2 doesn't support zig native (a.k.a: native-native or native) const mtriple = if (options.target.result.isDarwin()) b.fmt("{s}-apple-{s}", .{ if (options.target.result.cpu.arch.isAARCH64()) "arm64" else @tagName(options.target.result.cpu.arch), @tagName(options.target.result.os.tag) }) - else if (options.target.result.isWasm()) + else if (options.target.result.isWasm() and options.target.result.os.tag == .freestanding) b.fmt("{s}-unknown-unknown-wasm", .{@tagName(options.target.result.cpu.arch)}) - else if (options.target.result.isWasm() and options.target.result.os.tag == .wasi) + else if (options.target.result.isWasm()) b.fmt("{s}-unknown-{s}", .{ @tagName(options.target.result.cpu.arch), @tagName(options.target.result.os.tag) }) else b.fmt("{s}-{s}-{s}", .{ @tagName(options.target.result.cpu.arch), @tagName(options.target.result.os.tag), @tagName(options.target.result.abi) }); @@ -527,14 +525,8 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep { const zcc_exists = !std.meta.isError(std.fs.accessAbsolute(zcc_path, .{})); if (!zcc_exists) ldc_exec.step.dependOn(&install.step); - try cmds.append(b.fmt("--gcc={s}", .{zcc_path})); - try cmds.append(b.fmt("--linker={s}", .{zcc_path})); - } - - if (options.artifact) |lib_sokol| { - if (lib_sokol.rootModuleTarget().os.tag == .windows and lib_sokol.isDynamicLibrary()) { - ldc_exec.addArg(b.pathJoin(&.{ b.install_path, "lib", b.fmt("{s}.lib", .{lib_sokol.name}) })); - } else ldc_exec.addArtifactArg(lib_sokol); + ldc_exec.addArg(b.fmt("--gcc={s}", .{zcc_path})); + ldc_exec.addArg(b.fmt("--linker={s}", .{zcc_path})); } const example_run = b.addSystemCommand(&.{b.pathJoin(&.{ b.install_path, outputDir, options.name })}); @@ -546,19 +538,27 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep { b.step("test", "Run all tests"); if (options.target.result.isWasm()) { + // get D object file and put it in the wasm artifact const artifact = addArtifact(b, options); - artifact.addObjectFile(.{ .path = b.fmt("{s}/examples.{s}.o", .{ objpath, options.name }) }); + artifact.addObjectFile(.{ + .src_path = .{ + .sub_path = b.fmt("{s}/{s}.o", .{ objpath, options.name }), + .owner = b, + }, + }); artifact.linkLibrary(options.artifact.?); artifact.step.dependOn(&ldc_exec.step); - + const backend = resolveSokolBackend(options.backend, options.target.result); const link_step = try emLinkStep(b, .{ .lib_main = artifact, .target = options.target, .optimize = options.optimize, .emsdk = options.emsdk.?, - .use_webgl2 = true, + .use_webgpu = backend == .wgpu, + .use_webgl2 = backend != .wgpu, .use_emmalloc = true, .use_filesystem = false, + .release_use_lto = options.artifact.?.want_lto orelse false, .shell_file_path = "src/sokol/web/shell.html", // NOTE: This is required to make the Zig @returnAddress() builtin work, // which is used heavily in the stdlib allocator code (not just @@ -571,8 +571,14 @@ pub fn ldcBuildStep(b: *Build, options: DCompileStep) !*RunStep { const emrun = emRunStep(b, .{ .name = options.name, .emsdk = options.emsdk.? }); emrun.step.dependOn(&link_step.step); run.dependOn(&emrun.step); - } else run.dependOn(&example_run.step); - + } else { + if (options.artifact) |lib_sokol| { + if (lib_sokol.rootModuleTarget().os.tag == .windows and lib_sokol.isDynamicLibrary()) { + ldc_exec.addArg(b.pathJoin(&.{ b.install_path, "lib", b.fmt("{s}.lib", .{lib_sokol.name}) })); + } else ldc_exec.addArtifactArg(lib_sokol); + } + run.dependOn(&example_run.step); + } return ldc_exec; } @@ -590,6 +596,7 @@ pub const DCompileStep = struct { d_packages: ?[]const []const u8 = null, artifact: ?*Build.Step.Compile = null, emsdk: ?*Build.Dependency = null, + backend: SokolBackend = .auto, }; pub fn addArtifact(b: *Build, options: DCompileStep) *Build.Step.Compile { return Build.Step.Compile.create(b, .{ @@ -611,9 +618,7 @@ pub fn buildZigCC(b: *Build) *CompileStep { .name = "zcc", .target = b.host, .optimize = .ReleaseSafe, - .root_source_file = .{ - .path = "tools/zigcc.zig", - }, + .root_source_file = b.path("tools/zigcc.zig"), }); return exe; } @@ -675,7 +680,7 @@ pub const EmLinkOptions = struct { // lib_sokol: *Build.Step.Compile, emsdk: *Build.Dependency, release_use_closure: bool = true, - release_use_lto: bool = true, + release_use_lto: bool = false, use_webgpu: bool = false, use_webgl2: bool = false, use_emmalloc: bool = false, @@ -685,7 +690,7 @@ pub const EmLinkOptions = struct { }; pub fn emLinkStep(b: *Build, options: EmLinkOptions) !*Build.Step.Run { - const emcc_path = b.findProgram(&.{"emcc"}, &.{}) catch b.pathJoin(&.{ emSdkPath(b, options.emsdk), "upstream", "emscripten", "emcc" }); + const emcc_path = b.findProgram(&.{"emcc"}, &.{}) catch emSdkLazyPath(b, options.emsdk, &.{ "upstream", "emscripten", "emcc" }).getPath(b); // create a separate output directory zig-out/web try std.fs.cwd().makePath(b.fmt("{s}/web", .{b.install_path})); @@ -767,14 +772,14 @@ pub const EmRunOptions = struct { emsdk: *Build.Dependency, }; pub fn emRunStep(b: *Build, options: EmRunOptions) *Build.Step.Run { - const emrun_path = b.findProgram(&.{"emrun"}, &.{}) catch b.pathJoin(&.{ emSdkPath(b, options.emsdk), "upstream", "emscripten", "emrun" }); + const emrun_path = b.findProgram(&.{"emrun"}, &.{}) catch emSdkLazyPath(b, options.emsdk, &.{ "upstream", "emscripten", "emrun" }).getPath(b); const emrun = b.addSystemCommand(&.{ emrun_path, b.fmt("{s}/web/{s}.html", .{ b.install_path, options.name }) }); return emrun; } // helper function to extract emsdk path from the emsdk package dependency -fn emSdkPath(b: *Build, emsdk: *Build.Dependency) []const u8 { - return emsdk.path("").getPath(b); +fn emSdkLazyPath(b: *Build, emsdk: *Build.Dependency, subPaths: []const []const u8) Build.LazyPath { + return emsdk.path(b.pathJoin(subPaths)); } // One-time setup of the Emscripten SDK (runs 'emsdk install + activate'). If the @@ -783,17 +788,16 @@ fn emSdkPath(b: *Build, emsdk: *Build.Dependency) []const u8 { // if the emsdk was already setup, null will be returned. // NOTE: ideally this would go into a separate emsdk-zig package fn emSdkSetupStep(b: *Build, emsdk: *Build.Dependency) !?*Build.Step.Run { - const emsdk_path = emSdkPath(b, emsdk); - const dot_emsc_path = b.pathJoin(&.{ emsdk_path, ".emscripten" }); + const dot_emsc_path = emSdkLazyPath(b, emsdk, &.{".emscripten"}).getPath(b); const dot_emsc_exists = !std.meta.isError(std.fs.accessAbsolute(dot_emsc_path, .{})); if (!dot_emsc_exists) { var cmd = std.ArrayList([]const u8).init(b.allocator); defer cmd.deinit(); - if (builtin.os.tag == .windows) - try cmd.append(b.pathJoin(&.{ emsdk_path, "emsdk.bat" })) - else { + if (builtin.os.tag == .windows) { + try cmd.append(emSdkLazyPath(b, emsdk, &.{"emsdk.bat"}).getPath(b)); + } else { try cmd.append("bash"); // or try chmod - try cmd.append(b.pathJoin(&.{ emsdk_path, "emsdk" })); + try cmd.append(emSdkLazyPath(b, emsdk, &.{"emsdk"}).getPath(b)); } const emsdk_install = b.addSystemCommand(cmd.items); emsdk_install.addArgs(&.{ "install", "latest" }); diff --git a/build.zig.zon b/build.zig.zon index d7ac656..3ed5d65 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = "sokol-d", - .version = "0.1.1", + .version = "0.1.2", .min_zig_version = "0.12.0", .paths = .{ "src", @@ -12,12 +12,8 @@ }, .dependencies = .{ .emsdk = .{ - .url = "git+https://github.com/emscripten-core/emsdk#c18280c8f3f8f088b4337f0f6a5fdb2be0d67179", - .hash = "12203d61e8947f25993a86b4d73e2d91b4c1d96f1aa07c581b7dffba7cb5ca91bc35", - }, - .wasmd = .{ - .url = "git+https://github.com/kassane/wasmd#067e21e29aea24ec936d6c6b859f7c9a79894f78", - .hash = "122006f8e097d5bd627f26d2aa3b397d92b400c786f13396c47afed66fed1e8ef2c1", + .url = "git+https://github.com/emscripten-core/emsdk?ref=3.1.60#ce74ca2b1c968f897150bdc55daa9e3c12a3fefc", + .hash = "1220122266f201c6c3a774f7a5edd60e4b1b9655e345bca525360bed2ff9fcb479a8", }, }, } diff --git a/dub.sdl b/dub.sdl index 3169ec3..f07686b 100644 --- a/dub.sdl +++ b/dub.sdl @@ -1,5 +1,5 @@ name "sokol-d" -version "0.1.1" +version "0.1.2" description "D bindings for sokol" authors "Matheus Catarino França" "Andre Weissflog" copyright "Copyright 2023-2024 - Matheus Catarino França" @@ -36,12 +36,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/sgl_context.d" "src/examples/triangle.d" "src/examples/sgl_points.d" "src/examples/saudio.d" "src/examples/debugtext.d" "src/examples/mrt.d" "src/examples/user_data.d" "src/examples/cube.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "sgl_context" @@ -51,12 +51,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/clear.d" "src/examples/triangle.d" "src/examples/sgl_points.d" "src/examples/saudio.d" "src/examples/debugtext.d" "src/examples/mrt.d" "src/examples/user_data.d" "src/examples/cube.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "sgl_points" @@ -66,12 +66,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/clear.d" "src/examples/triangle.d" "src/examples/sgl_context.d" "src/examples/saudio.d" "src/examples/debugtext.d" "src/examples/mrt.d" "src/examples/user_data.d" "src/examples/cube.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "debugtext" @@ -81,12 +81,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/sgl_context.d" "src/examples/triangle.d" "src/examples/sgl_points.d" "src/examples/saudio.d" "src/examples/clear.d" "src/examples/mrt.d" "src/examples/user_data.d" "src/examples/cube.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "triangle" @@ -96,12 +96,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/sgl_context.d" "src/examples/clear.d" "src/examples/sgl_points.d" "src/examples/saudio.d" "src/examples/debugtext.d" "src/examples/mrt.d" "src/examples/user_data.d" "src/examples/cube.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "blend" @@ -111,12 +111,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/sgl_context.d" "src/examples/clear.d" "src/examples/saudio.d" "src/examples/debugtext.d" "src/examples/mrt.d" "src/examples/user_data.d" "src/examples/cube.d" "src/examples/triangle.d" "src/examples/sgl_points.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "saudio" @@ -126,12 +126,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/sgl_context.d" "src/examples/clear.d" "src/examples/triangle.d" "src/examples/sgl_points.d" "src/examples/debugtext.d" "src/examples/mrt.d" "src/examples/user_data.d" "src/examples/cube.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "mrt" @@ -141,12 +141,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/sgl_context.d" "src/examples/clear.d" "src/examples/saudio.d" "src/examples/debugtext.d" "src/examples/triangle.d" "src/examples/sgl_points.d" "src/examples/user_data.d" "src/examples/cube.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "cube" @@ -156,12 +156,12 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/sgl_context.d" "src/examples/clear.d" "src/examples/saudio.d" "src/examples/debugtext.d" "src/examples/triangle.d" "src/examples/sgl_points.d" "src/examples/user_data.d" "src/examples/mrt.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } subPackage { name "user_data" @@ -171,10 +171,10 @@ subPackage { libs "sokol" dflags "-preview=all" "-i" libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - lflags "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" + lflags "-w" "-lObjC" "-all_load" "-framework" "Cocoa" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "MetalKit" "-framework" "Metal" "-framework" "AudioToolbox" platform="osx" libs "user32" "gdi32" "kernel32" "dxgi" "d3d11" "ole32" platform="windows" lflags "-Lzig-out/lib" platform="posix" lflags "/LIBPATH:zig-out/lib" platform="windows" excludedSourceFiles "src/examples/sgl_context.d" "src/examples/clear.d" "src/examples/saudio.d" "src/examples/debugtext.d" "src/examples/triangle.d" "src/examples/sgl_points.d" "src/examples/cube.d" "src/examples/mrt.d" "src/examples/blend.d" "src/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast" + preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" } diff --git a/src/examples/clear.d b/src/examples/clear.d index 0a9daf0..c241147 100644 --- a/src/examples/clear.d +++ b/src/examples/clear.d @@ -25,11 +25,22 @@ static void init() { logger: { func: &log.slog_func }, }; sg.setup(gfx); - debug { - import std.stdio : writeln; - try { - writeln("Backend: ", sg.queryBackend()); - } catch (Exception) {} + debug + { + version (WebAssembly) + {/* none */} + else + { + import std.stdio : writeln; + + try + { + writeln("Backend: ", sg.queryBackend()); + } + catch (Exception) + { + } + } } } From 07ab4c3285ff2f4f20848afee371872641a5f5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20C=2E=20Fran=C3=A7a?= Date: Fri, 31 May 2024 20:30:11 -0300 Subject: [PATCH 2/2] `childProcess` rename ref.: https://github.com/ziglang/zig/commit/f47824f24d1b20c276a797df8cf99066c08203b6 --- tools/zigcc.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/zigcc.zig b/tools/zigcc.zig index de5ed4c..ef6ece3 100644 --- a/tools/zigcc.zig +++ b/tools/zigcc.zig @@ -55,7 +55,7 @@ pub fn main() !void { } } - var proc = std.ChildProcess.init(cmds.items, allocator); + var proc = std.process.Child.init(cmds.items, allocator); // See all flags // std.debug.print("debug flags: ", .{});