prepare c_library meta-program a bit

This commit is contained in:
Edward R. Gonzalez 2024-11-30 16:54:03 -05:00
parent a67fdef20a
commit 5527a27f7b
2 changed files with 55 additions and 2 deletions

View File

@ -18,4 +18,49 @@ GEN_NS_END
using namespace gen;
void format_file( char const* path )
{
String resolved_path = String::make(GlobalAllocator, to_str(path));
String style_arg = String::make(GlobalAllocator, txt("-style=file:"));
style_arg.append("../scripts/.clang-format ");
// Need to execute clang format on the generated file to get it to match the original.
#define clang_format "clang-format "
#define cf_format_inplace "-i "
#define cf_verbose "-verbose "
String command = String::make( GlobalAllocator, clang_format );
command.append( cf_format_inplace );
command.append( cf_verbose );
command.append( style_arg );
command.append( resolved_path );
log_fmt("\tRunning clang-format on file:\n");
system( command );
log_fmt("\tclang-format finished reformatting.\n");
#undef cf_cmd
#undef cf_format_inplace
#undef cf_style
#undef cf_verbse
}
Code dump_to_scratch_and_retireve( Code code )
{
Builder ecode_file_temp = Builder::open("gen/scratch.hpp");
ecode_file_temp.print(code);
ecode_file_temp.write();
format_file("gen/scratch.hpp");
Code result = scan_file( "gen/scratch.hpp" );
remove("gen/scratch.hpp");
return result;
}
int gen_main()
{
#define project_dir "../project/"
gen::init();
gen::deinit();
return 0;
#undef project_dir
}

View File

@ -44,6 +44,7 @@ Push-Location $path_root
$verbose = $false
[bool] $bootstrap = $false
[bool] $singleheader = $false
[bool] $c_library = $false
[bool] $unreal = $false
[bool] $test = $false
@ -59,6 +60,7 @@ if ( $args ) { $args | ForEach-Object {
"debug" { $release = $false }
"bootstrap" { $bootstrap = $true }
"singleheader" { $singleheader = $true }
"c_library" { $c_library = $true }
"unreal" { $unreal = $true }
"test" { $test = $true }
}
@ -103,8 +105,9 @@ write-host "Build Type: $(if ($release) {"Release"} else {"Debug"} )"
$path_build = Join-Path $path_root build
$path_project = Join-Path $path_root project
$path_scripts = Join-Path $path_root scripts
$path_singleheader = Join-Path $path_root singleheader
$path_unreal = Join-Path $path_root unreal_engine
$path_c_library = join-Path $path_root gen_c_library
$path_singleheader = Join-Path $path_root gen_singleheader
$path_unreal = Join-Path $path_root gen_unreal_engine
$path_test = Join-Path $path_root test
if ( $bootstrap )
@ -187,6 +190,11 @@ if ( $singleheader )
Pop-Location
}
if ( $c_library )
{
}
if ( $unreal )
{
$path_build = join-path $path_unreal build