Script additions and improvements, fix IO bug.

This commit is contained in:
Edward R. Gonzalez 2023-03-31 01:04:56 -04:00
parent 1b0c5d176c
commit 6e91555a20
5 changed files with 97 additions and 50 deletions

View File

@ -50,7 +50,7 @@ namespace IO
zpl_file_close( & src ); zpl_file_close( & src );
} }
while ( path++, left--, left > 1 ); while ( path++, left--, left > 0 );
uw persist_size = Largest_Src_Size * 2 + 8; uw persist_size = Largest_Src_Size * 2 + 8;

View File

@ -29,7 +29,10 @@ if ( -not( Test-Path $path_build ) )
$args_meson += "setup" $args_meson += "setup"
$args_meson += $path_build $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 ) if ( $type )
@ -39,14 +42,19 @@ if ( $type )
$args_meson += $path_build $args_meson += $path_build
$args_meson += "--buildtype $($type)" $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 = @()
$args_ninja += "-C" $args_ninja += "-C"
$args_ninja += $path_build $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 #endregion Regular Build
@ -56,7 +64,8 @@ if ( $test -eq $true )
write-host "`n`nBuilding Test`n" write-host "`n`nBuilding Test`n"
# Refactor thirdparty libraries # 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 = Join-Path $path_root test
$path_test_build = Join-Path $path_test build $path_test_build = Join-Path $path_test build
@ -67,15 +76,17 @@ if ( $test -eq $true )
$args_meson += "setup" $args_meson += "setup"
$args_meson += $path_test_build $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 = @()
$args_ninja += "-C" $args_ninja += "-C"
$args_ninja += $path_test_build $args_ninja += $path_test_build
write-host $args_ninja Push-Location $path_root
ninja $args_ninja
Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root Pop-Location
#endregion Test Build #endregion Test Build
} }

View File

@ -1,2 +1,2 @@
cls cls
& (Join-Path $PSScriptRoot 'build.ci.ps1') Invoke-Expression "& $(Join-Path $PSScriptRoot 'build.ci.ps1') $args"

View File

@ -25,48 +25,43 @@ foreach ( $file in $targetFiles )
} }
write-host "Beginning thirdpary refactor...`n" write-host "Beginning thirdpary refactor..."
$refactors = @(@()) $refactors = @(@())
if ( $false ){ if ( $args.Contains( "debug" ) )
foreach ( $file in $targetFiles )
{ {
$destination = Join-Path $path_test (Split-Path $file -leaf) $refactorParams += "-debug"
$destination = $destination.Replace( '.h', '.refactored.h' ) }
$refactorParams = @( $refactorParams = @(
"-src=$($file)", "-src=$(Join-Path $path_thirdparty "zpl.h")",
"-dst=$($destination)" "-dst=$(Join-Path $path_test "zpl.refactored.h")",
"-spec=$($file_spec)" "-spec=$($file_spec)"
) )
$refactors += (Start-Process $refactor $refactorParams -NoNewWindow -PassThru) & $refactor $refactorParams
$refactors = @(@())
$file_spec = Join-Path $path_test "stb_image.refactor"
if ( $args.Contains( "debug" ) )
{
$refactorParams += "-debug"
} }
}
else {
$refactorParams = @( $refactorParams = @(
# "-debug", "-src=$(Join-Path $path_thirdparty "stb_image.h")",
"-num=$($targetFiles.Count)" "-dst=$(Join-Path $path_test "stb_image.refactored.h")",
"-src=$($targetFiles)",
"-dst=$($refactoredFiles)",
"-spec=$($file_spec)" "-spec=$($file_spec)"
) )
Start-Process $refactor $refactorParams -NoNewWindow -PassThru -Wait & $refactor $refactorParams
}
foreach ( $process in $refactors ) Write-Host "`nRefactoring complete`n"
{
if ( $process )
{
$process.WaitForExit()
}
}
Write-Host "`nRefactoring complete`n`n"
write-host "Beginning project refactor...`n" write-host "Beginning project refactor..."
# Gather the files to be formatted. # Gather the files to be formatted.
$targetFiles = @(Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) $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 $file_spec = Join-Path $path_test project.refactor
write-host "FILE SPEC:" $file_spec
foreach ( $file in $targetFiles ) foreach ( $file in $targetFiles )
{ {
$destination = Join-Path $path_test (Split-Path $file -leaf) $destination = Join-Path $path_test (Split-Path $file -leaf)
@ -86,16 +79,20 @@ foreach ( $file in $targetFiles )
} }
$refactorParams = @( $refactorParams = @(
# "-debug",
"-num=$($targetFiles.Count)" "-num=$($targetFiles.Count)"
"-src=$($targetFiles)", "-src=$($targetFiles)",
"-dst=$($refactoredFiles)", "-dst=$($refactoredFiles)",
"-spec=$($file_spec)" "-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) # Can't format zpl library... (It hangs clang format)
@ -115,3 +112,4 @@ clang-format $formatParams $targetFiles
Write-Host "`nFormatting complete" Write-Host "`nFormatting complete"
} }

View File

@ -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"