bool CBWinProject::createProjectFile() { string project = projectDir + projectName + ".cbp"; string workspace = projectDir + projectName + ".workspace"; ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.cbp"),project, false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.workspace"),workspace, false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"icon.rc"), projectDir + "icon.rc", false, true); //let's do some renaming: string relRoot = getOFRelPath(ofFilePath::removeTrailingSlash(projectDir)); if (relRoot != "../../../") { string relRootWindows = relRoot; // let's make it windows friendly: for(int i = 0; i < relRootWindows.length(); i++) { if( relRootWindows[i] == '/' ) relRootWindows[i] = '\\'; } findandreplaceInTexfile(workspace, "../../../", relRoot); findandreplaceInTexfile(project, "../../../", relRoot); findandreplaceInTexfile(workspace, "..\\..\\..\\", relRootWindows); findandreplaceInTexfile(project, "..\\..\\..\\", relRootWindows); } return true; }
void testApp::generateExamples(){ ofDirectory dir; string examplesPath = ofFilePath::join(getOFRoot(),"examples"); ofLogNotice() << "Generating examples (from: " << examplesPath << ")"; dir.listDir(examplesPath); for (int i = 0; i < (int)dir.size(); i++){ // don't check subdirectories that aren't directories! (eg., .gitignore etc) if(!dir.getFile(i).isDirectory()) continue; if( target == "ios" ){ if( dir.getName(i) != "ios" ) continue; }else{ if (dir.getName(i) == "android" || dir.getName(i) == "ios") continue; } ofDirectory subdir; string examplesPath = dir.getPath(i); ofLogNotice() << "Generating examples in folder: " << examplesPath; subdir.listDir(examplesPath); for (int j = 0; j < (int)subdir.size(); j++){ // don't create projects that aren't directories! (eg., .gitkeep etc) if(!subdir.getFile(j).isDirectory()) continue; ofLogNotice() << "------------------------------------------------"; ofLogNotice() << "Generating example: " << subdir.getPath(j); ofLogNotice() << "------------------------------------------------"; project->setup(target); project->create(subdir.getPath(j)); vector < string > addons; parseAddonsDotMake(project->getPath() + "addons.make", addons); for (int i = 0; i < (int)addons.size(); i++){ ofAddon addon; addon.pathToOF = getOFRelPath(subdir.getPath(j)); addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target); project->addAddon(addon); } project->save(false); } } ofLogNotice() << " "; ofLogNotice() << "Finished generating examples for " << target; }
void baseProject::parseAddons(){ ofFile addonsMake(ofFilePath::join(projectDir,"addons.make")); ofBuffer addonsMakeMem; addonsMake >> addonsMakeMem; while(!addonsMakeMem.isLastLine()){ ofAddon addon; cout << projectDir << endl; addon.pathToOF = getOFRelPath(projectDir); cout << addon.pathToOF << endl; addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsMakeMem.getNextLine()),target); addAddon(addon); } }
ofFileDialogResult testApp::updateProjectViaDialog(){ #ifndef COMMAND_LINE_ONLY ofFileDialogResult res = ofSystemLoadDialog("choose a folder to update an OF project :)",true); if (res.fileName == "" || res.filePath == "") return res; //base.pushDirectory(res.fileName); // somehow an extra things here helps? vector <int> targetsToMake; if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); if( targetsToMake.size() == 0 ){ cout << "Error: updateProjectViaDialog - must specifiy a project to generate " <<endl; ofSystemAlertDialog("Error: updateProjectViaDialog - must specifiy a project platform to generate"); } for(int i = 0; i < (int)targetsToMake.size(); i++){ setupForTarget(targetsToMake[i]); project->setup(target); project->create(res.filePath); vector<string> addonsToggles = panelAddons.getControlNames(); for (int i = 0; i < (int)addonsToggles.size(); i++){ ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); // TODO: make this remove existing addons that are unchecked???? // probably requires a more complex logic chain: loadProject // (ticks the addons) and then you can untick etc??? if(toggle){ ofAddon addon; addon.pathToOF = getOFRelPath(res.filePath); addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); printf("adding %s addons \n", addonsToggles[i].c_str()); project->addAddon(addon); } } project->save(true); } return res; #endif }
bool visualStudioProject::createProjectFile(){ string project = ofFilePath::join(projectDir,projectName + ".vcxproj"); string user = ofFilePath::join(projectDir,projectName + ".vcxproj.user"); string solution = ofFilePath::join(projectDir,projectName + ".sln"); string filters = ofFilePath::join(projectDir, projectName + ".vcxproj.filters"); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj"),project,false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj.user"),user, false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.sln"),solution, false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj.filters"),filters, false, true); ofFile::copyFromTo(ofFilePath::join(templatePath,"icon.rc"), projectDir + "icon.rc", false, true); ofFile filterFile(filters); string temp = filterFile.readToBuffer(); pugi::xml_parse_result result = filterXmlDoc.load(temp.c_str()); if (result.status==pugi::status_ok) ofLogVerbose() << "loaded filter "; else ofLogVerbose() << "problem loading filter "; findandreplaceInTexfile(solution,"emptyExample",projectName); findandreplaceInTexfile(user,"emptyExample",projectName); findandreplaceInTexfile(project,"emptyExample",projectName); string relRoot = getOFRelPath(ofFilePath::removeTrailingSlash(projectDir)); if (relRoot != "../../../"){ string relRootWindows = relRoot; // let's make it windows friendly: for(int i = 0; i < relRootWindows.length(); i++) { if( relRootWindows[i] == '/' ) relRootWindows[i] = '\\'; } // sln has windows paths: findandreplaceInTexfile(solution, "..\\..\\..\\", relRootWindows); // vcx has unixy paths: //..\..\..\libs findandreplaceInTexfile(project, "../../../", relRoot); } return true; }
ofFileDialogResult testApp::makeNewProjectViaDialog(){ #ifndef COMMAND_LINE_ONLY ofFileDialogResult res = ofSystemSaveDialog("newProjectName", "choose a folder for a new OF project :)"); if (res.fileName == "" || res.filePath == "") return res; //base.pushDirectory(res.fileName); // somehow an extra things here helps? vector <int> targetsToMake; if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); if( targetsToMake.size() == 0 ){ cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <<endl; ofSystemAlertDialog("Error: makeNewProjectViaDialog - must specifiy a project platform to generate"); } for(int i = 0; i < (int)targetsToMake.size(); i++){ setupForTarget(targetsToMake[i]); project->setup(target); if(project->create(res.filePath)){ vector<string> addonsToggles = panelAddons.getControlNames(); for (int i = 0; i < (int) addonsToggles.size(); i++){ ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); if(toggle){ ofAddon addon; addon.pathToOF = getOFRelPath(res.filePath); addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); printf("adding %s addons \n", addonsToggles[i].c_str()); project->addAddon(addon); } } project->save(true); } } return res; #endif }
ofFileDialogResult testApp::updateProjectViaDialog(){ ofFileDialogResult res = ofSystemLoadDialog("choose a folder to update an OF project :)",true); if (res.fileName == "" || res.filePath == "") return res; //base.pushDirectory(res.fileName); // somehow an extra things here helps? project->setup(target); project->create(res.filePath); vector<string> addonsToggles = panelAddons.getControlNames(); for (int i = 0; i < (int)addonsToggles.size(); i++){ ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); if(toggle){ ofAddon addon; addon.pathToOF = getOFRelPath(res.filePath); addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); printf("adding %s addons \n", addonsToggles[i].c_str()); project->addAddon(addon); } } project->save(); return res; }
bool CBLinuxProject::createProjectFile(){ ofDirectory dir(projectDir); if(!dir.exists()) dir.create(true); ofFile project(ofFilePath::join(projectDir, projectName + ".cbp")); string src = ofFilePath::join(templatePath,"emptyExample_" + target + ".cbp"); string dst = project.path(); bool ret; if(!project.exists()){ ret = ofFile::copyFromTo(src,dst); if(!ret){ ofLogError(LOG_NAME) << "error copying cbp template from " << src << " to " << dst; return false; }else{ findandreplaceInTexfile(dst, "emptyExample", projectName); } } ofFile workspace(ofFilePath::join(projectDir, projectName + ".workspace")); if(!workspace.exists()){ src = ofFilePath::join(templatePath,"emptyExample_" + target + ".workspace"); dst = workspace.path(); ret = ofFile::copyFromTo(src,dst); if(!ret){ ofLogError(LOG_NAME) << "error copying workspace template from "<< src << " to " << dst; return false; }else{ findandreplaceInTexfile(dst, "emptyExample", projectName); } } ofFile makefile(ofFilePath::join(projectDir,"Makefile")); if(!makefile.exists()){ src = ofFilePath::join(templatePath,"Makefile"); dst = makefile.path(); ret = ofFile::copyFromTo(src,dst); if(!ret){ ofLogError(LOG_NAME) << "error copying Makefile template from " << src << " to " << dst; return false; } } ofFile config(ofFilePath::join(projectDir,"config.make")); if(!config.exists()){ src = ofFilePath::join(templatePath,"config.make"); dst = config.path(); ret = ofFile::copyFromTo(src,dst); if(!ret){ ofLogError(LOG_NAME) << "error copying config.make template from " << src << " to " << dst; return false; } } // handle the relative roots. string relRoot = getOFRelPath(ofFilePath::removeTrailingSlash(projectDir)); if (relRoot != "../../../"){ string relPath2 = relRoot; relPath2.erase(relPath2.end()-1); findandreplaceInTexfile(projectDir + "Makefile", "../../..", relPath2); findandreplaceInTexfile(projectDir + "config.make", "../../..", relPath2); findandreplaceInTexfile(ofFilePath::join(projectDir , projectName + ".workspace"), "../../../", relRoot); findandreplaceInTexfile(ofFilePath::join(projectDir , projectName + ".cbp"), "../../../", relRoot); } return true; }
void testApp::generateProject(){ vector <int> targetsToMake; for(int i = 0; i < platformsList.elements.size(); i++){ if ( *(platformsList.elements[i]) == true ){ if (platformsList.elements[i]->text == "windows (codeblocks)" ){ targetsToMake.push_back(OF_TARGET_WINGCC); } else if (platformsList.elements[i]->text == "windows (visualStudio)"){ targetsToMake.push_back(OF_TARGET_WINVS); } else if (platformsList.elements[i]->text == "linux (codeblocks)"){ targetsToMake.push_back(OF_TARGET_LINUX); } else if (platformsList.elements[i]->text == "linux64 (codeblocks)"){ targetsToMake.push_back(OF_TARGET_LINUX64); } else if (platformsList.elements[i]->text == "osx (xcode)"){ targetsToMake.push_back(OF_TARGET_OSX); } else if (platformsList.elements[i]->text == "ios (xcode)"){ targetsToMake.push_back(OF_TARGET_IPHONE); } } } cout << targetsToMake.size() << endl; if( targetsToMake.size() == 0 ){ cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <<endl; ofSystemAlertDialog("Error: makeNewProjectViaDialog - must specifiy a project platform to generate"); return; } if (buttons[0]->text.size() == 0){ ofSystemAlertDialog("Error: project must have a name"); return; } printf("start with project generation \n"); string path = ofFilePath::join(buttons[1]->text, buttons[0]->text); for(int i = 0; i < (int)targetsToMake.size(); i++){ string target = setTarget(targetsToMake[i]); if(project->create(path)){ vector<string> addons = coreAddonsList.getSelected(); for (int i = 0; i < addons.size(); i++){ ofAddon addon; addon.pathToOF = getOFRelPath(path); addon.fromFS(ofFilePath::join(addonsPath, addons[i]),target); project->addAddon(addon); } addons = coreAddonsList.getSelected(); for (int i = 0; i < addons.size(); i++){ ofAddon addon; addon.pathToOF = getOFRelPath(path); addon.fromFS(ofFilePath::join(addonsPath, addons[i]),target); project->addAddon(addon); } project->save(true); } setStatus("generated: " + buttons[1]->text + "/" + buttons[0]->text + " for " + platformsList.getSelected()[i]); } printf("done with project generation \n"); // go through the control panels, do stuff }
void testApp::generateProject(){ vector <int> targetsToMake; if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); targetsToMake.push_back(OF_TARGET_LINUX64); if( targetsToMake.size() == 0 ){ cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <<endl; ofSystemAlertDialog("Error: makeNewProjectViaDialog - must specifiy a project platform to generate"); return; } if (buttons[0].myText.size() == 0){ ofSystemAlertDialog("Error: project must have a name"); return; } printf("start with project generation \n"); string path = ofFilePath::join(buttons[1].myText, buttons[0].myText); for(int i = 0; i < (int)targetsToMake.size(); i++){ string target = setupForTarget(targetsToMake[i]); if(project->create(path)){ vector<string> addonsToggles = panelCoreAddons.getControlNames(); for (int i = 0; i < (int) addonsToggles.size(); i++){ ofxToggle toggle = panelCoreAddons.getToggle(addonsToggles[i]); if(toggle){ ofAddon addon; addon.pathToOF = getOFRelPath(path); addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); project->addAddon(addon); } } addonsToggles = panelOtherAddons.getControlNames(); for (int i = 0; i < (int) addonsToggles.size(); i++){ ofxToggle toggle = panelOtherAddons.getToggle(addonsToggles[i]); if(toggle){ ofAddon addon; addon.pathToOF = getOFRelPath(path); cout << getOFRelPath(path) << " " << path << endl; addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); project->addAddon(addon); } } project->save(true); } } printf("done with project generation \n"); setStatus("generated: " + buttons[1].myText + "/" + buttons[0].myText); // go through the control panels, do stuff }