Skip to content

Commit

Permalink
Support ifdef's in Makefiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibras committed Jan 9, 2019
1 parent 499deb2 commit 5de045e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion source/projectGenerator_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool ProjectGenerator::passStaticInclude(uint uiILength, StaticList& vStaticIncl

bool ProjectGenerator::passDynamicIncludeObject(uint& uiStartPos, uint& uiEndPos, string& sIdent, StaticList& vIncludes)
{
// Check if this is A valid File or a past compile option
// Check if this is a valid File or a past compile option
if (m_sInLine.at(uiStartPos) == '$') {
uiEndPos = m_sInLine.find(')', uiStartPos);
string sDynInc = m_sInLine.substr(uiStartPos + 2, uiEndPos - uiStartPos - 2);
Expand Down Expand Up @@ -470,6 +470,26 @@ bool ProjectGenerator::passMake()
m_ifInputFile.close();
return false;
}
} else if (m_sInLine.substr(0, 5) == "ifdef") {
// Check for configuration value
const uint startPos = m_sInLine.find_first_not_of(" \t", 5);
uint endPos = m_sInLine.find_first_of(" \t\n\r", startPos + 1);
endPos = (endPos == string::npos) ? endPos : endPos - startPos;
string config = m_sInLine.substr(startPos, endPos);
// Check if the config option is correct
auto option = m_ConfigHelper.getConfigOptionPrefixed(config);
if (option == m_ConfigHelper.m_configValues.end()) {
outputInfo("Unknown ifdef configuration option (" + config + ")");
return false;
}
if (option->m_value != "1") {
// Skip everything between the ifdefs
while (getline(m_ifInputFile, m_sInLine)) {
if ((m_sInLine.substr(0, 5) == "endif") || (m_sInLine.substr(0, 4) == "else")) {
break;
}
}
}
}
}
m_ifInputFile.close();
Expand Down

0 comments on commit 5de045e

Please sign in to comment.