Skip to content

Commit 30f1230

Browse files
authored
v83 - Fix local Frameworks, "src" files as relative paths, std::set for unique folders (#590)
1 parent c6503b0 commit 30f1230

3 files changed

Lines changed: 36 additions & 35 deletions

File tree

commandLine/src/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define OFPROJECTGENERATOR_MAJOR_VERSION "0"
2-
#define OFPROJECTGENERATOR_MINOR_VERSION "82"
2+
#define OFPROJECTGENERATOR_MINOR_VERSION "83"
33
#define OFPROJECTGENERATOR_PATCH_VERSION "0"
44

55
#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)

commandLine/src/main.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ void updateProject(const fs::path & path, const string & target, bool bConsiderP
255255
ofLogNotice() << "parsing addons.make";
256256
project->parseAddons();
257257
}
258+
for (auto & f : frameworks) {
259+
project->addFramework(f, "Frameworks", true);
260+
}
258261

259262
for (auto & srcPath : srcPaths) {
260263
project->addSrcRecursively(srcPath);
@@ -551,7 +554,7 @@ int main(int argc, char ** argv) {
551554
bAddonsPassedIn = true; // could be empty
552555
if (options[FRAMEWORKS].arg != NULL) {
553556
frameworks = ofSplitString(options[FRAMEWORKS].arg, ",", true, true);
554-
cout << "frameworks " << options[FRAMEWORKS].arg << endl;
557+
// cout << "frameworks " << options[FRAMEWORKS].arg << endl;
555558
}
556559
}
557560

@@ -702,12 +705,12 @@ int main(int argc, char ** argv) {
702705
for (auto & addon : addons) {
703706
project->addAddon(addon);
704707
}
705-
for (auto & f : frameworks) {
706-
project->addFramework(f, "", true);
707-
}
708708
}else{
709709
project->parseAddons();
710710
}
711+
for (auto & f : frameworks) {
712+
project->addFramework(f, "Frameworks", true);
713+
}
711714

712715
for (auto & s : srcPaths) {
713716
project->addSrcRecursively(s);

commandLine/src/projects/baseProject.cpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,13 @@ bool baseProject::create(const fs::path & _path, string templateName){
154154
// if (!fs::exists(projectDir)) {
155155
// fs::create_directory(projectDir);
156156
// }
157-
bool bDoesDirExist = false;
157+
bool bDoesSrcDirExist = false;
158158

159-
fs::path project { projectDir / "src" };
159+
// it can be only "src"
160+
fs::path projectSrc { projectDir / "src" };
160161

161-
if (fs::exists(project) && fs::is_directory(project)) {
162-
bDoesDirExist = true;
162+
if (fs::exists(projectSrc) && fs::is_directory(projectSrc)) {
163+
bDoesSrcDirExist = true;
163164
} else {
164165
for (auto & p : { fs::path("src"), fs::path("bin") }) {
165166
try {
@@ -214,40 +215,37 @@ bool baseProject::create(const fs::path & _path, string templateName){
214215

215216
parseConfigMake();
216217

217-
if (bDoesDirExist){
218-
vector < fs::path > fileNames;
219-
getFilesRecursively(projectDir / "src", fileNames);
218+
if (bDoesSrcDirExist){
219+
vector <fs::path> fileNames;
220+
221+
// CWD is already on projectDir. so with this we get relative paths
222+
getFilesRecursively("src", fileNames);
220223

221224
std::sort(fileNames.begin(), fileNames.end(), [](const fs::path & a, const fs::path & b) {
222225
return a.string() < b.string();
223226
});
224-
for (auto & f : fileNames) {
225-
fs::path rel { fs::relative(f, projectDir) };
226-
fs::path folder { rel.parent_path() };
227-
228-
string fileName = rel.string();
229-
230-
if (fileName != "src/ofApp.cpp" &&
231-
fileName != "src/ofApp.h" &&
232-
fileName != "src/main.cpp" &&
233-
fileName != "src/ofApp.mm" &&
234-
fileName != "src/main.mm") {
235-
addSrc(rel.string(), folder.string());
227+
for (const auto & f : fileNames) {
228+
if (f != "src/ofApp.cpp" &&
229+
f != "src/ofApp.h" &&
230+
f != "src/main.cpp" &&
231+
f != "src/ofApp.mm" &&
232+
f != "src/main.mm") {
233+
addSrc(f, f.parent_path());
236234
} else {
237235
}
238236
}
239-
// FIXME: Port to std::list, so no comparison is needed.
240-
vector < fs::path > paths;
237+
238+
std::set<fs::path> uniquePaths;
241239
for (auto & f : fileNames) {
242-
fs::path rel { fs::relative(fs::path(f).parent_path(), projectDir) };
243-
if (std::find(paths.begin(), paths.end(), rel) == paths.end()) {
244-
paths.emplace_back(rel);
245-
if (containsSourceFiles(rel)) {
246-
ofLogVerbose() << "[prjFiles-addIncludeDir] contains src - Adding dir: [" << rel.string() << "]";
247-
addInclude(rel);
248-
} else {
249-
ofLogVerbose() << "[prjFiles-addIncludeDir] no src - not adding: [" << rel.string() << "]";
250-
}
240+
uniquePaths.insert(f.parent_path());
241+
}
242+
243+
for (auto & p : uniquePaths) {
244+
if (containsSourceFiles(p)) {
245+
ofLogVerbose() << "[prjFiles-addIncludeDir] contains src - Adding dir: " << p;
246+
addInclude(p);
247+
} else {
248+
ofLogVerbose() << "[prjFiles-addIncludeDir] no src - not adding: " << p;
251249
}
252250
}
253251
}

0 commit comments

Comments
 (0)