From 3359dc7649fd549ec48b26558b0072ec0f3160b3 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Tue, 6 Jul 2021 15:43:33 +0200 Subject: [PATCH] Add a Yerbacon header (+ namespace) and move the getVersion function into it. --- CMakeLists.txt | 2 +- src/headers/Yerbacon.hpp | 8 ++++++++ src/headers/misc.hpp | 2 -- src/main.cpp | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 src/headers/Yerbacon.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 83c166d..6a74528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "Yerbacon ${CMAKE_PROJECT_VERSION_MAJOR}.${C set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${TIME}") include_directories(${CMAKE_CURRENT_LIST_DIR}) -add_executable(${EXENAME} src/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/processed/${PROJECT_NAME}.rc src/parser/MainParse.cpp src/transpiler/MainTranspile.cpp src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp src/headers/misc.hpp src/headers/parsing/ParseComponents.hpp src/headers/transpiler/Target.hpp src/headers/transpiler/implementations/Lua.hpp src/headers/transpiler/implementations/Js.hpp src/headers/transpiler/implementations/Py.hpp src/headers/parsing/Parser.hpp) +add_executable(${EXENAME} src/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/processed/${PROJECT_NAME}.rc src/parser/MainParse.cpp src/transpiler/MainTranspile.cpp src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp src/headers/misc.hpp src/headers/parsing/ParseComponents.hpp src/headers/transpiler/Target.hpp src/headers/transpiler/implementations/Lua.hpp src/headers/transpiler/implementations/Js.hpp src/headers/transpiler/implementations/Py.hpp src/headers/parsing/Parser.hpp src/headers/Yerbacon.hpp) target_compile_definitions(ybcon PRIVATE YBCON_VERSION="${CODENAME} ${PROJECT_VERSION}") # lpkg = linux package, wpkg = windows package diff --git a/src/headers/Yerbacon.hpp b/src/headers/Yerbacon.hpp new file mode 100644 index 0000000..50bfb90 --- /dev/null +++ b/src/headers/Yerbacon.hpp @@ -0,0 +1,8 @@ +#ifndef YERBACON_HPP +#define YERBACON_HPP + +namespace Yerbacon { + consteval const char* getVersion() noexcept { return YBCON_VERSION; } +} + +#endif \ No newline at end of file diff --git a/src/headers/misc.hpp b/src/headers/misc.hpp index 5468268..9a61602 100644 --- a/src/headers/misc.hpp +++ b/src/headers/misc.hpp @@ -5,8 +5,6 @@ #define YBCON_VERSION "UNKNOWN" #endif -consteval const char* getVersion() noexcept { return YBCON_VERSION; } - string getFileContent(const string& file); void outputFileContent(const string& file, string_view content); diff --git a/src/main.cpp b/src/main.cpp index 61d7ef5..1440bd1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,9 +5,10 @@ using namespace std; #include "headers/misc.hpp" +#include "headers/Yerbacon.hpp" int main(int argc, char* argv[]) { - if ((argc == 2) && (((string) argv[1]) == "--version")) { cout << getVersion() << endl; exit(EXIT_SUCCESS); } + if ((argc == 2) && (((string) argv[1]) == "--version")) { cout << Yerbacon::getVersion() << endl; exit(EXIT_SUCCESS); } string target = ".lua"; string_view currentArg; bool printResult = false;