WIP: Starting to improve failure/error handling (errors as values)

This commit is contained in:
ed committed 2026-10-03 20:33:50 -04:00
1 parent 61d53362e8
commit b754adcd96
16 files changed
+983 -292

No files matched your search

+3
View File
@@ -25,6 +25,9 @@ args:
segmented
singleheader
unreal
test
parser_bounds
lexer_failures
clang
msvc : By default this project builds with clang, specifying msvc will build with MSVC.
debug
+62 -9
View File
@@ -74,8 +74,10 @@ Push-Location $path_root
[bool] $c_lib = $false
[bool] $c_lib_static = $false
[bool] $c_lib_dyn = $false
[bool] $unreal = $false
[bool] $test = $false
[bool] $unreal = $false
[bool] $test = $false
[bool] $parser_bounds = $false
[bool] $lexer_failures = $false
[array] $vendors = @( "clang", "msvc" )
@@ -93,8 +95,10 @@ if ( $args ) { $args | ForEach-Object {
"c_lib" { $c_lib = $true }
"c_lib_static" { $c_lib_static = $true }
"c_lib_dyn" { $c_lib_dyn = $true }
"unreal" { $unreal = $true }
"test" { $test = $true }
"unreal" { $unreal = $true }
"test" { $test = $true }
"parser_bounds" { $parser_bounds = $true }
"lexer_failures" { $lexer_failures = $true }
}
}}
#endregion Arguments
@@ -114,6 +118,7 @@ if ( $vendor -eq $null ) {
if ( $release -eq $null ) {
write-host "No build type specified, assuming debug"
$release = $false
$debug = $true
}
elseif ( $release -eq $false ) {
$debug = $true
@@ -129,7 +134,9 @@ $cannot_build = $cannot_build -and $c_lib -eq $false
$cannot_build = $cannot_build -and $c_lib_static -eq $false
$cannot_build = $cannot_build -and $c_lib_dyn -eq $false
$cannot_build = $cannot_build -and $unreal -eq $false
$cannot_build = $cannot_build -and $test -eq $false
$cannot_build = $cannot_build -and $test -eq $false
$cannot_build = $cannot_build -and $parser_bounds -eq $false
$cannot_build = $cannot_build -and $lexer_failures -eq $false
if ( $cannot_build ) {
Stop-stage "No build target specified"
}
@@ -362,7 +369,6 @@ if ( $test -and $true )
$compiler_args += $flag_all_c
$compiler_args += $flag_updated_cpp_macro
$compiler_args += $flag_c11
$compiler_args += "-H"
$linker_args = @(
$flag_link_win_subsystem_console
@@ -421,10 +427,9 @@ if ($test)
$compiler_args = @()
$compiler_args += ( $flag_define + 'GEN_TIME' )
$compiler_args += @("-x", "c++")
$compiler_args += "-std=c++17"
$compiler_args += $flag_all_cpp
$compiler_args += $flag_cpp17
$compiler_args += ($flag_define + "GEN_BUILD_DEBUG=1")
$compiler_args += "-H"
$linker_args = @(
$flag_link_win_subsystem_console
@@ -442,6 +447,54 @@ if ($test) {
}
}
}
if ($parser_bounds)
{
$path_probe = join-path $path_test parser_bounds
$path_build = join-path $path_probe build
if ( -not(Test-Path($path_build) )) {
new-item -ItemType Directory -Path $path_build | Out-Null
}
$includes = @( $path_base )
$unit = join-path $path_probe "test.cpp"
$executable = join-path $path_build "parser_bounds.exe"
$compiler_args = @()
$compiler_args += ( $flag_define + 'GEN_TIME' )
$compiler_args += $flag_cpp17
$linker_args = @(
$flag_link_win_subsystem_console
)
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
invoke-stageTool -stage "parser_bounds" -compiled $result -executable $executable -path_work $path_probe
}
if ($lexer_failures)
{
$path_probe = join-path $path_test lexer_failures
$path_build = join-path $path_probe build
if ( -not(Test-Path($path_build) )) {
new-item -ItemType Directory -Path $path_build | Out-Null
}
$includes = @( $path_base )
$unit = join-path $path_probe "test.cpp"
$executable = join-path $path_build "lexer_failures.exe"
$compiler_args = @()
$compiler_args += ( $flag_define + 'GEN_TIME' )
$compiler_args += $flag_cpp17
$linker_args = @(
$flag_link_win_subsystem_console
)
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
invoke-stageTool -stage "lexer_failures" -compiled $result -executable $executable -path_work $path_probe
}
#endregion Building
pop-location # $path_root
+8
View File
@@ -19,6 +19,8 @@ $path_unreal_gen = Join-Path $path_unreal gen
$path_test = Join-Path $path_root test
$path_test_build = Join-Path $path_test build
$path_test_gen = Join-Path $path_test gen
$path_parser_bounds_build = Join-Path $path_test "parser_bounds\build"
$path_lexer_failures_build = Join-Path $path_test "lexer_failures\build"
$path_x64 = Join-Path $path_root x64
$path_release = Join-Path $path_root release
@@ -58,6 +60,12 @@ if ( Test-Path $path_test_build ) {
if ( Test-Path $path_test_gen ) {
Remove-Item $path_test_gen -Recurse -Verbose
}
if ( Test-Path $path_parser_bounds_build ) {
Remove-Item $path_parser_bounds_build -Recurse -Verbose
}
if ( Test-Path $path_lexer_failures_build ) {
Remove-Item $path_lexer_failures_build -Recurse -Verbose
}
if ( Test-Path $path_x64) {
Remove-Item $path_x64 -Recurse -Verbose
}
+3 -1
View File
@@ -149,7 +149,8 @@ if ( $vendor -match "clang" )
# https://clang.llvm.org/docs/ClangCommandLineReference.html
$flag_all_c = @('-x', 'c')
$flag_c11 = '-std=c11'
$flag_all_cpp = '-x c++'
$flag_cpp17 = '-std=c++17'
$flag_all_cpp = @('-x', 'c++')
$flag_charset_utf8 = '-utf-8'
$flag_compile = '-c'
$flag_color_diagnostics = '-fcolor-diagnostics'
@@ -389,6 +390,7 @@ if ( $vendor -match "msvc" )
# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170
$flag_all_c = '/TC'
$flag_c11 = '/std:c11'
$flag_cpp17 = '/std:c++17'
$flag_all_cpp = '/TP'
$flag_charset_utf8 = '/utf-8'
$flag_compile = '/c'