From 741cfe452156f7c6365d1a66b6228e15ef660bf6 Mon Sep 17 00:00:00 2001 From: ClarkeCode Date: Tue, 13 Jun 2023 23:41:28 -0400 Subject: Rough draft of compiling headless simulation --- SConstruct | 45 +++++++++++++++++++++++++++++++++++ headless_main.cpp | 22 ----------------- src/headless/main.cpp | 22 +++++++++++++++++ src/openvic/dataloader/Dataloader.hpp | 4 ++-- 4 files changed, 69 insertions(+), 24 deletions(-) create mode 100644 SConstruct delete mode 100644 headless_main.cpp create mode 100644 src/headless/main.cpp diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..50edb8f --- /dev/null +++ b/SConstruct @@ -0,0 +1,45 @@ +#!/usr/bin/env python +import os +import sys +from glob import glob +from pathlib import Path + +def GlobRecursive(pattern, nodes=['.']): + import SCons + results = [] + for node in nodes: + nnodes = [] + for f in Glob(str(node) + '/*', source=True): + if type(f) is SCons.Node.FS.Dir: + nnodes.append(f) + results += GlobRecursive(pattern, nnodes) + results += Glob(str(node) + '/' + pattern, source=True) + return results + +# For future reference: +# - CCFLAGS are compilation flags shared between C and C++ +# - CFLAGS are for C-specific compilation flags +# - CXXFLAGS are for C++-specific compilation flags +# - CPPFLAGS are for pre-processor flags +# - CPPDEFINES are for pre-processor defines +# - LINKFLAGS are for linking flags +env = Environment( + CPPDEFINES=["OPENVIC_HEADLESS_SIM"] +) + +# Require C++20 +if sys.platform == "win32" or sys.platform == "msys": + env.Append(CXXFLAGS=["/std:c++20", "/EHsc"]) +else: + env.Append(CXXFLAGS=["-std=c++20"]) + +# Tweak this if you want to use different folders, or more folders, to store your source code in. +paths = ["src"] +env.Append(CPPPATH=paths) +sources = GlobRecursive("*.cpp", paths) + +program = env.Program("headless-sim", sources) + + +Default(program) + diff --git a/headless_main.cpp b/headless_main.cpp deleted file mode 100644 index 20d89ee..0000000 --- a/headless_main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef OPENVIC_HEADLESS_SIM -#include -#include -#include "src/openvic/Simulation.hpp" -#include "src/openvic/dataloader/Dataloader.hpp" - - -int main() { - std::cout << "HEADLESS SIMULATION" << std::endl; - - - std::string vic2FolderLocation = ""; - if (vic2FolderLocation.length() <= 0) { - std::cout << "Path to Victoria 2 folder not specified. Manually specify location: "; - std::cin >> vic2FolderLocation; - } - std::filesystem::path path(vic2FolderLocation); - - OpenVic::Simulation sim; - std::cout << (OpenVic::Dataloader::loadDir(path, sim) ? "Dataloader suceeded" : "Dataloader failed") << std::endl; -} -#endif \ No newline at end of file diff --git a/src/headless/main.cpp b/src/headless/main.cpp new file mode 100644 index 0000000..70a57a9 --- /dev/null +++ b/src/headless/main.cpp @@ -0,0 +1,22 @@ +#ifdef OPENVIC_HEADLESS_SIM +#include +#include +#include "openvic/Simulation.hpp" +#include "openvic/dataloader/Dataloader.hpp" + + +int main() { + std::cout << "HEADLESS SIMULATION" << std::endl; + + + std::string vic2FolderLocation = ""; + if (vic2FolderLocation.length() <= 0) { + std::cout << "Path to Victoria 2 folder not specified. Manually specify location: "; + std::cin >> vic2FolderLocation; + } + std::filesystem::path path(vic2FolderLocation); + + OpenVic::Simulation sim; + std::cout << (OpenVic::Dataloader::loadDir(path, sim) ? "Dataloader suceeded" : "Dataloader failed") << std::endl; +} +#endif \ No newline at end of file diff --git a/src/openvic/dataloader/Dataloader.hpp b/src/openvic/dataloader/Dataloader.hpp index 250d100..062f3d5 100644 --- a/src/openvic/dataloader/Dataloader.hpp +++ b/src/openvic/dataloader/Dataloader.hpp @@ -6,10 +6,10 @@ namespace OpenVic { class Dataloader { public: enum class LoadingMode { - DL_COMPATABILITY + DL_COMPATIBILITY }; - static bool loadDir(std::filesystem::path p, Simulation& sim, LoadingMode loadMode = LoadingMode::DL_COMPATABILITY) { + static bool loadDir(std::filesystem::path p, Simulation& sim, LoadingMode loadMode = LoadingMode::DL_COMPATIBILITY) { return true; } }; -- cgit v1.2.3-56-ga3b1