Skip to content

Commit 8713cb7

Browse files
committed
Handle project sub directories.
1 parent c712535 commit 8713cb7

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

include/projectGenerator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class ProjectGenerator
6363
UnknownList m_unknowns;
6464
string m_projectName;
6565
string m_projectDir;
66+
StaticList m_subDirs;
6667

6768
map<string, StaticList> m_projectLibs;
6869

source/projectGenerator.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ bool ProjectGenerator::passAllMake()
6868
// Check if library is enabled
6969
if (m_configHelper.isConfigOptionEnabled(i)) {
7070
m_projectDir = m_configHelper.m_rootDirectory + "lib" + i + "/";
71+
const uint pos = m_projectDir.rfind('/', m_projectDir.length() - 2) + 1;
72+
m_projectName = m_projectDir.substr(pos, m_projectDir.length() - 1 - pos);
7173
// Locate the project dir for specified library
7274
string retFileName;
7375
if (!findFile(m_projectDir + "MakeFile", retFileName)) {
@@ -185,10 +187,6 @@ void ProjectGenerator::errorFunc(const bool cleanupFiles)
185187

186188
bool ProjectGenerator::outputProject()
187189
{
188-
// Output the generated files
189-
const uint pos = m_projectDir.rfind('/', m_projectDir.length() - 2) + 1;
190-
m_projectName = m_projectDir.substr(pos, m_projectDir.length() - 1 - pos);
191-
192190
// Check all files are correctly located
193191
if (!checkProjectFiles()) {
194192
return false;
@@ -431,6 +429,7 @@ void ProjectGenerator::outputProjectCleanup()
431429
m_libs.clear();
432430
m_unknowns.clear();
433431
m_projectDir.clear();
432+
m_subDirs.clear();
434433
}
435434

436435
bool ProjectGenerator::outputSolution()

source/projectGenerator_build.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ void ProjectGenerator::buildDependencyValues(StaticList& includeDirs, StaticList
254254
StaticList& definesShared, StaticList& definesStatic, const bool winrt) const
255255
{
256256
// Add hard dependencies
257-
string dep;
257+
string projRoot = "$(ProjectDir)/";
258258
string atomicCompatFile = m_configHelper.m_rootDirectory + "compat/atomics/win32/stdatomic.h";
259+
string dep;
259260
if (findFile(atomicCompatFile, dep)) {
260261
m_configHelper.makeFileProjectRelative(atomicCompatFile, atomicCompatFile);
261262
uint pos = atomicCompatFile.rfind('/'); // Get path only
@@ -266,8 +267,17 @@ void ProjectGenerator::buildDependencyValues(StaticList& includeDirs, StaticList
266267
// Add root directory
267268
if (m_configHelper.m_rootDirectory != "./" && m_configHelper.m_rootDirectory != "../") {
268269
m_configHelper.makeFileProjectRelative(m_configHelper.m_rootDirectory, dep);
269-
includeDirs.push_back("$(ProjectDir)/" + dep);
270+
projRoot += dep;
271+
includeDirs.push_back(projRoot);
272+
}
273+
274+
// Add subdirectory include dirs
275+
for (const auto& sub : m_subDirs) {
276+
includeDirs.push_back(projRoot + m_projectName + '/' + sub + '/');
270277
}
278+
if (!m_subDirs.empty()) {
279+
includeDirs.push_back(projRoot + m_projectName + '/');
280+
}
271281

272282
// Determine only those dependencies that are valid for current project
273283
map<string, bool> projectDeps;

source/projectGenerator_pass.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,32 @@ bool ProjectGenerator::passMake()
672672
startPos = newMake.find('$', startPos);
673673
}
674674
makeFiles.push_back(newMake);
675+
// Add to internal list of known subdirectories
676+
const uint rootPos = newMake.find(m_configHelper.m_rootDirectory);
677+
if (rootPos != string::npos) {
678+
newMake.erase(rootPos, m_configHelper.m_rootDirectory.length());
679+
}
680+
const uint projPos = newMake.find(m_projectName + '/');
681+
if (projPos != string::npos) {
682+
newMake.erase(projPos, m_projectName.length() + 1);
683+
}
684+
// Clean duplicate '//'
685+
uint findPos2 = newMake.find("//");
686+
while (findPos2 != string::npos) {
687+
newMake.erase(findPos2, 1);
688+
// get next
689+
findPos2 = newMake.find("//");
690+
}
691+
if (newMake[0] == '/') {
692+
newMake.erase(0, 1);
693+
}
694+
findPos2 = newMake.rfind('/');
695+
if (findPos2 != string::npos) {
696+
newMake.erase(findPos2);
697+
}
698+
if (!newMake.empty()) {
699+
m_subDirs.push_back(newMake);
700+
}
675701
}
676702
}
677703
m_inputFile.close();

0 commit comments

Comments
 (0)