Files
nostalgia/src/olympic/applib/applib.cpp
Gary Talent cb304ecf28
All checks were successful
Build / build (push) Successful in 1m12s
[applib] Cleanup
2025-05-17 17:46:38 -05:00

80 lines
1.8 KiB
C++

/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <ox/logconn/def.hpp>
#include <ox/logconn/logconn.hpp>
#ifndef OLYMPIC_PROJECT_NAME
#define OLYMPIC_PROJECT_NAME "OlympicProject"
#endif
#ifndef OLYMPIC_APP_NAME
#define OLYMPIC_APP_NAME "App"
#endif
#ifndef OLYMPIC_APP_VERSION
#define OLYMPIC_APP_VERSION "dev build"
#endif
#ifndef OLYMPIC_GUI_APP
#define OLYMPIC_GUI_APP 0
#endif
#ifndef OLYMPIC_PROJECT_NAMESPACE
#define OLYMPIC_PROJECT_NAMESPACE project
#endif
#ifndef OLYMPIC_PROJECT_DATADIR
#define OLYMPIC_PROJECT_DATADIR ".keel"
#endif
#ifndef OLYMPIC_LOAD_KEEL_MODULES
#define OLYMPIC_LOAD_KEEL_MODULES 1
#endif
#ifndef OLYMPIC_LOAD_STUDIO_MODULES
#define OLYMPIC_LOAD_STUDIO_MODULES 0
#endif
namespace olympic {
ox::String appVersion{OLYMPIC_APP_VERSION};
}
ox::Error run(
ox::StringView project,
ox::StringView appName,
ox::StringView projectDataDir,
ox::SpanView<ox::CString> argv) noexcept;
namespace OLYMPIC_PROJECT_NAMESPACE {
void registerKeelModules() noexcept;
void registerStudioModules() noexcept;
}
#if defined(_WIN32) && OLYMPIC_GUI_APP
int WinMain() {
auto const argc = __argc;
auto const argv = const_cast<const char**>(__argv);
#else
int main(int const argc, char const **argv) {
#endif
OX_INIT_DEBUG_LOGGER(loggerConn, OLYMPIC_PROJECT_NAME " " OLYMPIC_APP_NAME)
#if OLYMPIC_LOAD_KEEL_MODULES
OLYMPIC_PROJECT_NAMESPACE::registerKeelModules();
#endif
#if OLYMPIC_LOAD_STUDIO_MODULES
OLYMPIC_PROJECT_NAMESPACE::registerStudioModules();
#endif
auto const err = run(
OLYMPIC_PROJECT_NAME,
OLYMPIC_APP_NAME,
OLYMPIC_PROJECT_DATADIR,
{argv, static_cast<size_t>(argc)});
oxAssert(err, "Something went wrong...");
if (err) {
oxErrf("Failure: {}\n", toStr(err));
}
return static_cast<int>(err);
}