diff --git a/project/IO.cpp b/project/IO.cpp index 4e5ba68..920a246 100644 --- a/project/IO.cpp +++ b/project/IO.cpp @@ -50,7 +50,7 @@ namespace IO zpl_file_close( & src ); } - while ( path++, left--, left > 1 ); + while ( path++, left--, left > 0 ); uw persist_size = Largest_Src_Size * 2 + 8; diff --git a/scripts/build.ci.ps1 b/scripts/build.ci.ps1 index c223798..0553a9d 100644 --- a/scripts/build.ci.ps1 +++ b/scripts/build.ci.ps1 @@ -29,7 +29,10 @@ if ( -not( Test-Path $path_build ) ) $args_meson += "setup" $args_meson += $path_build - Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts + # Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts + Push-Location $path_scripts + & meson $args_meson + Pop-Location } if ( $type ) @@ -39,14 +42,19 @@ if ( $type ) $args_meson += $path_build $args_meson += "--buildtype $($type)" - Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts + # Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts + Push-Location $path_scripts + meson $args_meson + Pop-Location } $args_ninja = @() $args_ninja += "-C" $args_ninja += $path_build -Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root +Push-Location $path_root +ninja $args_ninja +Pop-Location #endregion Regular Build @@ -56,7 +64,8 @@ if ( $test -eq $true ) write-host "`n`nBuilding Test`n" # Refactor thirdparty libraries - & (Join-Path $PSScriptRoot 'refactor_and_format.ps1') + Invoke-Expression "& $(Join-Path $PSScriptRoot 'refactor_and_format.ps1') $args" + $path_test = Join-Path $path_root test $path_test_build = Join-Path $path_test build @@ -67,15 +76,17 @@ if ( $test -eq $true ) $args_meson += "setup" $args_meson += $path_test_build - Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_test + Push-Location $path_test + & meson $args_meson + Pop-Location } $args_ninja = @() $args_ninja += "-C" $args_ninja += $path_test_build - write-host $args_ninja - - Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root + Push-Location $path_root + ninja $args_ninja + Pop-Location #endregion Test Build } diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 3885667..4bbfb15 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -1,2 +1,2 @@ cls -& (Join-Path $PSScriptRoot 'build.ci.ps1') +Invoke-Expression "& $(Join-Path $PSScriptRoot 'build.ci.ps1') $args" diff --git a/scripts/refactor_and_format.ps1 b/scripts/refactor_and_format.ps1 index 9ff9488..86af64b 100644 --- a/scripts/refactor_and_format.ps1 +++ b/scripts/refactor_and_format.ps1 @@ -25,48 +25,43 @@ foreach ( $file in $targetFiles ) } -write-host "Beginning thirdpary refactor...`n" +write-host "Beginning thirdpary refactor..." $refactors = @(@()) -if ( $false ){ - foreach ( $file in $targetFiles ) - { - $destination = Join-Path $path_test (Split-Path $file -leaf) - $destination = $destination.Replace( '.h', '.refactored.h' ) - - $refactorParams = @( - "-src=$($file)", - "-dst=$($destination)" - "-spec=$($file_spec)" - ) - - $refactors += (Start-Process $refactor $refactorParams -NoNewWindow -PassThru) - } -} -else { - $refactorParams = @( - # "-debug", - "-num=$($targetFiles.Count)" - "-src=$($targetFiles)", - "-dst=$($refactoredFiles)", - "-spec=$($file_spec)" - ) - - Start-Process $refactor $refactorParams -NoNewWindow -PassThru -Wait -} - -foreach ( $process in $refactors ) +if ( $args.Contains( "debug" ) ) { - if ( $process ) - { - $process.WaitForExit() - } + $refactorParams += "-debug" } -Write-Host "`nRefactoring complete`n`n" +$refactorParams = @( + "-src=$(Join-Path $path_thirdparty "zpl.h")", + "-dst=$(Join-Path $path_test "zpl.refactored.h")", + "-spec=$($file_spec)" +) -write-host "Beginning project refactor...`n" +& $refactor $refactorParams + +$refactors = @(@()) +$file_spec = Join-Path $path_test "stb_image.refactor" + +if ( $args.Contains( "debug" ) ) +{ + $refactorParams += "-debug" +} + +$refactorParams = @( + "-src=$(Join-Path $path_thirdparty "stb_image.h")", + "-dst=$(Join-Path $path_test "stb_image.refactored.h")", + "-spec=$($file_spec)" +) + +& $refactor $refactorParams + +Write-Host "`nRefactoring complete`n" + + +write-host "Beginning project refactor..." # Gather the files to be formatted. $targetFiles = @(Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) @@ -74,8 +69,6 @@ $refactoredFiles = @() $file_spec = Join-Path $path_test project.refactor -write-host "FILE SPEC:" $file_spec - foreach ( $file in $targetFiles ) { $destination = Join-Path $path_test (Split-Path $file -leaf) @@ -86,16 +79,20 @@ foreach ( $file in $targetFiles ) } $refactorParams = @( - # "-debug", "-num=$($targetFiles.Count)" "-src=$($targetFiles)", "-dst=$($refactoredFiles)", "-spec=$($file_spec)" ) -Start-Process $refactor $refactorParams -NoNewWindow -PassThru -Wait +if ( $args.Contains( "debug" ) ) +{ + $refactorParams += "-debug" +} -write-host "`nRefactoring complete`n`n" +& $refactor $refactorParams + +write-host "`nRefactoring complete`n" # Can't format zpl library... (It hangs clang format) @@ -115,3 +112,4 @@ clang-format $formatParams $targetFiles Write-Host "`nFormatting complete" } + diff --git a/scripts/template_reafactor.ps1 b/scripts/template_reafactor.ps1 new file mode 100644 index 0000000..e1ab88f --- /dev/null +++ b/scripts/template_reafactor.ps1 @@ -0,0 +1,38 @@ +[string[]] $include = '*.h', '*.hh', '*.hpp', '*.c', '*.cc', '*.cpp' +[string[]] $exclude = '*.g.*', '*.refactor' + +# Change this to your root directory if needed. +$path_root = $PSScriptRoot + +# Change this to your desired destination +$path_dest = $path_root + +# Gather the files to be formatted. +$targetFiles = @(Get-ChildItem -Recurse -Path $path_root -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) +$refactoredFiles = @() + +foreach ( $file in $targetFiles ) +{ + $destination = Join-Path $path_dest (Split-Path $file -leaf) + $destination = $destination.Replace( '.h', '.refactored.h' ) + $destination = $destination.Replace( '.c', '.refactored.c' ) + + $refactoredFiles += $destination +} + + +write-host "Beginning refactor...`n" + +$refactors = @(@()) + +$refactorParams = @( + # "-debug", + "-num=$($targetFiles.Count)" + "-src=$($targetFiles)", + "-dst=$($refactoredFiles)", + "-spec=$($file_spec)" +) + +& $refactor $refactorParams + +Write-Host "`nRefactoring complete`n`n" \ No newline at end of file