diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 745a34ce..23fb020f 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -12,6 +12,31 @@ #include + +void ofAddon::getFrameworksRecursively(const fs::path & path, string platform) { +// alert ("getFrameworksRecursively " + path.string(), 34); + if (!fs::exists(path) || !fs::is_directory(path)) return; + + for (const auto & f : dirList(path)) { + if (fs::is_directory(f)) { + if (f.extension() == ".framework" || f.extension() == ".xcframework") { + bool platformFound = false; + if (!platform.empty() && f.string().find(platform) != std::string::npos) { + platformFound = true; + } + if(platformFound) { + if (f.extension() == ".framework") { + frameworks.emplace_back(f.string()); + } + if (f.extension() == ".xcframework") { + xcframeworks.emplace_back(f.string()); + } + } + } + } + } +} + static std::string toString(const std::string& str){ return str; } @@ -757,10 +782,10 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo getLibsRecursively(libsPath, libFiles, libs, "macos"); getLibsRecursively(libsPath, libFiles, libs, "osx"); - getFrameworksRecursively(libsPath, frameworks, "macos"); - getFrameworksRecursively(libsPath, frameworks, "osx"); - getXCFrameworksRecursively(libsPath, xcframeworks, "macos"); - getXCFrameworksRecursively(libsPath, xcframeworks, "osx"); + getFrameworksRecursively(libsPath, "macos"); + getFrameworksRecursively(libsPath, "osx"); +// getXCFrameworksRecursively(libsPath, "macos"); +// getXCFrameworksRecursively(libsPath, "osx"); removeDuplicates(libs); removeDuplicates(libFiles); @@ -777,8 +802,8 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo platform == "tvos"){//} || //platform == "macos"){ - getFrameworksRecursively(libsPath, frameworks, platform); - getXCFrameworksRecursively(libsPath, xcframeworks, platform); + getFrameworksRecursively(libsPath, platform); +// getXCFrameworksRecursively(libsPath, platform); } if (platform == "vs" || platform == "msys2" diff --git a/commandLine/src/addons/ofAddon.h b/commandLine/src/addons/ofAddon.h index f24478cc..a4a9352e 100644 --- a/commandLine/src/addons/ofAddon.h +++ b/commandLine/src/addons/ofAddon.h @@ -130,6 +130,8 @@ class ofAddon { ofAddon() = default; ofAddon(const ofAddon& other); + void getFrameworksRecursively(const fs::path & path, string platform = ""); + static string cleanName(const string& name); bool load(string addonName, const fs::path& projectDir, const string& targetPlatform); @@ -162,7 +164,7 @@ class ofAddon { vector < string > ldflags; vector < string > pkgConfigLibs; // linux only vector < string > frameworks; // osx only - vector < string > xcframeworks; // osx only + vector < string > xcframeworks; // osx only vector < string > data; vector < string > defines; diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 7ca147be..63d7a08c 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "81" +#define OFPROJECTGENERATOR_MINOR_VERSION "82" #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 f42a562b..4d734389 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -28,6 +28,7 @@ enum optionIndex { UNKNOWN, GET_HOST_PLATFORM, COMMAND, BACKUP_PROJECT_FILES, + FRAMEWORKS }; constexpr option::Descriptor usage[] = { @@ -47,6 +48,9 @@ constexpr option::Descriptor usage[] = { { GET_HOST_PLATFORM, 0, "i", "platform", option::Arg::None, " --getplatform, -i \treturn the current host platform" }, { COMMAND, 0, "c", "command", option::Arg::None, " --command, -c \truns command" }, { BACKUP_PROJECT_FILES, 0, "b", "backup", option::Arg::None, " --backup, -b \tbackup project files when replacing with template" }, + + { FRAMEWORKS, 0, "f", "frameworks", option::Arg::Optional, " --frameworks, -f \tframeworks list (such as Vision,ARKit)" }, + { 0, 0, 0, 0, 0, 0 } }; @@ -72,6 +76,7 @@ fs::path ofPath; vector addons; vector srcPaths; vector targets; +vector frameworks; string ofPathEnv; string templateName; @@ -460,6 +465,7 @@ int main(int argc, char ** argv) { printVersion(); return EXIT_OK; } + if (options[OFPATH].count() > 0) { if (options[OFPATH].arg != NULL) { @@ -541,6 +547,13 @@ int main(int argc, char ** argv) { } #endif + if (options[FRAMEWORKS].count() > 0) { + bAddonsPassedIn = true; // could be empty + if (options[FRAMEWORKS].arg != NULL) { + frameworks = ofSplitString(options[FRAMEWORKS].arg, ",", true, true); + cout << "frameworks " << options[FRAMEWORKS].arg << endl; + } + } if (parse.nonOptionsCount() > 0) { @@ -688,7 +701,10 @@ int main(int argc, char ** argv) { if(bAddonsPassedIn){ for (auto & addon : addons) { project->addAddon(addon); - } + } + for (auto & f : frameworks) { + project->addFramework(f, "", true); + } }else{ project->parseAddons(); } diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index f6cbe87a..0ba26a30 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -584,9 +584,9 @@ void baseProject::addAddon(ofAddon & addon){ addAddonDefines(addon); - addAddonFrameworks(addon); - - addAddonXCFrameworks(addon); + + addAddonFrameworks(addon); +// addAddonXCFrameworks(addon); copyAddonData(addon); diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index e7b28675..9a4d9923 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -96,6 +96,8 @@ class baseProject { bool bOverwrite = true; + virtual void addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK = false){}; + #ifdef OFADDON_OUTPUT_JSON_DEBUG void saveAddonsToJson(){ @@ -124,7 +126,7 @@ class baseProject { protected: virtual void addAddonFrameworks(const ofAddon& addon){} - virtual void addAddonXCFrameworks(const ofAddon& addon){} +// virtual void addAddonXCFrameworks(const ofAddon& addon){} virtual void addAddonBegin(const ofAddon& addon){} virtual void addAddonLibsPaths(const ofAddon& addon); virtual void addAddonIncludePaths(const ofAddon& addon); @@ -151,7 +153,6 @@ class baseProject { virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) = 0; // CXX_FLAGS virtual void addAfterRule(const std::string& script) = 0; virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) = 0; - void copyAddonData(ofAddon& addon); diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index e05c65c8..692f990c 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -4,7 +4,7 @@ #include #ifdef __APPLE__ #include // std::system - #include +// #include #endif #include #include @@ -361,7 +361,7 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b for (size_t x=0; x"); + } 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 "); + } } } diff --git a/commandLine/src/projects/xcodeProject.h b/commandLine/src/projects/xcodeProject.h index 456cf186..15cc66c6 100644 --- a/commandLine/src/projects/xcodeProject.h +++ b/commandLine/src/projects/xcodeProject.h @@ -19,16 +19,28 @@ class xcodeProject : public baseProject { bool debugCommands = false; static std::string LOG_NAME; - + protected: + struct fileProperties { + bool absolute = false; + bool reference = true; + bool addToBuildPhase = false; + bool codeSignOnCopy = false; + bool copyFilesBuildPhase = false; + bool linkBinaryWithLibraries = false; + bool addToBuildResource = false; + bool addToResources = false; + bool frameworksBuildPhase = false; + bool isSrc = false; + bool isGroupWithoutFolder = false; + bool isRelativeToSDK = false; + }; void addAddonFrameworks(const ofAddon& addon) override ; - void addAddonXCFrameworks(const ofAddon& addon) override ; +// void addAddonXCFrameworks(const 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; @@ -39,7 +51,7 @@ class xcodeProject : public baseProject { void addDefine(const string& define, LibType libType = RELEASE_LIB) override; void addCompileFlagsForMMFile(const fs::path & srcFile); - void addFramework(const fs::path & path, const fs::path & folder); + void addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK = false) override; void addXCFramework(const fs::path & path, const fs::path & folder); void addDylib(const fs::path & path, const fs::path & folder); @@ -47,21 +59,6 @@ class xcodeProject : public baseProject { void saveScheme(); void renameProject(); - struct fileProperties { - bool absolute = false; - bool reference = true; - bool addToBuildPhase = false; - bool codeSignOnCopy = false; - bool copyFilesBuildPhase = false; - bool linkBinaryWithLibraries = false; - bool addToBuildResource = false; - bool addToResources = false; - bool frameworksBuildPhase = false; - bool isSrc = false; - - bool isGroupWithoutFolder = false; - }; - string addFile(const fs::path & path, const fs::path & folder, const fileProperties & fp); void addCommand(const string & command); diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index d114a79a..256db95d 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -290,44 +290,6 @@ void getFoldersRecursively(const fs::path & path, std::vector < fs::path > & fol } } -void getFrameworksRecursively(const fs::path & path, std::vector < string > & frameworks, string platform) { -// alert ("getFrameworksRecursively " + path.string(), 34); - if (!fs::exists(path) || !fs::is_directory(path)) return; - - for (const auto & f : dirList(path)) { - if (fs::is_directory(f)) { - if (f.extension() == ".framework") { - bool platformFound = false; - if (!platform.empty() && f.string().find(platform) != std::string::npos) { - platformFound = true; - } - if(platformFound) { - frameworks.emplace_back(f.string()); - } - } - } - } -} - -void getXCFrameworksRecursively(const fs::path & path, std::vector & xcframeworks, string platform) { -// alert("getXCFrameworksRecursively " + path.string(), 34); - if (!fs::exists(path) || !fs::is_directory(path)) return; - - for (const auto & f : dirList(path)) { - if (fs::is_directory(f)) { - if (f.extension() == ".xcframework") { - bool platformFound = false; - if (!platform.empty() && f.string().find(platform) != std::string::npos) { - platformFound = true; - } - if(platformFound) { - xcframeworks.emplace_back(f.string()); - } - } - } - } -} - void getPropsRecursively(const fs::path & path, std::vector < fs::path > & props, const string & platform) { // alert ("getPropsRecursively " + path.string(), 34); diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index 9c112c9a..d9e6a235 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -69,12 +69,13 @@ void findandreplaceInTexfile (const fs::path & fileName, string tFind, string tR bool doesTagAndAttributeExist(pugi::xml_document & doc, string tag, string attribute, string newValue); pugi::xml_node appendValue(pugi::xml_document & doc, string tag, string attribute, string newValue, bool addMultiple = false); int countSubdirectories(const fs::path &path); + +// FIXME: - migrate this functions to ofAddon class without pointing the & to vector. void getFoldersRecursively(const fs::path & path, std::vector < fs::path > & folderNames, string platform); void getFilesRecursively(const fs::path & path, std::vector < string > & fileNames); void getFilesRecursively(const fs::path & path, std::vector < fs::path > & fileNames); void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFiles, std::vector < LibraryBinary > & libLibs, string platform = "", string arch = "", string target = ""); -void getFrameworksRecursively(const fs::path & path, std::vector < string > & frameworks, string platform = "" ); -void getXCFrameworksRecursively(const fs::path & path, std::vector & xcframeworks, string platform = ""); + void getPropsRecursively(const fs::path & path, std::vector < fs::path > & props, const string & platform); void getDllsRecursively(const fs::path & path, std::vector < fs::path > & dlls, string platform);