@@ -22,7 +22,7 @@ baseProject::baseProject(const string & _target) : target(_target) {
2222 bLoaded = false ;
2323}
2424
25- fs::path baseProject::getPlatformTemplateDir () {
25+ fs::path baseProject::getPlatformTemplateDir (std::string templateDir ) {
2626 string folder { target };
2727 if ( target == " msys2"
2828 || target == " linux"
@@ -33,12 +33,10 @@ fs::path baseProject::getPlatformTemplateDir() {
3333 ) {
3434 folder = " vscode" ;
3535 }
36-
37- // if ( target == "qtcreator" ) {
38- // return getOFRoot()
39- // }
40-
41- return getOFRoot () / templatesFolder / folder;
36+ if (templateDir != " " ) {
37+ folder = templateDir;
38+ }
39+ return fs::weakly_canonical (getOFRoot () / templatesFolder / folder);
4240}
4341
4442
@@ -139,26 +137,25 @@ bool baseProject::create(const fs::path & _path, string templateName){
139137
140138 addons.clear ();
141139 extSrcPaths.clear ();
142-
143- templatePath = normalizePath (getPlatformTemplateDir ());
140+ auto pathTemplate = getPlatformTemplateDir (templateName);
141+ if (fs::exists (pathTemplate)) {
142+ templatePath = normalizePath (pathTemplate);
143+ } else {
144+ ofLogError () << " templatePath does not exist: [" << templatePath << " ]" ;
145+ }
146+ if (fs::exists (templatePath)) {
147+ templatePath = normalizePath (pathTemplate);
148+ } else {
149+ ofLogError () << " templatePath does not exist: [" << templatePath << " ]" ;
150+ }
144151 ofLogNotice () << " templatePath: [" << templatePath << " ]" ;
145152 auto projectPath = fs::canonical (fs::current_path () / path);
146-
147153 projectDir = path;
148154 projectPath = normalizePath (projectPath);
149155 ofLogNotice () << " projectPath: [" << projectPath << " ]" ;
150-
151156 projectName = projectPath.filename ().string ();
152-
153- // we had this in some projects. if we decide to keep this is the place
154- // if (!fs::exists(projectDir)) {
155- // fs::create_directory(projectDir);
156- // }
157157 bool bDoesSrcDirExist = false ;
158-
159- // it can be only "src"
160158 fs::path projectSrc { projectDir / " src" };
161-
162159 if (fs::exists (projectSrc) && fs::is_directory (projectSrc)) {
163160 bDoesSrcDirExist = true ;
164161 } else {
@@ -175,18 +172,14 @@ bool baseProject::create(const fs::path & _path, string templateName){
175172 }
176173 }
177174 bool ret = createProjectFile ();
178- if (!ret) return false ;
179-
180- // cout << "after return : " << templateName << endl;
181- if (!empty (templateName)){
182- // cout << "templateName not empty " << templateName << endl;
183- // return getOFRoot() / templatesFolder / target;
184-
175+ if (!ret) {
176+ ofLogError () << " { \" errorMessage\" : \" " << " baseProject::create createProjectFile failed" << " \" , \" status:\" \" EXIT_FAILURE\" }" ;
177+ return false ;
178+ }
179+ if (templateName != " " && !empty (templateName)) {
185180 fs::path templateDir = getOFRoot () / templatesFolder / templateName;
186- ofLogNotice () << " templateDir: [" << templateDir << " ]" ;
187181 templateDir = normalizePath (templateDir);
188- // alert("templateDir " + templateDir.string());
189-
182+ ofLogNotice () << " templateDir: [" << templateDir << " ]" ;
190183 auto templateConfig = parseTemplate (templateDir);
191184 if (templateConfig){
192185 recursiveTemplateCopy (templateDir, projectDir);
@@ -208,13 +201,13 @@ bool baseProject::create(const fs::path & _path, string templateName){
208201 ofLogWarning () << " Cannot find " << templateName << " using platform template only" ;
209202 }
210203 }
211-
212204 ret = loadProjectFile ();
213-
214- if (!ret) return false ;
205+ if (!ret) {
206+ ofLogError () << " { \" errorMessage\" : \" " << " baseProject::create loadProjectFile failed" << " \" , \" status:\" \" EXIT_FAILURE\" }" ;
207+ return false ;
208+ }
215209
216210 parseConfigMake ();
217-
218211 if (bDoesSrcDirExist){
219212 vector <fs::path> fileNames;
220213
@@ -548,7 +541,6 @@ void baseProject::addAddon(ofAddon & addon){
548541 unless there is one addon added which needs another, and it needs another.
549542
550543 */
551- // alert("---> dependencies");
552544 for (auto & d : addon.dependencies ) {
553545 bool found = false ;
554546 for (auto & a : addons) {
@@ -564,12 +556,8 @@ void baseProject::addAddon(ofAddon & addon){
564556 ofLogVerbose () << " trying to add duplicated addon dependency! skipping: " << d;
565557 }
566558 }
567- // alert("---> dependencies");
568559 addons.emplace_back (addon);
569560
570-
571- // ofLogVerbose("baseProject") << "libs in addAddon " << addon.libs.size();
572-
573561 addAddonBegin (addon);
574562
575563 addAddonDllsToCopy (addon);
0 commit comments