Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 10 additions & 25 deletions src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ void ofAddon::exclude(vector<string> & variable, vector<string> exclusions){
if(regExp.match(variable[j])){
variable.erase(variable.begin()+j);
j--;
cout << "excluded" << endl;
}
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;


Expand All @@ -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];
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand Down
1 change: 1 addition & 0 deletions src/projects/CBWinProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions src/projects/baseProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand Down Expand Up @@ -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));
}

Expand Down
10 changes: 5 additions & 5 deletions src/projects/visualStudioProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool visualStudioProject::saveProjectFile(){
void visualStudioProject::appendFilter(string folderName){


fixSlashOrder(folderName);
toDosSlashOrder(folderName);

string uuid = generateUUID(folderName);

Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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){
Expand All @@ -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("\\");
Expand Down
72 changes: 35 additions & 37 deletions src/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string> platforms;
Expand Down Expand Up @@ -245,16 +247,18 @@ 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);
}


void getFrameworksRecursively( const string & path, vector < string > & frameworks, string platform){


ofDirectory dir;
dir.listDir(path);

Expand All @@ -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);
}
}

}
Expand All @@ -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<string> splittedPath = ofSplitString(path,"\\");
#else
vector<string> splittedPath = ofSplitString(path,"/");
#endif


if(platform!=""){
Expand Down Expand Up @@ -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<string> splittedPath = ofSplitString(dir.getPath(i),"\\");
#else
vector<string> splittedPath = ofSplitString(dir.getPath(i),"/");
toForwardSlashOrder(folder_path);
#endif

vector<string> 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!=""){
Expand All @@ -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 ){
Expand All @@ -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);
}

}
Expand Down Expand Up @@ -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(),'/', '\\');
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down