mirror of
https://github.com/Ed94/gencpp.git
synced 2024-11-13 20:24:52 -08:00
updates to test validations
They don't really work great right now...
This commit is contained in:
parent
1e4d5ce630
commit
1417a68757
@ -5,21 +5,64 @@
|
||||
#define GEN_BENCHMARK
|
||||
#include "gen.cpp"
|
||||
#include "gen.builder.cpp"
|
||||
#include "gen.scanner.cpp"
|
||||
#include "sanity.cpp"
|
||||
#include "SOA.cpp"
|
||||
|
||||
#ifdef GEN_SYSTEM_WINDOWS
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#include "validate.original.cpp"
|
||||
#include "validate.singleheader.cpp"
|
||||
|
||||
int gen_main()
|
||||
{
|
||||
using namespace gen;
|
||||
log_fmt("\ngen_time:");
|
||||
|
||||
// check_sanity();
|
||||
|
||||
// check_SOA();
|
||||
|
||||
validate_original_files_ast();
|
||||
// validate_original_files_ast();
|
||||
validate_singleheader_ast();
|
||||
|
||||
return 0;
|
||||
|
@ -8,10 +8,6 @@
|
||||
#include "gen.scanner.hpp"
|
||||
using namespace gen;
|
||||
|
||||
#ifdef GEN_SYSTEM_WINDOWS
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
#define path_root "../"
|
||||
#define path_project path_root "project/"
|
||||
#define path_scripts path_root "scripts/"
|
||||
@ -26,13 +22,32 @@ void validate_file_ast( char const* path, char const* path_gen )
|
||||
|
||||
String path_temp = String::make_length( GlobalAllocator, path_gen, str_len( path_gen ) );
|
||||
|
||||
// Sleep(100);
|
||||
FileContents file = file_read_contents( GlobalAllocator, true, path );
|
||||
// FileError error = file_open_mode( & path_temp, EFileMode_WRITE, path );
|
||||
// if ( error != EFileError_NONE )
|
||||
// {
|
||||
// log_failure( "gen::File::open - Could not open file: %s", path);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Duplicate and format
|
||||
{
|
||||
// Sleep(100);
|
||||
FileInfo scratch;
|
||||
FileError error = file_open_mode( & scratch, EFileMode_WRITE, "gen/scratch.cpp" );
|
||||
if ( error != EFileError_NONE ) {
|
||||
log_failure( "gen::File::open - Could not open file: %s", "gen/scratch.cpp");
|
||||
return;
|
||||
}
|
||||
// Sleep(100);
|
||||
b32 result = file_write( & scratch, file.data, file.size );
|
||||
if ( result == false ) {
|
||||
log_failure("gen::File::write - Failed to write to file: %s\n", file_name( & scratch ) );
|
||||
file_close( & scratch );
|
||||
return;
|
||||
}
|
||||
file_close( & scratch );
|
||||
// Sleep(100);
|
||||
format_file( "gen/scratch.cpp" );
|
||||
// Sleep(100);
|
||||
|
||||
file = file_read_contents( GlobalAllocator, true, "gen/scratch.cpp" );
|
||||
}
|
||||
|
||||
u64 time_start = time_rel_ms();
|
||||
CodeBody ast = parse_global_body( { file.size, (char const*)file.data } );
|
||||
@ -85,8 +100,11 @@ void validate_original_files_ast()
|
||||
gen::init();
|
||||
log_fmt("\nvalidate_original_files_ast:\n");
|
||||
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_DEF_INLINE") ));
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_IMPL_INLINE") ));
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_FILE_SEEK_PROC(")));
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_FILE_READ_AT_PROC(")));
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_FILE_WRITE_AT_PROC(")));
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_FILE_CLOSE_PROC(")));
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_FILE_OPEN_PROC(")));
|
||||
|
||||
// Helpers
|
||||
{
|
||||
@ -99,7 +117,7 @@ void validate_original_files_ast()
|
||||
// Dependencies
|
||||
{
|
||||
#define validate( path ) validate_file_ast( path_dependencies path, "gen/original/dependencies/" path )
|
||||
validate( "header_start.hpp" );
|
||||
validate( "platform.hpp" );
|
||||
validate( "macros.hpp" );
|
||||
validate( "basic_types.hpp" );
|
||||
validate( "debug.hpp" );
|
||||
|
@ -7,17 +7,38 @@
|
||||
#include "gen.scanner.hpp"
|
||||
using namespace gen;
|
||||
|
||||
#ifdef GEN_SYSTEM_WINDOWS
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
void validate_singleheader_ast()
|
||||
{
|
||||
#define root_dir "../"
|
||||
gen::init();
|
||||
log_fmt("\validate_singleheader_ast:\n");
|
||||
log_fmt("\nvalidate_singleheader_ast:\n");
|
||||
|
||||
FileContents file = file_read_contents( GlobalAllocator, true, root_dir "singleheader/gen/gen.hpp" );
|
||||
|
||||
// Duplicate and format
|
||||
{
|
||||
// Sleep(100);
|
||||
FileInfo scratch;
|
||||
FileError error = file_open_mode( & scratch, EFileMode_WRITE, "gen/scratch.cpp" );
|
||||
if ( error != EFileError_NONE ) {
|
||||
log_failure( "gen::File::open - Could not open file: %s", "gen/scratch.cpp");
|
||||
return;
|
||||
}
|
||||
// Sleep(100);
|
||||
b32 result = file_write( & scratch, file.data, file.size );
|
||||
if ( result == false ) {
|
||||
log_failure("gen::File::write - Failed to write to file: %s\n", file_name( & scratch ) );
|
||||
file_close( & scratch );
|
||||
return;
|
||||
}
|
||||
file_close( & scratch );
|
||||
// Sleep(100);
|
||||
format_file( "gen/scratch.cpp" );
|
||||
// Sleep(100);
|
||||
|
||||
file = file_read_contents( GlobalAllocator, true, "gen/scratch.cpp" );
|
||||
}
|
||||
|
||||
u64 time_start = time_rel_ms();
|
||||
CodeBody ast = parse_global_body( { file.size, (char const*)file.data } );
|
||||
log_fmt("\nAst generated. Time taken: %llu ms\n", time_rel_ms() - time_start);
|
||||
|
Loading…
Reference in New Issue
Block a user