Permalink
Browse files

projectGenerator: more complete command line options

  • Loading branch information...
1 parent bf05555 commit f0784ff214f017efcfaf8ed4f066428fcfdcbb28 @arturoc arturoc committed May 3, 2012
@@ -17,9 +17,60 @@ int main( int argc, char *argv[] ){
ofAppNoWindow window;
ofSetupOpenGL(&window, 1024,768, OF_WINDOW);
testApp * app = new testApp;
- app->projectPath = ofFilePath::removeTrailingSlash(ofFilePath::getPathForDirectory(ofFilePath::getAbsolutePath(argv[argc-1],false)));
- cout << app->projectPath << endl;
- cout << argv[0] << endl;
+ app->buildAllExamples = false;
+ for(int i=1;i<argc;i++){
+ string arg = argv[i];
+ if(arg.find("--")==0){
+ arg = arg.substr(2);
+ if(arg=="linux"){
+ app->targetsToMake.push_back( OF_TARGET_LINUX );
+ }else if(arg=="linux64"){
+ app->targetsToMake.push_back( OF_TARGET_LINUX64 );
+ }else if(arg=="wincb"){
+ app->targetsToMake.push_back( OF_TARGET_WINGCC );
+ }else if(arg=="vs2010"){
+ app->targetsToMake.push_back( OF_TARGET_WINVS );
+ }else if(arg=="osx"){
+ app->targetsToMake.push_back( OF_TARGET_OSX );
+ }else if(arg=="ios"){
+ app->targetsToMake.push_back( OF_TARGET_IPHONE );
+ }else if(arg=="android"){
+ ofLogError() << "platform not supported yet" << endl;
+ std::exit(1);
+ }else if(arg=="allplatforms"){
+ app->targetsToMake.push_back( OF_TARGET_LINUX );
+ app->targetsToMake.push_back( OF_TARGET_LINUX64 );
+ app->targetsToMake.push_back( OF_TARGET_WINGCC );
+ app->targetsToMake.push_back( OF_TARGET_WINVS );
+ app->targetsToMake.push_back( OF_TARGET_OSX );
+ app->targetsToMake.push_back( OF_TARGET_IPHONE );
+ }else if(arg=="allexamples"){
+ app->buildAllExamples = true;
+ }else if(arg=="help"){
+ cout << "OF Project Generator Usage:" << endl;
+ cout << "projectGenerator [options] [pathToExample]" << endl;
+ cout << "Options:" << endl;
+ cout << "--osx: generate osx project files" << endl;
+ cout << "--wincb: generate windows codeblocks project files" << endl;
+ cout << "--vs2010: generate windows vs2010 project files" << endl;
+ cout << "--linux: generate linux project files" << endl;
+ cout << "--linux64: generate linux 64bits project files" << endl;
+ cout << "--ios: generate iOS project files" << endl;
+ cout << "--allplatforms: generate all platforms project files" << endl;
+ cout << "--allexamples: generate all examples project files" << endl;
+ cout << endl;
+ cout << "default: create project files for current platform for selected path" << endl;
+ cout << "running over existing example updates project files for selected platforms" << endl;
+ cout << "without parameters, shows gui" << endl;
+ std::exit(0);
+ }
+ }else{
+ app->projectPath = ofFilePath::removeTrailingSlash(ofFilePath::getPathForDirectory(ofFilePath::getAbsolutePath(arg,false)));
+ }
+ }
+
+ if(app->targetsToMake.empty())
+ app->targetsToMake.push_back( ofGetTargetPlatform() );
ofRunApp( app );
}
#else
@@ -20,18 +20,24 @@ void testApp::setup(){
setupForTarget(targ);
- if(projectPath!=""){
- setupForTarget(ofGetTargetPlatform());
- project->setup(target);
- project->create(projectPath);
- vector < string > addons;
- parseAddonsDotMake(project->getPath() + "addons.make", addons);
- for (int i = 0; i < (int)addons.size(); i++){
- ofAddon addon;
- addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target);
- project->addAddon(addon);
- }
- project->save(false);
+ if(projectPath!="" || buildAllExamples){
+ for(int i = 0; i < (int)targetsToMake.size(); i++){
+ setupForTarget(targetsToMake[i]);
+ if(buildAllExamples){
+ generateExamples();
+ }else{
+ project->setup(target);
+ project->create(projectPath);
+ vector < string > addons;
+ parseAddonsDotMake(project->getPath() + "addons.make", addons);
+ for (int i = 0; i < (int)addons.size(); i++){
+ ofAddon addon;
+ addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target);
+ project->addAddon(addon);
+ }
+ project->save(false);
+ }
+ }
std::exit(0);
}
@@ -59,12 +65,12 @@ void testApp::setup(){
examplesPanel.setup("generate examples", "examples.xml", 400, 10);
examplesPanel.add(generateButton.setup("<--Generate"));
- examplesPanel.add(wincbToggle.setup("win CB projects",false));
- examplesPanel.add(winvsToggle.setup("win VS projects", false));
- examplesPanel.add(linuxcbToggle.setup("linux CB projects",false));
- examplesPanel.add(linux64cbToggle.setup("linux64 CB projects",false));
- examplesPanel.add(osxToggle.setup("osx projects",false));
- examplesPanel.add(iosToggle.setup("ios projects",false));
+ examplesPanel.add(wincbToggle.setup("win CB projects",ofGetTargetPlatform()==OF_TARGET_WINGCC));
+ examplesPanel.add(winvsToggle.setup("win VS projects", ofGetTargetPlatform()==OF_TARGET_WINVS));
+ examplesPanel.add(linuxcbToggle.setup("linux CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX));
+ examplesPanel.add(linux64cbToggle.setup("linux64 CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX64));
+ examplesPanel.add(osxToggle.setup("osx projects",ofGetTargetPlatform()==OF_TARGET_OSX));
+ examplesPanel.add(iosToggle.setup("ios projects",ofGetTargetPlatform()==OF_TARGET_IPHONE));
generateButton.addListener(this,&testApp::generateExamplesCB);
@@ -113,7 +119,7 @@ void testApp::generateExamplesCB(bool & pressed){
if (pressed == false) return; // don't do this again on the mouseup.
- vector <int> targetsToMake;
+ targetsToMake.clear();
if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX);
if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE);
if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC);
@@ -54,4 +54,7 @@ class testApp : public ofBaseApp{
ofxPanel examplesPanel;
ofxToggle osxToggle, iosToggle, wincbToggle, winvsToggle, linuxcbToggle, linux64cbToggle;
ofxButton generateButton;
+
+ vector <int> targetsToMake;
+ bool buildAllExamples;
};

0 comments on commit f0784ff

Please sign in to comment.