mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
Further improvements to build script
test is failing to complete properly, need to debug...
This commit is contained in:
parent
a6bf60a51e
commit
f574a9ba9a
@ -8,19 +8,19 @@ $devshell = Join-Path $PSScriptRoot 'helpers/devshell.ps1'
|
|||||||
cls
|
cls
|
||||||
|
|
||||||
#region Arguments
|
#region Arguments
|
||||||
$compiler = $null
|
$vendor = $null
|
||||||
$release = $null
|
$release = $null
|
||||||
[bool] $bootstrap = $false
|
[bool] $bootstrap = $false
|
||||||
[bool] $singleheader = $false
|
[bool] $singleheader = $false
|
||||||
[bool] $test = $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...
|
# This is a really lazy way of parsing the args, could use actual params down the line...
|
||||||
|
|
||||||
if ( $args ) { $args | ForEach-Object {
|
if ( $args ) { $args | ForEach-Object {
|
||||||
switch ($_){
|
switch ($_){
|
||||||
{ $_ -in $compilers } { $compiler = $_; break }
|
{ $_ -in $vendors } { $vendor = $_; break }
|
||||||
"release" { $release = $true }
|
"release" { $release = $true }
|
||||||
"debug" { $release = $false }
|
"debug" { $release = $false }
|
||||||
"bootstrap" { $bootstrap = $true }
|
"bootstrap" { $bootstrap = $true }
|
||||||
@ -30,8 +30,7 @@ if ( $args ) { $args | ForEach-Object {
|
|||||||
}}
|
}}
|
||||||
#endregion Arguments
|
#endregion Arguments
|
||||||
|
|
||||||
#region Building
|
#region Configuration
|
||||||
|
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
# This library was really designed to only run on 64-bit systems.
|
# This library was really designed to only run on 64-bit systems.
|
||||||
# (Its a development tool after all)
|
# (Its a development tool after all)
|
||||||
@ -46,12 +45,12 @@ $path_singleheader = Join-Path $path_root singleheader
|
|||||||
$path_test = Join-Path $path_root test
|
$path_test = Join-Path $path_root test
|
||||||
|
|
||||||
|
|
||||||
if ( $compiler -eq $null ) {
|
if ( $vendor -eq $null ) {
|
||||||
write-host "No compilier specified, assuming clang available"
|
write-host "No vendor specified, assuming clang available"
|
||||||
$compiler = "clang"
|
$compiler = "clang"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $release -eq $null ) {
|
if ( $vendor -eq $null ) {
|
||||||
write-host "No build type specified, assuming debug"
|
write-host "No build type specified, assuming debug"
|
||||||
$release = $false
|
$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"
|
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"} )"
|
write-host "Build Type: $(if ($release) {"Release"} else {"Debug"} )"
|
||||||
|
|
||||||
Push-Location $path_root
|
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
|
# https://clang.llvm.org/docs/ClangCommandLineReference.html
|
||||||
$flag_compile = '-c'
|
$flag_compile = '-c'
|
||||||
@ -170,7 +169,8 @@ if ( $compiler -match "clang" )
|
|||||||
|
|
||||||
function build-simple
|
function build-simple
|
||||||
{
|
{
|
||||||
param( $compiler, $linker, $includes, $unit, $executable )
|
param( $includes, $unit, $executable )
|
||||||
|
Write-Host "build-simple: clang"
|
||||||
|
|
||||||
$object = $executable -replace '\.exe', '.obj'
|
$object = $executable -replace '\.exe', '.obj'
|
||||||
$pdb = $executable -replace '\.exe', '.pdb'
|
$pdb = $executable -replace '\.exe', '.pdb'
|
||||||
@ -217,78 +217,11 @@ if ( $compiler -match "clang" )
|
|||||||
run-linker $linker $executable $linker_args
|
run-linker $linker $executable $linker_args
|
||||||
}
|
}
|
||||||
|
|
||||||
[array] $compiler_args = $null
|
$compiler = 'clang++'
|
||||||
[array] $linker_args = $null
|
$linker = 'lld-link'
|
||||||
|
|
||||||
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]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170
|
||||||
$flag_compile = '/c'
|
$flag_compile = '/c'
|
||||||
@ -321,7 +254,8 @@ if ( $compiler -match "msvc" )
|
|||||||
# This works because this project uses a single unit to build
|
# This works because this project uses a single unit to build
|
||||||
function build-simple
|
function build-simple
|
||||||
{
|
{
|
||||||
param( $compiler, $linker, $includes, $unit, $executable )
|
param( $includes, $unit, $executable )
|
||||||
|
Write-Host "build-simple: msvc"
|
||||||
|
|
||||||
$object = $executable -replace '\.exe', '.obj'
|
$object = $executable -replace '\.exe', '.obj'
|
||||||
$pdb = $executable -replace '\.exe', '.pdb'
|
$pdb = $executable -replace '\.exe', '.pdb'
|
||||||
@ -365,109 +299,111 @@ if ( $compiler -match "msvc" )
|
|||||||
run-linker $linker $executable $linker_args
|
run-linker $linker $executable $linker_args
|
||||||
}
|
}
|
||||||
|
|
||||||
[array] $compiler_args = $null
|
$compiler = 'cl'
|
||||||
[array] $linker_args = $null
|
$linker = 'link'
|
||||||
|
}
|
||||||
|
#endregion Configuration
|
||||||
|
|
||||||
if ( $bootstrap )
|
#region Building
|
||||||
{
|
if ( $bootstrap )
|
||||||
$path_build = join-path $path_project build
|
{
|
||||||
$path_gen = join-path $path_project gen
|
$path_build = join-path $path_project build
|
||||||
|
$path_gen = join-path $path_project gen
|
||||||
|
|
||||||
if ( -not(Test-Path($path_build) )) {
|
if ( -not(Test-Path($path_build) )) {
|
||||||
New-Item -ItemType Directory -Path $path_build
|
New-Item -ItemType Directory -Path $path_build
|
||||||
}
|
}
|
||||||
if ( -not(Test-Path($path_gen) )) {
|
if ( -not(Test-Path($path_gen) )) {
|
||||||
New-Item -ItemType Directory -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 cl link $includes $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 )
|
$includes = @( $path_project)
|
||||||
{
|
$unit = join-path $path_project "bootstrap.cpp"
|
||||||
$path_build = join-path $path_singleheader build
|
$executable = join-path $path_build "bootstrap.exe"
|
||||||
$path_gen = join-path $path_singleheader gen
|
|
||||||
|
|
||||||
if ( -not(Test-Path($path_build) )) {
|
build-simple $includes $unit $executable
|
||||||
New-Item -ItemType Directory -Path $path_build
|
|
||||||
}
|
|
||||||
if ( -not(Test-Path($path_gen) )) {
|
|
||||||
New-Item -ItemType Directory -Path $path_gen
|
|
||||||
}
|
|
||||||
|
|
||||||
$includes = @($path_project)
|
Push-Location $path_project
|
||||||
$unit = join-path $path_singleheader "singleheader.cpp"
|
if ( Test-Path( $executable ) ) {
|
||||||
$executable = join-path $path_build "singleheader.exe"
|
write-host "`nRunning bootstrap"
|
||||||
|
$time_taken = Measure-Command { & $executable
|
||||||
build-simple cl link $includes $unit $executable
|
| ForEach-Object {
|
||||||
|
write-host `t $_ -ForegroundColor Green
|
||||||
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"
|
}
|
||||||
}
|
write-host "`nBootstrap completed in $($time_taken.TotalMilliseconds) ms"
|
||||||
Pop-Location
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $test )
|
$includes = @($path_project)
|
||||||
{
|
$unit = join-path $path_singleheader "singleheader.cpp"
|
||||||
$path_gen = join-path $path_test gen
|
$executable = join-path $path_build "singleheader.exe"
|
||||||
$path_gen_build = join-path $path_gen build
|
|
||||||
$path_build = join-path $path_test build
|
|
||||||
|
|
||||||
if ( -not(Test-Path($path_build) )) {
|
build-simple $includes $unit $executable
|
||||||
New-Item -ItemType Directory -Path $path_build
|
|
||||||
}
|
|
||||||
if ( -not(Test-Path($path_gen) )) {
|
|
||||||
New-Item -ItemType Directory -Path $path_gen
|
|
||||||
}
|
|
||||||
if ( -not(Test-Path($path_gen_build) )) {
|
|
||||||
New-Item -ItemType Directory -Path $path_gen_build
|
|
||||||
}
|
|
||||||
|
|
||||||
$path_bootstrap = join-path $path_project gen
|
Push-Location $path_singleheader
|
||||||
|
if ( Test-Path($executable) ) {
|
||||||
$include = $path_bootstrap
|
write-host "`nRunning singleheader generator"
|
||||||
$unit = join-path $path_test "test.cpp"
|
$time_taken = Measure-Command { & $executable
|
||||||
$object = join-path $path_build "test.obj"
|
| ForEach-Object {
|
||||||
$executable = join-path $path_build "test.exe"
|
write-host `t $_ -ForegroundColor Green
|
||||||
$pdb = join-path $path_build "test.pdb"
|
|
||||||
|
|
||||||
build-simple cl link $include $unit $executable
|
|
||||||
|
|
||||||
Push-Location $path_test
|
|
||||||
if ( Test-Path( $executable ) ) {
|
|
||||||
write-host "`nRunning test generator"
|
|
||||||
$time_taken = Measure-Command { & $executable
|
|
||||||
| ForEach-Object {
|
|
||||||
write-host `t $_ -ForegroundColor Green
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
write-host "`nTest generator completed in $($time_taken.TotalMilliseconds) ms"
|
}
|
||||||
}
|
write-host "`nSingleheader generator completed in $($time_taken.TotalMilliseconds) ms"
|
||||||
Pop-Location
|
}
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $test )
|
||||||
|
{
|
||||||
|
$path_gen = join-path $path_test gen
|
||||||
|
$path_gen_build = join-path $path_gen build
|
||||||
|
$path_build = join-path $path_test build
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if ( -not(Test-Path($path_gen_build) )) {
|
||||||
|
New-Item -ItemType Directory -Path $path_gen_build
|
||||||
|
}
|
||||||
|
|
||||||
|
$path_bootstrap = join-path $path_project gen
|
||||||
|
|
||||||
|
$include = $path_bootstrap
|
||||||
|
$unit = join-path $path_test "test.cpp"
|
||||||
|
$object = join-path $path_build "test.obj"
|
||||||
|
$executable = join-path $path_build "test.exe"
|
||||||
|
$pdb = join-path $path_build "test.pdb"
|
||||||
|
|
||||||
|
build-simple $include $unit $executable
|
||||||
|
|
||||||
|
Push-Location $path_test
|
||||||
|
if ( Test-Path( $executable ) ) {
|
||||||
|
write-host "`nRunning test generator"
|
||||||
|
$time_taken = Measure-Command { & $executable
|
||||||
|
| ForEach-Object {
|
||||||
|
write-host `t $_ -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write-host "`nTest generator completed in $($time_taken.TotalMilliseconds) ms"
|
||||||
|
}
|
||||||
|
Pop-Location
|
||||||
}
|
}
|
||||||
#endregion Building
|
#endregion Building
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ void check_sanity()
|
|||||||
log_fmt("Num String Cache : %llu\n", StringCache.Entries.num(), StringCache);
|
log_fmt("Num String Cache : %llu\n", StringCache.Entries.num(), StringCache);
|
||||||
|
|
||||||
Builder builder;
|
Builder builder;
|
||||||
builder.open( "sanity.gen.hpp" );
|
builder.open( "gen/sanity.gen.hpp" );
|
||||||
|
|
||||||
idx = typedefs.num();
|
idx = typedefs.num();
|
||||||
#ifdef GEN_BENCHMARK
|
#ifdef GEN_BENCHMARK
|
||||||
|
@ -14,7 +14,7 @@ int gen_main()
|
|||||||
using namespace gen;
|
using namespace gen;
|
||||||
log_fmt("\ngen_time:");
|
log_fmt("\ngen_time:");
|
||||||
|
|
||||||
// check_sanity();
|
check_sanity();
|
||||||
|
|
||||||
// check_SOA();
|
// check_SOA();
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ void check_singleheader_ast()
|
|||||||
time_start = time_rel_ms();
|
time_start = time_rel_ms();
|
||||||
|
|
||||||
Builder
|
Builder
|
||||||
builder = Builder::open( "singleheader_copy.gen.hpp" );
|
builder = Builder::open( "gen/singleheader_copy.gen.hpp" );
|
||||||
builder.print( ast );
|
builder.print( ast );
|
||||||
builder.write();
|
builder.write();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user