diff --git a/src/addons/ofAddon.cpp b/src/addons/ofAddon.cpp index 7ca4397..b312bf0 100644 --- a/src/addons/ofAddon.cpp +++ b/src/addons/ofAddon.cpp @@ -263,6 +263,7 @@ void ofAddon::exclude(vector & variable, vector exclusions){ if(regExp.match(variable[j])){ variable.erase(variable.begin()+j); j--; + cout << "excluded" << endl; } } } @@ -347,7 +348,8 @@ void ofAddon::fromFS(string path, string platform){ name = ofFilePath::getFileName(path); addonPath = ofFilePath::join(getAddonsRoot(),name); - string filePath = path + "/src"; + string filePath = ofFilePath::join(path, "/src"); + toForwardSlashOrder(filePath); string ofRootPath = ofFilePath::addTrailingSlash(getOFRoot()); //we need to add a trailing slash for the erase to work properly ofLogVerbose() << "in fromFS, trying src " << filePath; @@ -359,17 +361,16 @@ void ofAddon::fromFS(string path, string platform){ 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"; + string libsPath = ofFilePath::join(path, "/libs"); +#ifdef TARGET_WIN32 + toForwardSlashOrder(libsPath); +#endif vector < string > libFiles; @@ -389,11 +390,7 @@ void ofAddon::fromFS(string path, string platform){ 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]; @@ -406,11 +403,7 @@ void ofAddon::fromFS(string path, string platform){ 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()); @@ -422,11 +415,7 @@ void ofAddon::fromFS(string path, string platform){ 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()); @@ -441,23 +430,19 @@ void ofAddon::fromFS(string path, string platform){ 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"); + ofLogVerbose() << "trying get folders recursively " << ofFilePath::join(path, "/libs"); // the dirList verbosity is crazy, so I'm setting this off for now. - getFoldersRecursively(path + "/libs", libFolders, platform); + getFoldersRecursively(ofFilePath::join(path, "/libs"), libFolders, platform); vector < string > srcFolders; - getFoldersRecursively(path + "/src", srcFolders, platform); + getFoldersRecursively(ofFilePath::join(path, "/src"), srcFolders, platform); for (int i = 0; i < (int)libFolders.size(); i++){ libFolders[i].erase (libFolders[i].begin(), libFolders[i].begin()+ofRootPath.length()); diff --git a/src/projects/CBWinProject.cpp b/src/projects/CBWinProject.cpp index 84cfde9..96db5c7 100644 --- a/src/projects/CBWinProject.cpp +++ b/src/projects/CBWinProject.cpp @@ -88,6 +88,7 @@ void CBWinProject::addInclude(string includeName){ } void CBWinProject::addLibrary(string libraryName, LibType libType){ + toDosSlashOrder(libraryName); ofLogNotice() << "adding library " << libraryName; appendValue(doc, "Add", "library", libraryName, true); // overwriteMultiple for a lib if it's there (so libsorder.make will work) diff --git a/src/projects/baseProject.cpp b/src/projects/baseProject.cpp index 904442f..cb1a33c 100644 --- a/src/projects/baseProject.cpp +++ b/src/projects/baseProject.cpp @@ -48,11 +48,7 @@ bool baseProject::create(string path){ fileNames[i].erase(fileNames[i].begin(), fileNames[i].begin() + projectDir.length()); string first, last; -#ifdef TARGET_WIN32 - splitFromLast(fileNames[i], "\\", first, last); -#else splitFromLast(fileNames[i], "/", first, last); -#endif if (fileNames[i] != "src/ofApp.cpp" && fileNames[i] != "src/ofApp.h" && fileNames[i] != "src/main.cpp" && @@ -88,11 +84,7 @@ bool baseProject::create(string path){ vector < string > includePaths; for (int i = 0; i < (int)fileNames.size(); i++){ size_t found; - #ifdef TARGET_WIN32 - found = fileNames[i].find_last_of("\\"); - #else found = fileNames[i].find_last_of("/"); - #endif paths.push_back(fileNames[i].substr(0,found)); } diff --git a/src/projects/visualStudioProject.cpp b/src/projects/visualStudioProject.cpp index b24995b..47b6b79 100644 --- a/src/projects/visualStudioProject.cpp +++ b/src/projects/visualStudioProject.cpp @@ -81,7 +81,7 @@ bool visualStudioProject::saveProjectFile(){ void visualStudioProject::appendFilter(string folderName){ - fixSlashOrder(folderName); + toDosSlashOrder(folderName); string uuid = generateUUID(folderName); @@ -112,8 +112,8 @@ void visualStudioProject::appendFilter(string folderName){ void visualStudioProject::addSrc(string srcFile, string folder, SrcType type){ - fixSlashOrder(folder); - fixSlashOrder(srcFile); + toDosSlashOrder(folder); + toDosSlashOrder(srcFile); vector < string > folderSubNames = ofSplitString(folder, "\\"); string folderName = ""; @@ -197,7 +197,7 @@ void visualStudioProject::addSrc(string srcFile, string folder, SrcType type){ void visualStudioProject::addInclude(string includeName){ - fixSlashOrder(includeName); + toDosSlashOrder(includeName); pugi::xpath_node_set source = doc.select_nodes("//ClCompile/AdditionalIncludeDirectories"); for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){ @@ -223,7 +223,7 @@ void visualStudioProject::addInclude(string includeName){ void visualStudioProject::addLibrary(string libraryName, LibType libType){ cout << "adding library " << libType << " " << libraryName << endl; - fixSlashOrder(libraryName); + toDosSlashOrder(libraryName); // ok first, split path and library name. size_t found = libraryName.find_last_of("\\"); diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index d7f8303..521a058 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -194,14 +194,16 @@ void getFilesRecursively(const string & path, vector < string > & fileNames){ for (int i = 0; i < dir.size(); i++){ ofFile temp(dir.getFile(i)); if (dir.getName(i) == ".svn") continue; // ignore svn + string file_path = dir.getPath(i); +#ifdef TARGET_WIN32 + toForwardSlashOrder(file_path); +#endif if (temp.isFile()){ - fileNames.push_back(dir.getPath(i)); + fileNames.push_back(file_path); } else if (temp.isDirectory()){ - getFilesRecursively(dir.getPath(i), fileNames); + getFilesRecursively(file_path, fileNames); } } - //folderNames.push_back(path); - } static vector platforms; @@ -245,7 +247,11 @@ void getFoldersRecursively(const string & path, vector < string > & folderNames, for (int i = 0; i < dir.size(); i++){ ofFile temp(dir.getFile(i)); if (temp.isDirectory() && isFolderNotCurrentPlatform(temp.getFileName(), platform) == false ){ - getFoldersRecursively(dir.getPath(i), folderNames, platform); + string folder_path = dir.getPath(i); +#ifdef TARGET_WIN32 + toForwardSlashOrder(folder_path); +#endif + getFoldersRecursively(folder_path, folderNames, platform); } } folderNames.push_back(path); @@ -253,8 +259,6 @@ void getFoldersRecursively(const string & path, vector < string > & folderNames, void getFrameworksRecursively( const string & path, vector < string > & frameworks, string platform){ - - ofDirectory dir; dir.listDir(path); @@ -263,16 +267,19 @@ void getFrameworksRecursively( const string & path, vector < string > & framewor ofFile temp(dir.getFile(i)); if (temp.isDirectory()){ - //getLibsRecursively(dir.getPath(i), folderNames); - + string folder_path = dir.getPath(i); +#ifdef TARGET_WIN32 + toForwardSlashOrder(folder_path); +#endif // on osx, framework is a directory, let's not parse it.... string ext = ""; string first = ""; - splitFromLast(dir.getPath(i), ".", first, ext); - if (ext != "framework") - getFrameworksRecursively(dir.getPath(i), frameworks, platform); - else - frameworks.push_back(dir.getPath(i)); + splitFromLast(folder_path, ".", first, ext); + if (ext != "framework") { + getFrameworksRecursively(folder_path, frameworks, platform); + } else { + frameworks.push_back(folder_path); + } } } @@ -282,19 +289,11 @@ void getFrameworksRecursively( const string & path, vector < string > & framewor void getLibsRecursively(const string & path, vector < string > & libFiles, vector < string > & libLibs, string platform ){ - - - - if (ofFile::doesFileExist(ofFilePath::join(path, "libsorder.make"))){ bool platformFound = false; -#ifdef TARGET_WIN32 - vector splittedPath = ofSplitString(path,"\\"); -#else vector splittedPath = ofSplitString(path,"/"); -#endif if(platform!=""){ @@ -331,28 +330,25 @@ void getLibsRecursively(const string & path, vector < string > & libFiles, vecto for (int i = 0; i < dir.size(); i++){ - + string folder_path = dir.getPath(i); #ifdef TARGET_WIN32 - vector splittedPath = ofSplitString(dir.getPath(i),"\\"); -#else - vector splittedPath = ofSplitString(dir.getPath(i),"/"); + toForwardSlashOrder(folder_path); #endif + vector splittedPath = ofSplitString(folder_path,"/"); + ofFile temp(dir.getFile(i)); if (temp.isDirectory()){ - //getLibsRecursively(dir.getPath(i), folderNames); - // on osx, framework is a directory, let's not parse it.... string ext = ""; string first = ""; - splitFromLast(dir.getPath(i), ".", first, ext); + splitFromLast(folder_path, ".", first, ext); if (ext != "framework") - getLibsRecursively(dir.getPath(i), libFiles, libLibs, platform); + getLibsRecursively(folder_path, libFiles, libLibs, platform); } else { - bool platformFound = false; if(platform!=""){ @@ -369,16 +365,16 @@ void getLibsRecursively(const string & path, vector < string > & libFiles, vecto //string ext = ofFilePath::getFileExt(temp.getFile(i)); string ext; string first; - splitFromLast(dir.getPath(i), ".", first, ext); + splitFromLast(folder_path, ".", first, ext); if (ext == "a" || ext == "lib" || ext == "dylib" || ext == "so" || ext == "dll"){ if (platformFound){ - libLibs.push_back(dir.getPath(i)); + libLibs.push_back(folder_path); //TODO: THEO hack if( platform == "ios" ){ //this is so we can add the osx libs for the simulator builds - string currentPath = dir.getPath(i); + string currentPath = folder_path; //TODO: THEO double hack this is why we need install.xml - custom ignore ofxOpenCv if( currentPath.find("ofxOpenCv") == string::npos ){ @@ -390,7 +386,7 @@ void getLibsRecursively(const string & path, vector < string > & libFiles, vecto } } } else if (ext == "h" || ext == "hpp" || ext == "c" || ext == "cpp" || ext == "cc"){ - libFiles.push_back(dir.getPath(i)); + libFiles.push_back(folder_path); } } @@ -437,9 +433,11 @@ void getLibsRecursively(const string & path, vector < string > & libFiles, vecto } +void toForwardSlashOrder(string & toFix){ + std::replace(toFix.begin(), toFix.end(),'\\', '/'); +} - -void fixSlashOrder(string & toFix){ +void toDosSlashOrder(string & toFix){ std::replace(toFix.begin(), toFix.end(),'/', '\\'); } diff --git a/src/utils/Utils.h b/src/utils/Utils.h index fd6e00e..7d92386 100644 --- a/src/utils/Utils.h +++ b/src/utils/Utils.h @@ -40,7 +40,8 @@ void splitFromFirst(string toSplit, string deliminator, string & first, string & void parseAddonsDotMake(string path, vector < string > & addons); -void fixSlashOrder(string & toFix); +void toForwardSlashOrder(string & toFix); +void toDosSlashOrder(string & toFix); string unsplitString (vector < string > strings, string deliminator ); string getOFRelPath(string from);