2023-10-06 10:06:40 -07:00
|
|
|
Clear-Host
|
2023-10-01 17:17:14 -07:00
|
|
|
|
2023-10-23 23:04:44 -07:00
|
|
|
$target_arch = Join-Path $PSScriptRoot 'helpers/target_arch.psm1'
|
|
|
|
$devshell = Join-Path $PSScriptRoot 'helpers/devshell.ps1'
|
|
|
|
$format_cpp = Join-Path $PSScriptRoot 'helpers/format_cpp.psm1'
|
|
|
|
$incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1'
|
|
|
|
$vendor_toolchain = Join-Path $PSScriptRoot 'helpers/vendor_toolchain.ps1'
|
|
|
|
$update_deps = Join-Path $PSScriptRoot 'update_deps.ps1'
|
2023-09-08 09:42:24 -07:00
|
|
|
|
2023-09-23 18:03:33 -07:00
|
|
|
$path_root = git rev-parse --show-toplevel
|
2023-10-06 10:06:40 -07:00
|
|
|
$path_build = Join-Path $path_root 'build'
|
2023-09-23 18:03:33 -07:00
|
|
|
|
|
|
|
Import-Module $target_arch
|
2023-10-01 17:17:14 -07:00
|
|
|
Import-Module $format_cpp
|
2023-09-08 09:42:24 -07:00
|
|
|
|
|
|
|
#region Arguments
|
2023-10-10 10:08:08 -07:00
|
|
|
$vendor = $null
|
|
|
|
$optimize = $null
|
|
|
|
$debug = $null
|
|
|
|
$analysis = $false
|
|
|
|
$dev = $false
|
|
|
|
$verbose = $null
|
|
|
|
$platform = $null
|
|
|
|
$engine = $null
|
|
|
|
$game = $null
|
|
|
|
$module_specified = $false
|
2023-09-08 09:42:24 -07:00
|
|
|
|
|
|
|
[array] $vendors = @( "clang", "msvc" )
|
|
|
|
|
|
|
|
# This is a really lazy way of parsing the args, could use actual params down the line...
|
|
|
|
|
|
|
|
if ( $args ) { $args | ForEach-Object {
|
|
|
|
switch ($_){
|
2023-09-15 18:35:27 -07:00
|
|
|
{ $_ -in $vendors } { $vendor = $_; break }
|
2023-09-28 15:38:06 -07:00
|
|
|
"optimize" { $optimize = $true }
|
2023-09-15 18:35:27 -07:00
|
|
|
"debug" { $debug = $true }
|
|
|
|
"analysis" { $analysis = $true }
|
2023-09-18 17:16:40 -07:00
|
|
|
"dev" { $dev = $true }
|
2023-10-01 17:17:14 -07:00
|
|
|
"verbose" { $verbose = $true }
|
2023-10-23 23:04:44 -07:00
|
|
|
"platform" { $platform = $true; $module_specified = $true }
|
2023-10-10 10:08:08 -07:00
|
|
|
"engine" { $engine = $true; $module_specified = $true }
|
|
|
|
"game" { $game = $true; $module_specified = $true }
|
2023-09-08 09:42:24 -07:00
|
|
|
}
|
|
|
|
}}
|
2023-09-15 18:35:27 -07:00
|
|
|
#endregion Argument
|
2023-09-08 09:42:24 -07:00
|
|
|
|
2023-10-10 10:08:08 -07:00
|
|
|
if ( -not $module_specified )
|
|
|
|
{
|
|
|
|
$platform = $true
|
|
|
|
$engine = $true
|
|
|
|
$game = $true
|
|
|
|
}
|
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
# Load up toolchain configuraion
|
2023-10-23 23:04:44 -07:00
|
|
|
. $vendor_toolchain
|
|
|
|
. $incremental_checks
|
2023-10-10 10:08:08 -07:00
|
|
|
|
2023-09-26 14:26:35 -07:00
|
|
|
#region Building
|
2023-10-06 10:06:40 -07:00
|
|
|
write-host "Building HandmadeHero with $vendor"
|
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$path_project = Join-Path $path_root 'project'
|
|
|
|
$path_scripts = Join-Path $path_root 'scripts'
|
|
|
|
$path_data = Join-Path $path_root 'data'
|
|
|
|
$path_binaries = Join-Path $path_data 'binaries'
|
|
|
|
$path_deps = Join-Path $path_project 'dependencies'
|
|
|
|
$path_codegen = Join-Path $path_project 'codegen'
|
|
|
|
$path_platform = Join-Path $path_project 'platform'
|
|
|
|
$path_engine = Join-Path $path_project 'engine'
|
|
|
|
$path_engine_gen = Join-Path $path_engine 'gen'
|
|
|
|
|
2023-09-28 18:21:05 -07:00
|
|
|
$handmade_process_active = Get-Process | Where-Object {$_.Name -like 'handmade_win32*'}
|
|
|
|
|
2023-09-08 09:42:24 -07:00
|
|
|
if ( (Test-Path $path_build) -eq $false ) {
|
|
|
|
New-Item $path_build -ItemType Directory
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (Test-Path $path_deps) -eq $false ) {
|
|
|
|
& $update_deps
|
|
|
|
}
|
|
|
|
|
2023-09-26 22:16:41 -07:00
|
|
|
if ( (Test-Path $path_binaries) -eq $false ) {
|
|
|
|
New-Item $path_binaries -ItemType Directory
|
|
|
|
}
|
|
|
|
|
2023-09-08 12:14:09 -07:00
|
|
|
#region Handmade Runtime
|
2023-09-09 14:06:47 -07:00
|
|
|
$includes = @(
|
2023-09-26 14:26:35 -07:00
|
|
|
$path_project
|
2023-09-09 14:06:47 -07:00
|
|
|
)
|
2023-09-09 17:14:40 -07:00
|
|
|
|
|
|
|
# Microsoft
|
2023-09-08 18:08:57 -07:00
|
|
|
$lib_gdi32 = 'Gdi32.lib'
|
2023-09-09 14:06:47 -07:00
|
|
|
$lib_xinput = 'Xinput.lib'
|
|
|
|
$lib_user32 = 'User32.lib'
|
2023-09-22 12:13:18 -07:00
|
|
|
$lib_winmm = 'Winmm.lib'
|
2023-09-08 15:54:16 -07:00
|
|
|
|
2023-09-09 17:14:40 -07:00
|
|
|
# Github
|
|
|
|
$lib_jsl = Join-Path $path_deps 'JoyShockLibrary/x64/JoyShockLibrary.lib'
|
|
|
|
|
2023-09-16 15:41:07 -07:00
|
|
|
$stack_size = 1024 * 1024 * 4
|
|
|
|
|
2023-09-15 18:35:27 -07:00
|
|
|
$compiler_args = @(
|
|
|
|
($flag_define + 'UNICODE'),
|
|
|
|
($flag_define + '_UNICODE')
|
2023-10-23 23:04:44 -07:00
|
|
|
( $flag_define + 'INTELLISENSE_DIRECTIVES=0'),
|
2023-09-16 15:41:07 -07:00
|
|
|
# ($flag_set_stack_size + $stack_size)
|
2023-09-20 21:26:23 -07:00
|
|
|
$flag_wall
|
|
|
|
$flag_warnings_as_errors
|
|
|
|
$flag_optimize_intrinsics
|
2023-09-15 18:35:27 -07:00
|
|
|
)
|
2023-09-08 14:50:22 -07:00
|
|
|
|
2023-09-18 17:16:40 -07:00
|
|
|
if ( $dev ) {
|
|
|
|
$compiler_args += ( $flag_define + 'Build_Development=1' )
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$compiler_args += ( $flag_define + 'Build_Development=0' )
|
|
|
|
}
|
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
function build-engine
|
2023-09-26 14:26:35 -07:00
|
|
|
{
|
2023-10-22 18:52:41 -07:00
|
|
|
$unit = Join-Path $path_codegen 'engine_gen.cpp'
|
|
|
|
$should_build = (check-FileForChanges $unit) -eq $true
|
|
|
|
if ( $should_build )
|
|
|
|
{
|
2023-10-28 14:10:30 -07:00
|
|
|
$executable = Join-Path $path_build 'engine_gen.exe'
|
2023-10-22 18:52:41 -07:00
|
|
|
|
|
|
|
$compiler_args = @()
|
|
|
|
$compiler_args += ( $flag_define + 'GEN_TIME' )
|
|
|
|
|
|
|
|
$linker_args = @(
|
|
|
|
$flag_link_win_subsystem_console
|
|
|
|
)
|
|
|
|
|
|
|
|
$build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
|
|
|
|
if ( $build_result -eq $false ) {
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
|
|
|
|
Push-Location $path_engine_gen
|
|
|
|
$time_taken = Measure-Command {
|
|
|
|
& $executable 2>&1 | ForEach-Object {
|
|
|
|
write-host `t $_ -ForegroundColor Green
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Pop-Location
|
|
|
|
|
|
|
|
push-location $path_scripts
|
|
|
|
$include = @(
|
|
|
|
'*.cpp'
|
|
|
|
'*.hpp'
|
|
|
|
)
|
|
|
|
format-cpp $path_engine_gen $include
|
|
|
|
pop-location
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
write-host "No changes detected in engine gen, skipping build" -ForegroundColor Yellow
|
|
|
|
}
|
|
|
|
|
2023-10-10 10:08:08 -07:00
|
|
|
$should_build = check-ModuleForChanges $path_engine
|
|
|
|
if ( $should_build -eq $false ) {
|
|
|
|
write-host "No changes detected in engine module, skipping build" -ForegroundColor Yellow
|
2023-10-10 21:56:16 -07:00
|
|
|
return $true
|
2023-10-10 10:08:08 -07:00
|
|
|
}
|
2023-10-20 20:15:35 -07:00
|
|
|
write-host "`nBuilding Engine Module" -ForegroundColor Green
|
2023-10-10 10:08:08 -07:00
|
|
|
|
2023-09-28 10:44:43 -07:00
|
|
|
$path_pdb_lock = Join-Path $path_binaries 'handmade_engine.pdb.lock'
|
2023-10-10 21:56:16 -07:00
|
|
|
New-Item $path_pdb_lock -ItemType File -Force > $null
|
2023-09-28 10:44:43 -07:00
|
|
|
|
|
|
|
# Delete old PDBs
|
|
|
|
[Array]$pdb_files = Get-ChildItem -Path $path_binaries -Filter "handmade_engine_*.pdb"
|
2023-09-26 22:16:41 -07:00
|
|
|
foreach ($file in $pdb_files) {
|
|
|
|
Remove-Item -Path $file.FullName -Force
|
2023-10-01 17:17:14 -07:00
|
|
|
if ( $verbose ) { Write-Host "Deleted $file" -ForegroundColor Green }
|
2023-09-26 22:16:41 -07:00
|
|
|
}
|
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
#region Building Engine Module Runtime
|
|
|
|
$local:includes = $script:includes
|
|
|
|
$includes += $path_engine
|
2023-10-06 23:33:39 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$local:compiler_args = $script:compiler_args
|
|
|
|
$compiler_args += ($flag_define + 'Build_DLL=1' )
|
2023-09-09 17:14:40 -07:00
|
|
|
|
2023-10-23 21:42:55 -07:00
|
|
|
if ( $IsWindows ) {
|
2023-10-20 20:15:35 -07:00
|
|
|
$compiler_args += ($flag_define + 'Engine_API=__declspec(dllexport)')
|
|
|
|
}
|
2023-10-23 21:42:55 -07:00
|
|
|
else {
|
2023-10-20 20:15:35 -07:00
|
|
|
$compiler_args += ($flag_define + 'Engine_API=__attribute__((visibility("default")))')
|
|
|
|
}
|
2023-09-09 17:14:40 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$local:linker_args = @(
|
|
|
|
$flag_link_dll
|
|
|
|
# $flag_link_optimize_references
|
|
|
|
)
|
2023-09-08 09:42:24 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$unit = Join-Path $path_project 'handmade_engine.cpp'
|
|
|
|
$dynamic_library = Join-Path $path_binaries 'handmade_engine.dll'
|
2023-09-26 14:26:35 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $dynamic_library
|
2023-09-26 14:26:35 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
Remove-Item $path_pdb_lock -Force
|
2023-09-26 14:26:35 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
if ( $build_result -eq $false ) {
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
#endregion
|
2023-10-10 21:56:16 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
#CodeGen Post-Build
|
2023-10-10 21:56:16 -07:00
|
|
|
if ( -not $handmade_process_active -and $build_result )
|
|
|
|
{
|
2023-10-10 10:08:08 -07:00
|
|
|
$path_engine_symbols = Join-Path $path_build 'handmade_engine.symbols'
|
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
# Create the symbol table
|
|
|
|
if ( Test-Path $dynamic_library )
|
|
|
|
{
|
|
|
|
# $data_path = Join-Path $path_data 'handmade_engine.dll'
|
|
|
|
# move-item $dynamic_library $data_path -Force
|
|
|
|
$path_lib = $dynamic_library -replace '\.dll', '.lib'
|
|
|
|
$path_exp = $dynamic_library -replace '\.dll', '.exp'
|
|
|
|
Remove-Item $path_lib -Force
|
|
|
|
if ( Test-Path $path_exp ) { Remove-Item $path_exp -Force }
|
|
|
|
|
|
|
|
# We need to generate the symbol table so that we can lookup the symbols we need when loading/reloading the library at runtime.
|
|
|
|
# This is done by sifting through the emitter.map file from the linker for the base symbol names
|
|
|
|
# and mapping them to their found decorated name
|
|
|
|
|
|
|
|
# Initialize the hashtable with the desired order of symbols
|
|
|
|
$engine_symbols = [ordered]@{
|
|
|
|
'on_module_reload' = $null
|
|
|
|
'startup' = $null
|
|
|
|
'shutdown' = $null
|
|
|
|
'update_and_render' = $null
|
|
|
|
'update_audio' = $null
|
2023-09-28 15:38:06 -07:00
|
|
|
}
|
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
$path_engine_obj = Join-Path $path_build 'handmade_engine.obj'
|
|
|
|
$path_engine_map = Join-Path $path_build 'handmade_engine.map'
|
|
|
|
$maxNameLength = ($engine_symbols.Keys | Measure-Object -Property Length -Maximum).Maximum
|
|
|
|
|
|
|
|
Get-Content -Path $path_engine_map | ForEach-Object {
|
|
|
|
# If all symbols are found, exit the loop
|
|
|
|
if ($engine_symbols.Values -notcontains $null) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
# Split the line into tokens
|
|
|
|
$tokens = $_ -split '\s+', 4
|
|
|
|
# Extract only the decorated name using regex for both MSVC and Clang conventions
|
|
|
|
$decoratedName = ($tokens[2] -match '(\?[\w@]+|_Z[\w@]+)') ? $matches[1] : $null
|
|
|
|
|
|
|
|
# Check the origin of the symbol
|
|
|
|
# If the origin matches 'handmade_engine.obj', then process the symbol
|
|
|
|
$originParts = $tokens[3] -split '\s+'
|
|
|
|
$origin = if ($originParts.Count -eq 3) { $originParts[2] } else { $originParts[1] }
|
|
|
|
|
|
|
|
# Diagnostic output
|
|
|
|
if ( $false -and $decoratedName) {
|
|
|
|
write-host "Found decorated name: $decoratedName" -ForegroundColor Yellow
|
|
|
|
write-host "Origin : $origin" -ForegroundColor Yellow
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($origin -like 'handmade_engine.obj') {
|
|
|
|
# Check each regular name against the current line
|
|
|
|
$engine_symbols.Keys | Where-Object { $engine_symbols[$_] -eq $null } | ForEach-Object {
|
|
|
|
if ($decoratedName -like "*$_*") {
|
|
|
|
$engine_symbols[$_] = $decoratedName
|
|
|
|
}
|
2023-09-28 15:38:06 -07:00
|
|
|
}
|
2023-09-26 14:26:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
if ($verbose) { write-host "Engine Symbol Table:" -ForegroundColor Green }
|
|
|
|
$engine_symbols.GetEnumerator() | ForEach-Object {
|
|
|
|
$paddedName = $_.Key.PadRight($maxNameLength)
|
|
|
|
$decoratedName = $_.Value
|
|
|
|
if ($verbose ) { write-host "`t$paddedName, $decoratedName" -ForegroundColor Green }
|
|
|
|
}
|
2023-09-28 10:44:43 -07:00
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
# Write the symbol table to a file
|
|
|
|
$engine_symbols.Values | Out-File -Path $path_engine_symbols
|
|
|
|
}
|
2023-10-20 20:15:35 -07:00
|
|
|
else {
|
|
|
|
return $false
|
2023-09-28 18:57:52 -07:00
|
|
|
}
|
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$unit = Join-Path $path_codegen 'engine_postbuild_gen.cpp'
|
|
|
|
$executable = Join-Path $path_build 'engine_postbuild_gen.exe'
|
|
|
|
$should_build = (check-FileForChanges $unit) -eq $true
|
|
|
|
if ( $should_build )
|
|
|
|
{
|
|
|
|
$compiler_args = @()
|
|
|
|
$compiler_args += ( $flag_define + 'GEN_TIME' )
|
2023-09-28 17:22:15 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$linker_args = @(
|
|
|
|
$flag_link_win_subsystem_console
|
|
|
|
)
|
2023-09-28 17:22:15 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$build_result = build-simple $path_build $local:includes $compiler_args $linker_args $unit $executable
|
|
|
|
if ( $build_result -eq $false ) {
|
|
|
|
return $false
|
2023-10-01 17:17:14 -07:00
|
|
|
}
|
2023-10-20 20:15:35 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
write-host "No changes detected in engine post-build gen, skipping build" -ForegroundColor Yellow
|
|
|
|
}
|
2023-10-10 21:56:16 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
Push-Location $path_build
|
|
|
|
$time_taken = Measure-Command {
|
|
|
|
& $executable 2>&1 | ForEach-Object {
|
|
|
|
write-host `t $_ -ForegroundColor Green
|
|
|
|
}
|
2023-10-01 17:17:14 -07:00
|
|
|
}
|
2023-10-20 20:15:35 -07:00
|
|
|
Pop-Location
|
2023-09-28 17:22:15 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
$path_generated_file = Join-Path $path_build 'engine_symbols.gen.hpp'
|
|
|
|
move-item $path_generated_file (join-path $path_engine_gen (split-path $path_generated_file -leaf)) -Force
|
|
|
|
|
|
|
|
push-location $path_scripts
|
|
|
|
$include = @(
|
|
|
|
'*.cpp'
|
|
|
|
'*.hpp'
|
|
|
|
)
|
|
|
|
format-cpp $path_engine_gen $include
|
|
|
|
pop-location
|
|
|
|
|
|
|
|
return $true
|
2023-09-28 17:22:15 -07:00
|
|
|
}
|
2023-10-01 17:17:14 -07:00
|
|
|
}
|
|
|
|
if ( $engine ) {
|
2023-10-10 21:56:16 -07:00
|
|
|
$build_result = build-engine
|
|
|
|
if ( $build_result -eq $false ) {
|
|
|
|
$path_csv = Join-Path $path_build 'engine_module_hashes.csv'
|
|
|
|
Remove-Item $path_csv -Force
|
|
|
|
}
|
2023-09-28 18:21:05 -07:00
|
|
|
}
|
2023-09-28 17:22:15 -07:00
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
function build-platform
|
2023-09-28 18:21:05 -07:00
|
|
|
{
|
2023-10-10 10:08:08 -07:00
|
|
|
if ( $handmade_process_active ) {
|
|
|
|
write-host "Handmade process is active, skipping platform build" -ForegroundColor Yellow
|
2023-10-10 21:56:16 -07:00
|
|
|
return $true
|
2023-10-10 10:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
$should_build = check-ModuleForChanges $path_platform
|
|
|
|
if ( $should_build -eq $false ) {
|
|
|
|
write-host "No changes detected in platform module, skipping build" -ForegroundColor Yellow
|
2023-10-10 21:56:16 -07:00
|
|
|
return $true
|
2023-10-10 10:08:08 -07:00
|
|
|
}
|
2023-10-20 20:15:35 -07:00
|
|
|
write-host "Building Platform Module" -ForegroundColor Green
|
2023-10-10 10:08:08 -07:00
|
|
|
|
2023-10-21 22:46:01 -07:00
|
|
|
$local:includes = $script:includes
|
|
|
|
$includes += $path_platform
|
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
# CodeGen Pre-Build
|
2023-10-20 20:15:35 -07:00
|
|
|
$path_engine_symbols = Join-Path $path_engine_gen 'engine_symbols.gen.hpp'
|
|
|
|
$unit = Join-Path $path_codegen 'platform_gen.cpp'
|
|
|
|
$should_build = (check-FileForChanges $unit) -eq $true -or (check-FileForChanges $path_engine_symbols) -eq $true
|
|
|
|
if ( $should_build )
|
2023-10-01 17:17:14 -07:00
|
|
|
{
|
|
|
|
# Delete old PDBs
|
|
|
|
$pdb_files = Get-ChildItem -Path $path_build -Filter "platform_gen_*.pdb"
|
|
|
|
foreach ($file in $pdb_files) {
|
|
|
|
Remove-Item -Path $file.FullName -Force
|
|
|
|
if ( $verbose ) { Write-Host "Deleted $file" -ForegroundColor Green }
|
|
|
|
}
|
|
|
|
|
|
|
|
$path_platform_gen = Join-Path $path_platform 'gen'
|
|
|
|
|
|
|
|
if ( -not (Test-Path $path_platform_gen) ) {
|
2023-10-10 21:56:16 -07:00
|
|
|
New-Item $path_platform_gen -ItemType Directory > $null
|
2023-10-01 17:17:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
$local:compiler_args = @()
|
|
|
|
$compiler_args += ( $flag_define + 'GEN_TIME' )
|
|
|
|
|
|
|
|
$local:linker_args = @(
|
|
|
|
$flag_link_win_subsystem_console
|
|
|
|
)
|
|
|
|
|
|
|
|
$unit = Join-Path $path_codegen 'platform_gen.cpp'
|
2023-10-10 10:08:08 -07:00
|
|
|
$executable = Join-Path $path_build 'platform_gen.exe'
|
2023-10-01 17:17:14 -07:00
|
|
|
|
2023-10-10 21:56:16 -07:00
|
|
|
$build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable $path_build
|
|
|
|
if ( $build_result -eq $false ) {
|
|
|
|
return $false
|
|
|
|
}
|
2023-10-01 17:17:14 -07:00
|
|
|
|
|
|
|
Push-Location $path_platform
|
|
|
|
$time_taken = Measure-Command {
|
|
|
|
& $executable 2>&1 | ForEach-Object {
|
|
|
|
write-host `t $_ -ForegroundColor Green
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Pop-Location
|
2023-10-10 10:08:08 -07:00
|
|
|
|
2023-10-20 20:15:35 -07:00
|
|
|
push-location $path_scripts
|
|
|
|
$include = @(
|
|
|
|
'*.cpp'
|
|
|
|
'*.hpp'
|
|
|
|
)
|
|
|
|
format-cpp (Join-Path $path_platform 'gen' ) $include
|
|
|
|
pop-location
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
write-host "No changes detected in platform gen, skipping build" -ForegroundColor Yellow
|
2023-10-01 17:17:14 -07:00
|
|
|
}
|
|
|
|
|
2023-09-28 18:21:05 -07:00
|
|
|
# Delete old PDBs
|
2023-09-26 22:16:41 -07:00
|
|
|
$pdb_files = Get-ChildItem -Path $path_binaries -Filter "handmade_win32_*.pdb"
|
|
|
|
foreach ($file in $pdb_files) {
|
|
|
|
Remove-Item -Path $file.FullName -Force
|
2023-10-01 17:17:14 -07:00
|
|
|
if ( $verbose ) { Write-Host "Deleted $file" -ForegroundColor Green }
|
2023-09-26 22:16:41 -07:00
|
|
|
}
|
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
$local:compiler_args = $script:compiler_args
|
|
|
|
$compiler_args += ($flag_define + 'Build_DLL=0' )
|
2023-09-26 14:26:35 -07:00
|
|
|
|
2023-10-01 17:17:14 -07:00
|
|
|
$local:linker_args = @(
|
2023-09-26 14:26:35 -07:00
|
|
|
$lib_gdi32,
|
|
|
|
# $lib_xinput,
|
|
|
|
$lib_user32,
|
|
|
|
$lib_winmm,
|
|
|
|
|
|
|
|
$lib_jsl,
|
|
|
|
|
2023-10-06 10:06:40 -07:00
|
|
|
$flag_link_win_subsystem_windows,
|
2023-09-28 17:22:15 -07:00
|
|
|
$flag_link_optimize_references
|
2023-09-26 14:26:35 -07:00
|
|
|
)
|
|
|
|
|
2023-09-26 22:16:41 -07:00
|
|
|
$unit = Join-Path $path_project 'handmade_win32.cpp'
|
|
|
|
$executable = Join-Path $path_binaries 'handmade_win32.exe'
|
2023-09-26 14:26:35 -07:00
|
|
|
|
2023-10-10 21:56:16 -07:00
|
|
|
return build-simple $path_build $includes $compiler_args $linker_args $unit $executable
|
2023-09-26 22:16:41 -07:00
|
|
|
}
|
2023-10-01 17:17:14 -07:00
|
|
|
if ( $platform ) {
|
2023-10-10 21:56:16 -07:00
|
|
|
$build_result = build-platform
|
|
|
|
if ( -not $build_result ) {
|
|
|
|
$path_csv = Join-Path $path_build 'platform_module_hashes.csv'
|
|
|
|
Remove-Item $path_csv -Force
|
|
|
|
}
|
2023-10-01 17:17:14 -07:00
|
|
|
}
|
2023-09-26 22:16:41 -07:00
|
|
|
|
|
|
|
$path_jsl_dll = Join-Path $path_binaries 'JoyShockLibrary.dll'
|
|
|
|
if ( (Test-Path $path_jsl_dll) -eq $false )
|
|
|
|
{
|
|
|
|
$path_jsl_dep_dll = Join-Path $path_deps 'JoyShockLibrary/x64/JoyShockLibrary.dll'
|
|
|
|
Copy-Item $path_jsl_dep_dll $path_jsl_dll
|
2023-09-26 14:26:35 -07:00
|
|
|
}
|
2023-09-08 12:14:09 -07:00
|
|
|
#endregion Handmade Runtime
|
|
|
|
|
|
|
|
Pop-Location
|
2023-09-26 14:26:35 -07:00
|
|
|
#endregion Building
|