if ($args.Count -ne 1) { $PROJECT_NAME = 'Project' } else { $PROJECT_NAME = $args[0] } New-Item -Name $PROJECT_NAME -ItemType Directory -ErrorAction Stop Set-Location -Path $PROJECT_NAME -ErrorAction Stop Write-Output "Generating project files..." zig init Remove-Item "build.zig", "src\root.zig" $BUILD_DOT_ZIG = @" const std = @import("std"); const rlz = @import("raylib_zig"); pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const raylib_dep = b.dependency("raylib_zig", .{ .target = target, .optimize = optimize, }); const raylib = raylib_dep.module("raylib"); const raylib_artifact = raylib_dep.artifact("raylib"); const exe_mod = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); exe_mod.addImport("raylib", raylib); exe_mod.linkLibrary(raylib_artifact); const run_step = b.step("run", "Run the app"); //web exports are completely separate if (target.query.os_tag == .emscripten) { const emsdk = rlz.emsdk; const wasm = b.addLibrary(.{ .name = "$PROJECT_NAME", .root_module = exe_mod, }); const install_dir: std.Build.InstallDir = .{ .custom = "web" }; const emcc_flags = emsdk.emccDefaultFlags(b.allocator, .{ .optimize = optimize, }); const emcc_settings = emsdk.emccDefaultSettings(b.allocator, .{ .optimize = optimize, }); const emcc_step = emsdk.emccStep(b, raylib_artifact, wasm, .{ .optimize = optimize, .flags = emcc_flags, .settings = emcc_settings, .shell_file_path = emsdk.shell(raylib_dep.builder), .install_dir = install_dir, .embed_paths = &.{.{ .src_path = "resources/" }}, }); b.getInstallStep().dependOn(emcc_step); const html_filename = try std.fmt.allocPrint(b.allocator, "{s}.html", .{wasm.name}); const emrun_step = emsdk.emrunStep( b, b.getInstallPath(install_dir, html_filename), &.{}, ); emrun_step.dependOn(emcc_step); run_step.dependOn(emrun_step); } else { const exe = b.addExecutable(.{ .name = "$PROJECT_NAME", .root_module = exe_mod, }); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); run_step.dependOn(&run_cmd.step); } } "@ New-Item -Name "build.zig" -ItemType "file" -Value $BUILD_DOT_ZIG -Force zig fetch --save git+https://github.com/raylib-zig/raylib-zig#devel zig fetch --save=emsdk git+https://github.com/emscripten-core/emsdk#4.0.9 New-Item -Name "resources" -ItemType "directory" New-Item -Name "resources/placeholder.txt" -ItemType "file" -Value "" -Force Copy-Item -Path "../examples/core/basic_window.zig" -Destination "src/main.zig"