Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commandLine/src/defines.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
26 changes: 14 additions & 12 deletions commandLine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,15 @@ int main(int argc, char ** argv) {
if (options[TEMPLATE].arg != NULL) {
string templateString(options[TEMPLATE].arg);
templateName = templateString;
ofLogNotice() << "{ \"Template\": \"" << templateName << "\" }";
}
}

if (options[PLATFORMS].count() > 0) {
if (options[PLATFORMS].arg != NULL) {
string platformString(options[PLATFORMS].arg);
addPlatforms(platformString);
ofLogNotice() << "{ \"Platform\": \"" << platformString << "\" }";
}
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand All @@ -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){
Expand All @@ -726,6 +725,7 @@ int main(int argc, char ** argv) {
project->save();
}
ofLogNotice() << "project created! ";
nProjectsCreated += 1;
}
ofLogNotice() << "-----------------------------------------------";
}
Expand All @@ -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;
}
64 changes: 26 additions & 38 deletions commandLine/src/projects/baseProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
}


Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -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 <fs::path> fileNames;

Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion commandLine/src/projects/baseProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class baseProject {

std::vector<Template> listAvailableTemplates(std::string target);
std::unique_ptr<baseProject::Template> parseTemplate(const fs::path & templateDir);
virtual fs::path getPlatformTemplateDir();
virtual fs::path getPlatformTemplateDir(std::string templateDir);

pugi::xml_document doc;
bool bLoaded;
Expand Down
2 changes: 1 addition & 1 deletion commandLine/src/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ unique_ptr<baseProject> getTargetProject(const string & targ) {
} else if (targ == "msys2") {
// return unique_ptr<QtCreatorProject>(new QtCreatorProject(targ));
return unique_ptr<VSCodeProject>(new VSCodeProject(targ));
} else if (targ == "vs") {
} else if (targ == "vs" || targ == "vs2019") {
return unique_ptr<visualStudioProject>(new visualStudioProject(targ));
} else if (targ == "linux" ||
targ == "linux64" ||
Expand Down
Loading