@@ -22,7 +22,7 @@ baseProject::baseProject(const string & _target) : target(_target) {
22
22
bLoaded = false ;
23
23
}
24
24
25
- fs::path baseProject::getPlatformTemplateDir () {
25
+ fs::path baseProject::getPlatformTemplateDir (std::string templateDir ) {
26
26
string folder { target };
27
27
if ( target == " msys2"
28
28
|| target == " linux"
@@ -33,12 +33,10 @@ fs::path baseProject::getPlatformTemplateDir() {
33
33
) {
34
34
folder = " vscode" ;
35
35
}
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);
42
40
}
43
41
44
42
@@ -139,26 +137,25 @@ bool baseProject::create(const fs::path & _path, string templateName){
139
137
140
138
addons.clear ();
141
139
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
+ }
144
151
ofLogNotice () << " templatePath: [" << templatePath << " ]" ;
145
152
auto projectPath = fs::canonical (fs::current_path () / path);
146
-
147
153
projectDir = path;
148
154
projectPath = normalizePath (projectPath);
149
155
ofLogNotice () << " projectPath: [" << projectPath << " ]" ;
150
-
151
156
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
- // }
157
157
bool bDoesSrcDirExist = false ;
158
-
159
- // it can be only "src"
160
158
fs::path projectSrc { projectDir / " src" };
161
-
162
159
if (fs::exists (projectSrc) && fs::is_directory (projectSrc)) {
163
160
bDoesSrcDirExist = true ;
164
161
} else {
@@ -175,18 +172,14 @@ bool baseProject::create(const fs::path & _path, string templateName){
175
172
}
176
173
}
177
174
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)) {
185
180
fs::path templateDir = getOFRoot () / templatesFolder / templateName;
186
- ofLogNotice () << " templateDir: [" << templateDir << " ]" ;
187
181
templateDir = normalizePath (templateDir);
188
- // alert("templateDir " + templateDir.string());
189
-
182
+ ofLogNotice () << " templateDir: [" << templateDir << " ]" ;
190
183
auto templateConfig = parseTemplate (templateDir);
191
184
if (templateConfig){
192
185
recursiveTemplateCopy (templateDir, projectDir);
@@ -208,13 +201,13 @@ bool baseProject::create(const fs::path & _path, string templateName){
208
201
ofLogWarning () << " Cannot find " << templateName << " using platform template only" ;
209
202
}
210
203
}
211
-
212
204
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
+ }
215
209
216
210
parseConfigMake ();
217
-
218
211
if (bDoesSrcDirExist){
219
212
vector <fs::path> fileNames;
220
213
@@ -548,7 +541,6 @@ void baseProject::addAddon(ofAddon & addon){
548
541
unless there is one addon added which needs another, and it needs another.
549
542
550
543
*/
551
- // alert("---> dependencies");
552
544
for (auto & d : addon.dependencies ) {
553
545
bool found = false ;
554
546
for (auto & a : addons) {
@@ -564,12 +556,8 @@ void baseProject::addAddon(ofAddon & addon){
564
556
ofLogVerbose () << " trying to add duplicated addon dependency! skipping: " << d;
565
557
}
566
558
}
567
- // alert("---> dependencies");
568
559
addons.emplace_back (addon);
569
560
570
-
571
- // ofLogVerbose("baseProject") << "libs in addAddon " << addon.libs.size();
572
-
573
561
addAddonBegin (addon);
574
562
575
563
addAddonDllsToCopy (addon);
0 commit comments