diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b7b1f55..662af45 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,9 +11,6 @@ jobs: runs-on: ${{ matrix.runs-on }} steps: - uses: actions/checkout@v4 - - uses: korandoru/setup-zig@v1 - with: - zig-version: master - uses: dlang-community/setup-dlang@v2 with: compiler: ldc-master @@ -25,24 +22,6 @@ jobs: sudo apt-get install libglu1-mesa-dev mesa-common-dev xorg-dev libasound-dev - name: (Dub) Build Native - if: runner.os != 'Windows' run: | - dub build :clear - dub build :sgl_context - dub build :sgl_points - dub build :debugtext - dub build :cube - dub build :blend - dub build :triangle - dub build :mrt - dub build :user_data - dub build :imgui - dub build :droptest - - - name: (Zig) Running Test - if: runner.os != 'Windows' - run: zig build test -DzigCC - - name: (Zig) Build Native - run: zig build -Dimgui -DzigCC --summary all - - name: (Zig + emsdk) Build Wasm - run: zig build -Dimgui -DzigCC --summary all -Dtarget=wasm32-emscripten-none -Doptimize=ReleaseSmall + dub + dub -- --download-emsdk --download-zig diff --git a/.gitignore b/.gitignore index 3f75dfd..615a02b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ # Executables *.exe +*.zip +*.tar* + # DUB .dub docs.json @@ -21,12 +24,11 @@ __dummy.html docs/ *.selections.json build/ +build +bin/ # Code coverage *.lst # Zig build -*zig-*/ - -# VScode -.vscode/ \ No newline at end of file +.*/ diff --git a/build.d b/build.d new file mode 100644 index 0000000..f5f6ac4 --- /dev/null +++ b/build.d @@ -0,0 +1,416 @@ +/* +zlib/libpng license + +Copyright (c) 2023-2024 Matheus Catarino França + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the +use of this software. +*/ + +import std; + +void main(string[] args) +{ + // Parse command line arguments + bool help = false; + string compiler = findProgram("gcc"); + string target = "native"; + string optimize = "debug"; + bool downloadEmsdk = false, downloadZig = false; + SokolBackend sokol_backend = SokolBackend.auto_; + + bool opt_use_gl = false; + bool opt_use_gles3 = false; + bool opt_use_wgpu = false; + bool opt_use_x11 = true; + bool opt_use_wayland = false; + bool opt_use_egl = false; + bool opt_with_sokol_imgui = false; + + foreach (arg; args[1 .. $]) + { + if (arg == "--help") + { + help = true; + } + else if (arg.startsWith("--backend=")) + { + sokol_backend = resolveSokolBackend(arg["--backend=".length .. $].to!SokolBackend, target); + } + else if (arg.startsWith("--toolchain=")) + { + compiler = findProgram(arg["--toolchain=".length .. $]); + } + else if (arg.startsWith("--optimize=")) + { + optimize = arg["--optimize=".length .. $]; + } + else if (arg.startsWith("--target=")) + { + target = arg["--target=".length .. $]; + } + else if (arg == "--download-emsdk") + { + downloadEmsdk = true; + } + else if (arg == "--download-zig") + { + downloadZig = true; + } + } + + if (args.length < 2 || help) + { + writeln("Usage: dub run -- [options]"); + writeln("Options:"); + writeln(" --help Show this help message"); + writeln( + " --backend= Select backend (auto, d3d11, metal, gl, gles3, wgpu)"); + writeln(" --toolchain= Select C toolchain (gcc, clang, emcc)"); + writeln(" --optimize= Select optimization level (debug, release)"); + writeln(" --target= Select target (native, wasm, android)"); + writeln(" --download-emsdk Download and setup Emscripten SDK"); + writeln(" --download-zig Download and setup Zig toolchain"); + return; + } + else + { + writeln("Currently configuration:"); + writeln("Using compiler: ", compiler); + writeln("Using target: ", target); + writeln("Using optimize: ", optimize); + writeln("Using backend: ", sokol_backend); + writeln("Get EmSDK: ", downloadEmsdk); + writeln("Get Zig: ", downloadZig); + } + + LibSokolOptions options = { + target: target, + optimize: optimize, + toolchain: compiler, + backend: sokol_backend, + use_wayland: opt_use_wayland, + use_x11: opt_use_x11, + use_egl: opt_use_egl, + with_sokol_imgui: opt_with_sokol_imgui, + }; + + // buildLibSokol(options); + + // Download and setup Emscripten SDK if requested + if (downloadEmsdk) + { + getEmSDK(); + } + if (downloadZig) + { + getZigToolchain(); + } +} + +void getZigToolchain() +{ + writeln("Downloading and setting up Zig toolchain..."); + + version (Windows) + string ext = ".zip", exe = ".exe"; + else + string ext = ".tar.xz", exe = ""; + + version (Windows) + string os = "windows"; + else version (Linux) + string os = "linux"; + else version (MacOS) + string os = "macos"; + else version (FreeBSD) + string os = "freebsd"; + + version (X86_64) + string arch = "x86_64"; + else version (X86) + string arch = "x86"; + else version (AArch64) + string arch = "aarch64"; + + string zig_version = "0.13.0"; + + string filename = fmt("zig-%s-%s-%s", os, arch, zig_version); + writeln("file: ", filename ~ ext); + + // Check if the file already exists + if (!exists(filename ~ ext)) + download(fmt("https://ziglang.org/download/%s/%s", zig_version, filename ~ ext), filename ~ ext); + + // Extract Zig toolchain + if (ext.endsWith("zip")) + extractZip(filename ~ ext, ".zig"); + else + extractTarXZ(filename ~ ext, ".zig"); + + auto res = execute([fmt("./.zig/%s/zig", filename) ~ exe, "version"]); + writefln("zig version: %s", res.output); +} + +void getEmSDK() +{ + writeln("Downloading and setting up Emscripten SDK"); + + // Download EMSDK + if (!exists("emsdk.zip")) + download("https://github.com/emscripten-core/emsdk/archive/master.zip", "emsdk.zip"); + + // Extract EMSDK + extractZip("emsdk.zip", ".emsdk"); + + version (Windows) + string ext = ".bat"; + else + string ext = ""; + + // Setup EMSDK + version (Posix) + { + auto result = execute(["chmod", "+x", "./.emsdk/emsdk" ~ ext]); + enforce(result.status == 0, "Failed to chmod .emsdk/emsdk"); + } + + auto pid = spawnProcess(["./.emsdk/emsdk" ~ ext, "install", "latest"]); + wait(pid); + + pid = spawnProcess(["./.emsdk/emsdk" ~ ext, "activate", "latest"]); + wait(pid); +} + +void extractTarXZ(string tarFile, string destination) +{ + if (exists(destination)) + rmdirRecurse(destination); + + mkdir(destination); + auto pid = spawnProcess([ + "tar", "xf", tarFile, fmt("--directory=%s", destination) + ]); + enforce(pid.wait() == 0, "Extraction failed"); +} + +void extractZip(string zipFile, string destination) +{ + scope archive = new ZipArchive(read(zipFile)); + std.stdio.writeln("unpacking:"); + string prefix; + + if (exists(zipFile)) + std.file.remove(zipFile); + + if (exists(destination)) + rmdirRecurse(destination); + + mkdir(destination); + + foreach (name, _; archive.directory) + { + prefix = name[0 .. $ - name.find("/").length + 1]; + break; + } + foreach (name, am; archive.directory) + { + if (!am.expandedSize) + continue; + + string path = buildPath(destination, chompPrefix(name, prefix)); + std.stdio.writeln(path); + auto dir = dirName(path); + if (!dir.empty && !dir.exists) + mkdirRecurse(dir); + archive.expand(am); + std.file.write(path, am.expandedData); + } +} + +void download(string url, string fileName) +{ + + auto buf = appender!(ubyte[])(); + size_t contentLength; + + auto http = HTTP(url); + http.method = HTTP.Method.get; + http.onReceiveHeader((in k, in v) { + if (k == "content-length") + contentLength = to!size_t(v); + }); + http.onReceive((data) { + buf.put(data); + std.stdio.writef("%sk/%sk\r", buf.data.length / 1024, + contentLength ? to!string(contentLength / 1024) : "?"); + std.stdio.stdout.flush(); + return data.length; + }); + http.dataTimeout = dur!"msecs"(0); + http.perform(); + immutable sc = http.statusLine().code; + enforce(sc / 100 == 2 || sc == 302, + fmt("HTTP request returned status code %s", sc)); + std.stdio.writeln("done "); + + auto file = File(fileName, "wb"); + scope (success) + file.close(); + file.rawWrite(buf.data); +} + +enum SokolBackend : ushort +{ + auto_, // Windows: D3D11, macOS/iOS: Metal, otherwise: GL + d3d11, + metal, + gl, + gles3, + wgpu +} + +struct LibSokolOptions +{ + string target; + string optimize; + string toolchain; + SokolBackend backend = SokolBackend.auto_; + bool use_egl = false; + bool use_x11 = true; + bool use_wayland = false; + string emsdk = null; + bool with_sokol_imgui = false; +} + +// Helper function to resolve .auto backend based on target platform +SokolBackend resolveSokolBackend(SokolBackend backend, string target) +{ + if (backend != SokolBackend.auto_) + { + return backend; + } + else if (target.canFind("darwin")) + { + return SokolBackend.metal; + } + else if (target.canFind("windows")) + { + return SokolBackend.d3d11; + } + else if (target.canFind("wasm")) + { + return SokolBackend.gles3; + } + else if (target.canFind("android")) + { + return SokolBackend.gles3; + } + else + { + return SokolBackend.gl; + } +} + +string rootPath() +{ + return __FILE__.dirName; +} + +// Build sokol into a static library +void buildLibSokol(LibSokolOptions options) +{ + bool sharedlib = false; + + string libName = "sokol"; + string[] cflags = ["-DIMPL"]; + + // Resolve .auto backend into specific backend by platform + SokolBackend backend = resolveSokolBackend(options.backend, options.target); + string backendCflag = "-DSOKOL_" ~ backend.to!string.toUpper; + cflags ~= backendCflag; + + // Platform specific compile and link options + if (options.target.canFind("darwin")) + { + cflags ~= "-ObjC"; + // Add framework linking for Darwin platforms + // ... + } + else if (options.target.canFind("android")) + { + if (backend != SokolBackend.gles3) + { + throw new Exception("For android targets, you must have backend set to GLES3"); + } + // Add Android-specific libraries + // ... + } + else if (options.target.canFind("linux")) + { + if (options.use_egl) + cflags ~= "-DSOKOL_FORCE_EGL"; + if (!options.use_x11) + cflags ~= "-DSOKOL_DISABLE_X11"; + if (!options.use_wayland) + cflags ~= "-DSOKOL_DISABLE_WAYLAND"; + // Add Linux-specific libraries + // ... + } + else if (options.target.canFind("windows")) + { + // Add Windows-specific libraries + // ... + } + + // Add C source files + string csrcRoot = "src/sokol/c/"; + string[] csources = [ + "sokol_log.c", "sokol_app.c", "sokol_gfx.c", "sokol_time.c", + "sokol_audio.c", "sokol_gl.c", "sokol_debugtext.c", "sokol_shape.c", + "sokol_fetch.c", "sokol_glue.c" + ]; + + foreach (csrc; csources) + { + string fullPath = buildPath(csrcRoot, csrc); + // Add compilation command for each C source file + } + + if (options.with_sokol_imgui) + { + string imgui_src = buildPath(csrcRoot, "sokol_imgui.c"); + // Add compilation command for sokol_imgui.c + + // Build and link cimgui + } +} + +string findProgram(string programName) @safe +{ + string[] paths = environment.get("PATH").split(pathSeparator); + foreach (path; paths) + { + string fullPath = buildPath(path, programName); + version (Windows) + { + fullPath ~= ".exe"; + } + if (exists(fullPath) && isFile(fullPath)) + { + return fullPath; + } + } + throw new Exception("Could not find program: " ~ programName); + // return null; +} + +string fmt(Args...)(string fmt, auto ref Args args) +{ + import std.array, std.format; + + auto app = appender!string(); + formattedWrite(app, fmt, args); + return app.data; +} diff --git a/dub.sdl b/dub.sdl index 620ebd9..1e9fdfc 100644 --- a/dub.sdl +++ b/dub.sdl @@ -4,6 +4,10 @@ description "D bindings for sokol" authors "Matheus Catarino França" "Andre Weissflog" copyright "Copyright 2023-2024 - Matheus Catarino França" license "Zlib" +targetType "executable" + +sourceFiles "build.d" +postBuildCommands "./sokol-d" buildType "debug" { buildOptions "debugMode" "debugInfo" @@ -26,196 +30,191 @@ buildType "release-debug" { } toolchainRequirements dmd=">=2.105.0" ldc=">=1.35.0" gdc=">=9.3.0" -configuration "default" { - targetType "sourceLibrary" - sourcePaths "src" -} - -configuration "unittest" { - targetType "library" - sourcePaths "src/handmade" -} - -subPackage { - name "clear" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/clear.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "sgl_context" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/sgl_context.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "sgl_points" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/sgl_points.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "debugtext" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/debugtext.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "triangle" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/triangle.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "blend" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/blend.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "saudio" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/saudio.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "mrt" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/mrt.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "cube" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/cube.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "user_data" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/user_data.d" - libs "sokol" - dflags "-preview=all" "-i" - libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" - 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" -} - -subPackage { - name "imgui" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/imgui.d" - libs "sokol" - 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/examples/user_data.d" "src/examples/droptest.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Dshared -Doptimize=ReleaseFast -Dimgui -Dartifact" -} - -subPackage { - name "droptest" - targetType "executable" - targetPath "build" - sourceFiles "src/examples/droptest.d" - libs "sokol" - 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/examples/user_data.d" "src/examples/imgui.d" "src/examples/shaders/*.d" - preBuildCommands "zig build -Dshared -Doptimize=ReleaseFast -Dimgui -Dartifact" -} +// configuration "unittest" { +// targetType "library" +// sourcePaths "src/handmade" +// } + +// subPackage { +// name "clear" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/clear.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "sgl_context" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/sgl_context.d" +// libs "sokol" +dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "sgl_points" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/sgl_points.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/handmade/*.d" "src/sokol/*.d" "src/examples/clear.d" "src/examples/sgl_points.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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "debugtext" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/debugtext.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "triangle" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/triangle.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "blend" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/blend.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "saudio" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/saudio.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "mrt" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/mrt.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "cube" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/cube.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "user_data" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/user_data.d" +// libs "sokol" +// dflags "-preview=all" "-i" +// libs "X11" "Xcursor" "Xi" "GL" "asound" platform="linux" +// 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/examples/imgui.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Doptimize=ReleaseFast -Dartifact" +// } + +// subPackage { +// name "imgui" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/imgui.d" +// libs "sokol" +// 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/examples/user_data.d" "src/examples/droptest.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Dshared -Doptimize=ReleaseFast -Dimgui -Dartifact" +// } + +// subPackage { +// name "droptest" +// targetType "executable" +// targetPath "build" +// sourceFiles "src/examples/droptest.d" +// libs "sokol" +// 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/examples/user_data.d" "src/examples/imgui.d" "src/examples/shaders/*.d" +// preBuildCommands "zig build -Dshared -Doptimize=ReleaseFast -Dimgui -Dartifact" +// }