2024-11-30 13:50:53 -08:00
|
|
|
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
|
|
|
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
|
|
|
#define GEN_EXPOSE_BACKEND
|
|
|
|
#include "gen.cpp"
|
|
|
|
|
|
|
|
#include "helpers/push_ignores.inline.hpp"
|
|
|
|
#include "helpers/helper.hpp"
|
|
|
|
|
|
|
|
GEN_NS_BEGIN
|
|
|
|
#include "dependencies/parsing.cpp"
|
|
|
|
GEN_NS_END
|
|
|
|
|
|
|
|
#include "auxillary/builder.hpp"
|
|
|
|
#include "auxillary/builder.cpp"
|
|
|
|
#include "auxillary/scanner.hpp"
|
|
|
|
|
|
|
|
#include <cstdlib> // for system()
|
|
|
|
|
|
|
|
using namespace gen;
|
|
|
|
|
2024-11-30 15:54:19 -08:00
|
|
|
constexpr char const* generation_notice =
|
|
|
|
"// This file was generated automatially by gencpp's c_library.cpp"
|
|
|
|
"(See: https://github.com/Ed94/gencpp)\n\n";
|
|
|
|
|
|
|
|
constexpr StrC roll_own_dependencies_guard_start = txt(R"(
|
|
|
|
//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file.
|
|
|
|
// Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
|
|
|
|
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
|
|
|
)");
|
|
|
|
|
|
|
|
constexpr StrC roll_own_dependencies_guard_end = txt(R"(
|
|
|
|
// GEN_ROLL_OWN_DEPENDENCIES
|
|
|
|
#endif
|
|
|
|
)");
|
|
|
|
|
|
|
|
constexpr StrC implementation_guard_start = txt(R"(
|
|
|
|
#pragma region GENCPP IMPLEMENTATION GUARD
|
|
|
|
#if defined(GEN_IMPLEMENTATION) && ! defined(GEN_IMPLEMENTED)
|
|
|
|
# define GEN_IMPLEMENTED
|
|
|
|
)");
|
|
|
|
|
|
|
|
constexpr StrC implementation_guard_end = txt(R"(
|
|
|
|
#endif
|
|
|
|
#pragma endregion GENCPP IMPLEMENTATION GUARD
|
|
|
|
)");
|
|
|
|
|
2024-11-30 13:54:03 -08:00
|
|
|
void format_file( char const* path )
|
|
|
|
{
|
|
|
|
String resolved_path = String::make(GlobalAllocator, to_str(path));
|
2024-11-30 13:50:53 -08:00
|
|
|
|
2024-11-30 13:54:03 -08:00
|
|
|
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();
|
|
|
|
|
2024-11-30 15:54:19 -08:00
|
|
|
Code push_ignores = scan_file( project_dir "helpers/push_ignores.inline.hpp" );
|
|
|
|
Code pop_ignores = scan_file( project_dir "helpers/pop_ignores.inline.hpp" );
|
|
|
|
Code single_header_start = scan_file( "components/header_start.hpp" );
|
|
|
|
|
|
|
|
Builder
|
|
|
|
header = Builder::open( "gen/gen.hpp" );
|
|
|
|
header.print_fmt( generation_notice );
|
|
|
|
header.print_fmt("#pragma once\n\n");
|
|
|
|
header.print( push_ignores );
|
|
|
|
|
|
|
|
// Headers
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2024-11-30 13:54:03 -08:00
|
|
|
|
|
|
|
gen::deinit();
|
|
|
|
return 0;
|
|
|
|
#undef project_dir
|
|
|
|
}
|