diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..34dfd1d --- /dev/null +++ b/build.ps1 @@ -0,0 +1,33 @@ +Param( + [switch]$Release +) + +$Compiler = "cl.exe" +$GeneralFlags = "/Wall /WX /wd4996" +$LibraryFlags = "/LD" +$IncludeDirs = Get-ChildItem -Path src -Recurse -Directory -ErrorAction SilentlyContinue -Force | %{$("/I " + '"' + $_.FullName + '"')} +$SrcFiles = Get-ChildItem -Path src -Recurse -Filter *.c -ErrorAction SilentlyContinue -Force | %{$('"' + $_.FullName + '"')} + +If ($Release -eq $True) { + $GeneralFlags += " /O2 /Og" + $BuildType = "release" +} Else { + $GeneralFlags += " /Zi /Od /fsanitize=address" + $BuildType = "debug" +} + +$BuildDir = "./libwapp-build/windows-$BuildType" +$ObjDir = "$BuildDir/objects" +$OutDir = "$BuildDir/output" +$OutBasename = "libwapp" +$Objects = "/Fo:$ObjDir/" +$Outputs = "/Fd:$OutDir/$OutBasename /Fe:$OutDir/$OutBasename" + +If (Test-Path $BuildDir) { + Remove-Item $BuildDir -Recurse -Force +} + +mkdir -p $ObjDir > $null +mkdir -p $OutDir > $null + +Invoke-Expression "$Compiler $GeneralFlags $LibraryFlags $IncludeDirs $SrcFiles $Objects $Outputs"