diff options
Diffstat (limited to 'buildtools')
-rw-r--r-- | buildtools/cmake/Exceptions.cmake | 31 | ||||
-rw-r--r-- | buildtools/codegen-companion/MacrosCodegen.hpp | 7 | ||||
-rw-r--r-- | buildtools/codegen-companion/Metadata.cpp | 1 | ||||
-rw-r--r-- | buildtools/codegen-companion/Metadata.hpp | 4 | ||||
-rw-r--r-- | buildtools/codegen-companion/MetadataBase.cpp | 1 | ||||
-rw-r--r-- | buildtools/codegen-companion/MetadataBase.hpp | 14 | ||||
-rw-r--r-- | buildtools/codegen/CodegenUtils.inl | 2 | ||||
-rw-r--r-- | buildtools/codegen/main.cpp | 8 |
8 files changed, 65 insertions, 3 deletions
diff --git a/buildtools/cmake/Exceptions.cmake b/buildtools/cmake/Exceptions.cmake new file mode 100644 index 0000000..89e7e69 --- /dev/null +++ b/buildtools/cmake/Exceptions.cmake @@ -0,0 +1,31 @@ +function(target_flag_exceptions_msvc TARGET_NAME ENABLED) + if(ENABLED) + target_compile_options(${TARGET_NAME} PRIVATE /EHsc) + else() + target_compile_options(${TARGET_NAME} PRIVATE /EH-) + endif() +endfunction() + +function(target_flag_exceptions_gcc TARGET_NAME ENABLED) + if(ENABLED) + target_compile_options(${TARGET_NAME} PRIVATE -fexceptions) + else() + target_compile_options(${TARGET_NAME} PRIVATE -fno-exceptions) + endif() +endfunction() + +function(target_flag_exceptions TARGET_NAME ENABLED) + if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + target_flag_exceptions_msvc(${TARGET_NAME} ${ENABLED}) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC") + target_flag_exceptions_msvc(${TARGET_NAME} ${ENABLED}) + elseif(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "GNU") + target_flag_exceptions_gcc(${TARGET_NAME} ${ENABLED}) + endif() + elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_flag_exceptions_gcc(${TARGET_NAME} ${ENABLED}) + else() + message(FATAL "target_flag_exceptions(): Unknown compiler ${CMAKE_CXX_COMPILER_ID}") + endif() +endfunction() diff --git a/buildtools/codegen-companion/MacrosCodegen.hpp b/buildtools/codegen-companion/MacrosCodegen.hpp new file mode 100644 index 0000000..6803023 --- /dev/null +++ b/buildtools/codegen-companion/MacrosCodegen.hpp @@ -0,0 +1,7 @@ +// NOTE: contents of this file is coupled with buildtools/codegen/ +// when updating, change both sides at the same time + +#pragma once + +#define BRUSSEL_CLASS(name, options) +#define BRUSSEL_ENUM(name, options) diff --git a/buildtools/codegen-companion/Metadata.cpp b/buildtools/codegen-companion/Metadata.cpp new file mode 100644 index 0000000..ee32054 --- /dev/null +++ b/buildtools/codegen-companion/Metadata.cpp @@ -0,0 +1 @@ +#include "Metadata.hpp" diff --git a/buildtools/codegen-companion/Metadata.hpp b/buildtools/codegen-companion/Metadata.hpp new file mode 100644 index 0000000..a038c15 --- /dev/null +++ b/buildtools/codegen-companion/Metadata.hpp @@ -0,0 +1,4 @@ +#pragma once + +#include "MacrosCodegen.hpp" +#include "MetadataBase.hpp" diff --git a/buildtools/codegen-companion/MetadataBase.cpp b/buildtools/codegen-companion/MetadataBase.cpp new file mode 100644 index 0000000..3ccf870 --- /dev/null +++ b/buildtools/codegen-companion/MetadataBase.cpp @@ -0,0 +1 @@ +#include "MetadataBase.hpp" diff --git a/buildtools/codegen-companion/MetadataBase.hpp b/buildtools/codegen-companion/MetadataBase.hpp new file mode 100644 index 0000000..8be668d --- /dev/null +++ b/buildtools/codegen-companion/MetadataBase.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include <optional> +#include <string_view> + +namespace Metadata { + +template <class TEnum> +std::string_view EnumToString(TEnum value); + +template <class TEnum> +std::optional<TEnum> EnumFromString(std::string_view str); + +} // namespace Metadata diff --git a/buildtools/codegen/CodegenUtils.inl b/buildtools/codegen/CodegenUtils.inl index f9d913e..6feb654 100644 --- a/buildtools/codegen/CodegenUtils.inl +++ b/buildtools/codegen/CodegenUtils.inl @@ -90,9 +90,9 @@ void ProduceGeneratedHeaderFileHeader(CodegenOutput& output) { void ProduceGeneratedSourceFileHeader(CodegenOutput& output) { output.AddOutputThing(CodegenOutputThing{ + // TODO we need to get the header name .text = &R"""( // This file is generated. Any changes will be overidden when building. -#include "GeneratedCode.hpp" #include <cstddef> #include <cstdint> diff --git a/buildtools/codegen/main.cpp b/buildtools/codegen/main.cpp index 2c259a4..b139515 100644 --- a/buildtools/codegen/main.cpp +++ b/buildtools/codegen/main.cpp @@ -642,6 +642,9 @@ void HandleInputFile(AppState& state, std::string_view filenameStem, std::string Utils::WriteOutputFile(cgHeaderOutput, state.outputDir, filenameStem, ".gh.inl"sv); Utils::WriteOutputFile(cgSourceOutput, state.outputDir, filenameStem, ".gs.inl"sv); + + // TODO see CMakeLists.txt for rationale, clean this up to be a proper citizen + Utils::WriteOutputFile(CodegenOutput{}, state.outputDir, filenameStem, ".gs.cpp"sv); } enum InputOpcode { @@ -750,8 +753,9 @@ where <output path>: the directory to write generated contents to. This will N } } - Utils::WriteOutputFile(state.mainHeaderOutput, state.outputDir, "GeneratedCode.hpp"sv); - Utils::WriteOutputFile(state.mainSourceOutput, state.outputDir, "GeneratedCode.cpp"sv); + // TODO do we even need these? + // Utils::WriteOutputFile(state.mainHeaderOutput, state.outputDir, "GeneratedCode.hpp"sv); + // Utils::WriteOutputFile(state.mainSourceOutput, state.outputDir, "GeneratedCode.cpp"sv); return 0; } |