Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature - ability to specify additional source/include folders to add to project #248

Merged
merged 7 commits into from
Sep 30, 2020
Prev Previous commit
Next Next commit
allow files inside of the OF_ROOT to be relative
ofTheo committed Jul 2, 2020
commit 77db35d5495268deaf9b5b9564cf2c2bc35c8cf7
16 changes: 14 additions & 2 deletions ofxProjectGenerator/src/projects/baseProject.cpp
Original file line number Diff line number Diff line change
@@ -302,6 +302,12 @@ void baseProject::addSrcRecursively(std::string srcPath){
getFilesRecursively(srcPath, srcFilesToAdd);
ofEnableDataPath();

//if the files being added are inside the OF root folder, make them relative to the folder.
bool bMakeRelative = false;
if( srcPath.find_first_of(getOFRoot()) == 0 ){
bMakeRelative = true;
}

//need this for absolute paths so we can subtract this path from each file path
//say we add this path: /user/person/documents/shared_of_code
//we want folders added for shared_of_code/ and any subfolders, but not folders added for /user/ /user/person/ etc
@@ -311,7 +317,7 @@ void baseProject::addSrcRecursively(std::string srcPath){
for( auto & fileToAdd : srcFilesToAdd){

//if it is an absolute path it is easy - add the file and enclosing folder to the project
if( ofFilePath::isAbsolute(fileToAdd) ){
if( ofFilePath::isAbsolute(fileToAdd) && !bMakeRelative ){
string folder = ofFilePath::getEnclosingDirectory(fileToAdd,false);
string absFolder = folder;

@@ -323,13 +329,19 @@ void baseProject::addSrcRecursively(std::string srcPath){
folder = folder.substr(parentFolder.size());
}

folder = ofFilePath::removeTrailingSlash(folder);

ofLogVerbose() << " adding file " << fileToAdd << " in folder " << folder << " to project ";
addSrc(fileToAdd, folder);
uniqueIncludeFolders[absFolder] = absFolder;
}else{

auto absPath = fileToAdd;

//if it is a realtive path make the file relative to the project folder
auto absPath = ofFilePath::getAbsolutePath( ofFilePath::join(ofFilePath::getCurrentExeDir(), fileToAdd) );
if( !ofFilePath::isAbsolute(absPath) ){
absPath = ofFilePath::getAbsolutePath( ofFilePath::join(ofFilePath::getCurrentExeDir(), fileToAdd) );
}
auto canPath = std::filesystem::canonical(absPath); //resolves the ./ and ../ to be the most minamlist absolute path

//get the file path realtive to the project