Skip to content
Permalink
Browse files

Allow emake to specify ENIGMA path (#1930)

  • Loading branch information
fundies committed Mar 23, 2020
1 parent 5803a27 commit a9995016b85b37633eeff793673103bec262fc77
@@ -111,6 +111,7 @@ OptionsParser::OptionsParser() : _desc("Options")
("collision,c", opt::value<std::string>()->default_value("None"), "Collision System (Precise, BBox, None)")
("extensions,e", opt::value<std::string>()->default_value("None"), "Extensions (Alarms, Paths, Timelines, Particles, MotionPlanning, ttf, libpng, IniFilesystem, RegistrySpoof, Asynchronous, StudioPhysics, VirtualKeys, XRandR, XTEST, FileDropper, None)")
("compiler,x", opt::value<std::string>()->default_value(def_compiler), "Compiler.ey Descriptor")
("enigma-root,s", opt::value<std::string>()->default_value(fs::current_path().string()), "Path to ENIGMA's sources")
("run,r", opt::bool_switch()->default_value(false), "Automatically run the game after it is built")
;

@@ -147,6 +148,10 @@ int OptionsParser::ReadArgs(int argc, char* argv[])
opt::store(opt::command_line_parser(argc, argv)
.options(_desc).positional(_positional).run(),
_rawArgs);

_enigmaRoot = fs::absolute(_rawArgs["enigma-root"].as<std::string>()).string();

if (!_enigmaRoot.empty() && _enigmaRoot.back() != '/') _enigmaRoot += "/";

if (!_rawArgs.count("info"))
opt::notify(_rawArgs);
@@ -220,6 +225,7 @@ std::string OptionsParser::APIyaml(const buffers::resources::Settings* currentCo
network = _rawArgs["network"].as<std::string>(),
eobjs_directory = fs::absolute(_rawArgs["workdir"].as<std::string>()).string(),
codegen_directory = fs::absolute(_rawArgs["codegen"].as<std::string>()).string();


int inherit_strings = 0,
inherit_escapes = 0,
@@ -259,6 +265,7 @@ std::string OptionsParser::APIyaml(const buffers::resources::Settings* currentCo
yaml += "inherit-equivalence-from: " + std::to_string(inherit_equivalence) + "\n";
yaml += "eobjs-directory: " + eobjs_directory + "\n";
yaml += "codegen-directory: " + codegen_directory + "\n";
yaml += "enigma-root: " + _enigmaRoot + "\n";
yaml += "sample-checkbox: on\n";
yaml += "sample-edit: DEADBEEF\n";
yaml += "sample-combobox: 0\n";
@@ -283,7 +290,8 @@ std::string OptionsParser::APIyaml(const buffers::resources::Settings* currentCo

int OptionsParser::find_ey(const char* dir)
{
fs::path targetDir(dir);
fs::path targetDir(_enigmaRoot);
targetDir /= dir;
fs::recursive_directory_iterator iter(targetDir);

for(auto& p : iter)
@@ -54,6 +54,7 @@ class OptionsParser

bool _readArgsFail;
std::string _extensions;
std::string _enigmaRoot;

opt::variables_map _rawArgs;
opt::options_description _desc;
@@ -217,6 +217,7 @@ int lang_CPP::compile(const GameData &game, const char* exe_filename, int mode)
edbg << "Cleaning..." << flushl;

string make = compilerInfo.make_vars["MAKEFLAGS"];
make += " -C " + enigma_root + " ";
make += " clean-game ";
make += "COMPILEPATH=\"" + compilepath + "\" ";
make += "WORKDIR=\"" + eobjs_directory + "\" ";
@@ -524,6 +525,7 @@ int lang_CPP::compile(const GameData &game, const char* exe_filename, int mode)

string make = compilerInfo.make_vars["MAKEFLAGS"];

make += "-C " + enigma_root + " ";
make += "Game ";
make += "WORKDIR=\"" + eobjs_directory + "\" ";
make += "CODEGEN=\"" + codegen_directory + "\" ";
@@ -104,6 +104,8 @@ static void reset_ide_editables()

extern const char* establish_bearings(const char *compiler);

std::string enigma_root;

void parse_ide_settings(const char* eyaml)
{
ey_data settree = parse_eyaml_str(eyaml);
@@ -135,6 +137,12 @@ void parse_ide_settings(const char* eyaml)
setting::automatic_semicolons = settree.get("automatic-semicolons").toBool();
setting::keyword_blacklist = settree.get("keyword-blacklist").toString();

// Path to enigma sources
enigma_root = settree.get("enigma-root").toString();
if (enigma_root.empty()) {
enigma_root = ".";
}

// Use a platform-specific make directory.
eobjs_directory = settree.get("eobjs-directory").toString();

@@ -156,11 +164,16 @@ void parse_ide_settings(const char* eyaml)
#if CURRENT_PLATFORM_ID == OS_WINDOWS
eobjs_directory = myReplace(escapeEnv(eobjs_directory), "\\","/");
codegen_directory = myReplace(escapeEnv(codegen_directory), "\\","/");
enigma_root = myReplace(escapeEnv(enigma_root), "\\","/");
#else
eobjs_directory = escapeEnv(eobjs_directory);
codegen_directory = escapeEnv(codegen_directory);
enigma_root = escapeEnv(enigma_root);
#endif

if (enigma_root.back() != '/')
enigma_root += '/';

if (eobjs_directory.back() != '/')
eobjs_directory += '/';

@@ -190,7 +203,7 @@ void parse_ide_settings(const char* eyaml)
ey_cp(network, networking,system)

ifstream ifs; string eyname;
ifs.open((eyname = "ENIGMAsystem/SHELL/Platforms/" + extensions::targetAPI.windowSys + "/Info/About.ey").c_str());
ifs.open((eyname = enigma_root + "ENIGMAsystem/SHELL/Platforms/" + extensions::targetAPI.windowSys + "/Info/About.ey").c_str());
if (ifs.is_open())
{
ey_data l = parse_eyaml(ifs, eyname.c_str());
@@ -223,7 +236,7 @@ void parse_ide_settings(const char* eyaml)
eygl(Networking_Systems, network);

string target_compiler = settree.get("target-compiler");
string cinffile = "Compilers/" CURRENT_PLATFORM_NAME "/" + target_compiler + ".ey";
string cinffile = enigma_root + "Compilers/" CURRENT_PLATFORM_NAME "/" + target_compiler + ".ey";

const char *a = establish_bearings(cinffile.c_str());
if (a) cout << "Parse fail: " << a << endl;
@@ -94,7 +94,7 @@ struct CompilerInfo {
};

extern CompilerInfo compilerInfo;

extern std::string enigma_root;
bool load_compiler_ey(std::string fPath);

#endif

0 comments on commit a999501

Please sign in to comment.
You can’t perform that action at this time.