Add a Yerbacon header (+ namespace) and move the getVersion function into it.

This commit is contained in:
Username404-59 2021-07-06 15:43:33 +02:00
parent a222e8a165
commit 3359dc7649
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
4 changed files with 11 additions and 4 deletions

View File

@ -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}") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${TIME}")
include_directories(${CMAKE_CURRENT_LIST_DIR}) 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}") target_compile_definitions(ybcon PRIVATE YBCON_VERSION="${CODENAME} ${PROJECT_VERSION}")
# lpkg = linux package, wpkg = windows package # lpkg = linux package, wpkg = windows package

8
src/headers/Yerbacon.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef YERBACON_HPP
#define YERBACON_HPP
namespace Yerbacon {
consteval const char* getVersion() noexcept { return YBCON_VERSION; }
}
#endif

View File

@ -5,8 +5,6 @@
#define YBCON_VERSION "UNKNOWN" #define YBCON_VERSION "UNKNOWN"
#endif #endif
consteval const char* getVersion() noexcept { return YBCON_VERSION; }
string getFileContent(const string& file); string getFileContent(const string& file);
void outputFileContent(const string& file, string_view content); void outputFileContent(const string& file, string_view content);

View File

@ -5,9 +5,10 @@
using namespace std; using namespace std;
#include "headers/misc.hpp" #include "headers/misc.hpp"
#include "headers/Yerbacon.hpp"
int main(int argc, char* argv[]) { 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 target = ".lua";
string_view currentArg; string_view currentArg;
bool printResult = false; bool printResult = false;