Exemplo n.º 1
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.º 2
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.º 3
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);
    }

}