diff --git a/commandLine/config.make b/commandLine/config.make index d43f10b9..d1b8e730 100644 --- a/commandLine/config.make +++ b/commandLine/config.make @@ -6,7 +6,7 @@ ################################################################################ # OF ROOT # The location of your root openFrameworks installation -# (default) OF_ROOT = ../../.. +# (default) OF_ROOT = ../../.. ################################################################################ OF_ROOT = ../../.. @@ -14,16 +14,16 @@ OF_ROOT = ../../.. # PROJECT ROOT # The location of the project - a starting place for searching for files # (default) PROJECT_ROOT = . (this directory) -# +# ################################################################################ # PROJECT_ROOT = . ################################################################################ # PROJECT SPECIFIC CHECKS -# This is a project defined section to create internal makefile flags to -# conditionally enable or disable the addition of various features within +# This is a project defined section to create internal makefile flags to +# conditionally enable or disable the addition of various features within # this makefile. For instance, if you want to make changes based on whether -# GTK is installed, one might test that here and create a variable to check. +# GTK is installed, one might test that here and create a variable to check. ################################################################################ # None APPNAME = projectGenerator @@ -33,23 +33,23 @@ PROJECT_AFTER_OSX="if test -f \"$TARGET_BUILD_DIR/projectGenerator\"; then rm \" ################################################################################ # PROJECT EXTERNAL SOURCE PATHS # These are fully qualified paths that are not within the PROJECT_ROOT folder. -# Like source folders in the PROJECT_ROOT, these paths are subject to +# Like source folders in the PROJECT_ROOT, these paths are subject to # exlclusion via the PROJECT_EXLCUSIONS list. # -# (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) +# (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) # # Note: Leave a leading space when adding list items with the += operator ################################################################################ -# PROJECT_EXTERNAL_SOURCE_PATHS = +# PROJECT_EXTERNAL_SOURCE_PATHS = ################################################################################ # PROJECT EXCLUSIONS -# These makefiles assume that all folders in your current project directory +# These makefiles assume that all folders in your current project directory # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations -# to look for source code. The any folders or files that match any of the +# to look for source code. The any folders or files that match any of the # items in the PROJECT_EXCLUSIONS list below will be ignored. # -# Each item in the PROJECT_EXCLUSIONS list will be treated as a complete +# Each item in the PROJECT_EXCLUSIONS list will be treated as a complete # string unless teh user adds a wildcard (%) operator to match subdirectories. # GNU make only allows one wildcard for matching. The second wildcard (%) is # treated literally. @@ -75,45 +75,45 @@ PROJECT_AFTER_OSX="if test -f \"$TARGET_BUILD_DIR/projectGenerator\"; then rm \" # Note: Leave a leading space when adding list items with the += operator ################################################################################ -# Currently, shared libraries that are needed are copied to the +# Currently, shared libraries that are needed are copied to the # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to -# add a runtime path to search for those shared libraries, since they aren't +# add a runtime path to search for those shared libraries, since they aren't # incorporated directly into the final executable application binary. # TODO: should this be a default setting? # PROJECT_LDFLAGS=-Wl,-rpath=./libs ################################################################################ # PROJECT DEFINES -# Create a space-delimited list of DEFINES. The list will be converted into +# Create a space-delimited list of DEFINES. The list will be converted into # CFLAGS with the "-D" flag later in the makefile. # # (default) PROJECT_DEFINES = (blank) # # Note: Leave a leading space when adding list items with the += operator ################################################################################ -# PROJECT_DEFINES = +# PROJECT_DEFINES = ################################################################################ # PROJECT CFLAGS -# This is a list of fully qualified CFLAGS required when compiling for this -# project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS +# This is a list of fully qualified CFLAGS required when compiling for this +# project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS # defined in your platform specific core configuration files. These flags are -# presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. +# presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. # # (default) PROJECT_CFLAGS = (blank) # -# Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in -# your platform specific configuration file will be applied by default and +# Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in +# your platform specific configuration file will be applied by default and # further flags here may not be needed. # # Note: Leave a leading space when adding list items with the += operator ################################################################################ -# PROJECT_CFLAGS = +# PROJECT_CFLAGS = ################################################################################ # PROJECT OPTIMIZATION CFLAGS -# These are lists of CFLAGS that are target-specific. While any flags could -# be conditionally added, they are usually limited to optimization flags. +# These are lists of CFLAGS that are target-specific. While any flags could +# be conditionally added, they are usually limited to optimization flags. # These flags are added BEFORE the PROJECT_CFLAGS. # # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. @@ -124,15 +124,15 @@ PROJECT_AFTER_OSX="if test -f \"$TARGET_BUILD_DIR/projectGenerator\"; then rm \" # # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) # -# Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the -# PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration -# file will be applied by default and further optimization flags here may not +# Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the +# PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration +# file will be applied by default and further optimization flags here may not # be needed. # # Note: Leave a leading space when adding list items with the += operator ################################################################################ PROJECT_OPTIMIZATION_CFLAGS_RELEASE = -O3 -# PROJECT_OPTIMIZATION_CFLAGS_DEBUG = +# PROJECT_OPTIMIZATION_CFLAGS_DEBUG = ################################################################################ # PROJECT COMPILERS @@ -141,8 +141,8 @@ PROJECT_OPTIMIZATION_CFLAGS_RELEASE = -O3 # (default) PROJECT_CC = (blank) # Note: Leave a leading space when adding list items with the += operator ################################################################################ -# PROJECT_CXX = -# PROJECT_CC = +# PROJECT_CXX = +# PROJECT_CC = #PLATFORM_CORE_EXCLUSIONS += ../../../libs/openFrameworks/utils @@ -179,11 +179,3 @@ PLATFORM_CORE_EXCLUSIONS += ../../../libs/fmod% # inside ofImage inside ofUtils #PLATFORM_CORE_EXCLUSIONS += ../../../libs/uriparser% - -export OF_NO_FMOD=1 -export USER_PREPROCESSOR_DEFINITIONS="OF_NO_FMOD=1" -export LIB_FMOD="" - -# Uncomment/comment below to switch between C++11 and C++17 ( or newer ). On macOS C++17 needs 10.15 or above. -export MAC_OS_MIN_VERSION = 10.15 -export MAC_OS_CPP_VER = -std=c++17 diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 80c24850..0c2b9988 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -886,7 +886,7 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t // we want to set addonMakeName before cleaning the addon name, so it is preserved in the exact same way as it was passed, and the addons.make file can be (re)constructed properly this->addonMakeName = addonName; - addonName = cleanName(addonName); +// addonName = cleanName(addonName); if(addonName.empty()){ ofLogError("baseProject::addAddon") << "cant add addon with empty name"; @@ -899,7 +899,12 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t //A local addon is not restricted to one that lives in folder with the name local_addons, should be any valid addon on the filesystem. //Parsing will generate the correct path to both OF and the project. //Everything else should be treated exactly in the same way, regardless of it being local or not. - if(addonName[0] == '.' && fs::exists( ofFilePath::join(projectDir, addonName))){ + + fs::path localAddon { addonName }; + + if (localAddon.has_parent_path() && fs::exists(projectDir / addonName)) { + +// if(addonName[0] == '.' && fs::exists( ofFilePath::join(projectDir, addonName))){ this->addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); this->isLocalAddon = true; diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 60a52241..28068156 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "86" +#define OFPROJECTGENERATOR_MINOR_VERSION "88" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 485e3579..8d95418f 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -304,7 +304,6 @@ void recursiveUpdate(const fs::path & path, const string & target) { } } - fs::current_path(path); updateProject(path, target, false); } } diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 79900364..9262213b 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -220,10 +220,14 @@ bool baseProject::create(const fs::path & _path, string templateName){ // CWD is already on projectDir. so with this we get relative paths getFilesRecursively("src", fileNames); - + std::sort(fileNames.begin(), fileNames.end(), [](const fs::path & a, const fs::path & b) { return a.string() < b.string(); }); + + // FIXME: I think we should remove this logic and remove the files from default project. + // only the files present are added to the project + for (const auto & f : fileNames) { if (f != "src/ofApp.cpp" && f != "src/ofApp.h" && @@ -302,12 +306,13 @@ bool baseProject::isAddonInCache(const string & addonPath, const string platform return addonsCache[platform].find(addonPath) != addonsCache[platform].end(); } -void baseProject::addAddon(const std::string& _addonName){ +void baseProject::addAddon(const std::string & _addonName){ ofLogVerbose("baseProject::addAddon") << _addonName; // alert( "baseProject::addAddon " + _addonName ); - auto addonName = ofAddon::cleanName(_addonName); - +// auto addonName = ofAddon::cleanName(_addonName); + auto addonName = _addonName; + // FIXME : not target, yes platform. //#ifdef TARGET_WIN32 diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index a4214cae..0ad522e9 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -214,8 +214,7 @@ void visualStudioProject::appendFilter(string folderName){ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type){ -// alert("addSrc file: " + srcFile.string(), 35); -// alert("addSrc folder: " + folder.string(), 35); +// alert("addSrc file: " + srcFile.string() + " folder: " + folder.string(), 35); // I had an empty ClCompile field causing errors if (srcFile.empty()) { @@ -239,6 +238,7 @@ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & fold for (std::size_t i = 0; i < folderSubNames.size(); i++){ if (i != 0) folderName += "\\"; folderName += folderSubNames[i]; +// alert("appendFilter: " + folderName, 34); appendFilter(folderName); } diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index c20a1656..ce0ba48a 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -9,7 +9,6 @@ #include #include - using nlohmann::json; using nlohmann::json_pointer; @@ -60,7 +59,7 @@ xcodeProject::xcodeProject(const string & target) : baseProject(target){ buildActionMaskUUID = "1D60588E0D05DD3D006BFB54"; projRootUUID = "29B97314FDCFA39411CA2CEA"; //mainGroup — OK resourcesUUID = "BB24DD8F10DA77E000E9C588"; - buildPhaseResourcesUUID = "1D60588D0D05DD3D006BFB54"; + copyBundleResourcesUUID = "1D60588D0D05DD3D006BFB54"; frameworksUUID = "1DF5F4E00D08C38300B7A737"; //PBXFrameworksBuildPhase // todo: check this? afterPhaseUUID = "928F60851B6710B200E2D791"; buildPhasesUUID = "9255DD331112741900D6945E"; @@ -244,16 +243,16 @@ void xcodeProject::renameProject(){ //base } fs::path getPathTo(fs::path path, string limit){ - fs::path p; - vector folders = std::vector(path.begin(), path.end()); - for(auto & f: folders){ - p /= f; - if(f.string() == limit){ + fs::path p; + vector folders = std::vector(path.begin(), path.end()); + for(auto & f: folders){ + p /= f; + if(f.string() == limit){ // alert("getPathTo "+ p.string(), 33); - return p; - } - } - return p; + return p; + } + } + return p; } @@ -280,8 +279,8 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b if (folders.size()){ // Iterating every folder from full path - - + + for (std::size_t a = 0; a < folders.size(); a++) { fs::path fullPath{""}; @@ -295,7 +294,7 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b for (const auto& j : joinFolders) { fullPath /= j; } - + // alert("xcodeProject::getFolderUUID fullpath: " + fullPath.string(),33); // Query if partial path is already stored. if not execute this following block @@ -305,7 +304,7 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b } else { - + string thisUUID = generateUUID(fullPath); folderUUID[fullPath] = thisUUID; folderFromUUID[thisUUID] = fullPath; @@ -337,59 +336,59 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b // } addCommand("Add :objects:"+thisUUID+":isa string PBXGroup"); - - - bool bFolderPathSet = false; - + + + bool bFolderPathSet = false; + if (folderName == "external_sources" || folderName == "local_addons") { - + addCommand("Add :objects:"+thisUUID+":sourceTree string SOURCE_ROOT"); - addCommand("Add :objects:"+thisUUID+":path string "); - bFolderPathSet = true; + addCommand("Add :objects:"+thisUUID+":path string "); + bFolderPathSet = true; } - else { - if (lastFolderUUID == projRootUUID ){//} || - // lastFolder == "external_sources" || lastFolder == "local_addons") { // - - - - // Base folders can be in a different depth, - // so we cut folders to point to the right path - // ROY: THIS hardly makes sense to me. I can see the purpose of it. base2 is never set to anything. - fs::path base2 { "" }; - size_t diff = folders.size() - (a+1); - for (size_t x=0; x"); // fs::path addonFolder { fs::path(fullPath).filename() }; addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(fullPath.filename())); - bFolderPathSet = true; + bFolderPathSet = true; } } addCommand("Add :objects:"+thisUUID+":children array"); - - if(!bFolderPathSet){ - if (folder.begin()->string() == "addons" || folder.begin()->string() == "src"){//} || folder.begin()->string() == "local_addons") { - addCommand("Add :objects:"+thisUUID+":sourceTree string "); - // fs::path addonFolder { fs::path(fullPath).filename() }; - addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(fullPath.filename())); - // alert ("group " + folder.string() + " : " + base.string() + " : " + addonFolder.string(), 32); - } else { - addCommand("Add :objects:"+thisUUID+":sourceTree string SOURCE_ROOT"); - } - } + + if(!bFolderPathSet){ + if (folder.begin()->string() == "addons" || folder.begin()->string() == "src"){//} || folder.begin()->string() == "local_addons") { + addCommand("Add :objects:"+thisUUID+":sourceTree string "); + // fs::path addonFolder { fs::path(fullPath).filename() }; + addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(fullPath.filename())); + // alert ("group " + folder.string() + " : " + base.string() + " : " + addonFolder.string(), 32); + } else { + addCommand("Add :objects:"+thisUUID+":sourceTree string SOURCE_ROOT"); + } + } // Add this new folder to its parent, projRootUUID if root addCommand("Add :objects:"+lastFolderUUID+":children: string " + thisUUID); @@ -406,8 +405,8 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type){ // alert ("xcodeProject::addSrc " + ofPathToString(srcFile) + " : " + ofPathToString(folder), 31); - - string ext = ofPathToString(srcFile.extension()); + + string ext = ofPathToString(srcFile.extension()); // .reference = true, // .addToBuildPhase = true, @@ -421,32 +420,39 @@ void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, Src fp.addToBuildPhase = true; fp.isSrc = true; - if( type == DEFAULT ){ - if (ext == ".h" || ext == ".hpp"){ - fp.addToBuildPhase = false; - } - else if (ext == ".xib"){ - fp.addToBuildPhase = false; - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if (ext == ".metal"){ - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if(ext == ".entitlements"){ - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if(ext == ".info"){ - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if( target == "ios" ){ - fp.addToBuildPhase = true; - fp.addToResources = true; - } +// if( type == DEFAULT ){ + if( target == "ios" ){ + fp.addToBuildPhase = true; + fp.addToResources = true; + } + + if (ext == ".h" || ext == ".hpp"){ + fp.addToBuildPhase = false; + } + else if (ext == ".xib"){ + fp.addToBuildPhase = false; + fp.addToBuildResource = true; + fp.addToResources = true; + } + else if (ext == ".metal"){ + fp.addToBuildResource = true; + fp.addToResources = true; } + else if(ext == ".entitlements"){ + fp.addToBuildResource = true; + fp.addToResources = true; + } + else if(ext == ".info"){ + fp.addToBuildResource = true; + fp.addToResources = true; + } + else if( ext == ".storyboard" ){ + fp.addToBuildPhase = false; + fp.copyBundleResources = true; + } + + + // } string UUID { @@ -459,10 +465,10 @@ void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, Src } void xcodeProject::addCompileFlagsForMMFile(const fs::path & srcFile) { - - // This requires a moro thorough inspection on how to deal with these files, and determine if these need the -fno-objc-arc flag. - // This flag should be added on a file by file basis, rather than the way it is done below where these are added globally, as such messes up other things. - + + // This requires a moro thorough inspection on how to deal with these files, and determine if these need the -fno-objc-arc flag. + // This flag should be added on a file by file basis, rather than the way it is done below where these are added globally, as such messes up other things. + // std::ifstream file(srcFile); // std::string line; // bool containsARCFunctions = false; @@ -481,12 +487,12 @@ void xcodeProject::addCompileFlagsForMMFile(const fs::path & srcFile) { // addCommand("Add :objects:"+c+":buildSettings:OTHER_CPLUSPLUSFLAGS: string -fno-objc-arc"); // } // } - + } void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK){ - ofLogVerbose() << "Adding framework " << ofPathToString(path) << " folder: " << folder; + ofLogVerbose() << "Adding framework " << ofPathToString(path) << " folder: " << folder; // alert( "xcodeProject::addFramework " + ofPathToString(path) + " : " + ofPathToString(folder) , 33); // path = the full path (w name) of this framework // folder = the path in the addon (in case we want to add this to the file browser -- we don't do that for system libs); @@ -499,7 +505,7 @@ void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, fp.copyFilesBuildPhase = !isRelativeToSDK; fp.isRelativeToSDK = isRelativeToSDK; fp.frameworksBuildPhase = (target != "ios" && !folder.empty()); - + string UUID; if (isRelativeToSDK) { fs::path frameworkPath { "System/Library/Frameworks/" + ofPathToString(path) + ".framework" } ; @@ -507,11 +513,11 @@ void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, } else { UUID = addFile(path, folder, fp); } - + if (!isRelativeToSDK) { addCommand("# ----- FRAMEWORK_SEARCH_PATHS"); string parent { ofPathToString(path.parent_path()) }; - + for (auto & c : buildConfigs) { if (path.extension() == ".framework") { addCommand("Add :objects:" + c + ":buildSettings:FRAMEWORK_SEARCH_PATHS: string " + parent); @@ -552,14 +558,14 @@ void xcodeProject::addLibrary(const LibraryBinary & lib){ } void xcodeProject::addLDFLAG(const string& ldflag, LibType libType){ - ofLogVerbose("xcodeProject::addLDFLAG") << ldflag; + ofLogVerbose("xcodeProject::addLDFLAG") << ldflag; for (auto & c : buildConfigs) { addCommand("Add :objects:"+c+":buildSettings:OTHER_LDFLAGS: string " + ldflag); } } void xcodeProject::addCFLAG(const string& cflag, LibType libType){ - ofLogVerbose("xcodeProject::addCFLAG") << cflag; + ofLogVerbose("xcodeProject::addCFLAG") << cflag; for (auto & c : buildConfigs) { // FIXME: add array here if it doesnt exist addCommand("Add :objects:"+c+":buildSettings:OTHER_CFLAGS: string " + cflag); @@ -604,43 +610,43 @@ void xcodeProject::addAfterRule(const string& rule){ void xcodeProject::addAddonLibs(const ofAddon& addon){ - for (auto & e : addon.libs) { - ofLogVerbose() << "adding addon libs: " << e.path; - addLibrary(e); - - fs::path dylibPath { e.path }; - - // cout << "dylibPath " << dylibPath << endl; - if (dylibPath.extension() == ".dylib") { - - if(addon.filesToFolders.find(dylibPath) == addon.filesToFolders.end()) { - addDylib(dylibPath, dylibPath.parent_path().lexically_relative(addon.pathToOF)); - }else{ - addDylib(dylibPath,addon.filesToFolders.at(dylibPath)); - } - } - } + for (auto & e : addon.libs) { + ofLogVerbose() << "adding addon libs: " << e.path; + addLibrary(e); + + fs::path dylibPath { e.path }; + + // cout << "dylibPath " << dylibPath << endl; + if (dylibPath.extension() == ".dylib") { + + if(addon.filesToFolders.find(dylibPath) == addon.filesToFolders.end()) { + addDylib(dylibPath, dylibPath.parent_path().lexically_relative(addon.pathToOF)); + }else{ + addDylib(dylibPath,addon.filesToFolders.at(dylibPath)); + } + } + } } void xcodeProject::addAddonSrcFiles(ofAddon& addon){ - std::sort(addon.srcFiles.begin(), addon.srcFiles.end(), [](const fs::path & a, const fs::path & b) { - return a.string() < b.string(); - }); - for (auto & e : addon.srcFiles) { - ofLogVerbose() << "adding addon srcFiles: " << e; - if(addon.filesToFolders.find(e) == addon.filesToFolders.end()) { - - addSrc(e,""); - }else{ - addSrc(e,addon.filesToFolders.at(e)); - } - } + std::sort(addon.srcFiles.begin(), addon.srcFiles.end(), [](const fs::path & a, const fs::path & b) { + return a.string() < b.string(); + }); + for (auto & e : addon.srcFiles) { + ofLogVerbose() << "adding addon srcFiles: " << e; + if(addon.filesToFolders.find(e) == addon.filesToFolders.end()) { + + addSrc(e,""); + }else{ + addSrc(e,addon.filesToFolders.at(e)); + } + } } //----------------------------------------------------------------------------------------------- void xcodeProject::addAddonFrameworks(const ofAddon& addon){ - ofLogVerbose("xcodeProject::addAddonFrameworks") << addon.name; - + ofLogVerbose("xcodeProject::addAddonFrameworks") << addon.name; + std::vector allFrameworks; allFrameworks.reserve( addon.frameworks.size() + addon.xcframeworks.size() ); allFrameworks.insert( allFrameworks.end(), addon.frameworks.begin(), addon.frameworks.end() ); @@ -648,27 +654,27 @@ void xcodeProject::addAddonFrameworks(const ofAddon& addon){ for (auto & f : allFrameworks) { // for (auto & f : addon.frameworks) { - ofLogVerbose() << "adding addon frameworks: " << f; + ofLogVerbose() << "adding addon frameworks: " << f; // alert ("ADD ADDON FRAMEWORKS " + f, 33); auto path = f; // The only addon I've found using fixed path to system Frameworks is ofxCoreLocation // https://github.com/robotconscience/ofxCoreLocation/blob/533ee4b0d380a4a1aafbe1c5923ae66c26b92d53/addon_config.mk#L32 - + if (ofIsStringInString(f, "/System/Library/Frameworks")){ fs::path fullPath = f; path = ofPathToString(fullPath.filename()); } - + bool isRelativeToSDK = false; - size_t found=path.find('/'); - if (found==string::npos) { + size_t found=path.find('/'); + if (found==string::npos) { isRelativeToSDK = true; - } + } fs::path folder = isRelativeToSDK ? "Frameworks" : addon.filesToFolders.at(f); addFramework(path, folder, isRelativeToSDK); - } + } } //----------------------------------------------------------------------------------------------- @@ -722,24 +728,24 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); } } else { - - if(folder.begin()->string() == "local_addons" || folder.begin()->string() == "external_sources"){ + + if(folder.begin()->string() == "local_addons" || folder.begin()->string() == "external_sources"){ // if(path.is_absolute()){ - addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); - addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); + addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); + addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); // }else{ // if (fs::exists( projectDir / path )) { // addCommand("Add :objects:"+UUID+":path string " + ofPathToString(projectDir /path)); // } // } - } else { + } else { if (fp.isRelativeToSDK) { addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); addCommand("Add :objects:"+UUID+":sourceTree string SDKROOT"); } else { addCommand("Add :objects:"+UUID+":sourceTree string "); } - } + } } // string folderUUID; @@ -752,9 +758,9 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con // } else { // folderUUID = getFolderUUID(folder, isFolder); // } - + // Eventually remove isFolder and base parameter - std::string folderUUID { getFolderUUID(folder, path)}; + std::string folderUUID { getFolderUUID(folder, path)}; //, isFolder) }; @@ -768,7 +774,8 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con fp.codeSignOnCopy || fp.copyFilesBuildPhase || fp.addToBuildResource || - fp.addToResources + fp.addToResources || + fp.copyBundleResources //|| fp.frameworksBuildPhase ~ I've just removed this one, favoring -InFrameworks ) { addCommand("# ---- addToBuildPhase " + buildUUID); @@ -782,6 +789,12 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con addCommand("Add :objects:"+buildActionMaskUUID+":files: string " + buildUUID); } + + if (fp.copyBundleResources) { + addCommand("# ---- copyBundleResources"); + addCommand("Add :objects:"+copyBundleResourcesUUID+":files: string " + buildUUID); + } + if (fp.copyFilesBuildPhase) { // If we are going to add xcframeworks to copy files -> destination frameworks, we should include here // if (path.extension() == ".framework" || path.extension() == ".xcframework") { @@ -863,7 +876,7 @@ bool xcodeProject::saveProjectFile(){ } fp.absolute = true; // addFile("../../../libs/openframeworks", "", fp); - addFile(fs::path{"bin"} / "data", "", fp); + addFile(fs::path{"bin"} / "data", "", fp); // debugCommands = false; @@ -888,13 +901,13 @@ bool xcodeProject::saveProjectFile(){ json j; try { j = json::parse(contents); - + // Ugly hack to make nlohmann json work with v 3.11.3 // auto dump = j.dump(1, ' '); // if (dump[0] == '[') { // j = j[0]; // } - + } catch (json::parse_error & ex) { ofLogError(xcodeProject::LOG_NAME) << "JSON parse error at byte" << ex.byte; ofLogError(xcodeProject::LOG_NAME) << "fileName" << fileName; @@ -921,7 +934,7 @@ bool xcodeProject::saveProjectFile(){ try { j[p] = c.substr(stringStart); } catch (std::exception & e) { - + ofLogError() << "substr " << c.substr(stringStart) << "\n" << "pointer " << p << "\n" << e.what(); @@ -936,7 +949,7 @@ bool xcodeProject::saveProjectFile(){ ofLogError() << "array " << e.what(); } } - } + } catch (std::exception & e) { cout << "pointer " << thispath; ofLogError(xcodeProject::LOG_NAME) << "first json error "; @@ -944,7 +957,7 @@ bool xcodeProject::saveProjectFile(){ ofLogError() << thispath; ofLogError() << "-------------------------"; } - + } else { @@ -982,7 +995,7 @@ bool xcodeProject::saveProjectFile(){ std::ofstream jsonFile(fileName); - + // This is not pretty but address some differences in nlohmann json 3.11.2 to 3.11.3 auto dump = j.dump(1, ' '); if (dump[0] == '[') { diff --git a/commandLine/src/projects/xcodeProject.h b/commandLine/src/projects/xcodeProject.h index ebb4ec0f..2b66276b 100644 --- a/commandLine/src/projects/xcodeProject.h +++ b/commandLine/src/projects/xcodeProject.h @@ -5,8 +5,6 @@ #include using std::string; - - class xcodeProject : public baseProject { public: xcodeProject(const string & target); @@ -17,9 +15,9 @@ class xcodeProject : public baseProject { bool saveProjectFile() override; void saveMakefile(); bool debugCommands = false; - - static std::string LOG_NAME; - + + static std::string LOG_NAME; + protected: struct fileProperties { bool absolute = false; @@ -34,13 +32,14 @@ class xcodeProject : public baseProject { bool isSrc = false; bool isGroupWithoutFolder = false; bool isRelativeToSDK = false; + bool copyBundleResources = false; }; - void addAddonFrameworks(const ofAddon& addon) override ; + void addAddonFrameworks(const ofAddon& addon) override ; // void addAddonXCFrameworks(const ofAddon& addon) override ; - void addAddonLibs(const ofAddon& addon) override; - void addAddonSrcFiles( ofAddon& addon) override; - + void addAddonLibs(const ofAddon& addon) override; + void addAddonSrcFiles( ofAddon& addon) override; + void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; void addInclude(const fs::path & includeName) override; void addLibrary(const LibraryBinary & lib) override; @@ -60,11 +59,11 @@ class xcodeProject : public baseProject { string addFile(const fs::path & path, const fs::path & folder, const fileProperties & fp); void addCommand(const string & command); - + string projRootUUID; string resourcesUUID; string frameworksUUID; - string buildPhaseResourcesUUID; + string copyBundleResourcesUUID; string afterPhaseUUID; string buildPhasesUUID; // note this UUID is in an array of *all* the build steps @@ -94,33 +93,35 @@ class xcodeProject : public baseProject { std::map folderUUID ; // Temporary std::map folderFromUUID ; - - string getFolderUUID(const fs::path & folder, fs::path base = "");//, bool isFolder = true, fs::path base = ""); + + string getFolderUUID(const fs::path & folder, fs::path base = "");//, bool isFolder = true, fs::path base = ""); // TODO: Phase out relRoot. totally fs::path relRoot = "../../.."; - + std::pair rootReplacements; - + std::map extensionToFileType { { ".framework" , "wrapper.framework" }, { ".xcframework" , "wrapper.xcframework" }, { ".dylib" , "compiled.mach-o.dylib" }, - + { ".cpp" , "sourcecode.cpp.cpp" }, { ".c" , "sourcecode.cpp.c" }, { ".h" , "sourcecode.cpp.h" }, { ".hpp" , "sourcecode.cpp.h" }, { ".mm" , "sourcecode.cpp.objcpp" }, { ".m" , "sourcecode.cpp.objcpp" }, - + { ".xib" , "file.xib" }, { ".metal" , "file.metal" }, { ".xcconfig" , "text.xcconfig" }, { ".entitlements" , "text.plist.entitlements" }, { ".plist" , "text.plist.xml" }, + + { ".storyboard" , "wrapper.storyboard" }, }; }; diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 256db95d..d23a8334 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -477,10 +477,11 @@ void alert(string msg, int color) { // TODO: Maybe rename this function to a more descriptive name. vector dirList(const fs::path & path) { + fs::path keyPath { fs::absolute(path) }; // map to cache recursive directory listing for subsequent usage static std::map> dirListMap; - if (dirListMap.find(path) == dirListMap.end()) { + if (dirListMap.find(keyPath) == dirListMap.end()) { // alert ("will list dir " + path.string(), 35); fs::recursive_directory_iterator it { path }; fs::recursive_directory_iterator last { }; @@ -494,12 +495,12 @@ vector dirList(const fs::path & path) { } // alert ("keep going " + it->path().filename().string(), 33); - dirListMap[path].emplace_back(it->path()); + dirListMap[keyPath].emplace_back(it->path()); } } else { // alert("IN CACHE " + path.string()); } - return dirListMap[path]; + return dirListMap[keyPath]; } vector folderList(const fs::path & path) {