Further improvements to build script

test is failing to complete properly, need to debug...
This commit is contained in:
Edward R. Gonzalez 2023-08-20 13:02:50 -04:00
parent a6bf60a51e
commit f574a9ba9a
4 changed files with 111 additions and 175 deletions

View File

@ -8,19 +8,19 @@ $devshell = Join-Path $PSScriptRoot 'helpers/devshell.ps1'
cls
#region Arguments
$compiler = $null
$vendor = $null
$release = $null
[bool] $bootstrap = $false
[bool] $singleheader = $false
[bool] $test = $false
[array] $compilers = @( "clang", "msvc" )
[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 ($_){
{ $_ -in $compilers } { $compiler = $_; break }
{ $_ -in $vendors } { $vendor = $_; break }
"release" { $release = $true }
"debug" { $release = $false }
"bootstrap" { $bootstrap = $true }
@ -30,8 +30,7 @@ if ( $args ) { $args | ForEach-Object {
}}
#endregion Arguments
#region Building
#region Configuration
if ($IsWindows) {
# This library was really designed to only run on 64-bit systems.
# (Its a development tool after all)
@ -46,12 +45,12 @@ $path_singleheader = Join-Path $path_root singleheader
$path_test = Join-Path $path_root test
if ( $compiler -eq $null ) {
write-host "No compilier specified, assuming clang available"
if ( $vendor -eq $null ) {
write-host "No vendor specified, assuming clang available"
$compiler = "clang"
}
if ( $release -eq $null ) {
if ( $vendor -eq $null ) {
write-host "No build type specified, assuming debug"
$release = $false
}
@ -60,7 +59,7 @@ if ( $bootstrap -eq $false -and $singleheader -eq $false -and $test -eq $false )
throw "No build target specified. One must be specified, this script will not assume one"
}
write-host "Building gencpp with $compiler"
write-host "Building gencpp with $vendor"
write-host "Build Type: $(if ($release) {"Release"} else {"Debug"} )"
Push-Location $path_root
@ -123,7 +122,7 @@ function run-linker
}
}
if ( $compiler -match "clang" )
if ( $vendor -match "clang" )
{
# https://clang.llvm.org/docs/ClangCommandLineReference.html
$flag_compile = '-c'
@ -170,7 +169,8 @@ if ( $compiler -match "clang" )
function build-simple
{
param( $compiler, $linker, $includes, $unit, $executable )
param( $includes, $unit, $executable )
Write-Host "build-simple: clang"
$object = $executable -replace '\.exe', '.obj'
$pdb = $executable -replace '\.exe', '.pdb'
@ -217,78 +217,11 @@ if ( $compiler -match "clang" )
run-linker $linker $executable $linker_args
}
[array] $compiler_args = $null
[array] $linker_args = $null
if ( $bootstrap )
{
$path_build = join-path $path_project build
$path_gen = join-path $path_project gen
if ( -not(Test-Path($path_build) )) {
New-Item -ItemType Directory -Path $path_build
}
if ( -not(Test-Path($path_gen) )) {
New-Item -ItemType Directory -Path $path_gen
}
$includes = @( $path_project )
$unit = join-path $path_project "bootstrap.cpp"
$executable = join-path $path_build "bootstrap.exe"
build-simple clang++ lld-link $include $unit $executable
Push-Location $path_project
if ( Test-Path( $executable ) ) {
write-host "`nRunning bootstrap"
$time_taken = Measure-Command { & $executable
| ForEach-Object {
write-host `t $_ -ForegroundColor Green
}
}
write-host "`nBootstrap completed in $($time_taken.TotalMilliseconds) ms"
}
Pop-Location
}
if ( $singleheader )
{
$path_build = join-path $path_singleheader build
$path_gen = join-path $path_singleheader gen
if ( -not(Test-Path($path_build) )) {
New-Item -ItemType Directory -Path $path_build
}
if ( -not(Test-Path($path_gen) )) {
New-Item -ItemType Directory -Path $path_gen
}
$include = $path_project
$unit = join-path $path_singleheader "singleheader.cpp"
$executable = join-path $path_build "singleheader.exe"
build-simple clang++ lld-link $include $unit $executable
Push-Location $path_singleheader
if ( Test-Path( $executable ) ) {
write-host "`nRunning singleheader generator"
$time_taken = Measure-Command { & $executable
| ForEach-Object {
write-host `t $_ -ForegroundColor Green
}
}
write-host "`nSingleheader generator completed in $($time_taken.TotalMilliseconds) ms"
}
Pop-Location
}
if ( $test )
{
# ... [your test compilation code here]
}
$compiler = 'clang++'
$linker = 'lld-link'
}
if ( $compiler -match "msvc" )
if ( $vendor -match "msvc" )
{
# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170
$flag_compile = '/c'
@ -321,7 +254,8 @@ if ( $compiler -match "msvc" )
# This works because this project uses a single unit to build
function build-simple
{
param( $compiler, $linker, $includes, $unit, $executable )
param( $includes, $unit, $executable )
Write-Host "build-simple: msvc"
$object = $executable -replace '\.exe', '.obj'
$pdb = $executable -replace '\.exe', '.pdb'
@ -365,11 +299,14 @@ if ( $compiler -match "msvc" )
run-linker $linker $executable $linker_args
}
[array] $compiler_args = $null
[array] $linker_args = $null
$compiler = 'cl'
$linker = 'link'
}
#endregion Configuration
if ( $bootstrap )
{
#region Building
if ( $bootstrap )
{
$path_build = join-path $path_project build
$path_gen = join-path $path_project gen
@ -384,7 +321,7 @@ if ( $compiler -match "msvc" )
$unit = join-path $path_project "bootstrap.cpp"
$executable = join-path $path_build "bootstrap.exe"
build-simple cl link $includes $unit $executable
build-simple $includes $unit $executable
Push-Location $path_project
if ( Test-Path( $executable ) ) {
@ -397,10 +334,10 @@ if ( $compiler -match "msvc" )
write-host "`nBootstrap completed in $($time_taken.TotalMilliseconds) ms"
}
Pop-Location
}
}
if ( $singleheader )
{
if ( $singleheader )
{
$path_build = join-path $path_singleheader build
$path_gen = join-path $path_singleheader gen
@ -415,7 +352,7 @@ if ( $compiler -match "msvc" )
$unit = join-path $path_singleheader "singleheader.cpp"
$executable = join-path $path_build "singleheader.exe"
build-simple cl link $includes $unit $executable
build-simple $includes $unit $executable
Push-Location $path_singleheader
if ( Test-Path($executable) ) {
@ -428,10 +365,10 @@ if ( $compiler -match "msvc" )
write-host "`nSingleheader generator completed in $($time_taken.TotalMilliseconds) ms"
}
Pop-Location
}
}
if ( $test )
{
if ( $test )
{
$path_gen = join-path $path_test gen
$path_gen_build = join-path $path_gen build
$path_build = join-path $path_test build
@ -454,7 +391,7 @@ if ( $compiler -match "msvc" )
$executable = join-path $path_build "test.exe"
$pdb = join-path $path_build "test.pdb"
build-simple cl link $include $unit $executable
build-simple $include $unit $executable
Push-Location $path_test
if ( Test-Path( $executable ) ) {
@ -467,7 +404,6 @@ if ( $compiler -match "msvc" )
write-host "`nTest generator completed in $($time_taken.TotalMilliseconds) ms"
}
Pop-Location
}
}
#endregion Building

View File

@ -64,7 +64,7 @@ void check_sanity()
log_fmt("Num String Cache : %llu\n", StringCache.Entries.num(), StringCache);
Builder builder;
builder.open( "sanity.gen.hpp" );
builder.open( "gen/sanity.gen.hpp" );
idx = typedefs.num();
#ifdef GEN_BENCHMARK

View File

@ -14,7 +14,7 @@ int gen_main()
using namespace gen;
log_fmt("\ngen_time:");
// check_sanity();
check_sanity();
// check_SOA();

View File

@ -23,7 +23,7 @@ void check_singleheader_ast()
time_start = time_rel_ms();
Builder
builder = Builder::open( "singleheader_copy.gen.hpp" );
builder = Builder::open( "gen/singleheader_copy.gen.hpp" );
builder.print( ast );
builder.write();