Skip to content

Commit e43e7fe

Browse files
authored
Create / Update (#355)
#changelog #core
1 parent f26d97f commit e43e7fe

6 files changed

Lines changed: 111 additions & 123 deletions

File tree

commandLine/src/addons/ofAddon.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ofAddon::ConfigParseState ofAddon::stateFromString(string name){
4949
if(name=="vs") return VS;
5050
if(name=="linuxarmv6l") return LinuxARMv6;
5151
if(name=="linuxarmv7l") return LinuxARMv7;
52+
if(name=="linuxaarch64") return LinuxAArch64;
5253
if(name=="android/armeabi") return AndroidARMv5;
5354
if(name=="android/armeabi-v7a") return AndroidARMv7;
5455
if(name=="android/x86") return Androidx86;
@@ -76,6 +77,8 @@ string ofAddon::stateName(ofAddon::ConfigParseState state){
7677
return "linuxarmv6";
7778
case LinuxARMv7:
7879
return "linuxarmv7";
80+
case LinuxAArch64:
81+
return "linuxaarch64";
7982
case AndroidARMv5:
8083
return "android/armeabi";
8184
case AndroidARMv7:

commandLine/src/addons/ofAddon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class ofAddon {
151151
VS,
152152
LinuxARMv6,
153153
LinuxARMv7,
154+
LinuxAArch64,
154155
AndroidARMv5,
155156
AndroidARMv7,
156157
Androidx86,

commandLine/src/main.cpp

Lines changed: 65 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ void addPlatforms(const std::string & value) {
148148
else if (p == "linuxarmv7l") {
149149
targets.emplace_back(OF_TARGET_LINUXARMV7L);
150150
}
151+
else if (p == "linuxaarch64") {
152+
targets.emplace_back(OF_TARGET_LINUXAARCH64);
153+
}
151154
else if (p == "msys2") {
152155
targets.emplace_back(OF_TARGET_MINGW);
153156
}
@@ -213,28 +216,27 @@ void updateProject(const fs::path & path, ofTargetPlatform target, bool bConside
213216
// bConsiderParameterAddons = do we consider that the user could call update with a new set of addons
214217
// either we read the addons.make file, or we look at the parameter list.
215218
// if we are updating recursively, we *never* consider addons passed as parameters.
216-
217219
ofLogNotice() << "updating project " << path;
218-
auto project = getTargetProject(target);
219220

220-
if (!bDryRun) project->create(path, templateName);
221+
if (!bDryRun) {
222+
auto project = getTargetProject(target);
223+
224+
project->create(path, templateName);
221225

222-
if(bConsiderParameterAddons && bAddonsPassedIn){
223-
for(auto & addon: addons){
224-
project->addAddon(addon);
226+
if(bConsiderParameterAddons && bAddonsPassedIn){
227+
for(auto & addon: addons){
228+
project->addAddon(addon);
229+
}
230+
}else{
231+
ofLogNotice() << "parsing addons.make";
232+
project->parseAddons();
225233
}
226-
}else{
227-
ofLogNotice() << "parsing addons.make";
228-
project->parseAddons();
229-
}
230234

231-
if(!bDryRun){
232235
for(auto & srcPath : srcPaths){
233236
project->addSrcRecursively(srcPath);
234237
}
238+
project->save();
235239
}
236-
237-
if (!bDryRun) project->save();
238240
}
239241

240242
void recursiveUpdate(const fs::path & path, ofTargetPlatform target) {
@@ -244,7 +246,7 @@ void recursiveUpdate(const fs::path & path, ofTargetPlatform target) {
244246
// second check if this is a folder that has src in it
245247
if (isGoodProjectPath(path)) {
246248
nProjectsUpdated++;
247-
auto project = getTargetProject(target);
249+
// auto project = getTargetProject(target);
248250
updateProject(path, target, false);
249251
return;
250252
} else {
@@ -483,100 +485,77 @@ int main(int argc, char** argv){
483485
else {
484486
mode = PG_MODE_CREATE;
485487
}
486-
487-
// mode = PG_MODE_CREATE;
488+
mode = PG_MODE_CREATE;
488489

489490

490491
if (bVerbose){
491492
ofSetLogLevel(OF_LOG_VERBOSE);
492493
}
493494

494-
if (mode == PG_MODE_CREATE) {
495-
nProjectsCreated += 1;
496-
497-
for (int i = 0; i < (int)targets.size(); i++) {
498-
auto project = getTargetProject(targets[i]);
499-
auto target = getTargetString(targets[i]);
500-
501-
495+
if (bRecursive) {
496+
for (auto & t : targets) {
502497
ofLogNotice() << "-----------------------------------------------";
503-
ofLogNotice() << "setting OF path to: " << ofPath;
504-
if(busingEnvVar){
505-
ofLogNotice() << "from PG_OF_PATH environment variable";
506-
}else{
507-
ofLogNotice() << "from -o option";
508-
}
509-
ofLogNotice() << "target platform is: " << target;
510-
ofLogNotice() << "project path is: " << projectPath;
511-
512-
if(templateName!=""){
513-
ofLogNotice() << "using additional template " << templateName;
514-
}
498+
ofLogNotice() << "updating an existing project";
499+
ofLogNotice() << "target platform is: " << getTargetString(t);
515500

501+
recursiveUpdate(projectPath, t);
516502

517-
ofLogNotice() << "setting up new project " << projectPath;
518-
if (!bDryRun) project->create(projectPath, templateName);
519-
503+
ofLogNotice() << "project updated! ";
504+
ofLogNotice() << "-----------------------------------------------";
505+
}
506+
} else {
507+
if (mode == PG_MODE_UPDATE && !isGoodProjectPath(projectPath)) {
508+
ofLogError() << "there's no src folder in this project path to update, maybe use create instead? (or use force to force updating)";
509+
} else {
510+
nProjectsCreated += 1;
520511

521-
if (!bDryRun){
522-
for(auto & addon: addons){
523-
project->addAddon(addon);
524-
}
525-
for(auto & srcPath : srcPaths){
526-
project->addSrcRecursively(srcPath);
512+
for (auto & t : targets) {
513+
ofLogNotice() << "-----------------------------------------------";
514+
ofLogNotice() << "setting OF path to: " << ofPath;
515+
if(busingEnvVar){
516+
ofLogNotice() << "from PG_OF_PATH environment variable";
517+
}else{
518+
ofLogNotice() << "from -o option";
527519
}
528-
}
529-
if (!bDryRun) project->save();
520+
ofLogNotice() << "target platform is: " << getTargetString(t);
521+
ofLogNotice() << "project path is: " << projectPath;
530522

531-
ofLogNotice() << "project created! ";
532-
ofLogNotice() << "-----------------------------------------------";
533-
consoleSpace();
534-
}
535-
}
523+
if(templateName != ""){
524+
ofLogNotice() << "using additional template " << templateName;
525+
}
536526

537-
else if (mode == PG_MODE_UPDATE) {
538-
if (!bRecursive) {
539-
if (isGoodProjectPath(projectPath) || bForce) {
540-
nProjectsUpdated += 1;
541-
542-
for (int i = 0; i < (int)targets.size(); i++) {
543-
ofLogNotice() << "-----------------------------------------------";
544-
ofLogNotice() << "setting OF path to: " << ofPath;
545-
if(busingEnvVar){
546-
ofLogNotice() << "from PG_OF_PATH environment variable";
547-
}else{
548-
ofLogNotice() << "from -o option";
549-
}
550-
ofLogNotice() << "target platform is: " << getTargetString(targets[i]);
527+
ofLogNotice() << "setting up new project " << projectPath;
551528

552-
if(templateName!=""){
553-
ofLogNotice() << "using additional template " << templateName;
529+
if (mode == PG_MODE_UPDATE) {
530+
531+
updateProject(projectPath, t);
532+
ofLogNotice() << "project updated! ";
533+
534+
} else {
535+
536+
if (!bDryRun){
537+
auto project = getTargetProject(t);
538+
project->create(projectPath, templateName);
539+
for(auto & addon: addons){
540+
project->addAddon(addon);
541+
}
542+
for(auto & srcPath : srcPaths){
543+
project->addSrcRecursively(srcPath);
544+
}
545+
project->save();
554546
}
555-
updateProject(projectPath,targets[i]);
556547

557-
ofLogNotice() << "project updated! ";
558-
ofLogNotice() << "-----------------------------------------------";
559-
consoleSpace();
548+
ofLogNotice() << "project created! ";
560549
}
561-
}
562-
else {
563-
ofLogError() << "there's no src folder in this project path to update, maybe use create instead? (or use force to force updating)";
564-
}
565-
}
566-
else {
567-
for (int i = 0; i < (int)targets.size(); i++) {
568-
ofLogNotice() << "-----------------------------------------------";
569-
ofLogNotice() << "updating an existing project";
570-
ofLogNotice() << "target platform is: " << getTargetString(targets[i]);
571-
572-
recursiveUpdate(projectPath, targets[i]);
573-
574-
ofLogNotice() << "project updated! ";
575550
ofLogNotice() << "-----------------------------------------------";
551+
consoleSpace();
576552
}
577553
}
554+
578555
}
579556

557+
558+
580559
consoleSpace();
581560
float elapsedTime = ofGetElapsedTimef() - startTime;
582561
if (nProjectsCreated > 0) std::cout << nProjectsCreated << " project created ";

commandLine/src/projects/baseProject.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ std::vector<baseProject::Template> baseProject::listAvailableTemplates(std::stri
112112

113113
bool baseProject::create(const fs::path & _path, std::string templateName){
114114
auto path = _path; // just because it is const
115-
115+
116116
templatePath = getPlatformTemplateDir();
117117
addons.clear();
118118
extSrcPaths.clear();
@@ -122,6 +122,11 @@ bool baseProject::create(const fs::path & _path, std::string templateName){
122122
}
123123
projectDir = path;
124124
projectName = path.filename();
125+
if (projectName == "") {
126+
projectName = path.parent_path().filename();
127+
}
128+
// cout << "path = " << path << endl;
129+
// cout << "projectName = " << projectName << endl;
125130
bool bDoesDirExist = false;
126131

127132
fs::path project { projectDir / "src" };
@@ -137,13 +142,9 @@ bool baseProject::create(const fs::path & _path, std::string templateName){
137142
bool ret = createProjectFile();
138143
if(!ret) return false;
139144

140-
//MARK: -
141145
if(templateName!=""){
142146
fs::path templateDir = getOFRoot() / templatesFolder / templateName;
143147

144-
// TODO: PORT
145-
// !!!: asdf
146-
// templateDir.setShowHidden(true);
147148
auto templateConfig = parseTemplate(templateDir);
148149
if(templateConfig){
149150
recursiveTemplateCopy(templateDir, projectDir);
@@ -152,8 +153,7 @@ bool baseProject::create(const fs::path & _path, std::string templateName){
152153
auto from = projectDir / rename.first;
153154
auto to = projectDir / rename.second;
154155
// auto to = projectDir / templateConfig->renames[rename.first];
155-
156-
// moveTo(const of::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false);
156+
// Reference: moveTo(const of::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false);
157157
ofFile(from).moveTo(to,true,true);
158158
}
159159
}else{
@@ -223,14 +223,14 @@ bool baseProject::save(){
223223
string str = line;
224224

225225
//add the of root path
226-
if( str.rfind("# OF_ROOT =", 0) == 0 ){
227-
228-
auto path = getOFRoot();
229-
if( projectDir.string().rfind(getOFRoot(),0) == 0 ){
230-
path = getOFRelPath(projectDir);
231-
}
232-
233-
saveConfig << "OF_ROOT = " << path << std::endl;
226+
if( str.rfind("# OF_ROOT =", 0) == 0 || str.rfind("OF_ROOT =", 0) == 0){
227+
auto path = getOFRoot().string();
228+
229+
if( projectDir.string().rfind(getOFRoot(),0) == 0 ){
230+
path = getOFRelPath(projectDir);
231+
}
232+
233+
saveConfig << "OF_ROOT = " << path << std::endl;
234234
}
235235
// replace this section with our external paths
236236
else if( extSrcPaths.size() && str.rfind("# PROJECT_EXTERNAL_SOURCE_PATHS =", 0) == 0 ){

commandLine/src/projects/xcodeProject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ xcodeProject::xcodeProject(string target)
6464

6565
bool xcodeProject::createProjectFile(){
6666
fs::path xcodeProject = projectDir / ( projectName + ".xcodeproj" );
67-
67+
// cout << "createProjectFile " << xcodeProject << endl;
6868
if (ofDirectory::doesDirectoryExist(xcodeProject)){
6969
ofDirectory::removeDirectory(xcodeProject, true);
7070
}
@@ -438,7 +438,7 @@ void xcodeProject::addSrc(string srcFile, string folder, SrcType type){
438438
}
439439

440440
void xcodeProject::addFramework(string name, string path, string folder){
441-
cout << "addFramework " << name << " path = " << path << " folder = " << folder << endl;
441+
// cout << "addFramework " << name << " path = " << path << " folder = " << folder << endl;
442442
// name = name of the framework
443443
// path = the full path (w name) of this framework
444444
// folder = the path in the addon (in case we want to add this to the file browser -- we don't do that for system libs);

commandLine/src/utils/Utils.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -417,31 +417,34 @@ std::string getOFRootFromConfig(){
417417

418418
std::string getTargetString(ofTargetPlatform t){
419419
switch (t) {
420-
case OF_TARGET_OSX:
421-
return "osx";
422-
case OF_TARGET_MINGW:
423-
return "msys2";
424-
case OF_TARGET_WINVS:
425-
return "vs";
426-
case OF_TARGET_IOS:
427-
return "ios";
428-
case OF_TARGET_ANDROID:
429-
return "android";
430-
case OF_TARGET_LINUX:
431-
return "linux";
432-
case OF_TARGET_LINUX64:
433-
return "linux64";
434-
case OF_TARGET_LINUXARMV6L:
435-
return "linuxarmv6l";
436-
case OF_TARGET_LINUXARMV7L:
437-
return "linuxarmv7l";
438-
default:
439-
return "";
420+
case OF_TARGET_OSX:
421+
return "osx";
422+
case OF_TARGET_MINGW:
423+
return "msys2";
424+
case OF_TARGET_WINVS:
425+
return "vs";
426+
case OF_TARGET_IOS:
427+
return "ios";
428+
case OF_TARGET_ANDROID:
429+
return "android";
430+
case OF_TARGET_LINUX:
431+
return "linux";
432+
case OF_TARGET_LINUX64:
433+
return "linux64";
434+
case OF_TARGET_LINUXARMV6L:
435+
return "linuxarmv6l";
436+
case OF_TARGET_LINUXARMV7L:
437+
return "linuxarmv7l";
438+
case OF_TARGET_LINUXAARCH64:
439+
return "linuxaarch64";
440+
default:
441+
return "";
440442
}
441443
}
442444

443445

444446
unique_ptr<baseProject> getTargetProject(ofTargetPlatform targ) {
447+
// cout << "getTargetProject :" << getTargetString(targ) << endl;
445448
switch (targ) {
446449
case OF_TARGET_OSX:
447450
return unique_ptr<xcodeProject>(new xcodeProject(getTargetString(targ)));
@@ -459,6 +462,8 @@ unique_ptr<baseProject> getTargetProject(ofTargetPlatform targ) {
459462
return unique_ptr<QtCreatorProject>(new QtCreatorProject(getTargetString(targ)));
460463
case OF_TARGET_LINUXARMV7L:
461464
return unique_ptr<QtCreatorProject>(new QtCreatorProject(getTargetString(targ)));
465+
case OF_TARGET_LINUXAARCH64:
466+
return unique_ptr<QtCreatorProject>(new QtCreatorProject(getTargetString(targ)));
462467
case OF_TARGET_ANDROID:
463468
return unique_ptr<AndroidStudioProject>(new AndroidStudioProject(getTargetString(targ)));
464469
default:

0 commit comments

Comments
 (0)