Add a "--buildInfo" argument to print the compiler and optimization options used when building
This commit is contained in:
parent
0ce02ea77f
commit
88d22e6183
@ -79,6 +79,7 @@ elseif(${IS_CLANG})
|
|||||||
endif()
|
endif()
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=full -fwhole-program-vtables -fstrict-vtable-pointers")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=full -fwhole-program-vtables -fstrict-vtable-pointers")
|
||||||
endif()
|
endif()
|
||||||
|
add_definitions(-DYBCON_FLAGS="${CMAKE_CXX_FLAGS_RELEASE}" -DYBCON_COMPILER="${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
|
||||||
|
|
||||||
if (MINGW OR MSVC)
|
if (MINGW OR MSVC)
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
@ -6,6 +6,14 @@
|
|||||||
#define YBCON_VERSION "UNKNOWN"
|
#define YBCON_VERSION "UNKNOWN"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef YBCON_FLAGS
|
||||||
|
#define YBCON_FLAGS "none"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef YBCON_COMPILER
|
||||||
|
#define YBCON_COMPILER "unknown"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __STDC_NO_THREADS__
|
#ifdef __STDC_NO_THREADS__
|
||||||
#error "A valid std::threads implementation is required"
|
#error "A valid std::threads implementation is required"
|
||||||
#endif
|
#endif
|
||||||
@ -27,6 +35,11 @@
|
|||||||
|
|
||||||
namespace Yerbacon {
|
namespace Yerbacon {
|
||||||
consteval const char* getVersion() noexcept { return YBCON_VERSION; }
|
consteval const char* getVersion() noexcept { return YBCON_VERSION; }
|
||||||
|
consteval const char* getBuildInfo() noexcept { return
|
||||||
|
"Build info:\n"
|
||||||
|
" Optimization flags: " YBCON_FLAGS "\n"
|
||||||
|
" Compiler: " YBCON_COMPILER;
|
||||||
|
}
|
||||||
static void exit(const std::initializer_list<const char*> reason) {
|
static void exit(const std::initializer_list<const char*> reason) {
|
||||||
std::for_each(reason.begin(), reason.end(), [](const char* current_string){
|
std::for_each(reason.begin(), reason.end(), [](const char* current_string){
|
||||||
std::cout << current_string;
|
std::cout << current_string;
|
||||||
@ -48,4 +61,6 @@ namespace Yerbacon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#undef YBCON_VERSION
|
#undef YBCON_VERSION
|
||||||
|
#undef YBCON_FLAGS
|
||||||
|
#undef YBCON_COMPILER
|
||||||
#endif
|
#endif
|
14
src/main.cpp
14
src/main.cpp
@ -18,8 +18,7 @@ int main(int argc, char* argv[]) {
|
|||||||
for (signed int i = 1; i < argc; ++i)
|
for (signed int i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
const string_view currentArg (argv[i]);
|
const string_view currentArg (argv[i]);
|
||||||
if ((argc == 2) && (currentArg == Argument("version"))) { cout << Yerbacon::getVersion() << endl; exit(EXIT_SUCCESS); }
|
if (currentArg == ArgumentShort("printresult")) printResult = true;
|
||||||
else if (currentArg == ArgumentShort("printresult")) printResult = true;
|
|
||||||
else if (currentArg == ArgumentAssignable("target")) {
|
else if (currentArg == ArgumentAssignable("target")) {
|
||||||
const string_view value = ArgumentAssignable::getValueFor(currentArg);
|
const string_view value = ArgumentAssignable::getValueFor(currentArg);
|
||||||
if (not value.empty()) (target = '.') += value;
|
if (not value.empty()) (target = '.') += value;
|
||||||
@ -28,7 +27,16 @@ int main(int argc, char* argv[]) {
|
|||||||
else if (currentArg == Argument("parallel")) parallel = true;
|
else if (currentArg == Argument("parallel")) parallel = true;
|
||||||
else if (currentArg == Argument("newlinesoff")) newLines = false;
|
else if (currentArg == Argument("newlinesoff")) newLines = false;
|
||||||
else if (currentArg.ends_with(".ybcon")) files.insert(currentArg);
|
else if (currentArg.ends_with(".ybcon")) files.insert(currentArg);
|
||||||
else Yerbacon::exit({"\"", currentArg.data(), "\" is not a valid argument."});
|
else {
|
||||||
|
if (argc == 2) {
|
||||||
|
if (currentArg == Argument("version")) {
|
||||||
|
cout << Yerbacon::getVersion();
|
||||||
|
} else if (currentArg == Argument("buildInfo")) {
|
||||||
|
cout << Yerbacon::getBuildInfo() ;
|
||||||
|
} else goto invalid_argument;
|
||||||
|
cout << endl; exit(EXIT_SUCCESS);
|
||||||
|
} else invalid_argument: Yerbacon::exit({"\"", currentArg.data(), "\" is not a valid argument."});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const auto compile = [&target, &newLines](string_view name) -> string {
|
const auto compile = [&target, &newLines](string_view name) -> string {
|
||||||
string transpiledString = transpile(parseString(getFileContent(name.data())), target, newLines);
|
string transpiledString = transpile(parseString(getFileContent(name.data())), target, newLines);
|
||||||
|
Loading…
Reference in New Issue
Block a user