diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 7051c4157b3a9..5462a45fd32dc 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -132,6 +132,7 @@ int main(int argc, char *argv[]) { } setup.features = getAllFeatures(); + setup.components = getAllComponents(setup.srcDir); ProjectType projectType = kProjectNone; const MSVCVersion *msvc = nullptr; @@ -317,6 +318,11 @@ int main(int argc, char *argv[]) { std::string libsDir = unifyPath(argv[++i]); removeTrailingSlash(libsDir); setup.libsDir = libsDir; + } else if (!std::strcmp(argv[i], "--list-components")) { + for (StringList::const_iterator j = setup.components.begin(); j != setup.components.end(); ++j) + cout << ' ' << *j << "\n"; + + return 0; } else { std::cerr << "ERROR: Unknown parameter \"" << argv[i] << "\"\n"; return -1; @@ -435,6 +441,9 @@ int main(int argc, char *argv[]) { StringList featureDefines = getFeatureDefines(setup.features); setup.defines.splice(setup.defines.begin(), featureDefines); + // Add all components + setup.defines.splice(setup.defines.begin(), setup.components); + if (projectType == kProjectXcode) { setup.defines.push_back("POSIX"); // Define both MACOSX, and IPHONE, but only one of them will be associated to the @@ -1148,7 +1157,6 @@ const Feature s_features[] = { { "highres", "USE_HIGHRES", false, true, "high resolution" }, { "imgui", "USE_IMGUI", false, true, "Dear ImGui based debugger" }, { "mt32emu", "USE_MT32EMU", false, true, "integrated MT-32 emulator" }, - { "lua", "USE_LUA", false, true, "lua" }, { "nasm", "USE_NASM", false, true, "IA-32 assembly support" }, // This feature is special in the regard, that it needs additional handling. { "tinygl", "USE_TINYGL", false, true, "TinyGL support" }, { "opengl", "USE_OPENGL", false, true, "OpenGL support" }, @@ -1220,6 +1228,51 @@ FeatureList getAllFeatures() { return features; } +StringList getAllComponents(const std::string &srcDir) { + std::string configureFile = srcDir + "/configure"; + + std::ifstream configure(configureFile.c_str()); + if (!configure) + return StringList(); + + std::string line; + StringList components; + bool seenComponents = false; + + for (;;) { + std::getline(configure, line); + if (configure.eof()) + break; + + if (configure.fail()) + error("Failed while reading from " + configureFile); + + TokenList tokens = tokenize(line); + + if (tokens.size() < 4) + continue; + + TokenList::const_iterator token = tokens.begin(); + + // add_component lua "lua" "USE_LUA" + if (*token != "add_component") { + if (seenComponents) // No need to read whole file + break; + else + continue; + } + + seenComponents = true; + ++token; + ++token; + ++token; + + components.push_back(*token); + } + + return components; +} + StringList getFeatureDefines(const FeatureList &features) { StringList defines; diff --git a/devtools/create_project/create_project.h b/devtools/create_project/create_project.h index 7327434d8e144..e784453a2a42a 100644 --- a/devtools/create_project/create_project.h +++ b/devtools/create_project/create_project.h @@ -188,6 +188,8 @@ typedef std::list ToolList; */ FeatureList getAllFeatures(); +StringList getAllComponents(const std::string &srcDir); + /** * Returns a list of all defines, according to the feature set * passed. @@ -238,6 +240,8 @@ struct BuildSetup { EngineDescList engines; ///< Engine list for the build (this may contain engines, which are *not* enabled!). FeatureList features; ///< Feature list for the build (this may contain features, which are *not* enabled!). + StringList components; + StringList defines; ///< List of all defines for the build. StringList testDirs; ///< List of all folders containing tests