Skip to content

Commit fd5f21c

Browse files
authored
Android - Visual studio v0.99.0 (#630)
* V0.98.0 - Android Studio exec open all platforms - Visual Studio determine target SLN and open version 2022 if target or 2019 if target. Fixes VS2019 installed opening by default * Visual Studio Fixes for opening correct Version * Android Studio -> Open IDE Windows
1 parent ceb5b22 commit fd5f21c

File tree

6 files changed

+161
-66
lines changed

6 files changed

+161
-66
lines changed

commandLine/src/defines.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define OFPROJECTGENERATOR_MAJOR_VERSION "0"
2-
#define OFPROJECTGENERATOR_MINOR_VERSION "97"
2+
#define OFPROJECTGENERATOR_MINOR_VERSION "99"
33
#define OFPROJECTGENERATOR_PATCH_VERSION "0"
44

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

commandLine/src/main.cpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,15 @@ int main(int argc, char ** argv) {
513513
if (options[TEMPLATE].arg != NULL) {
514514
string templateString(options[TEMPLATE].arg);
515515
templateName = templateString;
516+
ofLogNotice() << "{ \"Template\": \"" << templateName << "\" }";
516517
}
517518
}
518519

519520
if (options[PLATFORMS].count() > 0) {
520521
if (options[PLATFORMS].arg != NULL) {
521522
string platformString(options[PLATFORMS].arg);
522523
addPlatforms(platformString);
524+
ofLogNotice() << "{ \"Platform\": \"" << platformString << "\" }";
523525
}
524526
}
525527

@@ -581,9 +583,9 @@ int main(int argc, char ** argv) {
581583

582584
// try to get the OF_PATH as an environt variable
583585

584-
if (bVerbose) {
586+
//if (bVerbose) {
585587
ofSetLogLevel(OF_LOG_VERBOSE);
586-
}
588+
//}
587589

588590
if (projectName == "") {
589591
printHelp();
@@ -678,25 +680,22 @@ int main(int argc, char ** argv) {
678680
}
679681
} else {
680682
if (mode == PG_MODE_UPDATE && !isGoodProjectPath(projectPath)) {
681-
ofLogError() << "there is no src folder in this project path to update, maybe use create instead? (or use force to force updating)";
683+
messageError("there is no src folder in this project path to update, maybe use create instead? (or use force to force updating");
682684
} else {
683-
nProjectsCreated += 1;
684-
685+
685686
ofLogNotice() << "setting OF path to: [" << ofPath << "]";
686687
if (busingEnvVar) {
687688
ofLogNotice() << "from PG_OF_PATH environment variable";
688689
} else {
689690
ofLogNotice() << "from -o option";
690691
}
691-
692-
693692
for (auto & t : targets) {
694693
consoleSpace();
695694
ofLogNotice() << "-----------------------------------------------";
696695
ofLogNotice() << "target platform is: [" << t << "]";
697696
// ofLogNotice() << "project path is: [" << projectPath << "]";
698697
if (templateName != "") {
699-
ofLogNotice() << "using additional template " << templateName;
698+
ofLogNotice() << "using additional template [" << templateName << "]";
700699
}
701700
ofLogVerbose() << "setting up new project " << projectPath;
702701

@@ -706,7 +705,7 @@ int main(int argc, char ** argv) {
706705
ofLogNotice() << "project updated! ";
707706
} else {
708707
if (!bDryRun) {
709-
// ofLogNotice() << "project path is: [" << projectPath << "]";
708+
ofLogNotice() << "project path is: [" << projectPath << "]";
710709
auto project = getTargetProject(t);
711710
project->create(projectPath, templateName);
712711
if(bAddonsPassedIn){
@@ -726,6 +725,7 @@ int main(int argc, char ** argv) {
726725
project->save();
727726
}
728727
ofLogNotice() << "project created! ";
728+
nProjectsCreated += 1;
729729
}
730730
ofLogNotice() << "-----------------------------------------------";
731731
}
@@ -734,12 +734,14 @@ int main(int argc, char ** argv) {
734734

735735
consoleSpace();
736736
float elapsedTime = ofGetElapsedTimef() - startTime;
737-
if (nProjectsCreated > 0) std::cout << nProjectsCreated << " project created ";
738-
if (nProjectsUpdated == 1) std::cout << nProjectsUpdated << " project updated ";
737+
if (nProjectsCreated > 0) std::cout << nProjectsCreated << " project created at " << projectPath;
738+
if (nProjectsUpdated == 1) std::cout << nProjectsUpdated << " project updated at " << projectPath;
739739
if (nProjectsUpdated > 1) std::cout << nProjectsUpdated << " projects updated ";
740740
ofLogNotice() << "in " << elapsedTime << " seconds" << std::endl;
741741
consoleSpace();
742-
742+
std::cout << "{ \"inSeconds\": \"" << elapsedTime << "\" }" << std::endl;
743+
std::cout << "{ \"status\": \"" << "EXIT_OK" << "\" }";
743744
messageReturn("status", "EXIT_OK");
745+
744746
return EXIT_OK;
745747
}

commandLine/src/projects/baseProject.cpp

+26-38
Original file line numberDiff line numberDiff line change
@@ -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);

commandLine/src/projects/baseProject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class baseProject {
8282

8383
std::vector<Template> listAvailableTemplates(std::string target);
8484
std::unique_ptr<baseProject::Template> parseTemplate(const fs::path & templateDir);
85-
virtual fs::path getPlatformTemplateDir();
85+
virtual fs::path getPlatformTemplateDir(std::string templateDir);
8686

8787
pugi::xml_document doc;
8888
bool bLoaded;

commandLine/src/utils/Utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ unique_ptr<baseProject> getTargetProject(const string & targ) {
439439
} else if (targ == "msys2") {
440440
// return unique_ptr<QtCreatorProject>(new QtCreatorProject(targ));
441441
return unique_ptr<VSCodeProject>(new VSCodeProject(targ));
442-
} else if (targ == "vs") {
442+
} else if (targ == "vs" || targ == "vs2019") {
443443
return unique_ptr<visualStudioProject>(new visualStudioProject(targ));
444444
} else if (targ == "linux" ||
445445
targ == "linux64" ||

0 commit comments

Comments
 (0)