mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Finished initial implmentation bootstrap generation and singleheader implementation.
This commit is contained in:
parent
ebe049d3a0
commit
62b0ed2112
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,6 +6,8 @@ build/*
|
|||||||
**/*.gen.*
|
**/*.gen.*
|
||||||
**/gen/gen.hpp
|
**/gen/gen.hpp
|
||||||
**/gen/gen.cpp
|
**/gen/gen.cpp
|
||||||
|
**/gen/gen_dep.hpp
|
||||||
|
**/gen/gen_dep.cpp
|
||||||
|
|
||||||
gencpp.hpp
|
gencpp.hpp
|
||||||
gencpp.cpp
|
gencpp.cpp
|
||||||
|
9
.vscode/launch.json
vendored
9
.vscode/launch.json
vendored
@ -31,6 +31,15 @@
|
|||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}/project/",
|
"cwd": "${workspaceFolder}/project/",
|
||||||
"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis"
|
"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cppvsdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug singleheader vsdbg",
|
||||||
|
"program": "${workspaceFolder}/singleheader/build/gencpp_singleheader.exe",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/singleheader/",
|
||||||
|
"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -171,8 +171,8 @@ An example of building is provided within project, singleheader, and test.
|
|||||||
|
|
||||||
**Project**
|
**Project**
|
||||||
|
|
||||||
`gen.bootstrap.cpp` generates a segmented version of the library following a more traditional cpp convention.
|
`gen.bootstrap.cpp` generates a segmented version of the library where code is divided into `gen.hpp`, `gen.cpp`, `gen_dep.hpp`, and `gen_dep.cpp`.
|
||||||
With the exception that: *The component hpp and cpp files are all included into their respective header and source*
|
(Similar whats there already, but with the includes injected)
|
||||||
|
|
||||||
**Singleheader**
|
**Singleheader**
|
||||||
|
|
||||||
|
0
project/components/AttributeTokens.csv
Normal file
0
project/components/AttributeTokens.csv
Normal file
|
0
project/components/ECode.csv
Normal file
0
project/components/ECode.csv
Normal file
|
0
project/components/EOperator.csv
Normal file
0
project/components/EOperator.csv
Normal file
|
0
project/components/ESpecifier.csv
Normal file
0
project/components/ESpecifier.csv
Normal file
|
0
project/components/ETokType.csv
Normal file
0
project/components/ETokType.csv
Normal file
|
@ -402,7 +402,7 @@ StrC token_fmt_impl( sw num, ... )
|
|||||||
# define GEN_MAX_NAME_LENGTH 128
|
# define GEN_MAX_NAME_LENGTH 128
|
||||||
#endif
|
#endif
|
||||||
#ifndef GEN_MAX_UNTYPED_STR_LENGTH
|
#ifndef GEN_MAX_UNTYPED_STR_LENGTH
|
||||||
# define GEN_MAX_UNTYPED_STR_LENGTH kilobytes(640)
|
# define GEN_MAX_UNTYPED_STR_LENGTH megabytes(1)
|
||||||
#endif
|
#endif
|
||||||
#ifndef GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE
|
#ifndef GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE
|
||||||
# define GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE kilobytes(4)
|
# define GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE kilobytes(4)
|
||||||
|
@ -13,5 +13,5 @@
|
|||||||
//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file.
|
//! 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
|
// Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
|
||||||
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
||||||
# include "dependencies/gen.dep.hpp"
|
# include "gen.dep.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
9
project/components/gen.impl_start.cpp
Normal file
9
project/components/gen.impl_start.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
|
||||||
|
# error Gen.hpp : GEN_TIME not defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//! 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
|
||||||
|
# include "gen.dep.cpp"
|
||||||
|
#endif
|
@ -1,19 +0,0 @@
|
|||||||
// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)
|
|
||||||
#include "gen.dep.hpp"
|
|
||||||
|
|
||||||
#include "gen.impl_start.cpp"
|
|
||||||
|
|
||||||
GEN_NS_BEGIN
|
|
||||||
|
|
||||||
#include "gen.debug.cpp"
|
|
||||||
#include "gen.string_ops.cpp"
|
|
||||||
#include "gen.printing.cpp"
|
|
||||||
#include "gen.memory.cpp"
|
|
||||||
#include "gen.parsing.cpp"
|
|
||||||
#include "gen.hashing.cpp"
|
|
||||||
#include "gen.string.cpp"
|
|
||||||
#include "gen.timing.cpp"
|
|
||||||
|
|
||||||
#include "gen.file_handling.cpp"
|
|
||||||
|
|
||||||
GEN_NS_END
|
|
@ -1,20 +0,0 @@
|
|||||||
// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores)
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "gen.header_start.hpp"
|
|
||||||
|
|
||||||
GEN_NS_BEGIN
|
|
||||||
|
|
||||||
#include "gen.macros.hpp"
|
|
||||||
#include "gen.basic_types.hpp"
|
|
||||||
#include "gen.debug.hpp"
|
|
||||||
#include "gen.memory.hpp"
|
|
||||||
#include "gen.string_ops.hpp"
|
|
||||||
#include "gen.printing.hpp"
|
|
||||||
#include "gen.containers.hpp"
|
|
||||||
#include "gen.string.hpp"
|
|
||||||
#include "gen.file_handling.hpp"
|
|
||||||
#include "gen.parsing.hpp"
|
|
||||||
#include "gen.timing.hpp"
|
|
||||||
|
|
||||||
GEN_NS_END
|
|
@ -129,11 +129,3 @@
|
|||||||
# include <intrin.h>
|
# include <intrin.h>
|
||||||
# endif
|
# endif
|
||||||
#pragma endregion Mandatory Includes
|
#pragma endregion Mandatory Includes
|
||||||
|
|
||||||
#ifdef GEN_DONT_USE_NAMESPACE
|
|
||||||
# define GEN_NS_BEGIN
|
|
||||||
# define GEN_NS_END
|
|
||||||
#else
|
|
||||||
# define GEN_NS_BEGIN namespace gen {
|
|
||||||
# define GEN_NS_END }
|
|
||||||
#endif
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
struct FileInfo;
|
struct FileInfo;
|
||||||
|
|
||||||
#ifndef GEN_PRINTF_MAXLEN
|
#ifndef GEN_PRINTF_MAXLEN
|
||||||
# define GEN_PRINTF_MAXLEN 65536
|
# define GEN_PRINTF_MAXLEN kilobytes(128)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NOTE: A locally persisting buffer is used internally
|
// NOTE: A locally persisting buffer is used internally
|
||||||
|
@ -10,7 +10,7 @@ Code scan_file( char const* path )
|
|||||||
FileError error = file_open_mode( & file, EFileMode_READ, path );
|
FileError error = file_open_mode( & file, EFileMode_READ, path );
|
||||||
if ( error != EFileError_NONE )
|
if ( error != EFileError_NONE )
|
||||||
{
|
{
|
||||||
fatal( "scan_file: Could not open genc.macro.h: %s", path );
|
fatal( "scan_file: Could not open: %s", path );
|
||||||
}
|
}
|
||||||
|
|
||||||
sw fsize = file_size( & file );
|
sw fsize = file_size( & file );
|
||||||
|
@ -35,36 +35,135 @@ int gen_main()
|
|||||||
Code push_ignores = scan_file( "helpers/gen.push_ignores.inline.hpp" );
|
Code push_ignores = scan_file( "helpers/gen.push_ignores.inline.hpp" );
|
||||||
Code pop_ignores = scan_file( "helpers/gen.pop_ignores.inline.hpp" );
|
Code pop_ignores = scan_file( "helpers/gen.pop_ignores.inline.hpp" );
|
||||||
|
|
||||||
Builder gen_deps_header;
|
// gen_dep.hpp
|
||||||
{
|
{
|
||||||
|
Code header_start = scan_file( "dependencies/gen.header_start.hpp" );
|
||||||
|
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
||||||
|
Code macros = scan_file( "dependencies/gen.macros.hpp" );
|
||||||
|
Code basic_types = scan_file( "dependencies/gen.basic_types.hpp" );
|
||||||
|
Code debug = scan_file( "dependencies/gen.debug.hpp" );
|
||||||
|
Code memory = scan_file( "dependencies/gen.memory.hpp" );
|
||||||
|
Code string_ops = scan_file( "dependencies/gen.string_ops.hpp" );
|
||||||
|
Code printing = scan_file( "dependencies/gen.printing.hpp" );
|
||||||
|
Code containers = scan_file( "dependencies/gen.containers.hpp" );
|
||||||
|
Code string = scan_file( "dependencies/gen.string.hpp" );
|
||||||
|
Code file_handling = scan_file( "dependencies/gen.file_handling.hpp" );
|
||||||
|
Code parsing = scan_file( "dependencies/gen.parsing.hpp" );
|
||||||
|
Code timing = scan_file( "dependencies/gen.timing.hpp" );
|
||||||
|
|
||||||
|
Builder
|
||||||
|
deps_header;
|
||||||
|
deps_header.open("gen/gen_dep.hpp");
|
||||||
|
deps_header.print_fmt("// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n\n");
|
||||||
|
deps_header.print_fmt("#pragma once\n\n");
|
||||||
|
deps_header.print( push_ignores );
|
||||||
|
deps_header.print( header_start );
|
||||||
|
deps_header.print( nspace_macro );
|
||||||
|
deps_header.print_fmt( "GEN_NS_BEGIN\n\n");
|
||||||
|
deps_header.print( macros );
|
||||||
|
deps_header.print( basic_types );
|
||||||
|
deps_header.print( debug );
|
||||||
|
deps_header.print( memory );
|
||||||
|
deps_header.print( string_ops );
|
||||||
|
deps_header.print( printing );
|
||||||
|
deps_header.print( containers );
|
||||||
|
deps_header.print( string );
|
||||||
|
deps_header.print( file_handling );
|
||||||
|
deps_header.print( parsing );
|
||||||
|
deps_header.print( timing );
|
||||||
|
deps_header.print_fmt( "GEN_NS_END\n\n");
|
||||||
|
deps_header.print( pop_ignores );
|
||||||
|
deps_header.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder gen_deps_impl;
|
// gen_dep.cpp
|
||||||
{
|
{
|
||||||
|
CodeInclude header = def_include( txt_StrC("gen_dep.hpp") );
|
||||||
|
Code impl_start = scan_file( "dependencies/gen.impl_start.cpp" );
|
||||||
|
Code debug = scan_file( "dependencies/gen.debug.cpp" );
|
||||||
|
Code string_ops = scan_file( "dependencies/gen.string_ops.cpp" );
|
||||||
|
Code printing = scan_file( "dependencies/gen.printing.cpp" );
|
||||||
|
Code memory = scan_file( "dependencies/gen.memory.cpp" );
|
||||||
|
Code parsing = scan_file( "dependencies/gen.parsing.cpp" );
|
||||||
|
Code hashing = scan_file( "dependencies/gen.hashing.cpp" );
|
||||||
|
Code string = scan_file( "dependencies/gen.string.cpp" );
|
||||||
|
Code timing = scan_file( "dependencies/gen.timing.cpp" );
|
||||||
|
|
||||||
|
Builder
|
||||||
|
deps_impl;
|
||||||
|
deps_impl.open("gen/gen_dep.cpp");
|
||||||
|
deps_impl.print_fmt("// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n\n");
|
||||||
|
deps_impl.print( impl_start );
|
||||||
|
deps_impl.print( header );
|
||||||
|
deps_impl.print_fmt( "\nGEN_NS_BEGIN\n");
|
||||||
|
deps_impl.print( debug );
|
||||||
|
deps_impl.print( string_ops );
|
||||||
|
deps_impl.print( printing );
|
||||||
|
deps_impl.print( memory );
|
||||||
|
deps_impl.print( parsing );
|
||||||
|
deps_impl.print( string );
|
||||||
|
deps_impl.print( timing );
|
||||||
|
deps_impl.print_fmt( "GEN_NS_END\n\n");
|
||||||
|
deps_impl.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder gen_header;
|
// gen.hpp
|
||||||
{
|
{
|
||||||
Code header_start = scan_file( "components/gen.header_start.hpp" );
|
Code header_start = scan_file( "components/gen.header_start.hpp" );
|
||||||
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
||||||
|
Code types = scan_file( "components/gen.types.hpp" );
|
||||||
|
Code data_structs = scan_file( "components/gen.data_structures.hpp" );
|
||||||
|
Code interface = scan_file( "components/gen.interface.hpp" );
|
||||||
|
Code header_end = scan_file( "components/gen.header_end.hpp" );
|
||||||
|
|
||||||
gen_header.open( "gen/gen.hpp" );
|
Builder
|
||||||
gen_header.print_fmt("#pragma once\n\n");
|
header;
|
||||||
gen_header.print( push_ignores );
|
header.open( "gen/gen.hpp" );
|
||||||
gen_header.print( header_start );
|
header.print_fmt("#pragma once\n\n");
|
||||||
gen_header.print( nspace_macro );
|
header.print( push_ignores );
|
||||||
gen_header.print_fmt( "GEN_NS_BEGIN\n");
|
header.print( header_start );
|
||||||
|
header.print( nspace_macro );
|
||||||
gen_header.print_fmt( "\nGEN_NS_END\n\n");
|
header.print_fmt( "GEN_NS_BEGIN\n\n");
|
||||||
gen_header.print( pop_ignores );
|
header.print( types );
|
||||||
gen_header.write();
|
header.print( data_structs );
|
||||||
|
header.print( interface );
|
||||||
|
header.print( header_end );
|
||||||
|
header.print_fmt( "GEN_NS_END\n\n");
|
||||||
|
header.print( pop_ignores );
|
||||||
|
header.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder gen_impl;
|
// gen.cpp
|
||||||
{
|
{
|
||||||
|
Code impl_start = scan_file( "components/gen.impl_start.cpp" );
|
||||||
|
CodeInclude header = def_include( txt_StrC("gen.hpp") );
|
||||||
|
Code data = scan_file( "components/gen.data.cpp" );
|
||||||
|
Code ast_case_macros = scan_file( "components/gen.ast_case_macros.cpp" );
|
||||||
|
Code ast = scan_file( "components/gen.ast.cpp" );
|
||||||
|
Code interface = scan_file( "components/gen.interface.cpp" );
|
||||||
|
Code upfront = scan_file( "components/gen.interface.upfront.cpp" );
|
||||||
|
Code parsing = scan_file( "components/gen.interface.parsing.cpp" );
|
||||||
|
Code untyped = scan_file( "components/gen.untyped.cpp" );
|
||||||
|
|
||||||
|
Code builder = scan_file( "filesystem/gen.builder.cpp" );
|
||||||
|
|
||||||
|
Builder
|
||||||
|
impl;
|
||||||
|
impl.open( "gen/gen.cpp" );
|
||||||
|
impl.print( push_ignores );
|
||||||
|
impl.print( impl_start );
|
||||||
|
impl.print( header );
|
||||||
|
impl.print_fmt( "\nGEN_NS_BEGIN\n\n");
|
||||||
|
impl.print( data );
|
||||||
|
impl.print( ast_case_macros );
|
||||||
|
impl.print( ast );
|
||||||
|
impl.print( interface );
|
||||||
|
impl.print( upfront );
|
||||||
|
impl.print( parsing );
|
||||||
|
impl.print( untyped );
|
||||||
|
impl.print_fmt( "GEN_NS_END\n\n");
|
||||||
|
impl.print( pop_ignores );
|
||||||
|
impl.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
gen::deinit();
|
gen::deinit();
|
||||||
|
@ -6,11 +6,10 @@
|
|||||||
# error Gen.hpp : GEN_TIME not defined
|
# error Gen.hpp : GEN_TIME not defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file.
|
//! 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
|
//! Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
|
||||||
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
||||||
# include "dependencies/gen.dep.cpp"
|
# include "gen.dep.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gen.hpp"
|
#include "gen.hpp"
|
||||||
|
19
project/gen.dep.cpp
Normal file
19
project/gen.dep.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)
|
||||||
|
#include "gen.dep.hpp"
|
||||||
|
|
||||||
|
#include "dependencies/gen.impl_start.cpp"
|
||||||
|
|
||||||
|
GEN_NS_BEGIN
|
||||||
|
|
||||||
|
#include "dependencies/gen.debug.cpp"
|
||||||
|
#include "dependencies/gen.string_ops.cpp"
|
||||||
|
#include "dependencies/gen.printing.cpp"
|
||||||
|
#include "dependencies/gen.memory.cpp"
|
||||||
|
#include "dependencies/gen.parsing.cpp"
|
||||||
|
#include "dependencies/gen.hashing.cpp"
|
||||||
|
#include "dependencies/gen.string.cpp"
|
||||||
|
#include "dependencies/gen.timing.cpp"
|
||||||
|
|
||||||
|
#include "dependencies/gen.file_handling.cpp"
|
||||||
|
|
||||||
|
GEN_NS_END
|
28
project/gen.dep.hpp
Normal file
28
project/gen.dep.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores)
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dependencies/gen.header_start.hpp"
|
||||||
|
|
||||||
|
#ifdef GEN_DONT_USE_NAMESPACE
|
||||||
|
# define GEN_NS_BEGIN
|
||||||
|
# define GEN_NS_END
|
||||||
|
#else
|
||||||
|
# define GEN_NS_BEGIN namespace gen {
|
||||||
|
# define GEN_NS_END }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GEN_NS_BEGIN
|
||||||
|
|
||||||
|
#include "dependencies/gen.macros.hpp"
|
||||||
|
#include "dependencies/gen.basic_types.hpp"
|
||||||
|
#include "dependencies/gen.debug.hpp"
|
||||||
|
#include "dependencies/gen.memory.hpp"
|
||||||
|
#include "dependencies/gen.string_ops.hpp"
|
||||||
|
#include "dependencies/gen.printing.hpp"
|
||||||
|
#include "dependencies/gen.containers.hpp"
|
||||||
|
#include "dependencies/gen.string.hpp"
|
||||||
|
#include "dependencies/gen.file_handling.hpp"
|
||||||
|
#include "dependencies/gen.parsing.hpp"
|
||||||
|
#include "dependencies/gen.timing.hpp"
|
||||||
|
|
||||||
|
GEN_NS_END
|
@ -11,6 +11,14 @@
|
|||||||
#include "helpers/gen.push_ignores.inline.hpp"
|
#include "helpers/gen.push_ignores.inline.hpp"
|
||||||
#include "components/gen.header_start.hpp"
|
#include "components/gen.header_start.hpp"
|
||||||
|
|
||||||
|
#ifdef GEN_DONT_USE_NAMESPACE
|
||||||
|
# define GEN_NS_BEGIN
|
||||||
|
# define GEN_NS_END
|
||||||
|
#else
|
||||||
|
# define GEN_NS_BEGIN namespace gen {
|
||||||
|
# define GEN_NS_END }
|
||||||
|
#endif
|
||||||
|
|
||||||
GEN_NS_BEGIN
|
GEN_NS_BEGIN
|
||||||
|
|
||||||
#include "components/gen.types.hpp"
|
#include "components/gen.types.hpp"
|
||||||
|
@ -60,10 +60,10 @@ $formatParams = @(
|
|||||||
'-verbose'
|
'-verbose'
|
||||||
)
|
)
|
||||||
|
|
||||||
$include = @('gencpp.hpp', 'gencpp.cpp')
|
$include = @('gen.hpp', 'gen.cpp', 'gen_dep.hpp', 'gen_dep.cpp')
|
||||||
$exclude = $null
|
$exclude = $null
|
||||||
|
|
||||||
$targetFiles = @(Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName)
|
$targetFiles = @(Get-ChildItem -Recurse -Path $path_project_gen -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName)
|
||||||
|
|
||||||
clang-format $formatParams $targetFiles
|
clang-format $formatParams $targetFiles
|
||||||
Write-Host "`nFormatting complete"
|
Write-Host "`nFormatting complete"
|
||||||
|
@ -9,6 +9,7 @@ $path_project_build = Join-Path $path_project build
|
|||||||
$path_singleheader_build = Join-Path $path_singleheader build
|
$path_singleheader_build = Join-Path $path_singleheader build
|
||||||
$path_project_gen = Join-Path $path_project gen
|
$path_project_gen = Join-Path $path_project gen
|
||||||
$path_singleheader_gen = Join-Path $path_singleheader gen
|
$path_singleheader_gen = Join-Path $path_singleheader gen
|
||||||
|
$path_x64 = Join-Path $path_root x64
|
||||||
|
|
||||||
if ( Test-Path $path_project_build)
|
if ( Test-Path $path_project_build)
|
||||||
{
|
{
|
||||||
@ -30,7 +31,12 @@ if ( Test-Path $path_gen_build )
|
|||||||
Remove-Item $path_gen_build -Recurse
|
Remove-Item $path_gen_build -Recurse
|
||||||
}
|
}
|
||||||
|
|
||||||
[string[]] $include = 'gen.hpp', 'gen.cpp'
|
if ( Test-Path $path_x64)
|
||||||
|
{
|
||||||
|
Remove-Item $path_x64 -Recurse
|
||||||
|
}
|
||||||
|
|
||||||
|
[string[]] $include = 'gen.hpp', 'gen.cpp', 'gen_dep.hpp', 'gen_dep.cpp'
|
||||||
[string[]] $exclude =
|
[string[]] $exclude =
|
||||||
|
|
||||||
$files = Get-ChildItem -Recurse -Path $path_project_gen -Include $include -Exclude $exclude
|
$files = Get-ChildItem -Recurse -Path $path_project_gen -Include $include -Exclude $exclude
|
||||||
|
@ -18,7 +18,7 @@ $path_singleheader = Join-Path $path_root singleheader
|
|||||||
$path_singleheader_build = Join-Path $path_singleheader build
|
$path_singleheader_build = Join-Path $path_singleheader build
|
||||||
$path_singleheader_gen = Join-Path $path_singleheader gen
|
$path_singleheader_gen = Join-Path $path_singleheader gen
|
||||||
|
|
||||||
write-host "`n`nBuilding gencpp bootstrap`n"
|
write-host "`n`nBuilding gencpp singleheader`n"
|
||||||
|
|
||||||
if ( -not( Test-Path $path_singleheader_build) )
|
if ( -not( Test-Path $path_singleheader_build) )
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ if ( -not(Test-Path($path_singleheader_gen) )) {
|
|||||||
# Run meta-program
|
# Run meta-program
|
||||||
$gencpp_singleheader = Join-Path $path_singleheader_build gencpp_singleheader.exe
|
$gencpp_singleheader = Join-Path $path_singleheader_build gencpp_singleheader.exe
|
||||||
|
|
||||||
Write-Host `nRunning gencpp bootstrap...
|
Write-Host `nRunning gencpp singleheader...
|
||||||
& $gencpp_singleheader
|
& $gencpp_singleheader
|
||||||
|
|
||||||
# Format generated files
|
# Format generated files
|
||||||
@ -60,7 +60,7 @@ $formatParams = @(
|
|||||||
'-verbose'
|
'-verbose'
|
||||||
)
|
)
|
||||||
|
|
||||||
$include = @('gencpp.hpp')
|
$include = @('gen.hpp')
|
||||||
$exclude = $null
|
$exclude = $null
|
||||||
|
|
||||||
$targetFiles = @(Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName)
|
$targetFiles = @(Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName)
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
Public Address:
|
Public Address:
|
||||||
https://github.com/Ed94/gencpp
|
https://github.com/Ed94/gencpp
|
||||||
|
|
||||||
|
This is a single header variant of the library.
|
||||||
|
Define GEN_IMPLEMENTATION before including this file in a single compilation unit.
|
||||||
*/
|
*/
|
||||||
#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
|
#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
|
||||||
# error Gen.hpp : GEN_TIME not defined
|
# error Gen.hpp : GEN_TIME not defined
|
||||||
|
@ -28,49 +28,155 @@ constexpr StrC nspace_non_default = txt_StrC(R"(
|
|||||||
#endif
|
#endif
|
||||||
)");
|
)");
|
||||||
|
|
||||||
constexpr StrC gen_implementation_guard = txt_StrC(R"(
|
constexpr StrC implementation_guard_start = txt_StrC(R"(
|
||||||
#pragma region GENCPP IMPLEMENTATION GUARD
|
#pragma region GENCPP IMPLEMENTATION GUARD
|
||||||
#if ! defined(GEN_IMPLEMENTATION)
|
#if ! defined(GEN_IMPLEMENTATION)
|
||||||
# define GEN_IMPLEMENTATION
|
# define GEN_IMPLEMENTATION
|
||||||
)");
|
)");
|
||||||
|
|
||||||
constexpr StrC gen_implementation_end = txt_StrC(R"(
|
constexpr StrC implementation_guard_end = txt_StrC(R"(
|
||||||
#endif
|
#endif
|
||||||
#pragma endregion GENCPP IMPLEMENTATION GUARD
|
#pragma endregion GENCPP IMPLEMENTATION GUARD
|
||||||
)");
|
)");
|
||||||
|
|
||||||
|
constexpr StrC roll_own_dependencies_guard_start = txt_StrC(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_StrC(R"(
|
||||||
|
// GEN_ROLL_OWN_DEPENDENCIES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
)");
|
||||||
|
|
||||||
int gen_main()
|
int gen_main()
|
||||||
{
|
{
|
||||||
gen::init();
|
gen::init();
|
||||||
|
|
||||||
Code push_ignores = scan_file( "../project/helpers/gen.push_ignores.inline.hpp" );
|
#define project_dir "../project/"
|
||||||
Code pop_ignores = scan_file( "../project/helpers/gen.pop_ignores.inline.hpp" );
|
|
||||||
|
Code push_ignores = scan_file( project_dir "helpers/gen.push_ignores.inline.hpp" );
|
||||||
|
Code pop_ignores = scan_file( project_dir "helpers/gen.pop_ignores.inline.hpp" );
|
||||||
|
|
||||||
Code header_start = scan_file( "components/gen.header_start.hpp" );
|
Code header_start = scan_file( "components/gen.header_start.hpp" );
|
||||||
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
||||||
|
|
||||||
Builder gen_header;
|
Builder
|
||||||
gen_header.open( "gen/gen.hpp" );
|
header;
|
||||||
gen_header.print( push_ignores );
|
header.open( "gen/gen.hpp" );
|
||||||
|
header.print( push_ignores );
|
||||||
|
|
||||||
|
header.print_fmt("#pragma once\n\n");
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
gen_header.print_fmt("#pragma once\n\n");
|
{
|
||||||
gen_header.print( header_start );
|
header.print( header_start );
|
||||||
gen_header.print( nspace_macro );
|
header.print( nspace_macro );
|
||||||
gen_header.print_fmt( "GEN_NS_BEGIN\n");
|
|
||||||
|
|
||||||
gen_header.print_fmt( "\nGEN_NS_END\n");
|
{
|
||||||
|
header.print_fmt( roll_own_dependencies_guard_start );
|
||||||
|
|
||||||
|
Code header_start = scan_file( project_dir "dependencies/gen.header_start.hpp" );
|
||||||
|
Code macros = scan_file( project_dir "dependencies/gen.macros.hpp" );
|
||||||
|
Code basic_types = scan_file( project_dir "dependencies/gen.basic_types.hpp" );
|
||||||
|
Code debug = scan_file( project_dir "dependencies/gen.debug.hpp" );
|
||||||
|
Code memory = scan_file( project_dir "dependencies/gen.memory.hpp" );
|
||||||
|
Code string_ops = scan_file( project_dir "dependencies/gen.string_ops.hpp" );
|
||||||
|
Code printing = scan_file( project_dir "dependencies/gen.printing.hpp" );
|
||||||
|
Code containers = scan_file( project_dir "dependencies/gen.containers.hpp" );
|
||||||
|
Code string = scan_file( project_dir "dependencies/gen.string.hpp" );
|
||||||
|
Code file_handling = scan_file( project_dir "dependencies/gen.file_handling.hpp" );
|
||||||
|
Code parsing = scan_file( project_dir "dependencies/gen.parsing.hpp" );
|
||||||
|
Code timing = scan_file( project_dir "dependencies/gen.timing.hpp" );
|
||||||
|
|
||||||
|
header.print_fmt( "GEN_NS_BEGIN\n\n" );
|
||||||
|
header.print( header_start );
|
||||||
|
header.print( macros );
|
||||||
|
header.print( basic_types );
|
||||||
|
header.print( debug );
|
||||||
|
header.print( memory );
|
||||||
|
header.print( string_ops );
|
||||||
|
header.print( printing );
|
||||||
|
header.print( containers );
|
||||||
|
header.print( string );
|
||||||
|
header.print( file_handling );
|
||||||
|
header.print( parsing );
|
||||||
|
header.print( timing );
|
||||||
|
header.print_fmt( "GEN_NS_END\n" );
|
||||||
|
|
||||||
|
header.print_fmt( roll_own_dependencies_guard_end );
|
||||||
|
}
|
||||||
|
|
||||||
|
Code types = scan_file( project_dir "components/gen.types.hpp" );
|
||||||
|
Code data_structs = scan_file( project_dir "components/gen.data_structures.hpp" );
|
||||||
|
Code interface = scan_file( project_dir "components/gen.interface.hpp" );
|
||||||
|
Code header_end = scan_file( project_dir "components/gen.header_end.hpp" );
|
||||||
|
|
||||||
|
header.print_fmt( "GEN_NS_BEGIN\n\n" );
|
||||||
|
header.print( types );
|
||||||
|
header.print( data_structs );
|
||||||
|
header.print( interface );
|
||||||
|
header.print( header_end );
|
||||||
|
header.print_fmt( "GEN_NS_END\n" );
|
||||||
|
}
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
|
{
|
||||||
|
header.print_fmt( "%s\n", (char const*) implementation_guard_start );
|
||||||
|
{
|
||||||
|
header.print_fmt( roll_own_dependencies_guard_start );
|
||||||
|
|
||||||
gen_header.print_fmt( "%s\n\n", (char const*) gen_implementation_guard );
|
Code impl_start = scan_file( project_dir "dependencies/gen.impl_start.cpp" );
|
||||||
gen_header.print_fmt( "GEN_NS_BEGIN\n");
|
Code debug = scan_file( project_dir "dependencies/gen.debug.cpp" );
|
||||||
|
Code string_ops = scan_file( project_dir "dependencies/gen.string_ops.cpp" );
|
||||||
|
Code printing = scan_file( project_dir "dependencies/gen.printing.cpp" );
|
||||||
|
Code memory = scan_file( project_dir "dependencies/gen.memory.cpp" );
|
||||||
|
Code parsing = scan_file( project_dir "dependencies/gen.parsing.cpp" );
|
||||||
|
Code hashing = scan_file( project_dir "dependencies/gen.hashing.cpp" );
|
||||||
|
Code string = scan_file( project_dir "dependencies/gen.string.cpp" );
|
||||||
|
Code timing = scan_file( project_dir "dependencies/gen.timing.cpp" );
|
||||||
|
|
||||||
gen_header.print_fmt( "\nGEN_NS_END\n");
|
header.print_fmt( "GEN_NS_BEGIN\n\n");
|
||||||
gen_header.print_fmt( "%s\n", (char const*) gen_implementation_end );
|
header.print( impl_start );
|
||||||
|
header.print( debug );
|
||||||
|
header.print( string_ops );
|
||||||
|
header.print( printing );
|
||||||
|
header.print( memory );
|
||||||
|
header.print( parsing );
|
||||||
|
header.print( hashing );
|
||||||
|
header.print( string );
|
||||||
|
header.print( timing );
|
||||||
|
header.print_fmt( "GEN_NS_END\n");
|
||||||
|
|
||||||
gen_header.print( pop_ignores );
|
header.print_fmt( roll_own_dependencies_guard_end );
|
||||||
gen_header.write();
|
}
|
||||||
|
|
||||||
|
Code data = scan_file( project_dir "components/gen.data.cpp" );
|
||||||
|
Code ast_case_macros = scan_file( project_dir "components/gen.ast_case_macros.cpp" );
|
||||||
|
Code ast = scan_file( project_dir "components/gen.ast.cpp" );
|
||||||
|
Code interface = scan_file( project_dir "components/gen.interface.cpp" );
|
||||||
|
Code upfront = scan_file( project_dir "components/gen.interface.upfront.cpp" );
|
||||||
|
Code parsing = scan_file( project_dir "components/gen.interface.parsing.cpp" );
|
||||||
|
Code untyped = scan_file( project_dir "components/gen.untyped.cpp" );
|
||||||
|
|
||||||
|
header.print_fmt( "GEN_NS_BEGIN\n\n");
|
||||||
|
header.print( data );
|
||||||
|
header.print( ast_case_macros );
|
||||||
|
header.print( ast );
|
||||||
|
header.print( interface );
|
||||||
|
header.print( upfront );
|
||||||
|
header.print( parsing );
|
||||||
|
header.print( untyped );
|
||||||
|
header.print_fmt( "GEN_NS_END\n");
|
||||||
|
|
||||||
|
header.print_fmt( "%s\n", (char const*) implementation_guard_end );
|
||||||
|
}
|
||||||
|
|
||||||
|
header.print( pop_ignores );
|
||||||
|
header.write();
|
||||||
|
|
||||||
gen::deinit();
|
gen::deinit();
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user