did some reorganization, build script changes

Moved header and source to code

Changed all build scripts to just be powershell (preferred)
Added clang format (but forgot that you cannot format zpl because it hangs clang format)

Code changes:
* Removed long names just using short names (there is an issue with the opts_compile...)
* Removed zpl.refactored.h (its generated now when `.\build.ps1 test` is run
* Modified zpl.h to just have the radix sort modification.
This commit is contained in:
2023-03-13 20:17:12 -04:00
parent 9129b5a9fc
commit aec095a9f0
18 changed files with 326 additions and 18431 deletions

87
scripts/build.ps1 Normal file
View File

@ -0,0 +1,87 @@
cls
[string] $type = $null
[string] $test = $false
foreach ( $arg in $args )
{
if ( $arg -eq "test" )
{
$test = $true
}
else
{
$type = $arg
}
}
#region Regular Build
write-host "Building project`n"
$path_root = git rev-parse --show-toplevel
$path_build = Join-Path $path_root build
$path_scripts = Join-Path $path_root scripts
if ( -not( Test-Path $path_build ) )
{
$args_meson = @()
$args_meson += "setup"
$args_meson += $path_build
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
}
if ( $type )
{
$args_meson = @()
$args_meson += "configure"
$args_meson += $path_build
$args_meson += "--buildtype $($type)"
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
}
#endregion Regular Build
#region Test Build
write-host "`n`nBuilding Test`n"
if ( -not( Test-Path $path_build ) )
{
return;
}
$args_ninja = @()
$args_ninja += "-C"
$args_ninja += $path_build
Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root
# Refactor thirdparty libraries
& .\refactor_and_format.ps1
if ( $test -eq $false )
{
return;
}
$path_test = Join-Path $path_root test
$path_test_build = Join-Path $path_test build
if ( -not( Test-Path $path_test_build ) )
{
$args_meson = @()
$args_meson += "setup"
$args_meson += $path_test_build
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
}
$args_ninja = @()
$args_ninja += "-C"
$args_ninja += $path_build
Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_test
#endregion Test Build

14
scripts/clean.ps1 Normal file
View File

@ -0,0 +1,14 @@
$path_root = git rev-parse --show-toplevel
$path_build = Join-Path $path_root build
$path_test = Join-Path $path_root test
$path_test_build = Join-Path $path_test build
if ( Test-Path $path_build )
{
Remove-Item $path_build -Recurse
}
if ( Test-Path $path_test_build )
{
Remove-Item $path_test_build -Recurse
}

12
scripts/get_sources.ps1 Normal file
View File

@ -0,0 +1,12 @@
[string[]] $include = '*.c', '*.cc', '*.cpp'
# [stirng[]] $exclude =
$path_root = git rev-parse --show-toplevel
$path_proj = Join-Path $path_root project
$files = Get-ChildItem -Recurse -Path $path_proj -Include $include -Exclude $exclude
$sources = $files | Select-Object -ExpandProperty FullName | Resolve-Path -Relative
$sources = $sources.Replace( '\', '/' )
return $sources

19
scripts/meson.build Normal file
View File

@ -0,0 +1,19 @@
project( 'refactor', 'c', 'cpp', default_options : ['buildtype=debug'] )
# add_global_arguments('-E', language : 'cpp')
includes = include_directories(
[ '../project'
, '../thirdparty'
])
get_sources = files('./get_sources.ps1')
sources = files(run_command('powershell', get_sources, check: true).stdout().strip().split('\n'))
if get_option('buildtype').startswith('debug')
add_project_arguments('-DBuild_Debug', language : ['c', 'cpp'])
endif
executable( 'refactor', sources, include_directories : includes )

View File

@ -0,0 +1,63 @@
[string[]] $include = '*.h', '*.hh', '*.hpp', '*.c', '*.cc', '*.cpp'
[string[]] $exclude = '*.g.*', '*.refactor', 'bloat.refactored.hpp', 'refactor.refactored.cpp'
$path_root = git rev-parse --show-toplevel
$path_build = Join-Path $path_root build
$path_test = Join-Path $path_root test
$path_thirdparty = Join-Path $path_root thirdparty
$file_spec = Join-Path $path_test zpl.refactor
$refactor = Join-Path $path_build refactor.exe
# Gather the files to be formatted.
$targetFiles = @(Get-ChildItem -Recurse -Path $path_thirdparty -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName)
write-host "Beginning refactor...`n"
$refactors = @(@())
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)
}
foreach ( $process in $refactors )
{
if ( $process )
{
$process.WaitForExit()
}
}
Write-Host "`nRefactoring complete`n`n"
# Can't format zpl library... (It hangs clang format)
if ( $false )
{
Write-Host "Beginning format...`n"
# Format the files.
$formatParams = @(
'-i' # In-place
'-style=file' # Search for a .clang-format file in the parent directory of the source file.
'-verbose'
)
$targetFiles = @(Get-ChildItem -Recurse -Path $path_test -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName)
clang-format $formatParams $targetFiles
Write-Host "`nFormatting complete"
}