mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
prepare c_library meta-program a bit
This commit is contained in:
parent
a67fdef20a
commit
5527a27f7b
@ -18,4 +18,49 @@ GEN_NS_END
|
|||||||
|
|
||||||
using namespace gen;
|
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
|
||||||
|
}
|
||||||
|
@ -44,6 +44,7 @@ Push-Location $path_root
|
|||||||
$verbose = $false
|
$verbose = $false
|
||||||
[bool] $bootstrap = $false
|
[bool] $bootstrap = $false
|
||||||
[bool] $singleheader = $false
|
[bool] $singleheader = $false
|
||||||
|
[bool] $c_library = $false
|
||||||
[bool] $unreal = $false
|
[bool] $unreal = $false
|
||||||
[bool] $test = $false
|
[bool] $test = $false
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ if ( $args ) { $args | ForEach-Object {
|
|||||||
"debug" { $release = $false }
|
"debug" { $release = $false }
|
||||||
"bootstrap" { $bootstrap = $true }
|
"bootstrap" { $bootstrap = $true }
|
||||||
"singleheader" { $singleheader = $true }
|
"singleheader" { $singleheader = $true }
|
||||||
|
"c_library" { $c_library = $true }
|
||||||
"unreal" { $unreal = $true }
|
"unreal" { $unreal = $true }
|
||||||
"test" { $test = $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_build = Join-Path $path_root build
|
||||||
$path_project = Join-Path $path_root project
|
$path_project = Join-Path $path_root project
|
||||||
$path_scripts = Join-Path $path_root scripts
|
$path_scripts = Join-Path $path_root scripts
|
||||||
$path_singleheader = Join-Path $path_root singleheader
|
$path_c_library = join-Path $path_root gen_c_library
|
||||||
$path_unreal = Join-Path $path_root unreal_engine
|
$path_singleheader = Join-Path $path_root gen_singleheader
|
||||||
|
$path_unreal = Join-Path $path_root gen_unreal_engine
|
||||||
$path_test = Join-Path $path_root test
|
$path_test = Join-Path $path_root test
|
||||||
|
|
||||||
if ( $bootstrap )
|
if ( $bootstrap )
|
||||||
@ -187,6 +190,11 @@ if ( $singleheader )
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $c_library )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ( $unreal )
|
if ( $unreal )
|
||||||
{
|
{
|
||||||
$path_build = join-path $path_unreal build
|
$path_build = join-path $path_unreal build
|
||||||
|
Loading…
Reference in New Issue
Block a user