@@ -37,7 +37,7 @@ fs::path baseProject::getPlatformTemplateDir() {
3737// if ( target == "qtcreator" ) {
3838// return getOFRoot()
3939// }
40-
40+
4141 return getOFRoot () / templatesFolder / folder;
4242}
4343
@@ -125,7 +125,7 @@ bool baseProject::create(const fs::path & _path, string templateName){
125125// alert("getOFRoot() " + fs::weakly_canonical(fs::absolute(getOFRoot())).string());
126126// alert("path " + path.string());
127127// alert("path " + fs::weakly_canonical(fs::absolute(path)).string());
128-
128+
129129// cout << endl;
130130// ofLogNotice() << "create project " << path;
131131
@@ -144,14 +144,14 @@ bool baseProject::create(const fs::path & _path, string templateName){
144144 templatePath = getPlatformTemplateDir ();
145145 ofLogNotice () << " templatePath: " << templatePath;
146146 auto projectPath = fs::canonical (fs::current_path () / path);
147-
147+
148148// projectDir = path;
149149 projectDir = " " ;
150150 projectPath = normalizePath (projectPath);
151151 ofLogNotice () << " projectPath: " << projectPath;
152-
152+
153153 projectName = projectPath.filename ().string ();
154-
154+
155155 // we had this in some projects. if we decide to keep this is the place
156156 // if (!fs::exists(projectDir)) {
157157 // fs::create_directory(projectDir);
@@ -160,7 +160,7 @@ bool baseProject::create(const fs::path & _path, string templateName){
160160
161161 // it can be only "src"
162162 fs::path projectSrc { projectDir / " src" };
163-
163+
164164 if (fs::exists (projectSrc) && fs::is_directory (projectSrc)) {
165165 bDoesSrcDirExist = true ;
166166 } else {
@@ -173,7 +173,7 @@ bool baseProject::create(const fs::path & _path, string templateName){
173173 ofLogNotice () << e.what ();
174174
175175 }
176-
176+
177177 }
178178 }
179179 bool ret = createProjectFile ();
@@ -195,7 +195,7 @@ bool baseProject::create(const fs::path & _path, string templateName){
195195 for (auto & rename: templateConfig->renames ){
196196 auto from = projectDir / rename.first ;
197197 auto to = projectDir / rename.second ;
198-
198+
199199 if (fs::exists (to)) {
200200 fs::remove (to);
201201 }
@@ -222,14 +222,14 @@ bool baseProject::create(const fs::path & _path, string templateName){
222222
223223 // CWD is already on projectDir. so with this we get relative paths
224224 getFilesRecursively (" src" , fileNames);
225-
225+
226226 std::sort (fileNames.begin (), fileNames.end (), [](const fs::path & a, const fs::path & b) {
227227 return a.string () < b.string ();
228228 });
229-
229+
230230 // FIXME: I think we should remove this logic and remove the files from default project.
231231 // only the files present are added to the project
232-
232+
233233 for (const auto & f : fileNames) {
234234 if (f != " src/ofApp.cpp" &&
235235 f != " src/ofApp.h" &&
@@ -245,7 +245,7 @@ bool baseProject::create(const fs::path & _path, string templateName){
245245 for (auto & f : fileNames) {
246246 uniquePaths.insert (f.parent_path ());
247247 }
248-
248+
249249 for (auto & p : uniquePaths) {
250250 if (containsSourceFiles (p)) {
251251 ofLogVerbose () << " [prjFiles-addIncludeDir] contains src - Adding dir: " << p;
@@ -311,7 +311,7 @@ bool baseProject::isAddonInCache(const string & addonPath, const string platform
311311void baseProject::addAddon (const std::string & _addonName){
312312 ofLogVerbose (" baseProject::addAddon" ) << _addonName;
313313// alert( "baseProject::addAddon " + _addonName );
314-
314+
315315// auto addonName = ofAddon::cleanName(_addonName);
316316 auto addonName = _addonName;
317317
@@ -321,31 +321,31 @@ void baseProject::addAddon(const std::string & _addonName){
321321// // std::replace( addonName.begin(), addonName.end(), '/', '\\' );
322322// fixSlashOrder(addonName);
323323// #endif
324- //
325-
324+ //
325+
326326// addon.addonMakeName = addonName;
327- //
327+ //
328328// {
329329// auto s = ofSplitString(addonName, "#");
330330// if(s.size()){
331331// addonName = s[0];
332332// }
333333// }
334- //
335-
334+ //
335+
336336 if (addonName.empty ()){
337337 ofLogError (" baseProject::addAddon" ) << " cant add addon with empty name" ;
338338 return ;
339339 }
340-
340+
341341 // This should be the only instance where we check if the addon is either local or not.
342342 // being local just means that the addon name is a filepath and it starts with a dot.
343343 // otherwise it will look in the addons folder.
344344 // A local addon is not restricted to one that lives in folder with the name local_addons, should be any valid addon on the filesystem.
345345 // Parsing will generate the correct path to both OF and the project.
346346 // Everything else should be treated exactly in the same way, regardless of it being local or not.
347347// if(addonName[0] == '.' && fs::exists( ofFilePath::join(projectDir, addonName))){
348- //
348+ //
349349// addon.addonPath = normalizePath(ofFilePath::join(projectDir, addonName));
350350// addon.isLocalAddon = true;
351351// ofLogVerbose() << "Adding local addon: " << addonName;
@@ -355,32 +355,32 @@ void baseProject::addAddon(const std::string & _addonName){
355355// addon.addonPath = fs::path { getOFRoot() / "addons" / addonName };
356356// }
357357// addon.pathToOF = getOFRoot();
358- //
359- //
360- //
358+ //
359+ //
360+ //
361361// addon.pathToOF = normalizePath(addon.pathToOF);
362362// addon.addonPath = normalizePath(addon.addonPath);
363- //
363+ //
364364// addon.pathToProject = projectDir;
365-
365+
366366 ofAddon addon;
367-
367+
368368// bool addonOK = false;
369369// bool inCache = isAddonInCache(addonName, target);
370-
370+
371371 // fs::path addonPath { addonName };
372-
372+
373373 // if (fs::exists(addonPath)) {
374374 // addon.isLocalAddon = true;
375375 // } else {
376376 // addonPath = fs::path { getOFRoot() / "addons" / addonName };
377377 // addon.isLocalAddon = false;
378378 // addon.addonPath = addonPath;
379379 // }
380-
380+
381381// ofLogVerbose() << "addon.addonPath to: [" << addon.addonPath.string() << "]";
382382// ofLogVerbose() << "addon.pathToOF: [" << addon.pathToOF.string() << "]";
383-
383+
384384 if (isAddonInCache (addonName, target)){
385385 addon = addonsCache[target][addonName];
386386 }else {
@@ -397,22 +397,22 @@ void baseProject::addAddon(const std::string & _addonName){
397397// addon = addonsCache[target][addonName];
398398// addonOK = true;
399399// }
400-
400+
401401// if(!addonOK){
402402// ofLogVerbose() << "Ignoring addon that doesn't seem to exist: " << addonName;
403403// return; //if addon does not exist, stop early
404404// }
405-
405+
406406// if(!inCache){
407407// //cache the addon so we dont have to be reading form disk all the time
408408// addonsCache[target][addonName] = addon;
409409// }
410- //
410+ //
411411// for (auto & a : addons) {
412412// if (a.name == addon.name) return;
413413// }
414- //
415- //
414+ //
415+ //
416416// for (auto & d : addon.dependencies) {
417417// bool found = false;
418418// for (auto & a : addons) {
@@ -427,10 +427,10 @@ void baseProject::addAddon(const std::string & _addonName){
427427// ofLogVerbose() << "trying to add duplicated addon dependency! skipping: " << d;
428428// }
429429// }
430- //
431-
430+ //
431+
432432 ofLogNotice () << " adding addon: " << addon.name ;
433-
433+
434434
435435 // MARK: - SPECIFIC for each project.
436436 // XCode and VS override the base addAddon. other templates will use baseproject::addAddon(ofAddon...
@@ -569,7 +569,7 @@ void baseProject::addAddon(ofAddon & addon){
569569 addAddonBegin (addon);
570570
571571 addAddonDllsToCopy (addon);
572-
572+
573573 addAddonLibsPaths (addon);
574574 addAddonIncludePaths (addon);
575575 addAddonLibs (addon);
@@ -611,14 +611,14 @@ void baseProject::addAddonIncludePaths(const ofAddon& addon){
611611 ofLogVerbose () << " [addon.includePaths] contains src - Adding dir: [" << normalizedDir.string () << " ]" ;
612612 // fs::path ofpathChanged = ofRelativeToOFPATH(projectDir);
613613 // ofLogVerbose() << "[addon.includePaths] OFPATH: rel include dir: [" << ofpathChanged.string() << "]";
614-
614+
615615 addInclude (normalizedDir);
616616 } else {
617617 ofLogVerbose () << " [addon.includePaths] no src - not adding: [" << normalizedDir.string () << " ]" ;
618618 }
619619 }
620-
621-
620+
621+
622622// for (auto & a : addon.includePaths) {
623623// fs::path normalizedDir = makeRelative(projectDir, a);
624624// ofLogVerbose() << "adding addon include path: [" << normalizedDir.string() + "]";
@@ -662,7 +662,7 @@ void baseProject::addAddonLdflags(const ofAddon& addon){
662662}
663663
664664void baseProject::addSrcFiles (ofAddon& addon, const vector<fs::path> &filepaths, SrcType type, bool bFindInFilesToFolder){
665- for (auto &s : filepaths) {
665+ for (auto &s : filepaths) {
666666 if (bFindInFilesToFolder && (addon.filesToFolders .find (s) == addon.filesToFolders .end ())) {
667667 addon.filesToFolders [s] = fs::path{" " };
668668 }
@@ -713,7 +713,7 @@ void baseProject::addSrcRecursively(const fs::path & srcPath){
713713 uniqueIncludeFolders.insert (parent);
714714 }
715715 }
716-
716+
717717 for (auto & i : uniqueIncludeFolders){
718718 fs::path normalizedDir = normalizePath (projectDir);
719719 ofLogVerbose () << " [addSrcRecursively] search include paths for folder: [" << normalizedDir.string () << " ]" ;
@@ -731,7 +731,7 @@ void baseProject::addSrcRecursively(const fs::path & srcPath){
731731void baseProject::parseAddons (){
732732 fs::path parseFile { " addons.make" };
733733// alert ("baseProject::parseAddons() " + parseFile.string(), 33);
734-
734+
735735 for (auto & line : fileToStrings (parseFile)) {
736736 auto addon = ofTrim (line);
737737// alert("line " + addon);
@@ -796,15 +796,15 @@ bool baseProject::recursiveCopy(const fs::path & srcDir, const fs::path & destDi
796796bool baseProject::copyTemplateFile::run () {
797797// from = fs::relative(from);
798798// to = fs::relative(to);
799-
799+
800800 // needed for mingw only. maybe a ifdef here.
801801 if (fs::exists (from)) {
802802 ofLogVerbose () << " copyTemplateFile from: " << from << " to: " << to;
803803// alert("base::copyTemplateFile from: " + from.string() + " to: " + to.string(), 33);
804804
805805 if (findReplaces.size ()) {
806806 // Load file, replace contents, write to destination.
807-
807+
808808 std::ifstream fileFrom (from);
809809 std::string contents ((std::istreambuf_iterator<char >(fileFrom)), std::istreambuf_iterator<char >());
810810 fileFrom.close ();
@@ -817,7 +817,11 @@ bool baseProject::copyTemplateFile::run() {
817817 replaceAll (contents, f.first , f.second );
818818 ofLogVerbose () << " └─ Replacing " << f.first << " : " << f.second ;
819819 }
820-
820+
821+ for (auto & a : appends) {
822+ contents += " \n " + a;
823+ }
824+
821825 std::ofstream fileTo (to);
822826 try {
823827 fileTo << contents;
@@ -830,8 +834,8 @@ bool baseProject::copyTemplateFile::run() {
830834
831835 return false ;
832836 }
833-
834-
837+
838+
835839 } else {
836840 // straight copy
837841 try {
0 commit comments