bool visualStudioProject::create(string path){
	projectDir = ofFilePath::addTrailingSlash(path);
	ofLogVerbose(LOG_NAME) << "project dir:" << projectDir;
	projectName = ofFilePath::getFileName(path);
	ofLogVerbose(LOG_NAME) << "project name:" << projectName;
	ofFile project(projectDir + projectName + ".vcxproj");
	if(!project.exists()){
		ofLogVerbose(LOG_NAME) << "creating non existent project";
		ofDirectory dir(projectDir);
		dir.create(true);
		ofFile::copyFromTo(getOFRoot()+"/scripts/vs2010/template/emptyExample_vs2010.vcxproj",project.path());
		ofFile::copyFromTo(getOFRoot()+"/scripts/vs2010/template/emptyExample_vs2010.vcxproj.user",projectDir + projectName + ".vcxproj.user");
		ofFile::copyFromTo(getOFRoot()+"/scripts/vs2010/template/emptyExample_vs2010.sln",projectDir + projectName + ".sln");
		ofFile::copyFromTo(getOFRoot()+"/scripts/vs2010/template/src",projectDir);
		ofFile::copyFromTo(getOFRoot()+"/scripts/vs2010/template/bin",projectDir);
		project.open(projectDir + projectName + ".vcxproj");
	}

	pugi::xml_parse_result result = doc.load(project);
	if(result.status==pugi::status_ok){
		//TODO: change project name in xml and save
		//doc.save_file((projectDir + projectName + ".cbp").c_str());
		bLoaded = true;
	}else{
		bLoaded = false;
	}
	return bLoaded;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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);
	}
}
Exemplo n.º 4
0
void ofPg::setup(){
	while(!checkConfigExists()){
		askOFRoot();
	}
	setOFRoot(getOFRootFromConfig());

	addons.open(ofFilePath::join(getOFRoot(),"addons"));
	addons.listDir();
	
	addProject(new CBLinuxProject());
	addProject(new CBWinProject());
	addProject(new visualStudioProject());
	addProject(new xcodeProject());
	addProject(new CodeLiteLinuxProject());
}
Exemplo n.º 5
0
//--------------------------------------------------------------
void testApp::draw(){

    //ofBackgroundGradient(ofColor::gray,ofColor::black);

    panelAddons.draw();
	panelOptions.draw();
	examplesPanel.draw();

	ofSetColor(0,0,0,100);
	ofRect(ofGetWidth()-410,10,400,100);

    /*ofDrawBitmapString("press 'm' to make all files\npress ' ' to make a specific file", ofPoint(30,30));*/
	ofSetColor(255);
    ofDrawBitmapString("OF path: " + getOFRoot(), ofPoint(ofGetWidth() - 390,30));
}
Exemplo n.º 6
0
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

}
Exemplo n.º 7
0
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

}
Exemplo n.º 8
0
//--------------------------------------------------------------
void testApp::setupDrawableOFPath(){

#ifndef COMMAND_LINE_ONLY
	vector<string> subdirs = ofSplitString("OF path: " + getOFRoot(), "/");
	int textLength = 0;
	int padding = 5;
	string path = "";
	int lines=1;
	int fontSize = 8;
	float leading = 1.7;

	ofPathRect.x = padding;
	ofPathRect.y = padding;
	ofPathDrawPoint.x = padding*2;
	ofPathDrawPoint.y = padding*2 + fontSize * leading;

	for(int i = 0; i < subdirs.size(); i++) {
		if (i > 0 && i<subdirs.size()-1) {
			subdirs[i] += "/";
		}
		if(textLength + subdirs[i].length()*fontSize < ofGetWidth()-padding){
			textLength += subdirs[i].length()*fontSize;
			path += subdirs[i];
		}else {
			path += "\n";
			textLength = 0;
			lines++;
		}
	}
	ofPathRect.width = textLength + padding*2;
	if (lines > 1){
		ofPathRect.width = ofGetWidth() - padding*2;
	}
	ofPathRect.height = lines * fontSize * leading + (padding*2);

	drawableOfPath = path;

	panelAddons.setPosition(panelAddons.getPosition().x, ofPathRect.y + ofPathRect.height + padding);
	examplesPanel.setPosition(examplesPanel.getPosition().x, ofPathRect.y + ofPathRect.height + padding);
#endif


}
Exemplo n.º 9
0
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;
}
Exemplo n.º 10
0
void baseProject::setup(string _target){
    target = _target;
    templatePath = ofFilePath::join(getOFRoot(),"scripts/" + target + "/template/");
    setup(); // call the inherited class setup(), now that target is set.
}
Exemplo n.º 11
0
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){

    if (mode == MODE_NORMAL){


        // check the mouse for press

        for (int i = 0; i < buttons.size(); i++){
            buttons[i].checkMousePressed(ofPoint(x, y));
        }
        

        //-------------------------------------
        // 4 = genearate
        //-------------------------------------

        
        if (generateButton.bMouseOver == true){
            generateProject();
        }

        //-------------------------------------
        // 0 = sketch name
        //-------------------------------------

        if (buttons[0].bMouseOver == true){
            string text = ofSystemTextBoxDialog("choose sketch name", buttons[0].myText);
            fixStringCharacters(text);
            setStatus("sketch name set to: " + text);
            buttons[0].setText(text);
        }

        //-------------------------------------
        // 1 = sketch path
        //-------------------------------------

        if (buttons[1].bMouseOver == true){

            string command = "";

            ofDirectory dir(ofFilePath::join(getOFRoot(),defaultLoc));

            if (!dir.exists()){
                dir.create();
            }

          	
        #ifdef TARGET_WIN32
                    ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, windowsFromUnixPath(dir.path()));
        #else 
                    ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, dir.path());
        #endif
            

            if (res.bSuccess){
                string result = res.filePath;
                convertWindowsToUnixPath(result);
                buttons[1].setText( result );
                
                setStatus("path set to: " + result);
            }


        }


        //-------------------------------------
        // 2 = platform  (disabled)
        //-------------------------------------


        if (buttons[2].bMouseOver == true){
            // platform is diabled for now
             mode = 2;
        }

        //-------------------------------------
        // 3 = addon
        //-------------------------------------

        if (buttons[3].bMouseOver == true){
            mode = MODE_ADDON;

        }
    }

    //-------------------------------------
    // handle addon mode
    //-------------------------------------

    if (mode == MODE_ADDON ){

        //-------------------------------------
        // if we hit he back button, collect the addons for display
        //-------------------------------------

        if (addonButton.bMouseOver){

            string addons = "";

            for (int i = 0; i < panelCoreAddons.getNumControls(); i++){
                if (*((ofxToggle *)panelCoreAddons.getControl(i))){
                   if (addons.length() > 0) addons+=", ";
                    addons += ((ofxToggle *)panelCoreAddons.getControl(i))->getName();

                }

            }
            for (int i = 0; i < panelOtherAddons.getNumControls(); i++){
                if (*((ofxToggle *)panelOtherAddons.getControl(i))){
                    if (addons.length() > 0) addons+=", ";
                    addons += ((ofxToggle *)panelOtherAddons.getControl(i))->getName();

                }

            }
            buttons[3].setText(addons);

            setStatus("addons set to: " + addons);

            addonButton.bMouseOver = false;
            mode = MODE_NORMAL;
        }
    }

    if (mode == MODE_PLATFORM){

    }
}
void visualStudioProject::addAddon(ofAddon & addon){
    for(int i=0;i<(int)addons.size();i++){
		if(addons[i].name==addon.name) return;
	}

	addons.push_back(addon);

    for(int i=0;i<(int)addon.includePaths.size();i++){
        ofLogVerbose() << "adding addon include path: " << addon.includePaths[i];
        addInclude(addon.includePaths[i]);
    }

    // divide libs into debug and release libs
    // the most reliable would be to have seperate
    // folders for debug and release libs
    // i'm gonna start with a ghetto approach of just
    // looking for duplicate names except for a d.lib
    // at the end -> this is not great as many
    // libs compile with the d somewhere in the middle of the name...

    vector <string> debugLibs;
    vector <string> releaseLibs;

    vector <string> possibleReleaseOrDebugOnlyLibs;

    for(int i = 0; i < addon.libs.size(); i++){

        size_t found = 0;

        // get the full lib name
#ifdef TARGET_WIN32
    	found = addon.libs[i].find_last_of("\\");
#else
        found = addon.libs[i].find_last_of("/");
#endif

        string libName = addon.libs[i].substr(found+1);
        // get the first part of a lib name ie., libodd.lib -> libodd OR liboddd.lib -> liboddd
        found = libName.find_last_of(".");
        string firstPart = libName.substr(0,found);

        // check this lib name against every other lib name
        for(int j = 0; j < addon.libs.size(); j++){
            // check if this lib name is contained within another lib name and is not the same name
            if(ofIsStringInString(addon.libs[j], firstPart) && addon.libs[i] != addon.libs[j]){
                // if it is then add respecitive libs to debug and release
                if(!isInVector(addon.libs[j], debugLibs)){
                    //cout << "adding to DEBUG " << addon.libs[j] << endl;
                    debugLibs.push_back(addon.libs[j]);
                }
                if(!isInVector(addon.libs[i], releaseLibs)){
                    //cout << "adding to RELEASE " << addon.libs[i] << endl;
                    releaseLibs.push_back(addon.libs[i]);
                }
                // stop searching
                break;
            }else{
                // if we only have a release or only have a debug lib
                // we'll want to add it to both releaseLibs and debugLibs
                // NB: all debug libs will get added to this vector,
                // but we catch that once all pairs have been added
                // since we cannot guarantee the order of parsing libs
                // although this is innefficient it fixes issues on linux
                if(!isInVector(addon.libs[i], possibleReleaseOrDebugOnlyLibs)){
                    possibleReleaseOrDebugOnlyLibs.push_back(addon.libs[i]);
                }
                // keep searching...
            }
        }
    }

    for(int i=0;i<(int)possibleReleaseOrDebugOnlyLibs.size();i++){
         if(!isInVector(possibleReleaseOrDebugOnlyLibs[i], debugLibs) && !isInVector(possibleReleaseOrDebugOnlyLibs[i], releaseLibs)){
            ofLogVerbose() << "RELEASE ONLY LIBS FOUND " << possibleReleaseOrDebugOnlyLibs[i] << endl;
            debugLibs.push_back(possibleReleaseOrDebugOnlyLibs[i]);
            releaseLibs.push_back(possibleReleaseOrDebugOnlyLibs[i]);
         }
    }

    for(int i=0;i<(int)debugLibs.size();i++){
        ofLogVerbose() << "adding addon debug libs: " << debugLibs[i];
        addLibrary(debugLibs[i], DEBUG_LIB);
    }

    for(int i=0;i<(int)releaseLibs.size();i++){
        ofLogVerbose() << "adding addon release libs: " << releaseLibs[i];
        addLibrary(releaseLibs[i], RELEASE_LIB);
    }

    for(int i=0;i<(int)addon.srcFiles.size(); i++){
        ofLogVerbose() << "adding addon srcFiles: " << addon.srcFiles[i];
		if(addon.filesToFolders[addon.srcFiles[i]]=="") addon.filesToFolders[addon.srcFiles[i]]="other";
        addSrc(addon.srcFiles[i],addon.filesToFolders[addon.srcFiles[i]]);
    }

    for(int i=0;i<(int)addon.csrcFiles.size(); i++){
        ofLogVerbose() << "adding addon c srcFiles: " << addon.csrcFiles[i];
		if(addon.filesToFolders[addon.csrcFiles[i]]=="") addon.filesToFolders[addon.csrcFiles[i]]="other";
        addSrc(addon.csrcFiles[i],addon.filesToFolders[addon.csrcFiles[i]],C);
    }

    for(int i=0;i<(int)addon.cppsrcFiles.size(); i++){
        ofLogVerbose() << "adding addon c srcFiles: " << addon.cppsrcFiles[i];
		if(addon.filesToFolders[addon.cppsrcFiles[i]]=="") addon.filesToFolders[addon.cppsrcFiles[i]]="other";
        addSrc(addon.cppsrcFiles[i],addon.filesToFolders[addon.cppsrcFiles[i]],C);
    }

    for(int i=0;i<(int)addon.headersrcFiles.size(); i++){
        ofLogVerbose() << "adding addon c srcFiles: " << addon.headersrcFiles[i];
		if(addon.filesToFolders[addon.headersrcFiles[i]]=="") addon.filesToFolders[addon.headersrcFiles[i]]="other";
        addSrc(addon.headersrcFiles[i],addon.filesToFolders[addon.headersrcFiles[i]],C);
    }

    for(int i=0;i<(int)addon.objcsrcFiles.size(); i++){
        ofLogVerbose() << "adding addon c srcFiles: " << addon.objcsrcFiles[i];
		if(addon.filesToFolders[addon.objcsrcFiles[i]]=="") addon.filesToFolders[addon.objcsrcFiles[i]]="other";
        addSrc(addon.objcsrcFiles[i],addon.filesToFolders[addon.objcsrcFiles[i]],C);
    }

	for(int i=0;i<(int)addon.dllsToCopy.size();i++){
		ofLogVerbose() << "adding addon dlls to bin: " << addon.dllsToCopy[i];
		string dll = ofFilePath::join("addons/" + addon.name, addon.dllsToCopy[i]);
		ofFile(ofFilePath::join(getOFRoot(),dll)).copyTo(ofFilePath::join(projectDir,"bin/"),false,true);
	}

	for(int i=0;i<(int)addon.cflags.size();i++){
		addCFLAG(addon.cflags[i],RELEASE_LIB);
		addCFLAG(addon.cflags[i],DEBUG_LIB);
	}
}
Exemplo n.º 13
0
void ofAddon::fromFS(string path, string platform){

    
    
    clear();
    this->platform = platform;
	name = ofFilePath::getFileName(path);
	addonPath = ofFilePath::join(getAddonsRoot(),name);

    string filePath = path + "/src";
    string ofRootPath = ofFilePath::addTrailingSlash(getOFRoot()); //we need to add a trailing slash for the erase to work properly

    ofLogVerbose() << "in fromFS, trying src " << filePath;


	ofSetLogLevel(OF_LOG_NOTICE);
    getFilesRecursively(filePath, srcFiles);
	//ofSetLogLevel(OF_LOG_VERBOSE);

    for(int i=0;i<(int)srcFiles.size();i++){
    	srcFiles[i].erase (srcFiles[i].begin(), srcFiles[i].begin()+ofRootPath.length());
		//ofLogVerbose() << " srcFiles " << srcFiles[i];
    	int init = 0;
#ifdef TARGET_WIN32
    	int end = srcFiles[i].rfind("\\");
#else
        int end = srcFiles[i].rfind("/");
#endif
    	string folder = srcFiles[i].substr(init,end);
    	srcFiles[i] = pathToOF + srcFiles[i];
    	filesToFolders[srcFiles[i]] = folder;
    }

    string libsPath = path + "/libs";
    vector < string > libFiles;


	//ofSetLogLevel(OF_LOG_NOTICE);
    if (ofDirectory::doesDirectoryExist(libsPath)){
        getLibsRecursively(libsPath, libFiles, libs, platform);
        
        if (platform == "osx" || platform == "ios"){
            getFrameworksRecursively(libsPath, frameworks, platform);
            
        }
        
    }
    //ofSetLogLevel(OF_LOG_VERBOSE);


    // I need to add libFiles to srcFiles
    for (int i = 0; i < (int)libFiles.size(); i++){
    	libFiles[i].erase (libFiles[i].begin(), libFiles[i].begin()+ofRootPath.length());
		//ofLogVerbose() << " libFiles " << libFiles[i];
    	int init = 0;
#ifdef TARGET_WIN32
    	int end = libFiles[i].rfind("\\");
#else
        int end = libFiles[i].rfind("/");
#endif
        if (end > 0){
            string folder = libFiles[i].substr(init,end);
            libFiles[i] = pathToOF + libFiles[i];
            srcFiles.push_back(libFiles[i]);
            filesToFolders[libFiles[i]] = folder;
        }

    }

    for (int i = 0; i < (int)libs.size(); i++){

        // does libs[] have any path ? let's fix if so.
#ifdef TARGET_WIN32
    	int end = libs[i].rfind("\\");
#else
        int end = libs[i].rfind("/");
#endif
        if (end > 0){

            libs[i].erase (libs[i].begin(), libs[i].begin()+ofRootPath.length());
            libs[i] = pathToOF + libs[i];
        }

    }
    
    for (int i = 0; i < (int)frameworks.size(); i++){
        
        // does libs[] have any path ? let's fix if so.
#ifdef TARGET_WIN32
    	int end = frameworks[i].rfind("\\");
#else
        int end = frameworks[i].rfind("/");
#endif
        if (end > 0){
            
            frameworks[i].erase (frameworks[i].begin(), frameworks[i].begin()+ofRootPath.length());
            frameworks[i] = pathToOF + frameworks[i];
        }
        
    }
    
    

    // get a unique list of the paths that are needed for the includes.
    list < string > paths;
    for (int i = 0; i < (int)srcFiles.size(); i++){
        size_t found;
#ifdef TARGET_WIN32
    	found = srcFiles[i].find_last_of("\\");
#else
        found = srcFiles[i].find_last_of("/");
#endif
        paths.push_back(srcFiles[i].substr(0,found));
    }

    // get every folder in addon/src and addon/libs

    vector < string > libFolders;
    ofLogVerbose() << "trying get folders recursively " << (path + "/libs");

	// the dirList verbosity is crazy, so I'm setting this off for now.
	//ofSetLogLevel(OF_LOG_NOTICE);
    getFoldersRecursively(path + "/libs", libFolders, platform);
    vector < string > srcFolders;
    getFoldersRecursively(path + "/src", srcFolders, platform);
	//ofSetLogLevel(OF_LOG_VERBOSE);

    for (int i = 0; i < (int)libFolders.size(); i++){
        libFolders[i].erase (libFolders[i].begin(), libFolders[i].begin()+ofRootPath.length());
        libFolders[i] = pathToOF + libFolders[i];
        paths.push_back(libFolders[i]);
    }

    for (int i = 0; i < (int)srcFolders.size(); i++){
        srcFolders[i].erase (srcFolders[i].begin(), srcFolders[i].begin()+ofRootPath.length());
        srcFolders[i] = pathToOF + srcFolders[i];
        paths.push_back(srcFolders[i]);
    }

    paths.sort();
    paths.unique();
    for (list<string>::iterator it=paths.begin(); it!=paths.end(); ++it){
        includePaths.push_back(*it);
    }

    parseConfig();

}
Exemplo n.º 14
0
void ofAddon::fromFS(string path, string platform){
	
    clear();
	name = ofFilePath::getFileName(path);

    string filePath = path + "/src";
    
    
    cout << "in fromFS, trying src " << filePath << endl;
    getFilesRecursively(filePath, srcFiles);

    for(int i=0;i<(int)srcFiles.size();i++){
    	srcFiles[i].erase (srcFiles[i].begin(), srcFiles[i].begin()+getOFRoot().length());
    	int init = srcFiles[i].find("/")+1;
    	int end = srcFiles[i].rfind("/") - srcFiles[i].find("/");
    	string folder = srcFiles[i].substr(init,end);
    	srcFiles[i] = pathToOF + srcFiles[i];
    	filesToFolders[srcFiles[i]] = folder;
    }

    string libsPath = path + "/libs";
    vector < string > libFiles;
    vector < string > libLibs;
    if (ofDirectory::doesDirectoryExist(libsPath)){
        getLibsRecursively(libsPath, libFiles, libs, platform);
    }

    // I need to add libFiles to srcFiles
    for (int i = 0; i < (int)libFiles.size(); i++){
    	libFiles[i].erase (libFiles[i].begin(), libFiles[i].begin()+getOFRoot().length());
    	int init = libFiles[i].find("/")+1;
    	int end = libFiles[i].rfind("/") - libFiles[i].find("/");
    	string folder = libFiles[i].substr(init,end);
    	libFiles[i] = pathToOF + libFiles[i];
        srcFiles.push_back(libFiles[i]);
    	filesToFolders[libFiles[i]] = folder;
    }

    for (int i = 0; i < (int)libs.size(); i++){
    	libs[i].erase (libs[i].begin(), libs[i].begin()+getOFRoot().length());
    	libs[i] = pathToOF + libs[i];
    }

    
    // get a unique list of the paths that are needed for the includes.
    list < string > paths;
    for (int i = 0; i < (int)srcFiles.size(); i++){
        size_t found;
        found = srcFiles[i].find_last_of("/");
        paths.push_back(srcFiles[i].substr(0,found));
    }
    
    // get every folder in addon/src and addon/libs
    
    vector < string > libFolders;
    cout << "trying get folders recursively " << (path + "/libs") << endl;
    getFoldersRecursively(path + "/libs", libFolders);
    
    vector < string > srcFolders;
    getFoldersRecursively(path + "/src", srcFolders);
    
    for (int i = 0; i < libFolders.size(); i++){
        libFolders[i].erase (libFolders[i].begin(), libFolders[i].begin()+getOFRoot().length());
        libFolders[i] = pathToOF + libFolders[i];
        paths.push_back(libFolders[i]);
    }
    
    for (int i = 0; i < srcFolders.size(); i++){
        srcFolders[i].erase (srcFolders[i].begin(), srcFolders[i].begin()+getOFRoot().length());
        srcFolders[i] = pathToOF + srcFolders[i];
        paths.push_back(srcFolders[i]);
    }
    
    
    paths.sort();
    paths.unique();
    for (list<string>::iterator it=paths.begin(); it!=paths.end(); ++it){
        includePaths.push_back(*it);
    }

}
void CBLinuxProject::setup() {
	templatePath = ofFilePath::join(getOFRoot(),"scripts/linux/template/"+target);
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
    ofPoint mouse = ofPoint(x, y);
    if (mode == MODE_NORMAL){

        for (int i = 0; i < buttons.size(); i++){
            buttons[i]->checkMousePressed(mouse);
        }
        
        //-------------------------------------
        // 0 = sketch name
        //-------------------------------------
//        if (buttons[0].bMouseOver == true){
//            string text = ofSystemTextBoxDialog("choose sketch name", buttons[0].text);
//            fixStringCharacters(text);
//            setStatus("sketch name set to: " + text);
//            buttons[0].setText(text);
//        }

        //-------------------------------------
        // 1 = sketch path
        //-------------------------------------
        if (buttons[1]->bMouseOver == true){

            string command = "";

            ofDirectory dir(ofFilePath::join(getOFRoot(),defaultLoc));

            if (!dir.exists()){
                dir.create();
            }
          	
        #ifdef TARGET_WIN32
                    ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, windowsFromUnixPath(dir.path()));
        #else 
                    ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, dir.path());
        #endif
            

            if (res.bSuccess){
                string result = res.filePath;
                convertWindowsToUnixPath(result);
                buttons[1]->setText( result );
                
                setStatus("path set to: " + result);
            }
        }

        //-------------------------------------
        // 2 = platform  (disabled)
        //-------------------------------------
        if (buttons[2]->bMouseOver == true){
            // platform is diabled for now
             mode = MODE_PLATFORM;
        }

        //-------------------------------------
        // 3 = addon
        //-------------------------------------
        if (buttons[3]->bMouseOver == true){
            mode = MODE_ADDON;
        }
        
        //-------------------------------------
        // 4 = genearate
        //-------------------------------------
        if (generateButton.bMouseOver == true){
            generateProject();
        }
    }

    if (mode == MODE_ADDON ){
        
        coreAddonsList.checkMousePressed(mouse);
        if(bHaveNonCoreAddons)
            otherAddonsList.checkMousePressed(mouse);
        
        //-------------------------------------
        // if we hit he back button, collect the addons for display
        //-------------------------------------

        if (backButton.bMouseOver){
            string addons = coreAddonsList.getSelectedAsString() + otherAddonsList.getSelectedAsString();
            buttons[3]->setText(addons);
            setStatus("addons set to: " + addons);

            backButton.bMouseOver = false;
            mode = MODE_NORMAL;
        }
    }

    if (mode == MODE_PLATFORM){
        platformsList.checkMousePressed(mouse);
        
        if (backButton.bMouseOver){
            string platforms = platformsList.getSelectedAsString();
            buttons[2]->setText( platforms );
            setStatus("Platform targets set to: " + platforms);
            
            backButton.bMouseOver = false;
            mode = MODE_NORMAL;
        }
    }
}
Exemplo n.º 17
0
//--------------------------------------------------------------
void testApp::setup(){
    //ofSetLogLevel(OF_LOG_NOTICE);
	project = NULL;

	while(!checkConfigExists()){
		askOFRoot();
	}

	setOFRoot(getOFRootFromConfig());

	setupDrawableOFPath();

	int targ = ofGetTargetPlatform();
	//plat = OF_TARGET_IPHONE;

    setupForTarget(targ);
    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);
    }

#ifndef COMMAND_LINE_ONLY
    panelAddons.setup();
    ofDirectory addons(ofFilePath::join(getOFRoot(),"addons"));
    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);
    	if(addon.find("ofx")==0){
    		ofxToggle * toggle = new ofxToggle();
    		panelAddons.add(toggle->setup(addon,false,300));
    	}
    }

    panelOptions.setup("","settings.xml",ofGetWidth()-panelAddons.getWidth()-10,120);
    panelOptions.add(createProject.setup("create project",300));
    panelOptions.add(updateProject.setup("update project",300));
    panelOptions.add(createAndOpen.setup("create and open project",300));
    panelOptions.add(changeOFRoot.setup("change OF path",300));

    createProject.addListener(this,&testApp::createProjectPressed);
    updateProject.addListener(this,&testApp::updateProjectPressed);
    createAndOpen.addListener(this,&testApp::createAndOpenPressed);
    changeOFRoot.addListener(this,&testApp::changeOFRootPressed);

	examplesPanel.setup("generate examples", "examples.xml", 400, 10);
	examplesPanel.add(generateButton.setup("<--Generate"));
	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);

    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
	ofSetFrameRate(60);
#else
	std::exit(0);
#endif
}
Exemplo n.º 18
0
void ofAddon::fromFS(string path, string platform){

    clear();
	name = ofFilePath::getFileName(path);

    string filePath = path + "/src";
    string ofRootPath = ofFilePath::addTrailingSlash(getOFRoot()); //we need to add a trailing slash for the erase to work properly

    ofLogVerbose() << "in fromFS, trying src " << filePath;
    getFilesRecursively(filePath, srcFiles);

    for(int i=0;i<(int)srcFiles.size();i++){
    	srcFiles[i].erase (srcFiles[i].begin(), srcFiles[i].begin()+ofRootPath.length());
		ofLogVerbose() << " srcFiles " << srcFiles[i];
    	int init = 0;
#ifdef TARGET_WIN32
    	int end = srcFiles[i].rfind("\\");
#else
        int end = srcFiles[i].rfind("/");
#endif
    	string folder = srcFiles[i].substr(init,end);
    	srcFiles[i] = pathToOF + srcFiles[i];
    	filesToFolders[srcFiles[i]] = folder;
    }

    string libsPath = path + "/libs";
    vector < string > libFiles;
    
    cout << libs.size() << " libs size + platform =  " << platform << endl;
    
    if (ofDirectory::doesDirectoryExist(libsPath)){
        getLibsRecursively(libsPath, libFiles, libs, platform);
    }
    
    cout << libs.size() << " libs size " << endl;

    // I need to add libFiles to srcFiles
    for (int i = 0; i < (int)libFiles.size(); i++){
    	libFiles[i].erase (libFiles[i].begin(), libFiles[i].begin()+ofRootPath.length());
		ofLogVerbose() << " libFiles " << libFiles[i];
    	int init = 0;
#ifdef TARGET_WIN32
    	int end = libFiles[i].rfind("\\");
#else
        int end = libFiles[i].rfind("/");
#endif
        if (end > 0){
            string folder = libFiles[i].substr(init,end);
            libFiles[i] = pathToOF + libFiles[i];
            srcFiles.push_back(libFiles[i]);
            filesToFolders[libFiles[i]] = folder;
        }

    }

    for (int i = 0; i < (int)libs.size(); i++){

        // does libs[] have any path ? let's fix if so.
#ifdef TARGET_WIN32
    	int end = libs[i].rfind("\\");
#else
        int end = libs[i].rfind("/");
#endif
        if (end > 0){

            libs[i].erase (libs[i].begin(), libs[i].begin()+ofRootPath.length());
            libs[i] = pathToOF + libs[i];
        }

    }

    // get a unique list of the paths that are needed for the includes.
    list < string > paths;
    for (int i = 0; i < (int)srcFiles.size(); i++){
        size_t found;
#ifdef TARGET_WIN32
    	found = srcFiles[i].find_last_of("\\");
#else
        found = srcFiles[i].find_last_of("/");
#endif
        paths.push_back(srcFiles[i].substr(0,found));
    }

    // get every folder in addon/src and addon/libs

    vector < string > libFolders;
    ofLogVerbose() << "trying get folders recursively " << (path + "/libs");
    getFoldersRecursively(path + "/libs", libFolders, platform);

    vector < string > srcFolders;
    getFoldersRecursively(path + "/src", srcFolders, platform);

    for (int i = 0; i < libFolders.size(); i++){
        libFolders[i].erase (libFolders[i].begin(), libFolders[i].begin()+ofRootPath.length());
        libFolders[i] = pathToOF + libFolders[i];
        paths.push_back(libFolders[i]);
    }

    for (int i = 0; i < srcFolders.size(); i++){
        srcFolders[i].erase (srcFolders[i].begin(), srcFolders[i].begin()+ofRootPath.length());
        srcFolders[i] = pathToOF + srcFolders[i];
        paths.push_back(srcFolders[i]);
    }

    paths.sort();
    paths.unique();
    for (list<string>::iterator it=paths.begin(); it!=paths.end(); ++it){
        includePaths.push_back(*it);
    }

}
Exemplo n.º 19
0
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){

    if (mode == MODE_NORMAL){


        // check the mouse for press

        for (int i = 0; i < buttons.size(); i++){
            buttons[i].checkMousePressed(ofPoint(x, y));
        }

        //-------------------------------------
        // 4 = genearate
        //-------------------------------------

        if (buttons[4].bMouseOver == true){
            generateProject();
        }

        //-------------------------------------
        // 0 = sketch name
        //-------------------------------------

        if (buttons[0].bMouseOver == true){
            string text = ofSystemTextBoxDialog("choose sketch name", buttons[0].myText);
            fixStringCharacters(text);
            status = "sketch name set to: " + text;
            buttons[0].setText(text);
        }

        //-------------------------------------
        // 1 = sketch path
        //-------------------------------------

        if (buttons[1].bMouseOver == true){

             printf("here2? \n");

            string command;


            ofDirectory dir(ofFilePath::join(getOFRoot(),defaultLoc));

            //cout << dir.getAbsolutePath() << endl;

            if (!dir.exists()){
                dir.create();
            }

#ifdef TARGET_OSX

            printf("here? \n");

            char * MessageBuffer = "please select sketch folder";
            char * FileExtension = "";
            char ResultBuffer[1024];
            memset(ResultBuffer, 0,1024);

            string defaultStr = ofFilePath::join(getOFRoot(),defaultLoc);
            cout << defaultStr << endl;
            if (__g2ShowOpenDialog((char *)defaultStr.c_str(), MessageBuffer, FileExtension, ResultBuffer, 1024)){

                string res = string(ResultBuffer);
                buttons[1].setText(res);
                status = "sketch path set to: " + res;

            }
#else

            ofFileDialogResult results = ofSystemLoadDialog("please select sketch folder",true,buttons[1].myText);
            if(results.bSuccess){
				buttons[1].setText(results.filePath);
				status = "sketch path set to: " + results.filePath;
            }

#endif


        }


        //-------------------------------------
        // 2 = platform  (disabled)
        //-------------------------------------


        if (buttons[2].bMouseOver == true){
            // platform is diabled for now
            // mode = 2;
        }

        //-------------------------------------
        // 3 = addon
        //-------------------------------------

        if (buttons[3].bMouseOver == true){
            mode = MODE_ADDON;

        }
    }

    //-------------------------------------
    // handle addon mode
    //-------------------------------------

    if (mode == MODE_ADDON){

        //-------------------------------------
        // if we hit he back button, collect the addons for display
        //-------------------------------------

        if (addonButton.bMouseOver){

            string addons = "";

            for (int i = 0; i < panelCoreAddons.getNumControls(); i++){
                if (*((ofxToggle *)panelCoreAddons.getControl(i))){
                   if (addons.length() > 0) addons+=", ";
                    addons += ((ofxToggle *)panelCoreAddons.getControl(i))->getName();

                };

            }
            for (int i = 0; i < panelOtherAddons.getNumControls(); i++){
                if (*((ofxToggle *)panelOtherAddons.getControl(i))){
                    if (addons.length() > 0) addons+=", ";
                    addons += ((ofxToggle *)panelOtherAddons.getControl(i))->getName();

                };

            }
            buttons[3].setText(addons);

            status = "addons set to: " + addons;

            addonButton.bMouseOver = false;
            mode = MODE_NORMAL;
        }
    }

    if (mode == MODE_PLATFORM){

    }
}