diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 49aede68..3b22c6f4 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "97" +#define OFPROJECTGENERATOR_MINOR_VERSION "99" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index c264bb5b..2b520366 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -513,6 +513,7 @@ int main(int argc, char ** argv) { if (options[TEMPLATE].arg != NULL) { string templateString(options[TEMPLATE].arg); templateName = templateString; + ofLogNotice() << "{ \"Template\": \"" << templateName << "\" }"; } } @@ -520,6 +521,7 @@ int main(int argc, char ** argv) { if (options[PLATFORMS].arg != NULL) { string platformString(options[PLATFORMS].arg); addPlatforms(platformString); + ofLogNotice() << "{ \"Platform\": \"" << platformString << "\" }"; } } @@ -581,9 +583,9 @@ int main(int argc, char ** argv) { // try to get the OF_PATH as an environt variable - if (bVerbose) { + //if (bVerbose) { ofSetLogLevel(OF_LOG_VERBOSE); - } + //} if (projectName == "") { printHelp(); @@ -678,25 +680,22 @@ int main(int argc, char ** argv) { } } else { if (mode == PG_MODE_UPDATE && !isGoodProjectPath(projectPath)) { - ofLogError() << "there is no src folder in this project path to update, maybe use create instead? (or use force to force updating)"; + messageError("there is no src folder in this project path to update, maybe use create instead? (or use force to force updating"); } else { - nProjectsCreated += 1; - + ofLogNotice() << "setting OF path to: [" << ofPath << "]"; if (busingEnvVar) { ofLogNotice() << "from PG_OF_PATH environment variable"; } else { ofLogNotice() << "from -o option"; } - - for (auto & t : targets) { consoleSpace(); ofLogNotice() << "-----------------------------------------------"; ofLogNotice() << "target platform is: [" << t << "]"; // ofLogNotice() << "project path is: [" << projectPath << "]"; if (templateName != "") { - ofLogNotice() << "using additional template " << templateName; + ofLogNotice() << "using additional template [" << templateName << "]"; } ofLogVerbose() << "setting up new project " << projectPath; @@ -706,7 +705,7 @@ int main(int argc, char ** argv) { ofLogNotice() << "project updated! "; } else { if (!bDryRun) { -// ofLogNotice() << "project path is: [" << projectPath << "]"; + ofLogNotice() << "project path is: [" << projectPath << "]"; auto project = getTargetProject(t); project->create(projectPath, templateName); if(bAddonsPassedIn){ @@ -726,6 +725,7 @@ int main(int argc, char ** argv) { project->save(); } ofLogNotice() << "project created! "; + nProjectsCreated += 1; } ofLogNotice() << "-----------------------------------------------"; } @@ -734,12 +734,14 @@ int main(int argc, char ** argv) { consoleSpace(); float elapsedTime = ofGetElapsedTimef() - startTime; - if (nProjectsCreated > 0) std::cout << nProjectsCreated << " project created "; - if (nProjectsUpdated == 1) std::cout << nProjectsUpdated << " project updated "; + if (nProjectsCreated > 0) std::cout << nProjectsCreated << " project created at " << projectPath; + if (nProjectsUpdated == 1) std::cout << nProjectsUpdated << " project updated at " << projectPath; if (nProjectsUpdated > 1) std::cout << nProjectsUpdated << " projects updated "; ofLogNotice() << "in " << elapsedTime << " seconds" << std::endl; consoleSpace(); - + std::cout << "{ \"inSeconds\": \"" << elapsedTime << "\" }" << std::endl; + std::cout << "{ \"status\": \"" << "EXIT_OK" << "\" }"; messageReturn("status", "EXIT_OK"); + return EXIT_OK; } diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index dc4eee0b..5ef81c66 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -22,7 +22,7 @@ baseProject::baseProject(const string & _target) : target(_target) { bLoaded = false; } -fs::path baseProject::getPlatformTemplateDir() { +fs::path baseProject::getPlatformTemplateDir(std::string templateDir) { string folder { target }; if ( target == "msys2" || target == "linux" @@ -33,12 +33,10 @@ fs::path baseProject::getPlatformTemplateDir() { ) { folder = "vscode"; } - -// if ( target == "qtcreator" ) { -// return getOFRoot() -// } - - return getOFRoot() / templatesFolder / folder; + if (templateDir != "") { + folder = templateDir; + } + return fs::weakly_canonical(getOFRoot() / templatesFolder / folder); } @@ -139,26 +137,25 @@ bool baseProject::create(const fs::path & _path, string templateName){ addons.clear(); extSrcPaths.clear(); - - templatePath = normalizePath(getPlatformTemplateDir()); + auto pathTemplate = getPlatformTemplateDir(templateName); + if (fs::exists(pathTemplate)) { + templatePath = normalizePath(pathTemplate); + } else { + ofLogError() << "templatePath does not exist: [" << templatePath << "]"; + } + if (fs::exists(templatePath)) { + templatePath = normalizePath(pathTemplate); + } else { + ofLogError() << "templatePath does not exist: [" << templatePath << "]"; + } ofLogNotice() << "templatePath: [" << templatePath << "]"; auto projectPath = fs::canonical(fs::current_path() / path); - projectDir = path; projectPath = normalizePath(projectPath); ofLogNotice() << "projectPath: [" << projectPath << "]"; - projectName = projectPath.filename().string(); - - // we had this in some projects. if we decide to keep this is the place - // if (!fs::exists(projectDir)) { - // fs::create_directory(projectDir); - // } bool bDoesSrcDirExist = false; - - // it can be only "src" fs::path projectSrc { projectDir / "src" }; - if (fs::exists(projectSrc) && fs::is_directory(projectSrc)) { bDoesSrcDirExist = true; } else { @@ -175,18 +172,14 @@ bool baseProject::create(const fs::path & _path, string templateName){ } } bool ret = createProjectFile(); - if(!ret) return false; - -// cout << "after return : " << templateName << endl; - if(!empty(templateName)){ -// cout << "templateName not empty " << templateName << endl; -// return getOFRoot() / templatesFolder / target; - + if (!ret) { + ofLogError() << "{ \"errorMessage\": \"" << "baseProject::create createProjectFile failed" << "\", \"status:\" \"EXIT_FAILURE\" }"; + return false; + } + if (templateName != "" && !empty(templateName)) { fs::path templateDir = getOFRoot() / templatesFolder / templateName; - ofLogNotice() << "templateDir: [" << templateDir << "]"; templateDir = normalizePath(templateDir); -// alert("templateDir " + templateDir.string()); - + ofLogNotice() << "templateDir: [" << templateDir << "]"; auto templateConfig = parseTemplate(templateDir); if(templateConfig){ recursiveTemplateCopy(templateDir, projectDir); @@ -208,13 +201,13 @@ bool baseProject::create(const fs::path & _path, string templateName){ ofLogWarning() << "Cannot find " << templateName << " using platform template only"; } } - ret = loadProjectFile(); - - if(!ret) return false; + if (!ret) { + ofLogError() << "{ \"errorMessage\": \"" << "baseProject::create loadProjectFile failed" << "\", \"status:\" \"EXIT_FAILURE\" }"; + return false; + } parseConfigMake(); - if (bDoesSrcDirExist){ vector fileNames; @@ -548,7 +541,6 @@ void baseProject::addAddon(ofAddon & addon){ unless there is one addon added which needs another, and it needs another. */ -// alert("---> dependencies"); for (auto & d : addon.dependencies) { bool found = false; for (auto & a : addons) { @@ -564,12 +556,8 @@ void baseProject::addAddon(ofAddon & addon){ ofLogVerbose() << "trying to add duplicated addon dependency! skipping: " << d; } } -// alert("---> dependencies"); addons.emplace_back(addon); - - //ofLogVerbose("baseProject") << "libs in addAddon " << addon.libs.size(); - addAddonBegin(addon); addAddonDllsToCopy(addon); diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index 4f4cd18a..83c0c963 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -82,7 +82,7 @@ class baseProject { std::vector