organize build script

This commit is contained in:
Judah Caruso 2026-02-20 01:04:21 -07:00
parent efa98cd686
commit b84969d109
2 changed files with 35 additions and 18 deletions

39
do.ps1
View file

@ -1,4 +1,22 @@
#!/usr/bin/env pwsh
$OUT_DIR = "out";
$DEPS_DIR = "thirdparty";
$EXE_NAME = "p2601";
$C_SOURCE = "source/main.c";
$C_INCLUDES = "-Isrc -I$DEPS_DIR";
$C_FLAGS = "-std=c23 -fblocks -g $C_INCLUDES";
$RELEASE_FLAGS = "-Ofast -Wno-everything -ffast-math";
$WINDOWS_FLAGS = "-ld3d11 -lgdi32";
$MACOS_FLAGS = "-x objective-c -lobjc -framework Foundation -framework Cocoa -framework CoreFoundation -framework CoreGraphics -framework QuartzCore -framework Metal -framework MetalKit";
$LINUX_FLAGS = "-lgl";
$WASM_FLAGS = "-c -fno-sanitize=address -fno-sanitize=undefined";
# ..............
$ErrorActionPreference = "Stop";
$HOST_OS = &{
@ -21,11 +39,7 @@ $HOST_ARCH = &{
"Arm64" { "aarch64" }
default { Write-Error "Unsupported host architecture"; }
}
}
$OUT_DIR = "out";
$DEPS_DIR = "thirdparty";
$EXE_NAME = "p2601";
};
function Get-Ext($platform) {
if ($platform -eq "windows") { return ".exe"; }
@ -44,18 +58,9 @@ $BLOCKS_RT_RUNTIME = (Join-Path $BLOCKS_RT_DIR "BlocksRuntime" "runtime.c");
$BLOCKS_RT_DATA = (Join-Path $BLOCKS_RT_DIR "BlocksRuntime" "data.c");
$BLOCKS_RT_SOURCE = "$BLOCKS_RT_RUNTIME $BLOCKS_RT_DATA";
$EMSDK_REPO = "https://github.com/emscripten-core/emsdk.git";
$EMSDK_DIR = Join-Path $DEPS_DIR "emsdk";
$C_SOURCE = "source/main.c";
$C_INCLUDES = "-Isrc -I$DEPS_DIR";
$C_FLAGS = "-std=c23 -fblocks -g $C_INCLUDES";
$RELEASE_FLAGS = "-Ofast -Wno-everything -ffast-math";
$WINDOWS_FLAGS = "-ld3d11 -lgdi32";
$MACOS_FLAGS = "-x objective-c -lobjc -framework Foundation -framework Cocoa -framework CoreFoundation -framework CoreGraphics -framework QuartzCore -framework Metal -framework MetalKit";
$LINUX_FLAGS = "-lgl";
$WASM_FLAGS = "-c -fno-sanitize=address -fno-sanitize=undefined -isystem " + (Join-Path $EMSDK_DIR "upstream" "emscripten" "cache" "sysroot" "include");
$EMSDK_REPO = "https://github.com/emscripten-core/emsdk.git";
$EMSDK_DIR = Join-Path $DEPS_DIR "emsdk";
$WASM_FLAGS += " -isystem" + (Join-Path $EMSDK_DIR "upstream" "emscripten" "cache" "sysroot" "include");
# try vendoring zig
if (-not (Test-Path $ZIG)) {

View file

@ -1,2 +1,14 @@
default:
@pwsh do.ps1 b
@pwsh do.ps1 build
windows:
@pwsh do.ps1 build-cross x86_64-windows-gnu
linux:
@pwsh do.ps1 build-cross x86_64-linux-gnu
wasm:
@pwsh do.ps1 build-cross wasm32-emscripten
clean:
@pwsh do.ps1 clean