Skip to content

Commit

Permalink
DEVTOOLS: CREATE_PROJECT: Add support for components
Browse files Browse the repository at this point in the history
We scan the configure file and enable all components
  • Loading branch information
sev- committed Dec 2, 2024
1 parent 3300cbf commit 4d9a239
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
55 changes: 54 additions & 1 deletion devtools/create_project/create_project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions devtools/create_project/create_project.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ typedef std::list<Tool> ToolList;
*/
FeatureList getAllFeatures();

StringList getAllComponents(const std::string &srcDir);

/**
* Returns a list of all defines, according to the feature set
* passed.
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 4d9a239

Please sign in to comment.