VoxelEngine/src/main.cpp
MihailRis f5868b65f0 add build info to release (#725)
* attempt to add VC_BUILD_NAME

* fix

* fix

* update macos.yml

* fix

* update macos.yml

* update macos.yml

* add debug step

* update

* update

* fix release.yml

* update cmake

* update WindowControl.cpp

* update workflows

* update release.yml

* add --output-always

* cleanup
2025-12-08 19:21:50 +03:00

53 lines
1.3 KiB
C++

#include "engine/Engine.hpp"
#include "util/platform.hpp"
#include "util/command_line.hpp"
#include "debug/Logger.hpp"
#include <csignal>
#include <iostream>
#include <stdexcept>
static debug::Logger logger("main");
static void sigterm_handler(int signum) {
Engine::getInstance().quit();
}
int main(int argc, char** argv) {
#ifdef VC_BUILD_NAME
logger.info() << "build: " << VC_BUILD_NAME;
#endif
CoreParameters coreParameters;
try {
if (!parse_cmdline(argc, argv, coreParameters)) {
return EXIT_SUCCESS;
}
} catch (const std::runtime_error& err) {
std::cerr << err.what() << std::endl;
return EXIT_FAILURE;
}
std::signal(SIGTERM, sigterm_handler);
debug::Logger::init(coreParameters.userFolder.string() + "/latest.log");
platform::configure_encoding();
auto& engine = Engine::getInstance();
try {
engine.initialize(std::move(coreParameters));
engine.run();
} catch (const initialize_error& err) {
logger.error() << err.what();
logger.error() << "could not to initialize engine";
}
#if defined(NDEBUG) and defined(_WIN32)
catch (const std::exception& err) {
logger.error() << "uncaught exception: " << err.what();
debug::Logger::flush();
throw;
}
#endif
Engine::terminate();
return EXIT_SUCCESS;
}