From a3681b2300016f9a5e834ea82ab913e83f80a92e Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 16 Sep 2024 20:49:08 -0300 Subject: [PATCH 01/55] marking virtual override, set several functions in baseProject as pure abstract, and overriding these in derived classes --- commandLine/src/projects/CBLinuxProject.h | 6 ++--- commandLine/src/projects/CBWinProject.h | 19 +++++++++----- commandLine/src/projects/VSCodeProject.h | 25 ++++++++++++------- commandLine/src/projects/android2024.h | 20 ++++++++++----- .../src/projects/androidStudioProject.h | 19 +++++++++----- commandLine/src/projects/qtcreatorproject.h | 21 +++++++++++----- .../src/projects/visualStudioProject.cpp | 6 ++--- .../src/projects/visualStudioProject.h | 22 ++++++++-------- commandLine/src/projects/xcodeProject.cpp | 10 ++++---- commandLine/src/projects/xcodeProject.h | 22 ++++++++-------- 10 files changed, 104 insertions(+), 66 deletions(-) diff --git a/commandLine/src/projects/CBLinuxProject.h b/commandLine/src/projects/CBLinuxProject.h index 14117f67..4fbdb222 100644 --- a/commandLine/src/projects/CBLinuxProject.h +++ b/commandLine/src/projects/CBLinuxProject.h @@ -13,9 +13,9 @@ class CBLinuxProject: public CBWinProject { public: CBLinuxProject(const std::string & target) : CBWinProject(target) {}; - bool createProjectFile(); - void addInclude(const fs::path & includeName){}; - void addLibrary(const LibraryBinary & lib){}; + virtual bool createProjectFile() override; + virtual void addInclude(const fs::path & includeName) override{}; + virtual void addLibrary(const LibraryBinary & lib)override{}; static std::string LOG_NAME; }; diff --git a/commandLine/src/projects/CBWinProject.h b/commandLine/src/projects/CBWinProject.h index ccb1aa47..8f97c0e8 100644 --- a/commandLine/src/projects/CBWinProject.h +++ b/commandLine/src/projects/CBWinProject.h @@ -13,13 +13,20 @@ class CBWinProject: public baseProject { public: CBWinProject(const std::string & target) : baseProject(target) {}; - bool createProjectFile(); - bool loadProjectFile(); - bool saveProjectFile(); + virtual bool createProjectFile() override; + virtual bool loadProjectFile() override; + virtual bool saveProjectFile() override; - void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT); - void addInclude(const fs::path & includeName); - void addLibrary(const LibraryBinary & lib); + virtual void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT) override; + virtual void addInclude(const fs::path & includeName) override; + virtual void addLibrary(const LibraryBinary & lib) override; + virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + virtual void addAfterRule(const std::string& script) override {} + virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + + static std::string LOG_NAME; }; diff --git a/commandLine/src/projects/VSCodeProject.h b/commandLine/src/projects/VSCodeProject.h index 6d0fbce6..a4e14809 100644 --- a/commandLine/src/projects/VSCodeProject.h +++ b/commandLine/src/projects/VSCodeProject.h @@ -13,15 +13,22 @@ class VSCodeProject: public baseProject { public: VSCodeProject(const std::string & target) : baseProject(target) {}; - bool createProjectFile(); - bool loadProjectFile(); - bool saveProjectFile(); - - void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT); - void addInclude(const fs::path & includeName); - void addLibrary(const LibraryBinary & lib); - - void addAddon(ofAddon & addon); + virtual bool createProjectFile() override; + virtual bool loadProjectFile() override; + virtual bool saveProjectFile() override; + + virtual void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT) override; + virtual void addInclude(const fs::path & includeName) override; + virtual void addLibrary(const LibraryBinary & lib) override; + + virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + virtual void addAfterRule(const std::string& script) override {} + virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + + + void addAddon(ofAddon & addon) ; static std::string LOG_NAME; diff --git a/commandLine/src/projects/android2024.h b/commandLine/src/projects/android2024.h index ad17c8fe..9bd8fd3b 100644 --- a/commandLine/src/projects/android2024.h +++ b/commandLine/src/projects/android2024.h @@ -6,11 +6,19 @@ class android2024Project : public baseProject { public: android2024Project(const std::string & target); - bool createProjectFile(); - void addInclude(const fs::path & includeName){} - void addLibrary(const LibraryBinary & lib){} - void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT){}; - bool loadProjectFile() { return false; }; - bool saveProjectFile(){ return false; }; + virtual bool createProjectFile() override; + virtual void addInclude(const fs::path & includeName) override {} + virtual void addLibrary(const LibraryBinary & lib) override {} + virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override {}; + virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + virtual void addAfterRule(const std::string& script) override {} + virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + + + + virtual bool loadProjectFile() override { return false; }; + virtual bool saveProjectFile() override { return false; }; static std::string LOG_NAME; }; diff --git a/commandLine/src/projects/androidStudioProject.h b/commandLine/src/projects/androidStudioProject.h index 0ffa9634..47e91da8 100644 --- a/commandLine/src/projects/androidStudioProject.h +++ b/commandLine/src/projects/androidStudioProject.h @@ -6,11 +6,18 @@ class AndroidStudioProject : public baseProject { public: AndroidStudioProject(const std::string & target); - bool createProjectFile(); - void addInclude(const fs::path & includeName){} - void addLibrary(const LibraryBinary & lib){} - void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT){}; - bool loadProjectFile() { return false; }; - bool saveProjectFile(){ return false; }; + virtual bool createProjectFile() override; + virtual void addInclude(const fs::path & includeName) override {} + virtual void addLibrary(const LibraryBinary & lib) override {} + virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override {}; + virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + virtual void addAfterRule(const std::string& script) override {} + virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + + + virtual bool loadProjectFile() override { return false; }; + virtual bool saveProjectFile() override { return false; }; static std::string LOG_NAME; }; diff --git a/commandLine/src/projects/qtcreatorproject.h b/commandLine/src/projects/qtcreatorproject.h index a430d25c..fb35e026 100644 --- a/commandLine/src/projects/qtcreatorproject.h +++ b/commandLine/src/projects/qtcreatorproject.h @@ -8,12 +8,21 @@ class QtCreatorProject : public baseProject { public: QtCreatorProject(const std::string & target); - bool createProjectFile(); - void addInclude(const fs::path & includeName){} - void addLibrary(const LibraryBinary & lib){} - void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT); - bool loadProjectFile(); - bool saveProjectFile(); + virtual bool createProjectFile() override; + virtual void addInclude(const fs::path & includeName) override {} + virtual void addLibrary(const LibraryBinary & lib)override{} + virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; + + virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + virtual void addAfterRule(const std::string& script) override {} + virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + + + + virtual bool loadProjectFile() override; + virtual bool saveProjectFile() override; static std::string LOG_NAME; private: diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index 2cc0a730..ac255c9d 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -443,7 +443,7 @@ void visualStudioProject::addLibrary(const LibraryBinary & lib) { } -void visualStudioProject::addCFLAG(string cflag, LibType libType){ +void visualStudioProject::addCFLAG(const string& cflag, LibType libType){ pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); // FIXME: iterator for (auto & item : items) { @@ -467,7 +467,7 @@ void visualStudioProject::addCFLAG(string cflag, LibType libType){ } -void visualStudioProject::addCPPFLAG(string cppflag, LibType libType){ +void visualStudioProject::addCPPFLAG(const string& cppflag, LibType libType){ pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); for (auto & item : items) { pugi::xml_node additionalOptions; @@ -490,7 +490,7 @@ void visualStudioProject::addCPPFLAG(string cppflag, LibType libType){ } -void visualStudioProject::addDefine(string define, LibType libType) { +void visualStudioProject::addDefine(const string& define, LibType libType) { pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); for (auto & item : items) { pugi::xml_node additionalOptions; diff --git a/commandLine/src/projects/visualStudioProject.h b/commandLine/src/projects/visualStudioProject.h index 84fff806..75f0fced 100644 --- a/commandLine/src/projects/visualStudioProject.h +++ b/commandLine/src/projects/visualStudioProject.h @@ -7,19 +7,19 @@ class visualStudioProject : public baseProject { public: visualStudioProject(const std::string & target) : baseProject(target) {}; - bool createProjectFile(); - bool loadProjectFile(); - bool saveProjectFile(); + virtual bool createProjectFile() override; + virtual bool loadProjectFile() override; + virtual bool saveProjectFile() override; - void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT); - void addInclude(const fs::path & includeName); + virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; + virtual void addInclude(const fs::path & includeName) override; void addProps(fs::path propsFile); - void addLibrary(const LibraryBinary & lib); - void addCFLAG(std::string cflag, LibType libType = RELEASE_LIB); // C - void addCPPFLAG(std::string cppflag, LibType libType = RELEASE_LIB); // C++ - void addDefine(std::string define, LibType libType = RELEASE_LIB); - void ensureDllDirectoriesExist(); - void addAddon(ofAddon & addon); + virtual void addLibrary(const LibraryBinary & lib)override; + virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override ; // C + virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override ; // C++ + virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override ; + void ensureDllDirectoriesExist() ; + void addAddon(ofAddon & addon) ; static std::string LOG_NAME; diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index 8c522339..d9f09ac8 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -538,14 +538,14 @@ void xcodeProject::addLibrary(const LibraryBinary & lib){ } } -void xcodeProject::addLDFLAG(string ldflag, LibType libType){ +void xcodeProject::addLDFLAG(const string& ldflag, LibType libType){ // alert( "xcodeProject::addLDFLAG " + ldflag , 34); for (auto & c : buildConfigs) { addCommand("Add :objects:"+c+":buildSettings:OTHER_LDFLAGS: string " + ldflag); } } -void xcodeProject::addCFLAG(string cflag, LibType libType){ +void xcodeProject::addCFLAG(const string& cflag, LibType libType){ //alert("xcodeProject::addCFLAG " + cflag); for (auto & c : buildConfigs) { // FIXME: add array here if it doesnt exist @@ -553,7 +553,7 @@ void xcodeProject::addCFLAG(string cflag, LibType libType){ } } -void xcodeProject::addDefine(string define, LibType libType){ +void xcodeProject::addDefine(const string& define, LibType libType){ for (auto & c : buildConfigs) { // FIXME: add array here if it doesnt exist addCommand("Add :objects:"+c+":buildSettings:GCC_PREPROCESSOR_DEFINITIONS: string " + define); @@ -561,14 +561,14 @@ void xcodeProject::addDefine(string define, LibType libType){ } // FIXME: libtype is unused here -void xcodeProject::addCPPFLAG(string cppflag, LibType libType){ +void xcodeProject::addCPPFLAG(const string& cppflag, LibType libType){ for (auto & c : buildConfigs) { // FIXME: add array here if it doesnt exist addCommand("Add :objects:"+c+":buildSettings:OTHER_CPLUSPLUSFLAGS: string " + cppflag); } } -void xcodeProject::addAfterRule(string rule){ +void xcodeProject::addAfterRule(const string& rule){ // return; // cout << ">>>>>> addAfterRule " << rule << endl; addCommand("Add :objects:"+afterPhaseUUID+":buildActionMask string 2147483647"); diff --git a/commandLine/src/projects/xcodeProject.h b/commandLine/src/projects/xcodeProject.h index a07a132d..783480c7 100644 --- a/commandLine/src/projects/xcodeProject.h +++ b/commandLine/src/projects/xcodeProject.h @@ -12,9 +12,9 @@ class xcodeProject : public baseProject { xcodeProject(const string & target); private: - bool createProjectFile(); - bool loadProjectFile(); - bool saveProjectFile(); + virtual bool createProjectFile() override; + virtual bool loadProjectFile() override; + virtual bool saveProjectFile() override; void saveMakefile(); bool debugCommands = false; @@ -22,14 +22,14 @@ class xcodeProject : public baseProject { public: - void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT); - void addInclude(const fs::path & includeName); - void addLibrary(const LibraryBinary & lib); - void addLDFLAG(string ldflag, LibType libType = RELEASE_LIB); - void addCFLAG(string cflag, LibType libType = RELEASE_LIB); // Other C Flags - void addCPPFLAG(string cppflag, LibType libType = RELEASE_LIB); // Other C++ Flags - void addAfterRule(string script); - void addDefine(string define, LibType libType = RELEASE_LIB); + virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; + virtual void addInclude(const fs::path & includeName) override; + virtual void addLibrary(const LibraryBinary & lib) override; + virtual void addLDFLAG(const string& ldflag, LibType libType = RELEASE_LIB) override; + virtual void addCFLAG(const string& cflag, LibType libType = RELEASE_LIB) override; // Other C Flag overrides + virtual void addCPPFLAG(const string& cppflag, LibType libType = RELEASE_LIB) override; // Other C++ Flag overrides + virtual void addAfterRule(const string& script) override; + virtual 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); From b3712580ab33674b8c679cd7866a1f7626623546 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 16 Sep 2024 20:50:51 -0300 Subject: [PATCH 02/55] baseProject some functions now are pureabstract and have const reference string arg --- commandLine/src/projects/baseProject.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index c26f7bb8..a22f3776 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -56,15 +56,15 @@ class baseProject { virtual void addInclude(const fs::path & includeName) = 0; virtual void addLibrary(const LibraryBinary & lib) = 0; - // FIXME: change some strings to const & - virtual void addLDFLAG(std::string ldflag, LibType libType = RELEASE_LIB){} - virtual void addCFLAG(std::string cflag, LibType libType = RELEASE_LIB){} // C_FLAGS - virtual void addCPPFLAG(std::string cppflag, LibType libType = RELEASE_LIB){} // CXX_FLAGS - virtual void addAfterRule(std::string script){} - virtual void addDefine(std::string define, LibType libType = RELEASE_LIB) {} - - virtual void addAddon(std::string addon); - virtual void addAddon(ofAddon & addon); + + virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) = 0; + virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) = 0; // C_FLAGS + 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 addAddon(std::string addon); + void addAddon(ofAddon & addon); virtual void addSrcRecursively(const fs::path & srcPath); virtual void restoreBackup(const fs::path & srcPath){}; @@ -86,7 +86,7 @@ class baseProject { std::string projectName; std::string target; - bool bMakeRelative = false; +// bool bMakeRelative = false; bool bOverwrite = true; From af588f4b6ebe0a8a9bdc83a2b3d1b65730036434 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 16 Sep 2024 20:51:21 -0300 Subject: [PATCH 03/55] changing method to identify local addons --- commandLine/src/projects/baseProject.cpp | 54 ++++++++++++++++++------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 286974d2..e0a36e64 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -310,13 +310,39 @@ void baseProject::addAddon(string addonName){ #endif ofAddon addon; - // MARK: Review this path here. EDIT: I think it is finally good - - if (bMakeRelative) { - addon.pathToOF = fs::relative(getOFRoot(), projectDir); - } else { - addon.pathToOF = getOFRoot(); - } +// addon.addonMakeString = addonName; + + { + auto s = ofSplitString(addonName, "#"); + if(s.size()){ + addonName = s[0]; + } + } + + + if(addonName.empty()){ + ofLogError("baseProject::addAddon") << "cant add addon with empty name"; + return; + } + + //This should be the only instance where we check if the addon is either local or not. + //being local just means that the addon name is a filepath and it starts with a dot. + //otherwise it will look in the addons folder. + //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))){ + + addon.addonPath = ofFilePath::join(projectDir, addonName); + addon.isLocalAddon = true; + ofLogVerbose() << "Adding local addon: " << addonName; + // addon.pathToProject = makeRelative(getOFRoot(), projectDir); + // projectDir; + }else{ + addon.addonPath = fs::path { getOFRoot() / "addons" / addonName }; + } + addon.pathToOF = getOFRoot(); + addon.pathToOF = normalizePath(addon.pathToOF); @@ -329,13 +355,13 @@ void baseProject::addAddon(string addonName){ fs::path addonPath { addonName }; - if (fs::exists(addonPath)) { - addon.isLocalAddon = true; - } else { - addonPath = fs::path { getOFRoot() / "addons" / addonName }; - addon.isLocalAddon = false; - addon.addonPath = addonPath; - } +// if (fs::exists(addonPath)) { +// addon.isLocalAddon = true; +// } else { +// addonPath = fs::path { getOFRoot() / "addons" / addonName }; +// addon.isLocalAddon = false; +// addon.addonPath = addonPath; +// } ofLogVerbose() << "addon.addonPath to: [" << addon.addonPath.string() << "]"; ofLogVerbose() << "addon.pathToOF: [" << addon.pathToOF.string() << "]"; From db2ac57a1ff75a9d86b7e0f0da21f10c31a50d80 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 16 Sep 2024 22:50:05 -0300 Subject: [PATCH 04/55] adding virtual functions for the parsing and processing of each of the different elemetns an added addon. Classes extending baseProject should not call addAddon or override it, instead should override these added functions --- commandLine/src/projects/baseProject.cpp | 492 ++++++++++-------- commandLine/src/projects/baseProject.h | 44 +- .../src/projects/visualStudioProject.h | 5 + commandLine/src/projects/xcodeProject.cpp | 175 ++++--- commandLine/src/projects/xcodeProject.h | 11 +- 5 files changed, 425 insertions(+), 302 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index e0a36e64..46b23b38 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -301,16 +301,17 @@ bool baseProject::isAddonInCache(const string & addonPath, const string platform } void baseProject::addAddon(string addonName){ -// alert( "baseProject::addAddon " + addonName ); - - // FIXME : not target, yes platform. - #ifdef TARGET_WIN32 -// std::replace( addonName.begin(), addonName.end(), '/', '\\' ); - fixSlashOrder(addonName); - #endif - - ofAddon addon; -// addon.addonMakeString = addonName; + ofLogVerbose("baseProject::addAddon") << addonName; + // alert( "baseProject::addAddon " + addonName ); + + // FIXME : not target, yes platform. +#ifdef TARGET_WIN32 + // std::replace( addonName.begin(), addonName.end(), '/', '\\' ); + fixSlashOrder(addonName); +#endif + + ofAddon addon; + // addon.addonMakeString = addonName; { auto s = ofSplitString(addonName, "#"); @@ -319,156 +320,104 @@ void baseProject::addAddon(string addonName){ } } - - if(addonName.empty()){ - ofLogError("baseProject::addAddon") << "cant add addon with empty name"; - return; - } - - //This should be the only instance where we check if the addon is either local or not. - //being local just means that the addon name is a filepath and it starts with a dot. - //otherwise it will look in the addons folder. - //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))){ - - addon.addonPath = ofFilePath::join(projectDir, addonName); - addon.isLocalAddon = true; - ofLogVerbose() << "Adding local addon: " << addonName; - // addon.pathToProject = makeRelative(getOFRoot(), projectDir); - // projectDir; - }else{ - addon.addonPath = fs::path { getOFRoot() / "addons" / addonName }; - } - addon.pathToOF = getOFRoot(); - - - - addon.pathToOF = normalizePath(addon.pathToOF); - addon.addonPath = normalizePath(addon.addonPath); - - addon.pathToProject = projectDir; - - bool addonOK = false; - bool inCache = isAddonInCache(addonName, target); - - fs::path addonPath { addonName }; - -// if (fs::exists(addonPath)) { -// addon.isLocalAddon = true; -// } else { -// addonPath = fs::path { getOFRoot() / "addons" / addonName }; -// addon.isLocalAddon = false; -// addon.addonPath = addonPath; -// } - - ofLogVerbose() << "addon.addonPath to: [" << addon.addonPath.string() << "]"; - ofLogVerbose() << "addon.pathToOF: [" << addon.pathToOF.string() << "]"; - - if (!inCache) { - addonOK = addon.fromFS(addonPath, target); - } else { - addon = addonsCache[target][addonName]; - addonOK = true; - } - - if(!addonOK){ - ofLogVerbose() << "Ignoring addon that doesn't seem to exist: " << addonName; - return; //if addon does not exist, stop early - } - - if(!inCache){ - //cache the addon so we dont have to be reading form disk all the time - addonsCache[target][addonName] = addon; - } - - for (auto & a : addons) { - if (a.name == addon.name) return; - } - - - for (auto & d : addon.dependencies) { - bool found = false; - for (auto & a : addons) { - if (a.name == d) { - found = true; - break; - } - } - if (!found) { - baseProject::addAddon(d); - } else { - ofLogVerbose() << "trying to add duplicated addon dependency! skipping: " << d; - } - } - - - ofLogNotice() << "adding addon: " << addon.name; - addons.emplace_back(addon); - - for (auto & e : addon.includePaths) { - fs::path normalizedDir = normalizePath(projectDir); - ofLogVerbose() << "[addon.includePaths] adding addon include path: [" << normalizedDir << "]"; - if (containsSourceFiles(normalizedDir)) { - normalizedDir = makeRelative(projectDir, e); - ofLogVerbose() << "[addon.includePaths] contains src - Adding dir: [" << normalizedDir.string() << "]"; - fs::path ofpathChanged = ofRelativeToOFPATH(projectDir); - ofLogVerbose() << "[addon.includePaths] OFPATH: rel include dir: [" << ofpathChanged.string() << "]"; - - addInclude(normalizedDir); - } else { - ofLogVerbose() << "[addon.includePaths] no src - not adding: [" << normalizedDir.string() << "]"; - } - } - - // It was part exclusive of visualStudioProject. now it is part of baseProject, so dlls are copied in VSCode project and .so files in linux - for (auto & d : addon.dllsToCopy) { - ofLogVerbose() << "adding addon dlls to bin: " << d; - fs::path from { d }; - fs::path to { projectDir / "bin" / from.filename() }; - if (from.extension() == ".so") { - fs::path folder { projectDir / "bin" / "libs" }; - if (!fs::exists(folder)) { - try { - fs::create_directories(folder); - } catch(fs::filesystem_error& e) { - ofLogError("baseProject::addAddon") << "error creating folder " << folder; - ofLogError() << e.what(); - } - } -// to = projectDir / "bin" / "libs" / from.filename(); - to = folder / from.filename(); - } - if (from.extension() == ".dll") { - if (d.string().find("x64") != std::string::npos) { - to = fs::path { projectDir / "dll/x64" / from.filename() }; - ofLogVerbose() << "adding addon dlls to dll/x64: " << d; - } else if (d.string().find("ARM64EC") != std::string::npos) { - to = fs::path { projectDir / "dll/ARM64EC" / from.filename()}; - ofLogVerbose() << "adding addon dlls to dll/ARM64EC: " << d; - } else if (d.string().find("ARM64") != std::string::npos) { - to = fs::path { projectDir / "dll/ARM64" / from.filename() }; - ofLogVerbose() << "adding addon dlls to dll/ARM64: " << d; - } else { - // Default case if architecture is not found - to = fs::path { projectDir / "bin" / from.filename() }; - ofLogVerbose() << "adding addon dlls to bin: " << d; - } - } - - try { - fs::copy_file(from, to, fs::copy_options::overwrite_existing); // always overwrite DLLS - } catch(fs::filesystem_error& e) { - ofLogError("baseProject::addAddon") << "error copying template file " << from << endl << "to: " << to << endl << e.what(); - } - } - - // MARK: - SPECIFIC for each project. - // XCode and VS override the base addAddon. other templates will use baseproject::addAddon(ofAddon... - addAddon(addon); + + if(addonName.empty()){ + ofLogError("baseProject::addAddon") << "cant add addon with empty name"; + return; + } + + //This should be the only instance where we check if the addon is either local or not. + //being local just means that the addon name is a filepath and it starts with a dot. + //otherwise it will look in the addons folder. + //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))){ + + addon.addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); + addon.isLocalAddon = true; + ofLogVerbose() << "Adding local addon: " << addonName; + // addon.pathToProject = makeRelative(getOFRoot(), projectDir); + // projectDir; + }else{ + addon.addonPath = fs::path { getOFRoot() / "addons" / addonName }; + } + addon.pathToOF = getOFRoot(); + + + + addon.pathToOF = normalizePath(addon.pathToOF); + addon.addonPath = normalizePath(addon.addonPath); + + addon.pathToProject = projectDir; + + bool addonOK = false; + bool inCache = isAddonInCache(addonName, target); + + // fs::path addonPath { addonName }; + + // if (fs::exists(addonPath)) { + // addon.isLocalAddon = true; + // } else { + // addonPath = fs::path { getOFRoot() / "addons" / addonName }; + // addon.isLocalAddon = false; + // addon.addonPath = addonPath; + // } + + ofLogVerbose() << "addon.addonPath to: [" << addon.addonPath.string() << "]"; + ofLogVerbose() << "addon.pathToOF: [" << addon.pathToOF.string() << "]"; + + if (!inCache) { + addonOK = addon.fromFS(addon.addonPath, target); + } else { + addon = addonsCache[target][addonName]; + addonOK = true; + } + + if(!addonOK){ + ofLogVerbose() << "Ignoring addon that doesn't seem to exist: " << addonName; + return; //if addon does not exist, stop early + } + + if(!inCache){ + //cache the addon so we dont have to be reading form disk all the time + addonsCache[target][addonName] = addon; + } +// +// for (auto & a : addons) { +// if (a.name == addon.name) return; +// } +// +// +// for (auto & d : addon.dependencies) { +// bool found = false; +// for (auto & a : addons) { +// if (a.name == d) { +// found = true; +// break; +// } +// } +// if (!found) { +// baseProject::addAddon(d); +// } else { +// ofLogVerbose() << "trying to add duplicated addon dependency! skipping: " << d; +// } +// } +// + + ofLogNotice() << "adding addon: " << addon.name; + + + + + + // MARK: - SPECIFIC for each project. + // XCode and VS override the base addAddon. other templates will use baseproject::addAddon(ofAddon... + addAddon(addon); +} - // Process values from ADDON_DATA +void baseProject::copyAddonData(ofAddon& addon){ +// Process values from ADDON_DATA if(addon.data.size()){ for(auto & data : addon.data){ string d = data; @@ -509,6 +458,50 @@ void baseProject::addAddon(string addonName){ } } +void baseProject::addAddonDllsToCopy(ofAddon& addon){ + // It was part exclusive of visualStudioProject. now it is part of baseProject, so dlls are copied in VSCode project and .so files in linux + for (auto & d : addon.dllsToCopy) { + ofLogVerbose() << "adding addon dlls to bin: " << d; + fs::path from { d }; + fs::path to { projectDir / "bin" / from.filename() }; + if (from.extension() == ".so") { + fs::path folder { projectDir / "bin" / "libs" }; + if (!fs::exists(folder)) { + try { + fs::create_directories(folder); + } catch(fs::filesystem_error& e) { + ofLogError("baseProject::addAddon") << "error creating folder " << folder; + ofLogError() << e.what(); + } + } +// to = projectDir / "bin" / "libs" / from.filename(); + to = folder / from.filename(); + } + if (from.extension() == ".dll") { + if (d.string().find("x64") != std::string::npos) { + to = fs::path { projectDir / "dll/x64" / from.filename() }; + ofLogVerbose() << "adding addon dlls to dll/x64: " << d; + } else if (d.string().find("ARM64EC") != std::string::npos) { + to = fs::path { projectDir / "dll/ARM64EC" / from.filename()}; + ofLogVerbose() << "adding addon dlls to dll/ARM64EC: " << d; + } else if (d.string().find("ARM64") != std::string::npos) { + to = fs::path { projectDir / "dll/ARM64" / from.filename() }; + ofLogVerbose() << "adding addon dlls to dll/ARM64: " << d; + } else { + // Default case if architecture is not found + to = fs::path { projectDir / "bin" / from.filename() }; + ofLogVerbose() << "adding addon dlls to bin: " << d; + } + } + + try { + fs::copy_file(from, to, fs::copy_options::overwrite_existing); // always overwrite DLLS + } catch(fs::filesystem_error& e) { + ofLogError("baseProject::addAddon") << "error copying template file " << from << endl << "to: " << to << endl << e.what(); + } + } +} + // MARK: - This function is only called by addon dependencies, when one addon is asking for another one to be included. // this is only invoked by XCode and visualStudioProject, and I don't understand why as they are similar @@ -554,73 +547,148 @@ void baseProject::addAddon(ofAddon & addon){ ofLogVerbose("baseProject") << "libs in addAddon " << addon.libs.size(); - for(auto & lib: addon.libsPaths){ - ofLogVerbose("adding lib paths") << lib.string(); - } + + addAddonDllsToCopy(addon); + + addAddonLibsPaths(addon); + addAddonIncludePaths(addon); + addAddonLibs(addon); + addAddonCflags(addon); + addAddonCppflags(addon); + addAddonLdflags(addon); + addAddonSrcFiles(addon); + addAddonCsrcFiles(addon); + addAddonCppsrcFiles(addon); + addAddonObjcsrcFiles(addon); + addAddonHeadersrcFiles(addon); - for (auto & a : addon.includePaths) { - fs::path normalizedDir = makeRelative(projectDir, a); - ofLogVerbose() << "adding addon include path: [" << normalizedDir.string() + "]"; - addInclude(normalizedDir); - } - for (auto & a : addon.libs) { - ofLogVerbose() << "adding addon libs: " << a.path.string(); - addLibrary(a); - } - for (auto & a : addon.cflags) { - ofLogVerbose() << "adding addon cflags: " << a; - addCFLAG(a); + for (auto & a : addon.defines) { + ofLogVerbose() << "adding addon defines: [" << a << "]"; + addDefine(a); } + + addAddonFrameworks(addon); + + addAddonXCFrameworks(addon); + +// for (auto & f : addon.xcframeworks) { +// addXCFramework(f); +// } - for (auto & a : addon.cppflags) { - ofLogVerbose() << "adding addon cppflags: " << a; - addCPPFLAG(a); - } + copyAddonData(addon); + +} - for (auto & a : addon.ldflags) { - ofLogVerbose() << "adding addon ldflags: " << a; - addLDFLAG(a); - } - for (auto & a : addon.srcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon srcFiles: " << normalizedDir.string(); - addSrc(normalizedDir, addon.filesToFolders[a]); - } - for (auto & a : addon.csrcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon c srcFiles: " << normalizedDir.string(); - addSrc(normalizedDir, addon.filesToFolders[a], C); - } - for (auto & a : addon.cppsrcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon cpp srcFiles: " << normalizedDir.string(); - addSrc(normalizedDir, addon.filesToFolders[a],CPP); - } +void baseProject::addAddonLibsPaths(const ofAddon& addon){ + for (auto & lib: addon.libsPaths){ + ofLogVerbose("adding lib paths") << lib.string(); + } +} - for (auto & a : addon.objcsrcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon objc srcFiles: " << normalizedDir.string(); - addSrc(normalizedDir, addon.filesToFolders[a],OBJC); - } +void baseProject::addAddonIncludePaths(const ofAddon& addon){ + for (auto & e : addon.includePaths) { + fs::path normalizedDir = normalizePath(projectDir); + ofLogVerbose() << "[addon.includePaths] adding addon include path: [" << normalizedDir << "]"; + if (containsSourceFiles(normalizedDir)) { + normalizedDir = makeRelative(projectDir, e); + ofLogVerbose() << "[addon.includePaths] contains src - Adding dir: [" << normalizedDir.string() << "]"; + fs::path ofpathChanged = ofRelativeToOFPATH(projectDir); + ofLogVerbose() << "[addon.includePaths] OFPATH: rel include dir: [" << ofpathChanged.string() << "]"; + + addInclude(normalizedDir); + } else { + ofLogVerbose() << "[addon.includePaths] no src - not adding: [" << normalizedDir.string() << "]"; + } + } + + +// for (auto & a : addon.includePaths) { +// fs::path normalizedDir = makeRelative(projectDir, a); +// ofLogVerbose() << "adding addon include path: [" << normalizedDir.string() + "]"; +// addInclude(normalizedDir); +// } +} - for (auto & a : addon.headersrcFiles) { - - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon header srcFiles: [" << normalizedDir.string() << "]"; - addSrc(normalizedDir, addon.filesToFolders[a],HEADER); - } +void baseProject::addAddonLibs(const ofAddon& addon){ + for (auto & a : addon.libs) { + ofLogVerbose() << "adding addon libs: " << a.path.string(); + addLibrary(a); + } +} - for (auto & a : addon.defines) { - ofLogVerbose() << "adding addon defines: [" << a << "]"; - addDefine(a); - } +void baseProject::addAddonCflags(const ofAddon& addon){ + for (auto & a : addon.cflags) { + ofLogVerbose() << "adding addon cflags: " << a; + addCFLAG(a); + } +} + +void baseProject::addAddonCppflags(const ofAddon& addon){ + for (auto & a : addon.cppflags) { + ofLogVerbose() << "adding addon cppflags: " << a; + addCPPFLAG(a); + } +} + +void baseProject::addAddonLdflags(const ofAddon& addon){ + for (auto & a : addon.ldflags) { + ofLogVerbose() << "adding addon ldflags: " << a; + addLDFLAG(a); + } +} + +void baseProject::addAddonSrcFiles( ofAddon& addon){ + for (auto & a : addon.srcFiles) { + fs::path normalizedDir = makeRelative(getOFRoot(), a); + ofLogVerbose() << "adding addon srcFiles: " << normalizedDir.string(); + addSrc(normalizedDir, addon.filesToFolders.at(a)); + } +} + +void baseProject::addAddonCsrcFiles(const ofAddon& addon){ + for (auto & a : addon.csrcFiles) { + fs::path normalizedDir = makeRelative(getOFRoot(), a); + ofLogVerbose() << "adding addon c srcFiles: " << normalizedDir.string(); + addSrc(normalizedDir, addon.filesToFolders.at(a), C); + } +} + +void baseProject::addAddonCppsrcFiles(const ofAddon& addon){ + for (auto & a : addon.cppsrcFiles) { + fs::path normalizedDir = makeRelative(getOFRoot(), a); + ofLogVerbose() << "adding addon cpp srcFiles: " << normalizedDir.string(); + addSrc(normalizedDir, addon.filesToFolders.at(a),CPP); + } +} + +void baseProject::addAddonObjcsrcFiles(const ofAddon& addon){ + for (auto & a : addon.objcsrcFiles) { + fs::path normalizedDir = makeRelative(getOFRoot(), a); + ofLogVerbose() << "adding addon objc srcFiles: " << normalizedDir.string(); + addSrc(normalizedDir, addon.filesToFolders.at(a),OBJC); + } } +void baseProject::addAddonHeadersrcFiles(const ofAddon& addon){ + for (auto & a : addon.headersrcFiles) { + + fs::path normalizedDir = makeRelative(getOFRoot(), a); + ofLogVerbose() << "adding addon header srcFiles: [" << normalizedDir.string() << "]"; + addSrc(normalizedDir, addon.filesToFolders.at(a),HEADER); + } +} + + + + + + + void baseProject::addSrcRecursively(const fs::path & srcPath){ // alert("addSrcRecursively " + srcPath.string(), 32); diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index a22f3776..89eca6ba 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -52,16 +52,6 @@ class baseProject { void parseConfigMake(); bool save(); - virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) = 0; - virtual void addInclude(const fs::path & includeName) = 0; - virtual void addLibrary(const LibraryBinary & lib) = 0; - - - virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) = 0; - virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) = 0; // C_FLAGS - 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 addAddon(std::string addon); void addAddon(ofAddon & addon); @@ -107,6 +97,40 @@ class baseProject { // this should get called at the end. protected: + + virtual void addAddonFrameworks(const ofAddon& addon){} + virtual void addAddonXCFrameworks(const ofAddon& addon){} + virtual void addAddonLibsPaths(const ofAddon& addon); + virtual void addAddonIncludePaths(const ofAddon& addon); + virtual void addAddonLibs(const ofAddon& addon); + virtual void addAddonCflags(const ofAddon& addon); + virtual void addAddonCppflags(const ofAddon& addon); + virtual void addAddonLdflags(const ofAddon& addon); + virtual void addAddonSrcFiles(ofAddon& addon); + virtual void addAddonCsrcFiles(const ofAddon& addon); + virtual void addAddonCppsrcFiles(const ofAddon& addon); + virtual void addAddonObjcsrcFiles(const ofAddon& addon); + virtual void addAddonHeadersrcFiles(const ofAddon& addon); + virtual void addAddonDllsToCopy(ofAddon& addon); + + + virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) = 0; + virtual void addInclude(const fs::path & includeName) = 0; + virtual void addLibrary(const LibraryBinary & lib) = 0; + + virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) = 0; + virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) = 0; // C_FLAGS + 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); + + + + + void recursiveCopyContents(const fs::path & srcDir, const fs::path & destDir); void recursiveTemplateCopy(const fs::path & srcDir, const fs::path & destDir); bool recursiveCopy(const fs::path & srcDir, const fs::path & destDir); diff --git a/commandLine/src/projects/visualStudioProject.h b/commandLine/src/projects/visualStudioProject.h index 75f0fced..f54eae0a 100644 --- a/commandLine/src/projects/visualStudioProject.h +++ b/commandLine/src/projects/visualStudioProject.h @@ -18,6 +18,11 @@ class visualStudioProject : public baseProject { virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override ; // C virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override ; // C++ virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override ; + + virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + virtual void addAfterRule(const std::string& script) override {} + + void ensureDllDirectoriesExist() ; void addAddon(ofAddon & addon) ; diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index d9f09ac8..42ce885e 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -374,7 +374,8 @@ string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::p void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type){ // alert ("addSrc " + ofPathToString(srcFile) + " : " + ofPathToString(folder), 31); - string ext = ofPathToString(srcFile.extension()); + + string ext = ofPathToString(srcFile.extension()); // .reference = true, // .addToBuildPhase = true, @@ -448,6 +449,7 @@ void xcodeProject::addCompileFlagsForMMFile(const fs::path & srcFile) { void xcodeProject::addFramework(const fs::path & path, const fs::path & 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); @@ -481,6 +483,7 @@ void xcodeProject::addFramework(const fs::path & path, const fs::path & folder){ void xcodeProject::addXCFramework(const fs::path & path, const fs::path & folder) { + ofLogVerbose() << "Adding XCFramework " << ofPathToString(path) << " folder: " << folder; // alert( "xcodeProject::addFramework " + path.string() + " : " + folder.string() , 33); // path = the full path (w name) of this framework @@ -539,6 +542,7 @@ void xcodeProject::addLibrary(const LibraryBinary & lib){ } void xcodeProject::addLDFLAG(const string& ldflag, LibType libType){ + ofLogVerbose("xcodeProject::addLDFLAG") << ldflag; // alert( "xcodeProject::addLDFLAG " + ldflag , 34); for (auto & c : buildConfigs) { addCommand("Add :objects:"+c+":buildSettings:OTHER_LDFLAGS: string " + ldflag); @@ -546,6 +550,7 @@ void xcodeProject::addLDFLAG(const string& ldflag, LibType libType){ } void xcodeProject::addCFLAG(const string& cflag, LibType libType){ + ofLogVerbose("xcodeProject::addCFLAG") << cflag; //alert("xcodeProject::addCFLAG " + cflag); for (auto & c : buildConfigs) { // FIXME: add array here if it doesnt exist @@ -589,88 +594,102 @@ void xcodeProject::addAfterRule(const string& rule){ addCommand("Add :objects:"+buildConfigurationListUUID+":buildPhases: string " + afterPhaseUUID); } -void xcodeProject::addAddon(ofAddon & addon){ +// void xcodeProject::addAddon(ofAddon & addon){ + // // alert("xcodeProject addAddon string :: " + addon.name, 31); // Files listed alphabetically on XCode navigator. - 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.libs) { - ofLogVerbose() << "adding addon libs: " << e.path; - addLibrary(e); - - fs::path dylibPath { e.path }; - fs::path folder = dylibPath.parent_path().lexically_relative(addon.pathToOF); -// cout << "dylibPath " << dylibPath << endl; - if (dylibPath.extension() == ".dylib") { - addDylib(dylibPath, folder); - } - } - - for (auto & e : addon.cflags) { - ofLogVerbose() << "adding addon cflags: " << e; - addCFLAG(e); - } - - for (auto & e : addon.cppflags) { - ofLogVerbose() << "adding addon cppflags: " << e; - addCPPFLAG(e); - } - - for (auto & e : addon.ldflags) { - ofLogVerbose() << "adding addon ldflags: " << e; -// alert("addon ldflags " + e, 31 ); - addLDFLAG(e); - } - - for (auto & e : addon.srcFiles) { - ofLogVerbose() << "adding addon srcFiles: " << e; - if(addon.filesToFolders.find(e) == addon.filesToFolders.end()) { - addon.filesToFolders[e] = fs::path { "" }; - } - addSrc(e,addon.filesToFolders[e]); - } - - for (auto & e : addon.defines) { - ofLogVerbose() << "adding addon defines: " << e; - addDefine(e); - } - - for (auto & f : addon.frameworks) { - // alert (f, 31); - ofLogVerbose() << "adding addon frameworks: " << f; - - size_t found=f.find('/'); - if (found==string::npos) { // This path doesn't have slashes - fs::path folder = fs::path{ "addons" } / addon.name / "frameworks"; -// fs::path folder = addon.filesToFolders[f]; - - if (target == "ios"){ - addFramework( "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/" + f + ".framework", -// folder - "Frameworks" - ); - } else { - if (addon.isLocalAddon) { - folder = addon.addonPath / "frameworks"; - } - addFramework( "/System/Library/Frameworks/" + f + ".framework", folder); - } - } - else { - if (ofIsStringInString(f, "/System/Library")){ - addFramework(f, "addons/" + addon.name + "/frameworks"); + // std::sort(addon.srcFiles.begin(), addon.srcFiles.end(), [](const fs::path & a, const fs::path & b) { + // return a.string() < b.string(); + // }); +void xcodeProject::addAddonLibs(const ofAddon& addon){ + for (auto & e : addon.libs) { + ofLogVerbose() << "adding addon libs: " << e.path; + addLibrary(e); + + fs::path dylibPath { e.path }; + fs::path folder = dylibPath.parent_path().lexically_relative(addon.pathToOF); + // cout << "dylibPath " << dylibPath << endl; + if (dylibPath.extension() == ".dylib") { + addDylib(dylibPath, folder); + } + } +} - } else { - addFramework(f, addon.filesToFolders[f]); - } - } - } +// for (auto & e : addon.cflags) { +// ofLogVerbose() << "adding addon cflags: " << e; +// addCFLAG(e); +// } + +// for (auto & e : addon.cppflags) { +// ofLogVerbose() << "adding addon cppflags: " << e; +// addCPPFLAG(e); +// } + +// for (auto & e : addon.ldflags) { +// ofLogVerbose() << "adding addon ldflags: " << e; +//// alert("addon ldflags " + e, 31 ); +// addLDFLAG(e); +// } + +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)); + } + } +} +// for (auto & e : addon.defines) { +// ofLogVerbose() << "adding addon defines: " << e; +// addDefine(e); +// } + +//----------------------------------------------------------------------------------------------- +void xcodeProject::addAddonFrameworks(const ofAddon& addon){ + ofLogVerbose("xcodeProject::addAddonFrameworks") << addon.name; + + for (auto & f : addon.frameworks) { + ofLogVerbose() << "adding addon frameworks: " << f; + + size_t found=f.find('/'); + if (found==string::npos) { // This path doesn't have slashes + fs::path folder = fs::path{ "addons" } / addon.name / "frameworks"; +// fs::path folder = addon.filesToFolders[f]; + + if (target == "ios"){ + addFramework( "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/" + f + ".framework", +// folder + "Frameworks" + ); + } else { + if (addon.isLocalAddon) { + folder = addon.addonPath / "frameworks"; + } + addFramework( "/System/Library/Frameworks/" + f + ".framework", folder); + } + } + else { + if (ofIsStringInString(f, "/System/Library")){ + addFramework(f, "addons/" + addon.name + "/frameworks"); + + } else { + addFramework(f, addon.filesToFolders.at(f)); + } + } + } +} +//----------------------------------------------------------------------------------------------- +void xcodeProject::addAddonXCFrameworks(const ofAddon& addon){ + ofLogVerbose("xcodeProject::addAddonXCFrameworks") << addon.name; for (auto & f : addon.xcframeworks) { // alert ("xcodeproj addon.xcframeworks : " + f); ofLogVerbose() << "adding addon xcframeworks: " << f; @@ -690,7 +709,7 @@ void xcodeProject::addAddon(ofAddon & addon){ if (ofIsStringInString(f, "/System/Library")) { addXCFramework(f, "addons/" + addon.name + "/xcframeworks"); } else { - addXCFramework(f, addon.filesToFolders[f]); + addXCFramework(f, addon.filesToFolders.at(f)); } } } @@ -698,7 +717,7 @@ void xcodeProject::addAddon(ofAddon & addon){ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, const fileProperties & fp) { - //alert("addFile " + ofPathToString(path) + " : " + ofPathToString(folder) , 31); + alert("addFile " + ofPathToString(path) + " : " + ofPathToString(folder) , 31); string UUID { "" }; diff --git a/commandLine/src/projects/xcodeProject.h b/commandLine/src/projects/xcodeProject.h index 783480c7..8f878416 100644 --- a/commandLine/src/projects/xcodeProject.h +++ b/commandLine/src/projects/xcodeProject.h @@ -20,8 +20,15 @@ class xcodeProject : public baseProject { static std::string LOG_NAME; -public: +protected: + virtual void addAddonFrameworks(const ofAddon& addon) override ; + virtual void addAddonXCFrameworks(const ofAddon& addon) override ; + virtual void addAddonLibs(const ofAddon& addon) override; + virtual void addAddonSrcFiles( ofAddon& addon) override; + + + virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; virtual void addInclude(const fs::path & includeName) override; virtual void addLibrary(const LibraryBinary & lib) override; @@ -36,7 +43,7 @@ class xcodeProject : public baseProject { void addXCFramework(const fs::path & path, const fs::path & folder); void addDylib(const fs::path & path, const fs::path & folder); - void addAddon(ofAddon & addon); +// void addAddon(ofAddon & addon); void saveScheme(); void renameProject(); From 8b462cd1d551ecf1adb460160caec5cfde3dcb88 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 16 Sep 2024 23:49:16 -0300 Subject: [PATCH 05/55] correctly saving and loading addon_config --- commandLine/src/addons/ofAddon.cpp | 18 +++++++----- commandLine/src/addons/ofAddon.h | 2 +- commandLine/src/projects/baseProject.cpp | 37 +++++++++++------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 084ea21b..90ad23f2 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -71,7 +71,9 @@ ofAddon::ofAddon(const ofAddon& other) excludeSources(other.excludeSources), excludeIncludes(other.excludeIncludes), excludeFrameworks(other.excludeFrameworks), - excludeXCFrameworks(other.excludeXCFrameworks) + excludeXCFrameworks(other.excludeXCFrameworks), + addonMakeName(other.addonMakeName) + { } @@ -568,10 +570,11 @@ void ofAddon::excludeLibrary(vector & variables, vector e void ofAddon::preParseConfig(){ // alert ("ofAddon::parseConfig " + addonPath.string(), 33); - fs::path fileName = isLocalAddon ? - (pathToProject / addonPath / "addon_config.mk") : - (addonPath / "addon_config.mk") - ; + fs::path fileName = (addonPath / "addon_config.mk"); +// isLocalAddon ? +// (pathToProject / addonPath / "addon_config.mk") : +// (addonPath / "addon_config.mk") +// ; if (!fs::exists(fileName)) { // ofLogError() << "ofAddon::parseConfig() " << fileName << " not found " << ofPathToString(fileName); @@ -636,8 +639,9 @@ void ofAddon::preParseConfig(){ void ofAddon::parseConfig(){ // alert ("ofAddon::parseConfig " + addonPath.string(), 33); - fs::path fileName = isLocalAddon ? - (pathToProject / addonPath / "addon_config.mk") : + fs::path fileName = +// isLocalAddon ? +// (pathToProject / addonPath / "addon_config.mk") : (addonPath / "addon_config.mk") ; diff --git a/commandLine/src/addons/ofAddon.h b/commandLine/src/addons/ofAddon.h index 6bb8ac38..085c2fdf 100644 --- a/commandLine/src/addons/ofAddon.h +++ b/commandLine/src/addons/ofAddon.h @@ -175,7 +175,7 @@ class ofAddon { bool operator <(const ofAddon & addon) const{ return addon.name < name; } - + string addonMakeName; private: string currentParseState { "" }; diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 46b23b38..ad710062 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -259,11 +259,12 @@ bool baseProject::save(){ std::ofstream addonsMake(projectDir / "addons.make"); for (auto & a : addons) { - if (a.isLocalAddon) { - addonsMake << fs::path(a.addonPath).generic_string() << std::endl; - } else { - addonsMake << a.name << std::endl; - } + addonsMake << a.addonMakeName << std::endl; +// if (a.isLocalAddon) { +// addonsMake << fs::path(a.addonPath).generic_string() << std::endl; +// } else { +// addonsMake << a.name << std::endl; +// } } //save out params which the PG knows about to config.make @@ -311,7 +312,7 @@ void baseProject::addAddon(string addonName){ #endif ofAddon addon; - // addon.addonMakeString = addonName; + addon.addonMakeName = addonName; { auto s = ofSplitString(addonName, "#"); @@ -572,10 +573,6 @@ void baseProject::addAddon(ofAddon & addon){ addAddonFrameworks(addon); addAddonXCFrameworks(addon); - -// for (auto & f : addon.xcframeworks) { -// addXCFramework(f); -// } copyAddonData(addon); @@ -593,7 +590,7 @@ void baseProject::addAddonLibsPaths(const ofAddon& addon){ void baseProject::addAddonIncludePaths(const ofAddon& addon){ for (auto & e : addon.includePaths) { fs::path normalizedDir = normalizePath(projectDir); - ofLogVerbose() << "[addon.includePaths] adding addon include path: [" << normalizedDir << "]"; + ofLogVerbose("baseProject") << "[addon.includePaths] adding addon include path: [" << normalizedDir << "]"; if (containsSourceFiles(normalizedDir)) { normalizedDir = makeRelative(projectDir, e); ofLogVerbose() << "[addon.includePaths] contains src - Adding dir: [" << normalizedDir.string() << "]"; @@ -616,28 +613,28 @@ void baseProject::addAddonIncludePaths(const ofAddon& addon){ void baseProject::addAddonLibs(const ofAddon& addon){ for (auto & a : addon.libs) { - ofLogVerbose() << "adding addon libs: " << a.path.string(); + ofLogVerbose("baseProject") << "adding addon libs: " << a.path.string(); addLibrary(a); } } void baseProject::addAddonCflags(const ofAddon& addon){ for (auto & a : addon.cflags) { - ofLogVerbose() << "adding addon cflags: " << a; + ofLogVerbose("baseProject") << "adding addon cflags: " << a; addCFLAG(a); } } void baseProject::addAddonCppflags(const ofAddon& addon){ for (auto & a : addon.cppflags) { - ofLogVerbose() << "adding addon cppflags: " << a; + ofLogVerbose("baseProject") << "adding addon cppflags: " << a; addCPPFLAG(a); } } void baseProject::addAddonLdflags(const ofAddon& addon){ for (auto & a : addon.ldflags) { - ofLogVerbose() << "adding addon ldflags: " << a; + ofLogVerbose("baseProject") << "adding addon ldflags: " << a; addLDFLAG(a); } } @@ -645,7 +642,7 @@ void baseProject::addAddonLdflags(const ofAddon& addon){ void baseProject::addAddonSrcFiles( ofAddon& addon){ for (auto & a : addon.srcFiles) { fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon srcFiles: " << normalizedDir.string(); + ofLogVerbose("baseProject") << "adding addon srcFiles: " << normalizedDir.string(); addSrc(normalizedDir, addon.filesToFolders.at(a)); } } @@ -653,7 +650,7 @@ void baseProject::addAddonSrcFiles( ofAddon& addon){ void baseProject::addAddonCsrcFiles(const ofAddon& addon){ for (auto & a : addon.csrcFiles) { fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon c srcFiles: " << normalizedDir.string(); + ofLogVerbose("baseProject") << "adding addon c srcFiles: " << normalizedDir.string(); addSrc(normalizedDir, addon.filesToFolders.at(a), C); } } @@ -661,7 +658,7 @@ void baseProject::addAddonCsrcFiles(const ofAddon& addon){ void baseProject::addAddonCppsrcFiles(const ofAddon& addon){ for (auto & a : addon.cppsrcFiles) { fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon cpp srcFiles: " << normalizedDir.string(); + ofLogVerbose("baseProject") << "adding addon cpp srcFiles: " << normalizedDir.string(); addSrc(normalizedDir, addon.filesToFolders.at(a),CPP); } } @@ -669,7 +666,7 @@ void baseProject::addAddonCppsrcFiles(const ofAddon& addon){ void baseProject::addAddonObjcsrcFiles(const ofAddon& addon){ for (auto & a : addon.objcsrcFiles) { fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon objc srcFiles: " << normalizedDir.string(); + ofLogVerbose("baseProject") << "adding addon objc srcFiles: " << normalizedDir.string(); addSrc(normalizedDir, addon.filesToFolders.at(a),OBJC); } } @@ -678,7 +675,7 @@ void baseProject::addAddonHeadersrcFiles(const ofAddon& addon){ for (auto & a : addon.headersrcFiles) { fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose() << "adding addon header srcFiles: [" << normalizedDir.string() << "]"; + ofLogVerbose("baseProject") << "adding addon header srcFiles: [" << normalizedDir.string() << "]"; addSrc(normalizedDir, addon.filesToFolders.at(a),HEADER); } } From 8abbe8a174ebf63bbccbcded7ebc70ca219877be Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Tue, 17 Sep 2024 00:18:16 -0300 Subject: [PATCH 06/55] using correct relative paths --- commandLine/src/addons/ofAddon.cpp | 28 +++++++++++++++-------- commandLine/src/projects/xcodeProject.cpp | 3 ++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 90ad23f2..fcc80081 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -349,8 +349,8 @@ void ofAddon::parseVariableValue(const string & variable, const string & value, return; } - fs::path addonRelPath = isLocalAddon ? addonPath : (pathToOF / "addons" / name); - +// fs::path addonRelPath = isLocalAddon ? addonPath : (pathToOF / "addons" / name); + fs::path addonRelPath = makeRelative(addonPath, pathToProject); if (variable == "ADDON_ADDITIONAL_LIBS") { additionalLibsFolder.emplace_back(fs::path { value }); return; @@ -803,7 +803,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo } bool ofAddon::fromFS(const fs::path & path, const string & platform){ - //alert("ofAddon::fromFS path : " + path.string(), 33); + alert("ofAddon::fromFS path : " + path.string(), 33); if (!fs::exists(path)) { return false; @@ -813,7 +813,7 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){ this->platform = platform; addonPath = path; - + name = isLocalAddon ? ofPathToString(path.stem()) : ofPathToString(path.filename()); @@ -826,12 +826,14 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){ for (auto & s : srcFiles) { fs::path folder; + fs::path sFS { fixPath(s) }; + s = sFS; if (isLocalAddon) { - fs::path sFS { s }; +// fs::path sFS { s }; + folder = fs::path { "local_addons" } / fs::relative(sFS.parent_path(), parentFolder); } else { - fs::path sFS { fixPath(s) }; - s = sFS; + folder = fs::relative(sFS.parent_path(), getOFRoot()); } filesToFolders[s] = folder; @@ -855,7 +857,8 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){ if (fs::exists(libsPath)) { getFoldersRecursively(libsPath, libFolders, platform); for (auto & path : libFolders) { - paths.emplace_back( isLocalAddon ? path : fixPath(path) ); +// paths.emplace_back( isLocalAddon ? path : fixPath(path) ); + paths.emplace_back( fixPath(path) ); } } @@ -863,7 +866,8 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){ if (fs::exists(srcPath)) { getFoldersRecursively(srcPath, srcFolders, platform); for (auto & path : srcFolders) { - paths.emplace_back( isLocalAddon ? path : fixPath(path) ); +// paths.emplace_back( isLocalAddon ? path : fixPath(path) ); + paths.emplace_back( fixPath(path) ); } } @@ -938,5 +942,9 @@ fs::path ofAddon::fixPath(const fs::path & path) { but the problem is fs::relative actually calculate symlink paths, modifying filename. which is not good for macos dylibs, like ofxHapPlayer, so I had to replace with the original filename back */ - return normalizePath(( pathToOF / fs::relative(path, getOFRoot()) ).parent_path() / path.filename()); + if(isLocalAddon){ + return normalizePath(( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename()); + }else{ + return normalizePath(( pathToOF / fs::relative(path, getOFRoot()) ).parent_path() / path.filename()); + } } diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index 42ce885e..3fa2bcb5 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -373,7 +373,7 @@ string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::p } void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type){ -// alert ("addSrc " + ofPathToString(srcFile) + " : " + ofPathToString(folder), 31); + alert ("xcodeProject::addSrc " + ofPathToString(srcFile) + " : " + ofPathToString(folder), 31); string ext = ofPathToString(srcFile.extension()); @@ -640,6 +640,7 @@ void xcodeProject::addAddonSrcFiles(ofAddon& addon){ 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)); From 4a75fa633ee09823512f51e51cade1cb2a78047f Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 23 Sep 2024 18:17:52 -0300 Subject: [PATCH 07/55] corrected adddon Relative Path. --- commandLine/src/addons/ofAddon.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index fcc80081..93faa9dc 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -349,8 +349,7 @@ void ofAddon::parseVariableValue(const string & variable, const string & value, return; } -// fs::path addonRelPath = isLocalAddon ? addonPath : (pathToOF / "addons" / name); - fs::path addonRelPath = makeRelative(addonPath, pathToProject); + fs::path addonRelPath = makeRelative(pathToProject, addonPath); if (variable == "ADDON_ADDITIONAL_LIBS") { additionalLibsFolder.emplace_back(fs::path { value }); return; From 351bc846dca8b7d600cf6eaf7c98a87e9b0a721f Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 23 Sep 2024 18:20:05 -0300 Subject: [PATCH 08/55] moved redundant code into single function for adding elements to filesToFolders --- commandLine/src/addons/ofAddon.cpp | 87 +++++++++++++++++------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 93faa9dc..f59dbf78 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -709,6 +709,17 @@ void ofAddon::parseConfig(){ } } +void ofAddon::addToFolder(const fs::path& path, const fs::path & parentFolder){ + + fs::path folder; + if (isLocalAddon) { + folder = fs::path { "local_addons" } / fs::relative(path.parent_path(), parentFolder); + } else { + folder = fs::relative(path.parent_path(), getOFRoot()); + } + filesToFolders[path] = folder; +} + void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFolder) { // alert ("parseLibsPath " + libsPath.string(), 35); if (!fs::exists(libsPath)) { @@ -749,15 +760,16 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo } for (auto & s : libFiles) { - fs::path folder; - if (isLocalAddon) { - folder = fs::path { "local_addons" } / fs::relative(s.parent_path(), parentFolder); - } else { - folder = fs::relative(s.parent_path(), getOFRoot()); - s = fixPath(s); - } + addToFolder(s, parentFolder); +// fs::path folder; +// if (isLocalAddon) { +// folder = fs::path { "local_addons" } / fs::relative(s.parent_path(), parentFolder); +// } else { +// folder = fs::relative(s.parent_path(), getOFRoot()); +// s = fixPath(s); +// } srcFiles.emplace_back(s); - filesToFolders[s] = folder; +// filesToFolders[s] = folder; } // so addons will never be system. @@ -775,29 +787,31 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo ; // do we need to do anything here? } else { // if addon is local, it is relative to the project folder, and if it is not, it is related to the project folder, ex: addons/ofxSvg - fs::path rel = fs::relative (f, isLocalAddon ? pathToProject : pathToOF); - fs::path folder = rel.parent_path(); - - if (isLocalAddon) { - fs::path fFS { f }; - folder = fs::path { "local_addons" } / fs::relative(fFS.parent_path(), parentFolder); - } - - filesToFolders[f] = folder; +// fs::path rel = fs::relative (f, isLocalAddon ? pathToProject : pathToOF); +// fs::path folder = rel.parent_path(); +// +// if (isLocalAddon) { +// fs::path fFS { f }; +// folder = fs::path { "local_addons" } / fs::relative(fFS.parent_path(), parentFolder); +// } +// +// filesToFolders[f] = folder; + addToFolder(f, parentFolder); } } for (const auto & f : xcframeworks) { - fs::path rel = fs::relative(f, isLocalAddon ? pathToProject : pathToOF); - fs::path folder = rel.parent_path(); - - if (isLocalAddon) { - fs::path fFS { f }; - folder = fs::path { "local_addons" } / fs::relative(fFS.parent_path(), parentFolder); - } - - filesToFolders[f] = folder; +// fs::path rel = fs::relative(f, isLocalAddon ? pathToProject : pathToOF); +// fs::path folder = rel.parent_path(); +// +// if (isLocalAddon) { +// fs::path fFS { f }; +// folder = fs::path { "local_addons" } / fs::relative(fFS.parent_path(), parentFolder); +// } +// +// filesToFolders[f] = folder; + addToFolder(f, parentFolder); } } @@ -824,18 +838,19 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){ fs::path parentFolder { path.parent_path() }; for (auto & s : srcFiles) { - fs::path folder; +// fs::path folder; fs::path sFS { fixPath(s) }; s = sFS; - if (isLocalAddon) { -// fs::path sFS { s }; - - folder = fs::path { "local_addons" } / fs::relative(sFS.parent_path(), parentFolder); - } else { - - folder = fs::relative(sFS.parent_path(), getOFRoot()); - } - filesToFolders[s] = folder; + addToFolder(s, parentFolder); +// if (isLocalAddon) { +//// fs::path sFS { s }; +// +// folder = fs::path { "local_addons" } / fs::relative(sFS.parent_path(), parentFolder); +// } else { +// +// folder = fs::relative(sFS.parent_path(), getOFRoot()); +// } +// filesToFolders[s] = folder; } From cae1fe058418f22c15c98584f6b966dc700cc513 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 23 Sep 2024 18:20:45 -0300 Subject: [PATCH 09/55] fixing libraries paths even when it is a local_addon. --- commandLine/src/addons/ofAddon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index f59dbf78..0aa0237d 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -751,13 +751,13 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo // TODO: this is not needed even if it is local addon but project is outside OF root path // Absolute paths will be used in this case too. // Maybe it is the same situation for all others fixPath occurences? - if (!isLocalAddon) { +// if (!isLocalAddon) { for (auto & l : libs) { // alert("fixpath before " + ofPathToString(l.path)); l.path = fixPath(l.path); // alert("fixpath after " + ofPathToString(l.path)); } - } +// } for (auto & s : libFiles) { addToFolder(s, parentFolder); From 4662abc1004f4995a5e973753b8dfffac389ac17 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 23 Sep 2024 18:20:58 -0300 Subject: [PATCH 10/55] cleanup + comments --- commandLine/src/addons/ofAddon.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 0aa0237d..64e6a38b 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -72,7 +72,7 @@ ofAddon::ofAddon(const ofAddon& other) excludeIncludes(other.excludeIncludes), excludeFrameworks(other.excludeFrameworks), excludeXCFrameworks(other.excludeXCFrameworks), - addonMakeName(other.addonMakeName) + addonMakeName(other.addonMakeName) { } @@ -99,7 +99,7 @@ bool ofAddon::checkCorrectVariable(const string & variable, const string & state AddonMetaVariables.end(), variable) != AddonMetaVariables.end(); } - else if (state == "osx") { + else if (state == "osx") {// Why only checking for osx? return std::find(AddonProjectVariables.begin(), AddonProjectVariables.end(), variable) != AddonProjectVariables.end(); @@ -380,14 +380,7 @@ void ofAddon::parseVariableValue(const string & variable, const string & value, } else if(variable == "ADDON_INCLUDES"){ -// if (!addToValue) { -// alert ("CLEAR " + variable, 36); -// alert ("value " + value, 36); -// } -// cout << includePaths.size() << endl; addReplaceStringVectorPathPrefix(includePaths, value, addonRelPath, addToValue); - // cout << includePaths.size() << endl; -// cout << "----" << endl; } else if(variable == ADDON_CFLAGS){ From 47373ed1024aabbde1beb4379baa0749fb764a1e Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 23 Sep 2024 18:21:21 -0300 Subject: [PATCH 11/55] comments --- commandLine/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 8b26d712..d19188ae 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -79,7 +79,7 @@ bool busingEnvVar; bool bVerbose; bool bAddonsPassedIn; bool bForce; // force even if things like ofRoot seem wrong of if update folder looks wonky -pgMode mode; // what mode are we in? +pgMode mode; // what mode are we in? //mode is never set to anything else. this is unnecesary. bool bRecursive; // do we recurse in update mode? bool bHelpRequested; // did we request help? bool bListTemplates; // did we request help? From f0538d2f2a40787e93c5792eb8861a27553a0157 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 23 Sep 2024 18:22:40 -0300 Subject: [PATCH 12/55] setting fs::current_path( to project's path so the paths are relative to it. --- commandLine/src/projects/baseProject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index ad710062..b39b7e43 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -117,7 +117,7 @@ vector baseProject::listAvailableTemplates(string target) bool baseProject::create(const fs::path & _path, string templateName){ // alert("baseProject::create " + path.string() + " : " + templateName, 35); auto path = _path; // just because it is const - + fs::current_path(path); //if the files being added are inside the OF root folder, make them relative to the folder. From 92bd210ebacdfdfbbdb3c3953d1d8d5f795d904a Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Tue, 24 Sep 2024 16:56:50 -0300 Subject: [PATCH 13/55] encapsulating ofAddon loading. --- commandLine/src/addons/ofAddon.cpp | 114 +++++++++++++++++++++++++---- commandLine/src/addons/ofAddon.h | 16 +++- 2 files changed, 113 insertions(+), 17 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 64e6a38b..67b593f5 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -714,7 +714,7 @@ void ofAddon::addToFolder(const fs::path& path, const fs::path & parentFolder){ } void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFolder) { -// alert ("parseLibsPath " + libsPath.string(), 35); + alert ("parseLibsPath " + libsPath.string(), 35); if (!fs::exists(libsPath)) { // alert("file not found " + libsPath.string(), 35); return; @@ -753,13 +753,14 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo // } for (auto & s : libFiles) { + s = fixPath(s); addToFolder(s, parentFolder); // fs::path folder; // if (isLocalAddon) { // folder = fs::path { "local_addons" } / fs::relative(s.parent_path(), parentFolder); // } else { // folder = fs::relative(s.parent_path(), getOFRoot()); -// s = fixPath(s); + // } srcFiles.emplace_back(s); // filesToFolders[s] = folder; @@ -807,28 +808,108 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo addToFolder(f, parentFolder); } } +string ofAddon::cleanName(const string& name){ + auto addonName = name; +#ifdef TARGET_WIN32 + // std::replace( addonName.begin(), addonName.end(), '/', '\\' ); + fixSlashOrder(addonName); +#endif + + { + // in case that addonName contains a comment, get rid of it + auto s = ofSplitString(addonName, "#"); + if(s.size()){ + addonName = s[0]; + } + } + return addonName; +} + +bool ofAddon::load(string addonName, const fs::path& projectDir, const string& targetPlatform){ + // 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 + addonMakeName = addonName; + + addonName = cleanName(addonName); + +// // FIXME : not target, yes platform. +//#ifdef TARGET_WIN32 +// // std::replace( addonName.begin(), addonName.end(), '/', '\\' ); +// fixSlashOrder(addonName); +//#endif +// +// +// addonMakeName = addonName; +// +// { +// // in case that addonName contains a comment, get rid of it +// auto s = ofSplitString(addonName, "#"); +// if(s.size()){ +// addonName = s[0]; +// } +// } +// + + if(addonName.empty()){ + ofLogError("baseProject::addAddon") << "cant add addon with empty name"; + return false; + } + + //This should be the only instance where we check if the addon is either local or not. + //being local just means that the addon name is a filepath and it starts with a dot. + //otherwise it will look in the addons folder. + //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))){ + + addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); + isLocalAddon = true; + ofLogVerbose() << "Adding local addon: " << addonName; + // addon.pathToProject = makeRelative(getOFRoot(), projectDir); + // projectDir; + }else{ + addonPath = fs::path { getOFRoot() / "addons" / addonName }; + } + pathToOF = getOFRoot(); + + + pathToOF = normalizePath(pathToOF); + addonPath = normalizePath(addonPath); + + + pathToProject = projectDir; + + this->platform = targetPlatform; + + ofLogVerbose() << "addonPath to: [" << addonPath.string() << "]"; + ofLogVerbose() << "pathToOF: [" << pathToOF.string() << "]"; + + + return fromFS(); +} + + +bool ofAddon::fromFS(){//const fs::path & path, const string & platform){ + alert("ofAddon::fromFS path : " + addonPath.string(), 33); -bool ofAddon::fromFS(const fs::path & path, const string & platform){ - alert("ofAddon::fromFS path : " + path.string(), 33); - - if (!fs::exists(path)) { + if (!fs::exists(addonPath)) { return false; } clear(); - this->platform = platform; +// this->platform = platform; - addonPath = path; +// addonPath = addonPath; - name = isLocalAddon ? ofPathToString(path.stem()) : ofPathToString(path.filename()); + name = isLocalAddon ? ofPathToString(addonPath.stem()) : ofPathToString(addonPath.filename()); - fs::path srcPath { path / "src" }; + fs::path srcPath { addonPath / "src" }; if (fs::exists(srcPath)) { getFilesRecursively(srcPath, srcFiles); } - fs::path parentFolder { path.parent_path() }; + fs::path parentFolder { addonPath.parent_path() }; for (auto & s : srcFiles) { // fs::path folder; @@ -854,12 +935,15 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){ - fs::path libsPath { path / "libs" }; + fs::path libsPath { addonPath / "libs" }; // paths that are needed for the includes. std::list < fs::path > paths; // get every folder in addon/src and addon/libs + + + vector < fs::path > libFolders; if (fs::exists(libsPath)) { getFoldersRecursively(libsPath, libFolders, platform); @@ -868,6 +952,8 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){ paths.emplace_back( fixPath(path) ); } } + + vector < fs::path > srcFolders; if (fs::exists(srcPath)) { @@ -887,12 +973,12 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){ // lib paths are directories to parse for libs for (auto & a : libsPaths) { // alert(a, 33); - parseLibsPath((path / a), parentFolder); + parseLibsPath((addonPath / a), parentFolder); } for (auto & a : additionalLibsFolder) { // parseLibsPath(fs::weakly_canonical(path / a), parentFolder); - parseLibsPath((path / a), parentFolder); + parseLibsPath((addonPath / a), parentFolder); } paths.sort([](const fs::path & a, const fs::path & b) { diff --git a/commandLine/src/addons/ofAddon.h b/commandLine/src/addons/ofAddon.h index 085c2fdf..32a7ca25 100644 --- a/commandLine/src/addons/ofAddon.h +++ b/commandLine/src/addons/ofAddon.h @@ -121,9 +121,10 @@ class ofAddon { ofAddon() = default; ofAddon(const ofAddon& other); - - bool fromFS(const fs::path & path, const string & platform); - void parseLibsPath(const fs::path & path, const fs::path & parentFolder); + static string cleanName(const string& name); + + bool load(string addonName, const fs::path& projectDir, const string& targetPlatform); + // void fromXML(string installXmlName); @@ -176,7 +177,16 @@ class ofAddon { return addon.name < name; } string addonMakeName; + + + private: + + + bool fromFS(); + void parseLibsPath(const fs::path & path, const fs::path & parentFolder); + + void addToFolder(const fs::path& path, const fs::path & parentFolder); string currentParseState { "" }; string emptyString = { "" }; From 06695f2e0c6ef2dab954d4e15dc9dcb359997319 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Tue, 24 Sep 2024 16:59:18 -0300 Subject: [PATCH 14/55] updating use of ofAddon. --- commandLine/src/projects/baseProject.cpp | 112 +++++++++++++---------- commandLine/src/projects/baseProject.h | 2 +- 2 files changed, 64 insertions(+), 50 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index b39b7e43..074aed61 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -301,26 +301,28 @@ bool baseProject::isAddonInCache(const string & addonPath, const string platform return addonsCache[platform].find(addonPath) != addonsCache[platform].end(); } -void baseProject::addAddon(string addonName){ - ofLogVerbose("baseProject::addAddon") << addonName; +void baseProject::addAddon(const std::string& _addonName){ + ofLogVerbose("baseProject::addAddon") << _addonName; // alert( "baseProject::addAddon " + addonName ); - // FIXME : not target, yes platform. -#ifdef TARGET_WIN32 - // std::replace( addonName.begin(), addonName.end(), '/', '\\' ); - fixSlashOrder(addonName); -#endif - - ofAddon addon; - addon.addonMakeName = addonName; + auto addonName = ofAddon::cleanName(_addonName); - { - auto s = ofSplitString(addonName, "#"); - if(s.size()){ - addonName = s[0]; - } - } + // FIXME : not target, yes platform. +//#ifdef TARGET_WIN32 +// // std::replace( addonName.begin(), addonName.end(), '/', '\\' ); +// fixSlashOrder(addonName); +//#endif +// +// addon.addonMakeName = addonName; +// +// { +// auto s = ofSplitString(addonName, "#"); +// if(s.size()){ +// addonName = s[0]; +// } +// } +// if(addonName.empty()){ ofLogError("baseProject::addAddon") << "cant add addon with empty name"; @@ -333,27 +335,29 @@ void baseProject::addAddon(string addonName){ //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))){ - - addon.addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); - addon.isLocalAddon = true; - ofLogVerbose() << "Adding local addon: " << addonName; - // addon.pathToProject = makeRelative(getOFRoot(), projectDir); - // projectDir; - }else{ - addon.addonPath = fs::path { getOFRoot() / "addons" / addonName }; - } - addon.pathToOF = getOFRoot(); - - - - addon.pathToOF = normalizePath(addon.pathToOF); - addon.addonPath = normalizePath(addon.addonPath); +// if(addonName[0] == '.' && fs::exists( ofFilePath::join(projectDir, addonName))){ +// +// addon.addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); +// addon.isLocalAddon = true; +// ofLogVerbose() << "Adding local addon: " << addonName; +// // addon.pathToProject = makeRelative(getOFRoot(), projectDir); +// // projectDir; +// }else{ +// addon.addonPath = fs::path { getOFRoot() / "addons" / addonName }; +// } +// addon.pathToOF = getOFRoot(); +// +// +// +// addon.pathToOF = normalizePath(addon.pathToOF); +// addon.addonPath = normalizePath(addon.addonPath); +// +// addon.pathToProject = projectDir; - addon.pathToProject = projectDir; + ofAddon addon; - bool addonOK = false; - bool inCache = isAddonInCache(addonName, target); +// bool addonOK = false; +// bool inCache = isAddonInCache(addonName, target); // fs::path addonPath { addonName }; @@ -365,25 +369,35 @@ void baseProject::addAddon(string addonName){ // addon.addonPath = addonPath; // } - ofLogVerbose() << "addon.addonPath to: [" << addon.addonPath.string() << "]"; - ofLogVerbose() << "addon.pathToOF: [" << addon.pathToOF.string() << "]"; +// ofLogVerbose() << "addon.addonPath to: [" << addon.addonPath.string() << "]"; +// ofLogVerbose() << "addon.pathToOF: [" << addon.pathToOF.string() << "]"; - if (!inCache) { - addonOK = addon.fromFS(addon.addonPath, target); - } else { + if(isAddonInCache(addonName, target)){ addon = addonsCache[target][addonName]; - addonOK = true; + }else{ + if(addon.load(_addonName, projectDir, target)){ + addonsCache[target][addonName] = addon; + }else{ + ofLogVerbose("baseProject::addAddon") << "Ignoring addon that doesn't seem to exist: " << _addonName; + return; //if addon does not exist, stop early + } } +// if (!inCache) { +// addonOK = addon.fromFS(addon.addonPath, target); +// } else { +// addon = addonsCache[target][addonName]; +// addonOK = true; +// } - if(!addonOK){ - ofLogVerbose() << "Ignoring addon that doesn't seem to exist: " << addonName; - return; //if addon does not exist, stop early - } +// if(!addonOK){ +// ofLogVerbose() << "Ignoring addon that doesn't seem to exist: " << addonName; +// return; //if addon does not exist, stop early +// } - if(!inCache){ - //cache the addon so we dont have to be reading form disk all the time - addonsCache[target][addonName] = addon; - } +// if(!inCache){ +// //cache the addon so we dont have to be reading form disk all the time +// addonsCache[target][addonName] = addon; +// } // // for (auto & a : addons) { // if (a.name == addon.name) return; diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index 89eca6ba..1c2b19fb 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -53,7 +53,7 @@ class baseProject { bool save(); - void addAddon(std::string addon); + void addAddon(const std::string& addon); void addAddon(ofAddon & addon); virtual void addSrcRecursively(const fs::path & srcPath); From 7113d7c2f0d71c28cb04cd436a4f92062b21b5f3 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Tue, 24 Sep 2024 17:49:53 -0300 Subject: [PATCH 15/55] fixes to getFolderUUID so it properly handles local addons --- commandLine/src/projects/xcodeProject.cpp | 160 ++++++++++++++-------- commandLine/src/projects/xcodeProject.h | 2 +- 2 files changed, 103 insertions(+), 59 deletions(-) diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index 3fa2bcb5..cfffc961 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -243,9 +243,23 @@ 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){ + alert("getPathTo "+ p.string(), 33); + return p; + } + } + return p; +} + + // FIXME: Double check if isFolder is even being used. Remove it if not -string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::path base) { -// alert ("xcodeProject::getFolderUUID "+folder.string()+" : isfolder="+ofToString(isFolder)+" : base="+ base.string()); +string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, bool isFolder, fs::path base) { +// alert ("xcodeProject::getFolderUUID "+folder.string());//+" : isfolder="+ofToString(isFolder)+" : base="+ base.string()); // TODO: Change key of folderUUID to base + folder, so "src" in additional source folders // doesn't get confused with "src" from project. @@ -266,6 +280,8 @@ string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::p if (folders.size()){ // Iterating every folder from full path + + for (std::size_t a = 0; a < folders.size(); a++) { fs::path fullPath{""}; @@ -279,7 +295,8 @@ string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::p 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 if ( folderUUID.find(fullPath) != folderUUID.end() ) { @@ -288,6 +305,7 @@ string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::p } else { + string thisUUID = generateUUID(fullPath); folderUUID[fullPath] = thisUUID; folderFromUUID[thisUUID] = fullPath; @@ -297,67 +315,81 @@ string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::p addCommand("Add :objects:"+thisUUID+":name string " + folderName); // FIXME: Inspect if this is really being used - if (isFolder) { - alert("getFolderUUID, isFolder INSIDE " , 31); - fs::path filePath; - fs::path filePath_full { relRoot / fullPath }; - // FIXME: known issue: doesn't handle files with spaces in name. - - if (fs::exists(filePath_full)) { - filePath = filePath_full; - } - if (fs::exists(fullPath)) { - filePath = fullPath; - } - - if (!filePath.empty()) { - addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(filePath)); - } else { - } - } else { -// alert("getFolderUUID isFolder false", 31); - } +// if (isFolder) { +// alert("getFolderUUID, isFolder INSIDE " , 31); +// fs::path filePath; +// fs::path filePath_full { relRoot / fullPath }; +// // FIXME: known issue: doesn't handle files with spaces in name. +// +// if (fs::exists(filePath_full)) { +// filePath = filePath_full; +// } +// if (fs::exists(fullPath)) { +// filePath = fullPath; +// } +// +// if (!filePath.empty()) { +// addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(filePath)); +// } else { +// } +// } else { +//// alert("getFolderUUID isFolder false", 31); +// } addCommand("Add :objects:"+thisUUID+":isa string PBXGroup"); - + + + bool bFolderPathSet = false; + if (folderName == "external_sources" || folderName == "local_addons") { - addCommand("Add :objects:"+thisUUID+":sourceTree string "); + + addCommand("Add :objects:"+thisUUID+":sourceTree string SOURCE_ROOT"); + addCommand("Add :objects:"+thisUUID+":path string "); + bFolderPathSet = true; } - else { - if (lastFolderUUID == projRootUUID || - lastFolder == "external_sources" || lastFolder == "local_addons") { // - -// alert ("external_sources base = " + ofPathToString(base), 33); - - // Base folders can be in a different depth, - // so we cut folders to point to the right path - fs::path base2 { base }; - 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(addonFolder)); +// fs::path addonFolder { fs::path(fullPath).filename() }; + addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(fullPath.filename())); + bFolderPathSet = true; } } addCommand("Add :objects:"+thisUUID+":children array"); - - if (folder.begin()->string() == "addons" || folder.begin()->string() == "src") { - addCommand("Add :objects:"+thisUUID+":sourceTree string "); - fs::path addonFolder { fs::path(fullPath).filename() }; - addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(addonFolder)); - // 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); @@ -373,7 +405,7 @@ string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::p } void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type){ - alert ("xcodeProject::addSrc " + ofPathToString(srcFile) + " : " + ofPathToString(folder), 31); +// alert ("xcodeProject::addSrc " + ofPathToString(srcFile) + " : " + ofPathToString(folder), 31); string ext = ofPathToString(srcFile.extension()); @@ -718,7 +750,7 @@ void xcodeProject::addAddonXCFrameworks(const ofAddon& addon){ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, const fileProperties & fp) { - alert("addFile " + ofPathToString(path) + " : " + ofPathToString(folder) , 31); +// alert("addFile " + ofPathToString(path) + " : " + ofPathToString(folder) , 31); string UUID { "" }; @@ -770,7 +802,19 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); } } else { - addCommand("Add :objects:"+UUID+":sourceTree string "); + + 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"); +// }else{ +// if (fs::exists( projectDir / path )) { +// addCommand("Add :objects:"+UUID+":path string " + ofPathToString(projectDir /path)); +// } +// } + }else{ + addCommand("Add :objects:"+UUID+":sourceTree string "); + } } // string folderUUID; @@ -785,7 +829,7 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con // } // Eventually remove isFolder and base parameter - std::string folderUUID { getFolderUUID(folder, isFolder) }; + std::string folderUUID { getFolderUUID(folder, path)};//, isFolder) }; addCommand("# ---- addFileToFolder UUID : " + ofPathToString(folder)); diff --git a/commandLine/src/projects/xcodeProject.h b/commandLine/src/projects/xcodeProject.h index 8f878416..2ee5ff01 100644 --- a/commandLine/src/projects/xcodeProject.h +++ b/commandLine/src/projects/xcodeProject.h @@ -99,7 +99,7 @@ class xcodeProject : public baseProject { // Temporary std::map folderFromUUID ; - string getFolderUUID(const fs::path & folder, 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 = "../../.."; From e0860d1e05ac9df4f7aaa519d71181ff668d3930 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Tue, 24 Sep 2024 17:51:24 -0300 Subject: [PATCH 16/55] Horrible hack to properly parse libs and frameworks on when these use macos instead of osx --- commandLine/src/addons/ofAddon.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 67b593f5..6834d808 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -720,11 +720,29 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo return; } - getLibsRecursively(libsPath, libFiles, libs, platform); - if (platform == "osx" || + + if (platform == "osx" || platform == "macos"){ + // Horrible hack to make it work with the bad idea of renaming osx to macos + 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"); + + + + }else{ + + getLibsRecursively(libsPath, libFiles, libs, platform); + } + + if (//platform == "osx" || platform == "ios" || - platform == "tvos" || - platform == "macos"){ + platform == "tvos"){//} || + //platform == "macos"){ + getFrameworksRecursively(libsPath, frameworks, platform); getXCFrameworksRecursively(libsPath, xcframeworks, platform); } From 87c6fe62b2d543be2c43431484fbd47f9e7439d1 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 25 Sep 2024 19:50:44 -0300 Subject: [PATCH 17/55] dont remove comments from the addons in addons.make file --- commandLine/src/projects/baseProject.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 074aed61..b7372a32 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -293,6 +293,7 @@ bool baseProject::save(){ saveConfig << str << std::endl; } } + saveAddonsToJson(); return saveProjectFile(); } @@ -541,7 +542,7 @@ void baseProject::addAddon(ofAddon & addon){ unless there is one addon added which needs another, and it needs another. */ - alert("---> dependencies"); +// alert("---> dependencies"); for (auto & d : addon.dependencies) { bool found = false; for (auto & a : addons) { @@ -557,7 +558,7 @@ void baseProject::addAddon(ofAddon & addon){ ofLogVerbose() << "trying to add duplicated addon dependency! skipping: " << d; } } - alert("---> dependencies"); +// alert("---> dependencies"); addons.emplace_back(addon); ofLogVerbose("baseProject") << "libs in addAddon " << addon.libs.size(); @@ -687,7 +688,6 @@ void baseProject::addAddonObjcsrcFiles(const ofAddon& addon){ void baseProject::addAddonHeadersrcFiles(const ofAddon& addon){ for (auto & a : addon.headersrcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); ofLogVerbose("baseProject") << "adding addon header srcFiles: [" << normalizedDir.string() << "]"; addSrc(normalizedDir, addon.filesToFolders.at(a),HEADER); @@ -746,8 +746,10 @@ void baseProject::parseAddons(){ // alert("line " + addon); if(addon[0] == '#') continue; if(addon == "") continue; - auto s = ofSplitString(addon, "#")[0]; - addAddon(ofSplitString(addon, "#")[0]); +// auto s = ofSplitString(addon, "#")[0]; +// addAddon(ofSplitString(addon, "#")[0]); + //we want to keep the comments in the addons.make file since those are use in the package manage + addAddon(addon); } } From 26160d3b95585167070658cd511a50801482fc6b Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 25 Sep 2024 20:01:03 -0300 Subject: [PATCH 18/55] added json output for ofAddon class. moslty for development debugging purposes. --- commandLine/src/addons/ofAddon.h | 7 +++++++ commandLine/src/defines.h | 4 ++++ commandLine/src/projects/baseProject.cpp | 2 ++ commandLine/src/projects/baseProject.h | 15 ++++++++++++--- commandLine/src/utils/LibraryBinary.h | 17 +++++++++++++++-- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/commandLine/src/addons/ofAddon.h b/commandLine/src/addons/ofAddon.h index 32a7ca25..f4d1fe0d 100644 --- a/commandLine/src/addons/ofAddon.h +++ b/commandLine/src/addons/ofAddon.h @@ -13,6 +13,7 @@ #include #include + namespace fs = of::filesystem; using std::string; using std::vector; @@ -237,4 +238,10 @@ class ofAddon { return fs::path(""); } } + +#ifdef OFADDON_OUTPUT_JSON_DEBUG +public: + + NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(ofAddon, additionalLibsFolder, libFiles, filesToFolders, srcFiles, csrcFiles, cppsrcFiles, headersrcFiles, objcsrcFiles, propsFiles, libs, dllsToCopy, includePaths, libsPaths, dependencies, cflags, cppflags, ldflags, pkgConfigLibs, frameworks, xcframeworks, data, defines, definesCMAKE, name, addonPath, description, author, tags, url, pathToOF, pathToProject, isLocalAddon, addonMakeName, currentParseState, platform, excludeLibs, excludeSources, excludeIncludes, excludeFrameworks, excludeXCFrameworks) +#endif }; diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 502100af..5951a6a1 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -3,3 +3,7 @@ #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) + + +// Uncomment this line to generate a json file with all the data parsed and contained on each ofAddon instance. This is only for development debugging. +//#define OFADDON_OUTPUT_JSON_DEBUG diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index b7372a32..ad54fdcb 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -293,7 +293,9 @@ bool baseProject::save(){ saveConfig << str << std::endl; } } +#ifdef OFADDON_OUTPUT_JSON_DEBUG saveAddonsToJson(); +#endif return saveProjectFile(); } diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index 1c2b19fb..6f46c00f 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -81,9 +81,18 @@ class baseProject { bool bOverwrite = true; - - - +#ifdef OFADDON_OUTPUT_JSON_DEBUG + void saveAddonsToJson(){ + auto dir = ofFilePath::join(projectDir, "addonsJson"); + ofDirectory::createDirectory(dir, false, true); + + for(auto& a: addons){ + ofJson j = a; + ofSavePrettyJson(ofFilePath::join(dir, a.name+".json"), j); + } + } +#endif + // this shouldn't be called by anyone. call "create(...), save" etc private: diff --git a/commandLine/src/utils/LibraryBinary.h b/commandLine/src/utils/LibraryBinary.h index 8e38f485..bcbe31d8 100644 --- a/commandLine/src/utils/LibraryBinary.h +++ b/commandLine/src/utils/LibraryBinary.h @@ -3,11 +3,19 @@ #include #include + #include "ofConstants.h" -namespace fs = of::filesystem; +#include "defines.h" -struct LibraryBinary { +#ifdef OFADDON_OUTPUT_JSON_DEBUG // defined in defines.h. only for dev debugging +#include "ofJson.h" +#endif +namespace fs = of::filesystem; + +class LibraryBinary { +public: + LibraryBinary(){} LibraryBinary(fs::path p, std::string a, std::string t) { path = p; arch = a; @@ -19,4 +27,9 @@ struct LibraryBinary { static const std::vector archs; static const std::vector targets; + +#ifdef OFADDON_OUTPUT_JSON_DEBUG + NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(LibraryBinary, path, arch, target) +#endif + }; From c254a2cc193a43cb4b3cfff174482c2d6b82f9ac Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 25 Sep 2024 20:01:30 -0300 Subject: [PATCH 19/55] removed some alerts --- commandLine/src/addons/ofAddon.cpp | 2 +- commandLine/src/utils/Utils.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 6834d808..b7b91845 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -714,7 +714,7 @@ void ofAddon::addToFolder(const fs::path& path, const fs::path & parentFolder){ } void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFolder) { - alert ("parseLibsPath " + libsPath.string(), 35); +// alert ("parseLibsPath " + libsPath.string(), 35); if (!fs::exists(libsPath)) { // alert("file not found " + libsPath.string(), 35); return; diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index e9782a9d..755988b0 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -365,7 +365,7 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil // alert ("target " + target, 34); // if (!fs::exists(path) || !fs::is_directory(path)) return; if (!fs::exists(path) || !fs::is_directory(path)) { -// alert ("not found!"); + alert ("getLibsRecursively: path not found!" + path.string(), 31); return; } @@ -418,6 +418,11 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil } } } + + for(const auto& l: libLibs){ + alert(l.path , 35); + } + } string convertStringToWindowsSeparator(string in) { From a5258269077804846bf071e3450737f7dd0da748 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 25 Sep 2024 22:37:11 -0300 Subject: [PATCH 20/55] removing duplicates --- commandLine/src/addons/ofAddon.cpp | 4 +++- commandLine/src/utils/Utils.h | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index b7b91845..feb1696f 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -731,7 +731,9 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo getXCFrameworksRecursively(libsPath, xcframeworks, "macos"); getXCFrameworksRecursively(libsPath, xcframeworks, "osx"); - + removeDuplicates(libFiles); + removeDuplicates(frameworks); + removeDuplicates(xcframeworks); }else{ diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index b76e875b..a734d3a0 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -12,6 +12,7 @@ #include "ofLog.h" #include "ofSystemUtils.h" #include "baseProject.h" +#include struct LibraryBinary; std::string execute_popen(const char* cmd); @@ -102,6 +103,31 @@ inline bool isInVector(T item, std::vector & vec){ return bIsInVector; } + +inline void removeDuplicates(std::vector & vec){ + std::unordered_set seen; + std::vector output; + + for (const auto& value : vec) { + if (seen.insert(value).second) { // If insertion is successful (element not seen before) + output.push_back(value); + } + } + vec = std::move(output); +} + +inline void removeDuplicates(std::vector & vec){ + std::unordered_set seen; + std::vector output; + + for (const auto& value : vec) { + if (seen.insert(value.string()).second) { // If insertion is successful (element not seen before) + output.emplace_back(value); + } + } + vec = std::move(output); +} + string colorText(const string & s, int color = 32); void alert(string msg, int color=32); From df541089d0946acdbfc8d248cfdbc4dc1b41fb75 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 25 Sep 2024 23:36:00 -0300 Subject: [PATCH 21/55] changing LibraryBinary from struct to class --- commandLine/src/utils/Utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index a734d3a0..b1e31669 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -13,7 +13,7 @@ #include "ofSystemUtils.h" #include "baseProject.h" #include -struct LibraryBinary; +class LibraryBinary; std::string execute_popen(const char* cmd); From bb6b022cc97c023f9683f7ba65d6bd447adddf96 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 25 Sep 2024 23:38:55 -0300 Subject: [PATCH 22/55] remove unnecesary alert --- commandLine/src/utils/Utils.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 755988b0..41993edb 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -418,11 +418,6 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil } } } - - for(const auto& l: libLibs){ - alert(l.path , 35); - } - } string convertStringToWindowsSeparator(string in) { From 1677f28bd44943aee923a3e26c87d6c30499d271 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Sun, 29 Sep 2024 17:51:49 -0300 Subject: [PATCH 23/55] Removed noARC flag as it is being added improperly to some objc files. --- commandLine/src/projects/xcodeProject.cpp | 41 +++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index 5722d529..bcf5e47b 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -459,24 +459,29 @@ void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, Src } void xcodeProject::addCompileFlagsForMMFile(const fs::path & srcFile) { - std::ifstream file(srcFile); - std::string line; - bool containsARCFunctions = false; -#if __APPLE__ - std::regex arcRegex(R"(\b(alloc|dealloc)\b)"); - - while (std::getline(file, line)) { - if (std::regex_search(line, arcRegex)) { - containsARCFunctions = true; - break; - } - } -#endif - if (containsARCFunctions) { - for (auto & c : buildConfigs) { - addCommand("Add :objects:"+c+":buildSettings:OTHER_CPLUSPLUSFLAGS: string -fno-objc-arc"); - } - } + + // 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; +//#if __APPLE__ +// std::regex arcRegex(R"(\b(alloc|dealloc)\b)"); +// +// while (std::getline(file, line)) { +// if (std::regex_search(line, arcRegex)) { +// containsARCFunctions = true; +// break; +// } +// } +//#endif +// if (containsARCFunctions) { +// for (auto & c : buildConfigs) { +// addCommand("Add :objects:"+c+":buildSettings:OTHER_CPLUSPLUSFLAGS: string -fno-objc-arc"); +// } +// } + } From 6b323079bb78b4354b150dc328a4483620877c53 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Sun, 29 Sep 2024 20:52:28 -0300 Subject: [PATCH 24/55] ofAddon: removed fromFS function and parsing name before normalizing the addon's path --- commandLine/src/addons/ofAddon.cpp | 14 ++++++-------- commandLine/src/addons/ofAddon.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index feb1696f..3db36d2b 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -905,24 +905,22 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t ofLogVerbose() << "pathToOF: [" << pathToOF.string() << "]"; - return fromFS(); -} +// return fromFS(); +//} -bool ofAddon::fromFS(){//const fs::path & path, const string & platform){ +//bool ofAddon::fromFS(){//const fs::path & path, const string & platform){ alert("ofAddon::fromFS path : " + addonPath.string(), 33); if (!fs::exists(addonPath)) { + ofLogVerbose("ofAddon::load") << "addon does not exist!" << addonPath; return false; } clear(); -// this->platform = platform; - -// addonPath = addonPath; + fs::path addonNamePath { addonName}; - - name = isLocalAddon ? ofPathToString(addonPath.stem()) : ofPathToString(addonPath.filename()); + name = isLocalAddon ? ofPathToString(addonNamePath.stem()) : ofPathToString(addonNamePath.filename()); fs::path srcPath { addonPath / "src" }; if (fs::exists(srcPath)) { diff --git a/commandLine/src/addons/ofAddon.h b/commandLine/src/addons/ofAddon.h index f4d1fe0d..4cff4d7f 100644 --- a/commandLine/src/addons/ofAddon.h +++ b/commandLine/src/addons/ofAddon.h @@ -184,7 +184,7 @@ class ofAddon { private: - bool fromFS(); +// bool fromFS(); void parseLibsPath(const fs::path & path, const fs::path & parentFolder); void addToFolder(const fs::path& path, const fs::path & parentFolder); From ebc0a3fcb5fc42e0e0d21fe516ab926fc46c32cf Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Thu, 3 Oct 2024 17:56:53 -0300 Subject: [PATCH 25/55] removing redundant virtual declaration of functions that already have override declared --- commandLine/src/projects/CBWinProject.h | 22 +++++++------- commandLine/src/projects/VSCodeProject.h | 22 +++++++------- commandLine/src/projects/android2024.h | 22 +++++++------- .../src/projects/androidStudioProject.h | 22 +++++++------- commandLine/src/projects/qtcreatorproject.h | 24 +++++++-------- .../src/projects/visualStudioProject.h | 22 +++++++------- commandLine/src/projects/xcodeProject.h | 30 +++++++++---------- 7 files changed, 81 insertions(+), 83 deletions(-) diff --git a/commandLine/src/projects/CBWinProject.h b/commandLine/src/projects/CBWinProject.h index 8f97c0e8..5e79bc59 100644 --- a/commandLine/src/projects/CBWinProject.h +++ b/commandLine/src/projects/CBWinProject.h @@ -13,19 +13,19 @@ class CBWinProject: public baseProject { public: CBWinProject(const std::string & target) : baseProject(target) {}; - virtual bool createProjectFile() override; - virtual bool loadProjectFile() override; - virtual bool saveProjectFile() override; + bool createProjectFile() override; + bool loadProjectFile() override; + bool saveProjectFile() override; - virtual void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT) override; - virtual void addInclude(const fs::path & includeName) override; - virtual void addLibrary(const LibraryBinary & lib) override; + void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT) override; + void addInclude(const fs::path & includeName) override; + void addLibrary(const LibraryBinary & lib) override; - virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} - virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} - virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} - virtual void addAfterRule(const std::string& script) override {} - virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + void addAfterRule(const std::string& script) override {} + void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} static std::string LOG_NAME; diff --git a/commandLine/src/projects/VSCodeProject.h b/commandLine/src/projects/VSCodeProject.h index a4e14809..d70cb57e 100644 --- a/commandLine/src/projects/VSCodeProject.h +++ b/commandLine/src/projects/VSCodeProject.h @@ -13,19 +13,19 @@ class VSCodeProject: public baseProject { public: VSCodeProject(const std::string & target) : baseProject(target) {}; - virtual bool createProjectFile() override; - virtual bool loadProjectFile() override; - virtual bool saveProjectFile() override; + bool createProjectFile() override; + bool loadProjectFile() override; + bool saveProjectFile() override; - virtual void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT) override; - virtual void addInclude(const fs::path & includeName) override; - virtual void addLibrary(const LibraryBinary & lib) override; + void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT) override; + void addInclude(const fs::path & includeName) override; + void addLibrary(const LibraryBinary & lib) override; - virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} - virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} - virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} - virtual void addAfterRule(const std::string& script) override {} - virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + void addAfterRule(const std::string& script) override {} + void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} void addAddon(ofAddon & addon) ; diff --git a/commandLine/src/projects/android2024.h b/commandLine/src/projects/android2024.h index 9bd8fd3b..a0a99247 100644 --- a/commandLine/src/projects/android2024.h +++ b/commandLine/src/projects/android2024.h @@ -6,19 +6,19 @@ class android2024Project : public baseProject { public: android2024Project(const std::string & target); - virtual bool createProjectFile() override; - virtual void addInclude(const fs::path & includeName) override {} - virtual void addLibrary(const LibraryBinary & lib) override {} - virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override {}; - virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} - virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} - virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} - virtual void addAfterRule(const std::string& script) override {} - virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + bool createProjectFile() override; + void addInclude(const fs::path & includeName) override {} + void addLibrary(const LibraryBinary & lib) override {} + void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override {}; + void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + void addAfterRule(const std::string& script) override {} + void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} - virtual bool loadProjectFile() override { return false; }; - virtual bool saveProjectFile() override { return false; }; + bool loadProjectFile() override { return false; }; + bool saveProjectFile() override { return false; }; static std::string LOG_NAME; }; diff --git a/commandLine/src/projects/androidStudioProject.h b/commandLine/src/projects/androidStudioProject.h index 47e91da8..c76e7b97 100644 --- a/commandLine/src/projects/androidStudioProject.h +++ b/commandLine/src/projects/androidStudioProject.h @@ -6,18 +6,18 @@ class AndroidStudioProject : public baseProject { public: AndroidStudioProject(const std::string & target); - virtual bool createProjectFile() override; - virtual void addInclude(const fs::path & includeName) override {} - virtual void addLibrary(const LibraryBinary & lib) override {} - virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override {}; - virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} - virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} - virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} - virtual void addAfterRule(const std::string& script) override {} - virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + bool createProjectFile() override; + void addInclude(const fs::path & includeName) override {} + void addLibrary(const LibraryBinary & lib) override {} + void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override {}; + void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + void addAfterRule(const std::string& script) override {} + void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} - virtual bool loadProjectFile() override { return false; }; - virtual bool saveProjectFile() override { return false; }; + bool loadProjectFile() override { return false; }; + bool saveProjectFile() override { return false; }; static std::string LOG_NAME; }; diff --git a/commandLine/src/projects/qtcreatorproject.h b/commandLine/src/projects/qtcreatorproject.h index fb35e026..b7a5670a 100644 --- a/commandLine/src/projects/qtcreatorproject.h +++ b/commandLine/src/projects/qtcreatorproject.h @@ -8,21 +8,19 @@ class QtCreatorProject : public baseProject { public: QtCreatorProject(const std::string & target); - virtual bool createProjectFile() override; - virtual void addInclude(const fs::path & includeName) override {} - virtual void addLibrary(const LibraryBinary & lib)override{} - virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; + bool createProjectFile() override; + void addInclude(const fs::path & includeName) override {} + void addLibrary(const LibraryBinary & lib)override{} + void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; - virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} - virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} - virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} - virtual void addAfterRule(const std::string& script) override {} - virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + void addAfterRule(const std::string& script) override {} + void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} - - - virtual bool loadProjectFile() override; - virtual bool saveProjectFile() override; + bool loadProjectFile() override; + bool saveProjectFile() override; static std::string LOG_NAME; private: diff --git a/commandLine/src/projects/visualStudioProject.h b/commandLine/src/projects/visualStudioProject.h index f54eae0a..51dafa48 100644 --- a/commandLine/src/projects/visualStudioProject.h +++ b/commandLine/src/projects/visualStudioProject.h @@ -7,20 +7,20 @@ class visualStudioProject : public baseProject { public: visualStudioProject(const std::string & target) : baseProject(target) {}; - virtual bool createProjectFile() override; - virtual bool loadProjectFile() override; - virtual bool saveProjectFile() override; + bool createProjectFile() override; + bool loadProjectFile() override; + bool saveProjectFile() override; - virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; - virtual void addInclude(const fs::path & includeName) override; + void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; + void addInclude(const fs::path & includeName) override; void addProps(fs::path propsFile); - virtual void addLibrary(const LibraryBinary & lib)override; - virtual void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override ; // C - virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override ; // C++ - virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override ; + void addLibrary(const LibraryBinary & lib)override; + void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override ; // C + void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override ; // C++ + void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override ; - virtual void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} - virtual void addAfterRule(const std::string& script) override {} + void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + void addAfterRule(const std::string& script) override {} void ensureDllDirectoriesExist() ; diff --git a/commandLine/src/projects/xcodeProject.h b/commandLine/src/projects/xcodeProject.h index 2ee5ff01..456cf186 100644 --- a/commandLine/src/projects/xcodeProject.h +++ b/commandLine/src/projects/xcodeProject.h @@ -12,9 +12,9 @@ class xcodeProject : public baseProject { xcodeProject(const string & target); private: - virtual bool createProjectFile() override; - virtual bool loadProjectFile() override; - virtual bool saveProjectFile() override; + bool createProjectFile() override; + bool loadProjectFile() override; + bool saveProjectFile() override; void saveMakefile(); bool debugCommands = false; @@ -22,21 +22,21 @@ class xcodeProject : public baseProject { protected: - virtual void addAddonFrameworks(const ofAddon& addon) override ; - virtual void addAddonXCFrameworks(const ofAddon& addon) override ; - virtual void addAddonLibs(const ofAddon& addon) override; - virtual void addAddonSrcFiles( 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; - virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) override; - virtual void addInclude(const fs::path & includeName) override; - virtual void addLibrary(const LibraryBinary & lib) override; - virtual void addLDFLAG(const string& ldflag, LibType libType = RELEASE_LIB) override; - virtual void addCFLAG(const string& cflag, LibType libType = RELEASE_LIB) override; // Other C Flag overrides - virtual void addCPPFLAG(const string& cppflag, LibType libType = RELEASE_LIB) override; // Other C++ Flag overrides - virtual void addAfterRule(const string& script) override; - virtual void addDefine(const string& define, LibType libType = RELEASE_LIB) 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; + void addLDFLAG(const string& ldflag, LibType libType = RELEASE_LIB) override; + void addCFLAG(const string& cflag, LibType libType = RELEASE_LIB) override; // Other C Flag overrides + void addCPPFLAG(const string& cppflag, LibType libType = RELEASE_LIB) override; // Other C++ Flag overrides + void addAfterRule(const string& script) override; + 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); From abe0e5bd15eb2aec67e40dea140aeb54c9ff02ea Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 7 Oct 2024 19:05:32 -0300 Subject: [PATCH 26/55] Update defines.h bump version to differentiate --- commandLine/src/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 5951a6a1..b88c0dca 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "78" +#define OFPROJECTGENERATOR_MINOR_VERSION "79" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) From a136c43329ed93a804d4e13eb4ac0cb4e3e069e9 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:19:53 -0300 Subject: [PATCH 27/55] adding addon stuff in virtual functions --- commandLine/src/projects/baseProject.cpp | 19 +++++++++++----- commandLine/src/projects/baseProject.h | 29 +++++++++++++----------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index ad54fdcb..4cf0a425 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -563,7 +563,9 @@ void baseProject::addAddon(ofAddon & addon){ // alert("---> dependencies"); addons.emplace_back(addon); - ofLogVerbose("baseProject") << "libs in addAddon " << addon.libs.size(); + //ofLogVerbose("baseProject") << "libs in addAddon " << addon.libs.size(); + + addAddonBegin(addon); addAddonDllsToCopy(addon); @@ -582,17 +584,15 @@ void baseProject::addAddon(ofAddon & addon){ - for (auto & a : addon.defines) { - ofLogVerbose() << "adding addon defines: [" << a << "]"; - addDefine(a); - } - + addAddonDefines(addon); addAddonFrameworks(addon); addAddonXCFrameworks(addon); copyAddonData(addon); + addAddonProps(addon); + } @@ -628,6 +628,13 @@ void baseProject::addAddonIncludePaths(const ofAddon& addon){ // } } +void baseProject::addAddonDefines(const ofAddon& addon) { + for (auto & a : addon.defines) { + ofLogVerbose() << "adding addon defines: [" << a << "]"; + addDefine(a); + } +} + void baseProject::addAddonLibs(const ofAddon& addon){ for (auto & a : addon.libs) { ofLogVerbose("baseProject") << "adding addon libs: " << a.path.string(); diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index 6f46c00f..fb85a2cd 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -109,19 +109,22 @@ class baseProject { virtual void addAddonFrameworks(const ofAddon& addon){} virtual void addAddonXCFrameworks(const ofAddon& addon){} - virtual void addAddonLibsPaths(const ofAddon& addon); - virtual void addAddonIncludePaths(const ofAddon& addon); - virtual void addAddonLibs(const ofAddon& addon); - virtual void addAddonCflags(const ofAddon& addon); - virtual void addAddonCppflags(const ofAddon& addon); - virtual void addAddonLdflags(const ofAddon& addon); - virtual void addAddonSrcFiles(ofAddon& addon); - virtual void addAddonCsrcFiles(const ofAddon& addon); - virtual void addAddonCppsrcFiles(const ofAddon& addon); - virtual void addAddonObjcsrcFiles(const ofAddon& addon); - virtual void addAddonHeadersrcFiles(const ofAddon& addon); - virtual void addAddonDllsToCopy(ofAddon& addon); - + virtual void addAddonBegin(const ofAddon& addon){} + virtual void addAddonLibsPaths(const ofAddon& addon); + virtual void addAddonIncludePaths(const ofAddon& addon); + virtual void addAddonLibs(const ofAddon& addon); + virtual void addAddonCflags(const ofAddon& addon); + virtual void addAddonCppflags(const ofAddon& addon); + virtual void addAddonLdflags(const ofAddon& addon); + virtual void addAddonSrcFiles(ofAddon& addon); + virtual void addAddonCsrcFiles(const ofAddon& addon); + virtual void addAddonCppsrcFiles(const ofAddon& addon); + virtual void addAddonObjcsrcFiles(const ofAddon& addon); + virtual void addAddonHeadersrcFiles(const ofAddon& addon); + virtual void addAddonDllsToCopy(ofAddon& addon); + virtual void addAddonDefines(const ofAddon& addon); + + virtual addAddonProps(const ofAddon& addon) {}; virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) = 0; virtual void addInclude(const fs::path & includeName) = 0; From 082bbda5ec2f317cb95c9ab5f943ac314fbb03fd Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:20:19 -0300 Subject: [PATCH 28/55] srcType to string --- commandLine/src/projects/baseProject.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index fb85a2cd..2c9b33d9 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -31,6 +31,22 @@ class baseProject { KOTLIN }; + std::string toString(SrcType type){ + switch(type){ + case DEFAULT: return "DEFAULT"; + case HEADER: return "HEADER"; + case CPP: return "CPP"; + case C: return "C"; + case OBJC: return "OBJC"; + case METAL: return "METAL"; + case SWIFT: return "SWIFT"; + case JAVA: return "JAVA"; + case KOTLIN: return "KOTLIN"; + } + return ""; + } + + struct Template { // ofDirectory dir; fs::path dir; @@ -140,7 +156,8 @@ class baseProject { void copyAddonData(ofAddon& addon); - + virtual void addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder = true); + void recursiveCopyContents(const fs::path & srcDir, const fs::path & destDir); From cf7d4b87dbf89222d60cc3fc408bc7c1d4e5bdb4 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:21:03 -0300 Subject: [PATCH 29/55] Moved a lot of redundant code into virtual function --- commandLine/src/projects/baseProject.cpp | 86 +++++++++++++++--------- 1 file changed, 56 insertions(+), 30 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 4cf0a425..3f87a57c 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -663,45 +663,71 @@ void baseProject::addAddonLdflags(const ofAddon& addon){ } } +void baseProject::addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder){ + for (auto &s : filepaths) { + if (bFindInFilesToFolder && (addon.filesToFolders.find(s) == addon.filesToFolders.end())) { + addon.filesToFolders[s] = fs::path{""}; + } + fs::path normalizedDir = makeRelative(getOFRoot(), a); + ofLogVerbose("baseProject::addSrcFiles") << "Adding addon " << toString(type) << " source file: [" << s.string() << "] folder:[" << addon.filesToFolders[s].string() << "]"; + addSrc(normalizedDir, addon.filesToFolders[s]); + } +} + void baseProject::addAddonSrcFiles( ofAddon& addon){ - for (auto & a : addon.srcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose("baseProject") << "adding addon srcFiles: " << normalizedDir.string(); - addSrc(normalizedDir, addon.filesToFolders.at(a)); - } + addSrcFiles(addon, addon.srcFiles, DEFAULT); + + // for (auto & a : addon.srcFiles) { + // fs::path normalizedDir = makeRelative(getOFRoot(), a); + // ofLogVerbose("baseProject") << "adding addon srcFiles: " << normalizedDir.string(); + // addSrc(normalizedDir, addon.filesToFolders.at(a)); + // } } void baseProject::addAddonCsrcFiles(const ofAddon& addon){ - for (auto & a : addon.csrcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose("baseProject") << "adding addon c srcFiles: " << normalizedDir.string(); - addSrc(normalizedDir, addon.filesToFolders.at(a), C); - } + // for (auto & a : addon.csrcFiles) { + // fs::path normalizedDir = makeRelative(getOFRoot(), a); + // ofLogVerbose("baseProject") << "adding addon c srcFiles: " << normalizedDir.string(); + // addSrc(normalizedDir, addon.filesToFolders.at(a), C); + // } + addSrcFiles(addon, addon.csrcFiles, C); } -void baseProject::addAddonCppsrcFiles(const ofAddon& addon){ - for (auto & a : addon.cppsrcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose("baseProject") << "adding addon cpp srcFiles: " << normalizedDir.string(); - addSrc(normalizedDir, addon.filesToFolders.at(a),CPP); - } -} -void baseProject::addAddonObjcsrcFiles(const ofAddon& addon){ - for (auto & a : addon.objcsrcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose("baseProject") << "adding addon objc srcFiles: " << normalizedDir.string(); - addSrc(normalizedDir, addon.filesToFolders.at(a),OBJC); - } -} -void baseProject::addAddonHeadersrcFiles(const ofAddon& addon){ - for (auto & a : addon.headersrcFiles) { - fs::path normalizedDir = makeRelative(getOFRoot(), a); - ofLogVerbose("baseProject") << "adding addon header srcFiles: [" << normalizedDir.string() << "]"; - addSrc(normalizedDir, addon.filesToFolders.at(a),HEADER); - } +void baseProject::addAddonCppsrcFiles(const ofAddon& addon) { + addSrcFiles(addon, addon.cppsrcFiles, CPP); } +void baseProject::addAddonObjcsrcFiles(const ofAddon& addon) { + addSrcFiles(addon, addon.objcsrcFiles, OBJC); +} +void baseProject::addAddonHeadersrcFiles(const ofAddon& addon) { + addSrcFiles(addon, addon.headersrcFiles, HEADER); +} + +// void baseProject::addAddonCppsrcFiles(const ofAddon& addon){ +// for (auto & a : addon.cppsrcFiles) { +// fs::path normalizedDir = makeRelative(getOFRoot(), a); +// ofLogVerbose("baseProject") << "adding addon cpp srcFiles: " << normalizedDir.string(); +// addSrc(normalizedDir, addon.filesToFolders.at(a),CPP); +// } +// } + +// void baseProject::addAddonObjcsrcFiles(const ofAddon& addon){ +// for (auto & a : addon.objcsrcFiles) { +// fs::path normalizedDir = makeRelative(getOFRoot(), a); +// ofLogVerbose("baseProject") << "adding addon objc srcFiles: " << normalizedDir.string(); +// addSrc(normalizedDir, addon.filesToFolders.at(a),OBJC); +// } +// } + +// void baseProject::addAddonHeadersrcFiles(const ofAddon& addon){ +// for (auto & a : addon.headersrcFiles) { +// fs::path normalizedDir = makeRelative(getOFRoot(), a); +// ofLogVerbose("baseProject") << "adding addon header srcFiles: [" << normalizedDir.string() << "]"; +// addSrc(normalizedDir, addon.filesToFolders.at(a),HEADER); +// } +// } From d9f7018f89bb294cba287d634cabc10d2108bb7b Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:21:56 -0300 Subject: [PATCH 30/55] removed ofRelativeToOFPATH which was useless --- commandLine/src/projects/baseProject.cpp | 11 ++++--- commandLine/src/utils/Utils.cpp | 40 ++++++++++++------------ commandLine/src/utils/Utils.h | 2 +- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 3f87a57c..31313801 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -567,7 +567,6 @@ void baseProject::addAddon(ofAddon & addon){ addAddonBegin(addon); - addAddonDllsToCopy(addon); addAddonLibsPaths(addon); @@ -599,6 +598,9 @@ void baseProject::addAddon(ofAddon & addon){ void baseProject::addAddonLibsPaths(const ofAddon& addon){ + if(addon.libsPaths.size()){ + ofLogWarning("baseProject::addAddonLibsPaths") << "this is not implemented!"; + } for (auto & lib: addon.libsPaths){ ofLogVerbose("adding lib paths") << lib.string(); } @@ -606,13 +608,14 @@ void baseProject::addAddonLibsPaths(const ofAddon& addon){ void baseProject::addAddonIncludePaths(const ofAddon& addon){ for (auto & e : addon.includePaths) { + ofLogVerbose("baseProject") << "----------------------------------------------------------------"; fs::path normalizedDir = normalizePath(projectDir); - ofLogVerbose("baseProject") << "[addon.includePaths] adding addon include path: [" << normalizedDir << "]"; + ofLogVerbose("baseProject") << "[addon.includePaths] adding addon include path: [" << e.string() << "]"; if (containsSourceFiles(normalizedDir)) { normalizedDir = makeRelative(projectDir, e); ofLogVerbose() << "[addon.includePaths] contains src - Adding dir: [" << normalizedDir.string() << "]"; - fs::path ofpathChanged = ofRelativeToOFPATH(projectDir); - ofLogVerbose() << "[addon.includePaths] OFPATH: rel include dir: [" << ofpathChanged.string() << "]"; + // fs::path ofpathChanged = ofRelativeToOFPATH(projectDir); + // ofLogVerbose() << "[addon.includePaths] OFPATH: rel include dir: [" << ofpathChanged.string() << "]"; addInclude(normalizedDir); } else { diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 41993edb..1d50c81b 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -691,26 +691,26 @@ bool containsSourceFiles(const fs::path& dir) { } -fs::path ofRelativeToOFPATH(const fs::path& path) { - try { - fs::path normalized_path = path; - std::string path_str = normalized_path.string(); -#ifdef TARGET_WIN32 - std::regex relative_pattern(R"((\.\.\\\.\.\\\.\.\\)|(\.\.\\\.\.\\\.\.))"); -#else - std::regex relative_pattern(R"((\.\.\/\.\.\/\.\.\/))"); -#endif - path_str = std::regex_replace(path_str, relative_pattern, "$(OF_PATH)/"); -#ifdef TARGET_WIN32 - fixSlashOrderPath(normalized_path); -#endif - return normalized_path; - } catch (const std::exception& ex) { - std::cout << "Canonical path for [" << path << "] threw exception:\n" - << ex.what() << '\n'; - return fs::path(""); - } -} +// fs::path ofRelativeToOFPATH(const fs::path& path) { +// try { +// fs::path normalized_path = path; +// std::string path_str = normalized_path.string(); +// #ifdef TARGET_WIN32 +// std::regex relative_pattern(R"((\.\.\\\.\.\\\.\.\\)|(\.\.\\\.\.\\\.\.))"); +// #else +// std::regex relative_pattern(R"((\.\.\/\.\.\/\.\.\/))"); +// #endif +// path_str = std::regex_replace(path_str, relative_pattern, "$(OF_PATH)/"); +// #ifdef TARGET_WIN32 +// fixSlashOrderPath(normalized_path); +// #endif +// return normalized_path; +// } catch (const std::exception& ex) { +// std::cout << "Canonical path for [" << path << "] threw exception:\n" +// << ex.what() << '\n'; +// return fs::path(""); +// } +// } diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index b1e31669..ede4f33a 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -147,7 +147,7 @@ std::string normalizePath(const std::string& path); fs::path normalizePath(const fs::path& path); bool containsSourceFiles(const fs::path& dir); -fs::path ofRelativeToOFPATH(const fs::path& path); +// fs::path ofRelativeToOFPATH(const fs::path& path); /* Idea: create an object to hold the origin and destination files, with renames where needed From f42d113ea2b1c5ca57cac909778dc3933abfff17 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:23:49 -0300 Subject: [PATCH 31/55] made a single function from to almost identical ones --- .../src/projects/visualStudioProject.cpp | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index ac255c9d..f0464a26 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -347,43 +347,41 @@ void visualStudioProject::addInclude(const fs::path & includeName){ //appendValue(doc, "Add", "directory", includeName); } -void addLibraryPath(const pugi::xpath_node_set & nodes, string libFolder) { -// alert ("addLibraryPath " + libFolder); +void addToNode(const pugi::xpath_node_set & nodes, string item) { for (auto & node : nodes) { string includes = node.node().first_child().value(); std::vector < string > strings = ofSplitString(includes, ";"); bool bAdd = true; for (size_t i = 0; i < strings.size(); i++) { - if (strings[i].compare(libFolder) == 0) { + if (strings[i].compare(item) == 0) { bAdd = false; + break; } } if (bAdd == true) { - strings.emplace_back(libFolder); - string libPathsNew = unsplitString(strings, ";"); - node.node().first_child().set_value(libPathsNew.c_str()); + strings.emplace_back(item); + node.node().first_child().set_value(unsplitString(strings, ";").c_str()); } } } -void addLibraryName(const pugi::xpath_node_set & nodes, string libName) { - for (auto & node : nodes) { - string includes = node.node().first_child().value(); - std::vector < string > strings = ofSplitString(includes, ";"); - bool bAdd = true; - for (size_t i = 0; i < strings.size(); i++) { - if (strings[i].compare(libName) == 0) { - bAdd = false; - } - } - - if (bAdd == true) { - strings.emplace_back(libName); - string libsNew = unsplitString(strings, ";"); - node.node().first_child().set_value(libsNew.c_str()); - } - } -} +// void addLibraryName(const pugi::xpath_node_set & nodes, string lib) { +// for (auto & node : nodes) { +// string includes = node.node().first_child().value(); +// std::vector < string > strings = ofSplitString(includes, ";"); +// bool bAdd = true; +// for (size_t i = 0; i < strings.size(); i++) { +// if (strings[i].compare(lib) == 0) { +// bAdd = false; +// } +// } +// if (bAdd == true) { +// strings.emplace_back(lib); +// string libNew = unsplitString(strings, ";"); +// node.node().first_child().set_value(libNew.c_str()); +// } +// } +// } void visualStudioProject::addProps(fs::path propsFile){ // alert ("visualStudioProject::addProps " + propsFile.string()); @@ -432,14 +430,14 @@ void visualStudioProject::addLibrary(const LibraryBinary & lib) { if (!libFolderString.empty()) { pugi::xpath_node_set addlLibsDir = doc.select_nodes((linkPath + "AdditionalLibraryDirectories").c_str()); ofLogVerbose() << "adding " << lib.arch << " lib path " << linkPath; - addLibraryPath(addlLibsDir, libFolderString); + addToNode(addlLibsDir, libFolderString); } pugi::xpath_node_set addlDeps = doc.select_nodes((linkPath + "AdditionalDependencies").c_str()); - addLibraryName(addlDeps, libName.string()); + addToNode(addlDeps, libName.string()); - ofLogVerbose() << "adding lib path " << libFolder; - ofLogVerbose() << "adding lib " << libName; + ofLogVerbose("visualStudioProject::addLibrary") << "adding lib path " << libFolder; + ofLogVerbose("visualStudioProject::addLibrary") << "adding lib " << libName; } From 382a5871442dd94b3a614ec64ab3663d612b80c7 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:26:10 -0300 Subject: [PATCH 32/55] removing a lot of redundat code and properly overriding funcs --- .../src/projects/visualStudioProject.cpp | 165 +++++++++--------- .../src/projects/visualStudioProject.h | 20 ++- 2 files changed, 96 insertions(+), 89 deletions(-) diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index f0464a26..6a432255 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -530,9 +530,11 @@ void visualStudioProject::ensureDllDirectoriesExist() { -void visualStudioProject::addAddon(ofAddon &addon) { +// void visualStudioProject::addAddon(ofAddon &addon) { + +void visualStudioProject::addAddonBegin(const ofAddon& addon){ // Log the addition of the addon - ofLogVerbose() << "Adding addon: [" << addon.name << "]"; + ofLogVerbose("visualStudioProject::") << "Adding addon: [" << addon.name << "]"; // Handle additional vcxproj files in the addon fs::path additionalFolder = addon.addonPath / (addon.name + "Lib"); if (fs::exists(additionalFolder)) { @@ -543,91 +545,10 @@ void visualStudioProject::addAddon(ofAddon &addon) { } } } +} + - // Add props files from the addon - for (auto &props : addon.propsFiles) { - fs::path normalizedDir = makeRelative(projectDir, props); - ofLogVerbose() << "Adding addon props: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders[props].string() << "]"; - addProps(normalizedDir); - } - - // Add libraries from the addon - for (auto &lib : addon.libs) { - fs::path normalizedDir = makeRelative(projectDir, lib.path); - lib.path = normalizedDir; - ofLogVerbose() << "Adding addon library: [" << lib.path.string() << "]"; - addLibrary(lib); - } - - // Add source files to the project, avoiding excessive directory nesting - for (auto &s : addon.srcFiles) { - fs::path normalizedDir = makeRelative(projectDir, s); - - if (addon.filesToFolders.find(s) == addon.filesToFolders.end()) { - addon.filesToFolders[s] = fs::path{""}; - } - ofLogVerbose() << "Adding addon source file: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders[s].string() << "]"; - addSrc(normalizedDir, addon.filesToFolders[s]); - } - - // Add C source files to the project - for (auto &a : addon.csrcFiles) { - fs::path normalizedDir = makeRelative(projectDir, a); - - if (addon.filesToFolders.find(a) == addon.filesToFolders.end()) { - addon.filesToFolders[a] = fs::path{""}; - } - ofLogVerbose() << "Adding addon C source file: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders[a].string() << "]"; - addSrc(normalizedDir, addon.filesToFolders[a], C); - } - - // Add C++ source files to the project - for (auto &a : addon.cppsrcFiles) { - fs::path normalizedDir = makeRelative(projectDir, a); - - if (addon.filesToFolders.find(a) == addon.filesToFolders.end()) { - addon.filesToFolders[a] = fs::path{""}; - } - ofLogVerbose() << "Adding addon C++ source file: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders[a].string() << "]"; - addSrc(normalizedDir, addon.filesToFolders[a], CPP); - } - - // Add Objective-C source files to the project - for (auto &a : addon.objcsrcFiles) { - fs::path normalizedDir = makeRelative(projectDir, a); - - if (addon.filesToFolders.find(a) == addon.filesToFolders.end()) { - addon.filesToFolders[a] = fs::path{""}; - } - ofLogVerbose() << "Adding addon Objective-C source file ?: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders[a].string() << "]"; - addSrc(normalizedDir, addon.filesToFolders[a], OBJC); - } - - // Add header files to the project - for (auto &a : addon.headersrcFiles) { - fs::path normalizedDir = makeRelative(projectDir, a); - ofLogVerbose() << "Adding addon header file: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders[a].string() << "]"; - addSrc(normalizedDir, addon.filesToFolders[a], HEADER); - } - - // Add CFLAGS, CPPFLAGS, and defines from the addon - for (auto &a : addon.cflags) { - ofLogVerbose() << "Adding addon CFLAG: [" << a << "]"; - addCFLAG(a, RELEASE_LIB); - addCFLAG(a, DEBUG_LIB); - } - - for (auto &a : addon.cppflags) { - ofLogVerbose() << "Adding addon CPPFLAG: [" << a << "]"; - addCPPFLAG(a, RELEASE_LIB); - addCPPFLAG(a, DEBUG_LIB); - } - - for (auto &a : addon.defines) { - ofLogVerbose() << "Adding addon define: [" << a << "]"; - addDefine(a, RELEASE_LIB); - addDefine(a, DEBUG_LIB); - } +void visualStudioProject::addAddonIncludePaths(const ofAddon& addon) { std::set uniqueIncludeDirs; for (const auto &dir : addon.includePaths) { @@ -656,4 +577,76 @@ void visualStudioProject::addAddon(ofAddon &addon) { } } } +// void visualStudioProject::addAddonLibs(const ofAddon& addon) { +// // Add libraries from the addon +// for (auto &lib : addon.libs) { +// fs::path normalizedDir = makeRelative(projectDir, lib.path); +// lib.path = normalizedDir; +// ofLogVerbose() << "Adding addon library: [" << lib.path.string() << "]"; +// addLibrary(lib); +// } +// } +void visualStudioProject::addAddonCflags(const ofAddon& addon) { + for (auto &a : addon.cflags) { + ofLogVerbose() << "Adding addon CFLAG: [" << a << "]"; + addCFLAG(a, RELEASE_LIB); + addCFLAG(a, DEBUG_LIB); + } +} +void visualStudioProject::addAddonCppflags(const ofAddon& addon) { + for (auto &a : addon.cppflags) { + ofLogVerbose() << "Adding addon CPPFLAG: [" << a << "]"; + addCPPFLAG(a, RELEASE_LIB); + addCPPFLAG(a, DEBUG_LIB); + } +} +// void visualStudioProject::addAddonLdflags(const ofAddon& addon) { + +// } + +void visualStudioProject::addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder){ + for (auto &s : filepaths) { + + if (bFindInFilesToFolder && (addon.filesToFolders.find(s) == addon.filesToFolders.end())) { + addon.filesToFolders[s] = fs::path{""}; + } + ofLogVerbose("visualStudioProject::addSrcFiles") << "Adding addon " << toString(type) << " source file: [" << s.string() << "] folder:[" << addon.filesToFolders[s].string() << "]"; + addSrc(s, addon.filesToFolders[s]); + } +} + +// void visualStudioProject::addAddonSrcFiles(ofAddon& addon) { +// addSrcFiles(addon, addon.srcFiles, DEFAULT); +// } +// void visualStudioProject::addAddonCsrcFiles(const ofAddon& addon) { +// addSrcFiles(addon, addon.csrcFiles, C); +// } + +// void visualStudioProject::addAddonCppsrcFiles(const ofAddon& addon) { +// addSrcFiles(addon, addon.cppsrcFiles, CPP); +// } +// void visualStudioProject::addAddonObjcsrcFiles(const ofAddon& addon) { +// addSrcFiles(addon, addon.objcsrcFiles, OBJC); +// } +// void visualStudioProject::addAddonHeadersrcFiles(const ofAddon& addon) { +// addSrcFiles(addon, addon.headersrcFiles, HEADER); +// } + +void visualStudioProject::addAddonDefines(const ofAddon& addon){ + for (auto &a : addon.defines) { + ofLogVerbose() << "Adding addon define: [" << a << "]"; + addDefine(a, RELEASE_LIB); + addDefine(a, DEBUG_LIB); + } +} + + +void visualStudioProject::addAddonProps(const ofAddon& addon){ + // Add props files from the addon + for (auto &props : addon.propsFiles) { + fs::path normalizedDir = makeRelative(projectDir, props); + ofLogVerbose() << "Adding addon props: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders[props].string() << "]"; + addProps(normalizedDir); + } +} diff --git a/commandLine/src/projects/visualStudioProject.h b/commandLine/src/projects/visualStudioProject.h index 51dafa48..3528ad83 100644 --- a/commandLine/src/projects/visualStudioProject.h +++ b/commandLine/src/projects/visualStudioProject.h @@ -23,8 +23,20 @@ class visualStudioProject : public baseProject { void addAfterRule(const std::string& script) override {} - void ensureDllDirectoriesExist() ; - void addAddon(ofAddon & addon) ; + + void addAddonIncludePaths(const ofAddon& addon) override; + + void addAddonCflags(const ofAddon& addon) override; + void addAddonCppflags(const ofAddon& addon) override; + + void addAddonDefines(const ofAddon& addon) override; + void addAddonDllsToCopy(ofAddon& addon) override; + void addAddonProps(const ofAddon& addon) override; + + void addAddonBegin(const ofAddon& addon) override; + + + void ensureDllDirectoriesExist() ; static std::string LOG_NAME; @@ -34,6 +46,8 @@ class visualStudioProject : public baseProject { vector additionalvcxproj; fs::path solution; -private: +protected: + void addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder = true) override; + }; From d506085ed705fbe505024299a0afd4b04273a618 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:26:44 -0300 Subject: [PATCH 33/55] alerts and etc. --- commandLine/src/projects/visualStudioProject.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index 6a432255..829b5178 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -214,7 +214,8 @@ void visualStudioProject::appendFilter(string folderName){ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type){ -// alert("addSrc " + srcFile.string(), 35); + alert("addSrc file: " + srcFile.string(), 35); + alert("addSrc folder: " + folder.string(), 35); // I had an empty ClCompile field causing errors if (srcFile.empty()) { @@ -321,9 +322,10 @@ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & fold } void visualStudioProject::addInclude(const fs::path & includeName){ -// alert ("visualStudioProject::addInclude " + includeName, 35); + alert ("visualStudioProject::addInclude " + includeName.string(), 35); string inc = includeName.string(); fixSlashOrder(inc); + alert ("visualStudioProject::addInclude " + inc, 35); pugi::xpath_node_set source = doc.select_nodes("//ClCompile/AdditionalIncludeDirectories"); for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){ @@ -334,6 +336,7 @@ void visualStudioProject::addInclude(const fs::path & includeName){ for (size_t i = 0; i < strings.size(); i++){ if (strings[i].compare(includeName.string()) == 0){ bAdd = false; + break; } } if (bAdd == true){ @@ -401,7 +404,7 @@ void visualStudioProject::addLibrary(const LibraryBinary & lib) { auto libraryName = fs::path { lib.path }; auto libFolder = libraryName.parent_path(); string libFolderString = libFolder.string(); - fixSlashOrder(libFolderString); + // fixSlashOrder(libFolderString); auto libName = libraryName.filename(); // Determine the correct link path based on the target and architecture @@ -474,7 +477,8 @@ void visualStudioProject::addCPPFLAG(const string& cppflag, LibType libType){ if(libType==RELEASE_LIB && condition.find("Debug") != string::npos){ additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); found = true; - }else if(libType==DEBUG_LIB && condition.find("Release") != string::npos){ + } + else if(libType==DEBUG_LIB && condition.find("Release") != string::npos) { additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); found = true; } From 35663f468c2731cd8138295f409837e1ad4bec84 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:27:00 -0300 Subject: [PATCH 34/55] cleanup --- commandLine/src/addons/ofAddon.cpp | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 3db36d2b..87a12d2d 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -630,12 +630,7 @@ void ofAddon::preParseConfig(){ } void ofAddon::parseConfig(){ -// alert ("ofAddon::parseConfig " + addonPath.string(), 33); - fs::path fileName = -// isLocalAddon ? -// (pathToProject / addonPath / "addon_config.mk") : - (addonPath / "addon_config.mk") - ; + fs::path fileName = (addonPath / "addon_config.mk"); if (!fs::exists(fileName)) { // ofLogError() << "ofAddon::parseConfig() " << fileName << " not found " << ofPathToString(fileName); @@ -851,24 +846,6 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t addonName = cleanName(addonName); -// // FIXME : not target, yes platform. -//#ifdef TARGET_WIN32 -// // std::replace( addonName.begin(), addonName.end(), '/', '\\' ); -// fixSlashOrder(addonName); -//#endif -// -// -// addonMakeName = addonName; -// -// { -// // in case that addonName contains a comment, get rid of it -// auto s = ofSplitString(addonName, "#"); -// if(s.size()){ -// addonName = s[0]; -// } -// } -// - if(addonName.empty()){ ofLogError("baseProject::addAddon") << "cant add addon with empty name"; return false; From f2bd861ab90e420c6203489047a0598316165f41 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:32:26 -0300 Subject: [PATCH 35/55] fixed typo --- commandLine/src/projects/baseProject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index 2c9b33d9..2e7a9689 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -140,7 +140,7 @@ class baseProject { virtual void addAddonDllsToCopy(ofAddon& addon); virtual void addAddonDefines(const ofAddon& addon); - virtual addAddonProps(const ofAddon& addon) {}; + virtual void addAddonProps(const ofAddon& addon) {}; virtual void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT) = 0; virtual void addInclude(const fs::path & includeName) = 0; From c9414064ff574031561689c57ae6eae924a32bec Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:56:59 -0300 Subject: [PATCH 36/55] removed unneded func override --- commandLine/src/projects/visualStudioProject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/projects/visualStudioProject.h b/commandLine/src/projects/visualStudioProject.h index 3528ad83..cc670bbf 100644 --- a/commandLine/src/projects/visualStudioProject.h +++ b/commandLine/src/projects/visualStudioProject.h @@ -30,7 +30,7 @@ class visualStudioProject : public baseProject { void addAddonCppflags(const ofAddon& addon) override; void addAddonDefines(const ofAddon& addon) override; - void addAddonDllsToCopy(ofAddon& addon) override; + void addAddonProps(const ofAddon& addon) override; void addAddonBegin(const ofAddon& addon) override; From 3c87dd90955755abb2dd546261bbbfb1ca911ce7 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:57:48 -0300 Subject: [PATCH 37/55] removed const from a bunc of functions --- commandLine/src/projects/baseProject.cpp | 8 ++++---- commandLine/src/projects/baseProject.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 31313801..488dc9b1 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -687,7 +687,7 @@ void baseProject::addAddonSrcFiles( ofAddon& addon){ // } } -void baseProject::addAddonCsrcFiles(const ofAddon& addon){ +void baseProject::addAddonCsrcFiles(ofAddon& addon){ // for (auto & a : addon.csrcFiles) { // fs::path normalizedDir = makeRelative(getOFRoot(), a); // ofLogVerbose("baseProject") << "adding addon c srcFiles: " << normalizedDir.string(); @@ -698,13 +698,13 @@ void baseProject::addAddonCsrcFiles(const ofAddon& addon){ -void baseProject::addAddonCppsrcFiles(const ofAddon& addon) { +void baseProject::addAddonCppsrcFiles(ofAddon& addon) { addSrcFiles(addon, addon.cppsrcFiles, CPP); } -void baseProject::addAddonObjcsrcFiles(const ofAddon& addon) { +void baseProject::addAddonObjcsrcFiles(ofAddon& addon) { addSrcFiles(addon, addon.objcsrcFiles, OBJC); } -void baseProject::addAddonHeadersrcFiles(const ofAddon& addon) { +void baseProject::addAddonHeadersrcFiles(ofAddon& addon) { addSrcFiles(addon, addon.headersrcFiles, HEADER); } diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index 2e7a9689..e7b28675 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -133,10 +133,10 @@ class baseProject { virtual void addAddonCppflags(const ofAddon& addon); virtual void addAddonLdflags(const ofAddon& addon); virtual void addAddonSrcFiles(ofAddon& addon); - virtual void addAddonCsrcFiles(const ofAddon& addon); - virtual void addAddonCppsrcFiles(const ofAddon& addon); - virtual void addAddonObjcsrcFiles(const ofAddon& addon); - virtual void addAddonHeadersrcFiles(const ofAddon& addon); + virtual void addAddonCsrcFiles( ofAddon& addon); + virtual void addAddonCppsrcFiles( ofAddon& addon); + virtual void addAddonObjcsrcFiles( ofAddon& addon); + virtual void addAddonHeadersrcFiles( ofAddon& addon); virtual void addAddonDllsToCopy(ofAddon& addon); virtual void addAddonDefines(const ofAddon& addon); From 490bbf1c33c7b0de0d496bedee9497b8a02db1c9 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Wed, 9 Oct 2024 23:57:58 -0300 Subject: [PATCH 38/55] fix typo --- commandLine/src/projects/baseProject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 488dc9b1..5fad85d7 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -671,7 +671,7 @@ void baseProject::addSrcFiles(ofAddon& addon, const vector &filepaths, if (bFindInFilesToFolder && (addon.filesToFolders.find(s) == addon.filesToFolders.end())) { addon.filesToFolders[s] = fs::path{""}; } - fs::path normalizedDir = makeRelative(getOFRoot(), a); + fs::path normalizedDir = makeRelative(getOFRoot(), s); ofLogVerbose("baseProject::addSrcFiles") << "Adding addon " << toString(type) << " source file: [" << s.string() << "] folder:[" << addon.filesToFolders[s].string() << "]"; addSrc(normalizedDir, addon.filesToFolders[s]); } From 47325ff9662ccf5ae6874dbb69dfd575b90d5d26 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Thu, 10 Oct 2024 00:03:18 -0300 Subject: [PATCH 39/55] using at instead of [] --- commandLine/src/projects/visualStudioProject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index 829b5178..3a2f66d7 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -649,7 +649,7 @@ void visualStudioProject::addAddonProps(const ofAddon& addon){ // Add props files from the addon for (auto &props : addon.propsFiles) { fs::path normalizedDir = makeRelative(projectDir, props); - ofLogVerbose() << "Adding addon props: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders[props].string() << "]"; + ofLogVerbose() << "Adding addon props: [" << normalizedDir.string() << "] folder:[" << addon.filesToFolders.at(props).string() << "]"; addProps(normalizedDir); } } From 631f4c60ba992af05fb1d564c4d897f8383430b8 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Thu, 10 Oct 2024 00:04:17 -0300 Subject: [PATCH 40/55] dont remove path variable if not found so the IDE/compiler deals with it --- commandLine/src/addons/ofAddon.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 87a12d2d..20873bd9 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -152,8 +152,10 @@ void ofAddon::addReplaceStringVector(std::vector &variable, const s } else if (!ofGetEnv(varName.c_str()).empty()) { varValue = ofGetEnv(varName.c_str()); } - ofStringReplace(val, "$(" + varName + ")", varValue); - ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << val; + if(!varValue.empty()){ + ofStringReplace(val, "$(" + varName + ")", varValue); + ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << val; + } } } @@ -192,8 +194,10 @@ void ofAddon::addReplaceStringVectorPathStr(std::vector &variable, fs: } else if (!ofGetEnv(varName.c_str()).empty()) { varValue = ofGetEnv(varName.c_str()); } - ofStringReplace(val, "$(" + varName + ")", varValue); - ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << val; + if(!varValue.empty()){ + ofStringReplace(val, "$(" + varName + ")", varValue); + ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << val; + } } } @@ -242,8 +246,10 @@ void ofAddon::addReplaceStringVectorPathAll(std::vector & variable, fs } else if (!ofGetEnv(varName.c_str()).empty()) { varValue = ofGetEnv(varName.c_str()); } - ofStringReplace(val, "$(" + varName + ")", varValue); - ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << val; + if(!varValue.empty()){ + ofStringReplace(val, "$(" + varName + ")", varValue); + ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << val; + } } } @@ -279,8 +285,10 @@ void ofAddon::addReplaceStringVectorPath(std::vector &variable, c } else if (!ofGetEnv(varName.c_str()).empty()) { varValue = ofGetEnv(varName.c_str()); } - ofStringReplace(v, "$(" + varName + ")", varValue); - ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << v; + if(!varValue.empty()){ + ofStringReplace(v, "$(" + varName + ")", varValue); + ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << v; + } } } @@ -317,8 +325,10 @@ void ofAddon::addReplaceStringVectorLibrary(std::vector &variable } else if (!ofGetEnv(varName.c_str()).empty()) { varValue = ofGetEnv(varName.c_str()); } - ofStringReplace(v, "$(" + varName + ")", varValue); - ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << v; + if(!varValue.empty()){ + ofStringReplace(v, "$(" + varName + ")", varValue); + ofLogVerbose("ofAddon") << "addon config: substituting " << varName << " with " << varValue << " = " << v; + } } } From 6c246c7c6854b26cf1ba1c7e805edc557b12f32e Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Thu, 10 Oct 2024 00:04:29 -0300 Subject: [PATCH 41/55] cleanup --- commandLine/src/addons/ofAddon.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 20873bd9..3be193ae 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -573,10 +573,6 @@ void ofAddon::excludeLibrary(vector & variables, vector e void ofAddon::preParseConfig(){ // alert ("ofAddon::parseConfig " + addonPath.string(), 33); fs::path fileName = (addonPath / "addon_config.mk"); -// isLocalAddon ? -// (pathToProject / addonPath / "addon_config.mk") : -// (addonPath / "addon_config.mk") -// ; if (!fs::exists(fileName)) { // ofLogError() << "ofAddon::parseConfig() " << fileName << " not found " << ofPathToString(fileName); @@ -643,7 +639,6 @@ void ofAddon::parseConfig(){ fs::path fileName = (addonPath / "addon_config.mk"); if (!fs::exists(fileName)) { -// ofLogError() << "ofAddon::parseConfig() " << fileName << " not found " << ofPathToString(fileName); return; } From 15db75056c3b2065cedb08d286461fae833d348c Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Thu, 10 Oct 2024 00:43:36 -0300 Subject: [PATCH 42/55] keeping include paths that have some sort of system variable --- commandLine/src/addons/ofAddon.cpp | 11 +++++------ .../src/projects/visualStudioProject.cpp | 18 +++++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 3be193ae..f93a8810 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -159,7 +159,7 @@ void ofAddon::addReplaceStringVector(std::vector &variable, const s } } - if (prefix == "" || val.find(ofPathToString(pathToOF)) == 0 || fs::path{val}.is_absolute()) { + if (prefix == "" || val.find(ofPathToString(pathToOF)) == 0 || fs::path{val}.is_absolute() || (val.size() && val[0] == '$')) { variable.emplace_back(val); } else { fs::path p = fs::path{prefix} / val; @@ -200,8 +200,7 @@ void ofAddon::addReplaceStringVectorPathStr(std::vector &variable, fs: } } } - - if (prefix == "" || val.find(ofPathToString(pathToOF)) == 0 || fs::path { val }.is_absolute()) { + if (prefix == "" || val.find(ofPathToString(pathToOF)) == 0 || fs::path { val }.is_absolute() || (val.size() && val[0] == '$')) { variable.emplace_back(fs::path { val }); } else { fs::path p = fs::path { prefix } / val; @@ -253,7 +252,7 @@ void ofAddon::addReplaceStringVectorPathAll(std::vector & variable, fs } } - if (prefix.string() == "" || val.find(ofPathToString(pathToOF)) == 0 || fs::path{val}.is_absolute()) { + if (prefix.string() == "" || val.find(ofPathToString(pathToOF)) == 0 || fs::path{val}.is_absolute() || (val.size() && val[0] == '$')) { variable.emplace_back(fs::path{val}); } else { fs::path p = fs::path{prefix} / val; @@ -292,7 +291,7 @@ void ofAddon::addReplaceStringVectorPath(std::vector &variable, c } } - if (prefix.empty() || v.find(ofPathToString(pathToOF)) == 0 || fs::path{v}.is_absolute()) { + if (prefix.empty() || v.find(ofPathToString(pathToOF)) == 0 || fs::path{v}.is_absolute() || (v.size() && v[0] == '$')) { variable.push_back({ fs::path { v }, "", "" }); } else { fs::path p = fs::path{prefix / v }; @@ -332,7 +331,7 @@ void ofAddon::addReplaceStringVectorLibrary(std::vector &variable } } - if (prefix == "" || v.find(ofPathToString(pathToOF)) == 0 || fs::path{v}.is_absolute()) { + if (prefix == "" || v.find(ofPathToString(pathToOF)) == 0 || fs::path{v}.is_absolute() || (v.size() && v[0] == '$')) { variable.push_back({ fs::path { v }, "", "" }); } else { fs::path p = fs::path{prefix} / v; diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index 3a2f66d7..6717fa9d 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -571,13 +571,17 @@ void visualStudioProject::addAddonIncludePaths(const ofAddon& addon) { } for (const auto &dir : uniqueIncludeDirs) { - fs::path normalizedDir = normalizePath(dir); - if (containsSourceFiles(normalizedDir)) { - normalizedDir = makeRelative(projectDir, dir); - ofLogVerbose() << "[vsproject]-uniqueIncludeDirs] contains src - Adding dir:: [" << normalizedDir.string() << "]"; - addInclude(normalizedDir); - } else { - ofLogVerbose() << "[vsproject]-uniqueIncludeDirs] no src - not adding [" << normalizedDir.string() << "]"; + if( (dir.string().size() && dir.string()[0] == '$')){ + addInclude(dir.string()); + } else{ + fs::path normalizedDir = normalizePath(dir); + if (containsSourceFiles(normalizedDir)) { + normalizedDir = makeRelative(projectDir, dir); + ofLogVerbose() << "[vsproject]-uniqueIncludeDirs] contains src - Adding dir:: [" << normalizedDir.string() << "]"; + addInclude(normalizedDir); + } else { + ofLogVerbose() << "[vsproject]-uniqueIncludeDirs] no src - not adding [" << normalizedDir.string() << "]"; + } } } } From d9f71f658a3ed04484a047fafd97193471185031 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Thu, 10 Oct 2024 00:44:03 -0300 Subject: [PATCH 43/55] disabling fixSlashOrder --- commandLine/src/utils/Utils.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 1d50c81b..21b45ff1 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -426,28 +426,29 @@ string convertStringToWindowsSeparator(string in) { } void fixSlashOrder(std::string &toFix) { - std::replace(toFix.begin(), toFix.end(), '/', '\\'); - // Remove duplicate backslashes - toFix = std::regex_replace(toFix, std::regex(R"(\\\\)"), R"(\\)"); - toFix = std::regex_replace(toFix, std::regex(R"(\\\\\\)"), R"(\\\\)"); + // std::replace(toFix.begin(), toFix.end(), '/', '\\'); + // // Remove duplicate backslashes + // toFix = std::regex_replace(toFix, std::regex(R"(\\\\)"), R"(\\)"); + // toFix = std::regex_replace(toFix, std::regex(R"(\\\\\\)"), R"(\\\\)"); } void fixSlashOrderPath(fs::path &toFix) { - string p = toFix.string(); - std::replace(p.begin(), p.end(), '/', '\\'); - // Remove duplicate backslashes - p = std::regex_replace(p, std::regex(R"(\\\\)"), R"(\\)"); - p = std::regex_replace(p, std::regex(R"(\\\\\\)"), R"(\\\\)"); - toFix = fs::path { p }; + // string p = toFix.string(); + // std::replace(p.begin(), p.end(), '/', '\\'); + // // Remove duplicate backslashes + // p = std::regex_replace(p, std::regex(R"(\\\\)"), R"(\\)"); + // p = std::regex_replace(p, std::regex(R"(\\\\\\)"), R"(\\\\)"); + // toFix = fs::path { p }; } fs::path fixSlashOrderPathReturn(const fs::path &toFix) { - string p = toFix.string(); - std::replace(p.begin(), p.end(), '/', '\\'); - // Remove duplicate backslashes - p = std::regex_replace(p, std::regex(R"(\\\\)"), R"(\\)"); - p = std::regex_replace(p, std::regex(R"(\\\\\\)"), R"(\\\\)"); - return fs::path { p }; + // string p = toFix.string(); + // std::replace(p.begin(), p.end(), '/', '\\'); + // // Remove duplicate backslashes + // p = std::regex_replace(p, std::regex(R"(\\\\)"), R"(\\)"); + // p = std::regex_replace(p, std::regex(R"(\\\\\\)"), R"(\\\\)"); + // return fs::path { p }; + return toFix; } string unsplitString (std::vector < string > strings, string deliminator ){ From e8b4ab56171ecc6fd4994817a06e08dbf7587ac4 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 14 Oct 2024 16:17:10 -0300 Subject: [PATCH 44/55] visualStudioProject: added addCompileOption function to remove a lot of redundant code. Preprocessor flags added properly. --- .../src/projects/visualStudioProject.cpp | 279 +++++++++++------- .../src/projects/visualStudioProject.h | 2 +- 2 files changed, 178 insertions(+), 103 deletions(-) diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index 6717fa9d..da429e5b 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -214,8 +214,8 @@ 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(), 35); +// alert("addSrc folder: " + folder.string(), 35); // I had an empty ClCompile field causing errors if (srcFile.empty()) { @@ -321,53 +321,82 @@ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & fold } } -void visualStudioProject::addInclude(const fs::path & includeName){ - alert ("visualStudioProject::addInclude " + includeName.string(), 35); - string inc = includeName.string(); - fixSlashOrder(inc); - alert ("visualStudioProject::addInclude " + inc, 35); - - pugi::xpath_node_set source = doc.select_nodes("//ClCompile/AdditionalIncludeDirectories"); - for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){ - pugi::xpath_node node = *it; - std::string includes = node.node().first_child().value(); - std::vector < std::string > strings = ofSplitString(includes, ";"); - bool bAdd = true; - for (size_t i = 0; i < strings.size(); i++){ - if (strings[i].compare(includeName.string()) == 0){ - bAdd = false; - break; - } - } - if (bAdd == true){ - strings.emplace_back(includeName.string()); - std::string includesNew = unsplitString(strings, ";"); -// alert ("includesNew " + includesNew); - node.node().first_child().set_value(includesNew.c_str()); +bool exclusiveAppend( string& values, string item, string delimiter = ";") { + auto strings = ofSplitString(values, delimiter); + bool bAdd = true; + for (size_t i = 0; i < strings.size(); i++) { + if (strings[i].compare(item) == 0) { + bAdd = false; + break; } - } - //appendValue(doc, "Add", "directory", includeName); + if (bAdd == true) { + // strings.emplace_back(item); + values += delimiter+item; + //unsplitString(strings, delimiter); + return true; + } + return false; } -void addToNode(const pugi::xpath_node_set & nodes, string item) { +void addToAllNode(const pugi::xpath_node_set & nodes, string item, string delimiter = ";", bool bPrint = false) { for (auto & node : nodes) { - string includes = node.node().first_child().value(); - std::vector < string > strings = ofSplitString(includes, ";"); - bool bAdd = true; - for (size_t i = 0; i < strings.size(); i++) { - if (strings[i].compare(item) == 0) { - bAdd = false; - break; + std::string values = node.node().first_child().value(); + if(exclusiveAppend(values, item, delimiter)){ + + node.node().first_child().set_value(values.c_str()); + if(bPrint) { + string msg = "Adding To Node: " + string(node.node().first_child().value()); + alert(msg, 35); } } - if (bAdd == true) { - strings.emplace_back(item); - node.node().first_child().set_value(unsplitString(strings, ";").c_str()); - } + // std::vector < std::string > strings = ofSplitString(includes, delimiter); + // bool bAdd = true; + // for (size_t i = 0; i < strings.size(); i++) { + // if (strings[i].compare(item) == 0) { + // bAdd = false; + // break; + // } + // } + // if (bAdd == true) { + // strings.emplace_back(item); + // node.node().first_child().set_value(unsplitString(strings, delimiter).c_str()); + // } } } +void visualStudioProject::addInclude(const fs::path & includeName){ + // alert ("visualStudioProject::addInclude " + includeName.string(), 35); + // string inc = includeName.string(); + // fixSlashOrder(inc); + //alert ("visualStudioProject::addInclude " + inc, 35); + + pugi::xpath_node_set source = doc.select_nodes("//ClCompile/AdditionalIncludeDirectories"); + addToAllNode(source, includeName.string()); + +// for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){ +// pugi::xpath_node node = *it; +// std::string includes = node.node().first_child().value(); +// std::vector < std::string > strings = ofSplitString(includes, ";"); +// bool bAdd = true; +// for (size_t i = 0; i < strings.size(); i++) { +// if (strings[i].compare(includeName.string()) == 0){ +// bAdd = false; +// break; +// } +// } +// if (bAdd == true){ +// strings.emplace_back(includeName.string()); +// std::string includesNew = unsplitString(strings, ";"); +// // alert ("includesNew " + includesNew); +// node.node().first_child().set_value(includesNew.c_str()); +// } + +// } + //appendValue(doc, "Add", "directory", includeName); +} + + // void addLibraryName(const pugi::xpath_node_set & nodes, string lib) { // for (auto & node : nodes) { // string includes = node.node().first_child().value(); @@ -433,87 +462,133 @@ void visualStudioProject::addLibrary(const LibraryBinary & lib) { if (!libFolderString.empty()) { pugi::xpath_node_set addlLibsDir = doc.select_nodes((linkPath + "AdditionalLibraryDirectories").c_str()); ofLogVerbose() << "adding " << lib.arch << " lib path " << linkPath; - addToNode(addlLibsDir, libFolderString); + addToAllNode(addlLibsDir, libFolderString); } pugi::xpath_node_set addlDeps = doc.select_nodes((linkPath + "AdditionalDependencies").c_str()); - addToNode(addlDeps, libName.string()); + addToAllNode(addlDeps, libName.string()); ofLogVerbose("visualStudioProject::addLibrary") << "adding lib path " << libFolder; ofLogVerbose("visualStudioProject::addLibrary") << "adding lib " << libName; } -void visualStudioProject::addCFLAG(const string& cflag, LibType libType){ - pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); - // FIXME: iterator - for (auto & item : items) { - pugi::xml_node additionalOptions; - bool found=false; - string condition(item.node().attribute("Condition").value()); - if (libType == RELEASE_LIB && condition.find("Release") != string::npos) { - additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); - found = true; - }else if(libType==DEBUG_LIB && condition.find("Debug") != string::npos){ - additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); - found = true; - } - if(!found) continue; - if(!additionalOptions){ - item.node().child("ClCompile").append_child("AdditionalOptions").append_child(pugi::node_pcdata).set_value(cflag.c_str()); - }else{ - additionalOptions.set_value((string(additionalOptions.value()) + " " + cflag).c_str()); - } +void visualStudioProject::addCompileOption(const string& nodeName, const string& value, const string& delimiter, LibType libType, bool bPrint){ + + string configuration = ((libType == DEBUG_LIB)?"Debug":"Release"); + string nodePath = "//ItemDefinitionGroup[contains(@Condition,'" + configuration + "')]/ClCompile/"+nodeName; + + pugi::xpath_node_set source = doc.select_nodes(nodePath.c_str()); + if(bPrint){ + alert("visualStudioProject::addCompileOption " + nodeName + " val: " + value + " del: " + delimiter, 33 ); + alert(" nodePath: " + nodePath, 33); } + + addToAllNode(source, value, delimiter, bPrint); + + +// pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); +// for (auto & item : items) { +// pugi::xml_node options; +// bool found=false; +// string condition(item.node().attribute("Condition").value()); +// ofLogNotice() << "Condition: " << condition ; +// if (libType == RELEASE_LIB && condition.find("Release") != string::npos) { +// options = item.node().child("ClCompile").child(nodeName.c_str()); +// found = true; +// }else if(libType==DEBUG_LIB && condition.find("Debug") != string::npos){ +// options = item.node().child("ClCompile").child(nodeName.c_str()); +// found = true; +// } +// if(!found) continue; +// if(!options){ +// item.node().child("ClCompile").append_child(nodeName.c_str()).append_child(pugi::node_pcdata).set_value(value.c_str()); +// }else{ +// string option_values = options.value(); +// if(exclusiveAppend(option_values, value, delimiter)){ +// alert("adding option: " + option_values, 34); +// options.set_value(option_values.c_str()); +// } +// // options.set_value((string(options.value()) + delimiter + value).c_str()); +// } +// // addToNode(options, value, delimiter); +// doc.print(std::cout); +// } +} + +void visualStudioProject::addCFLAG(const string& cflag, LibType libType){ + addCompileOption("AdditionalOptions", cflag, " ", libType); + // pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); + // // FIXME: iterator + // for (auto & item : items) { + // pugi::xml_node additionalOptions; + // bool found=false; + // string condition(item.node().attribute("Condition").value()); + // if (libType == RELEASE_LIB && condition.find("Release") != string::npos) { + // additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); + // found = true; + // }else if(libType==DEBUG_LIB && condition.find("Debug") != string::npos){ + // additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); + // found = true; + // } + // if(!found) continue; + // if(!additionalOptions){ + // item.node().child("ClCompile").append_child("AdditionalOptions").append_child(pugi::node_pcdata).set_value(cflag.c_str()); + // }else{ + // additionalOptions.set_value((string(additionalOptions.value()) + " " + cflag).c_str()); + // } + // } } void visualStudioProject::addCPPFLAG(const string& cppflag, LibType libType){ - pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); - for (auto & item : items) { - pugi::xml_node additionalOptions; - bool found=false; - string condition(item.node().attribute("Condition").value()); - if(libType==RELEASE_LIB && condition.find("Debug") != string::npos){ - additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); - found = true; - } - else if(libType==DEBUG_LIB && condition.find("Release") != string::npos) { - additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); - found = true; - } - if(!found) continue; - if(!additionalOptions){ - item.node().child("ClCompile").append_child("AdditionalOptions").append_child(pugi::node_pcdata).set_value(cppflag.c_str()); - }else{ - additionalOptions.set_value((string(additionalOptions.value()) + " " + cppflag).c_str()); - } - } + addCompileOption("AdditionalOptions", cppflag, " ", libType); + // pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); + // for (auto & item : items) { + // pugi::xml_node additionalOptions; + // bool found=false; + // string condition(item.node().attribute("Condition").value()); + // if(libType==RELEASE_LIB && condition.find("Release") != string::npos){ + // additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); + // found = true; + // } + // else if(libType==DEBUG_LIB && condition.find("Debug") != string::npos) { + // additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); + // found = true; + // } + // if(!found) continue; + // if(!additionalOptions){ + // item.node().child("ClCompile").append_child("AdditionalOptions").append_child(pugi::node_pcdata).set_value(cppflag.c_str()); + // }else{ + // additionalOptions.set_value((string(additionalOptions.value()) + " " + cppflag).c_str()); + // } + // } } void visualStudioProject::addDefine(const string& define, LibType libType) { - pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); - for (auto & item : items) { - pugi::xml_node additionalOptions; - bool found = false; - string condition(item.node().attribute("Condition").value()); - if (libType == RELEASE_LIB && condition.find("Debug") != string::npos) { - additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); - found = true; - } - else if (libType == DEBUG_LIB && condition.find("Release") != string::npos) { - additionalOptions = item.node().child("ClCompile").child("AdditionalOptions"); - found = true; - } - if (!found) continue; - if (!additionalOptions) { - item.node().child("ClCompile").append_child("PreprocessorDefinitions").append_child(pugi::node_pcdata).set_value(define.c_str()); - } - else { - additionalOptions.set_value((string(additionalOptions.value()) + " " + define).c_str()); - } - } + addCompileOption("PreprocessorDefinitions", define, ";", libType, true); + // pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); + // for (auto & item : items) { + // pugi::xml_node preprocessorDefinitions; + // bool found = false; + // string condition(item.node().attribute("Condition").value()); + // if (libType == RELEASE_LIB && condition.find("Release") != string::npos) { + // preprocessorDefinitions = item.node().child("ClCompile").child("PreprocessorDefinitions"); + // found = true; + // } + // else if (libType == DEBUG_LIB && condition.find("Debug") != string::npos) { + // preprocessorDefinitions = item.node().child("ClCompile").child("PreprocessorDefinitions"); + // found = true; + // } + // if (!found) continue; + // if (!preprocessorDefinitions) { + // item.node().child("ClCompile").append_child("AdditionalOptions").append_child(pugi::node_pcdata).set_value(define.c_str()); + // } + // else { + // additionalOptions.set_value((string(additionalOptions.value()) + " " + define).c_str()); + // } + // } } void visualStudioProject::ensureDllDirectoriesExist() { diff --git a/commandLine/src/projects/visualStudioProject.h b/commandLine/src/projects/visualStudioProject.h index cc670bbf..b359b50a 100644 --- a/commandLine/src/projects/visualStudioProject.h +++ b/commandLine/src/projects/visualStudioProject.h @@ -49,5 +49,5 @@ class visualStudioProject : public baseProject { protected: void addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder = true) override; - + void addCompileOption(const string& nodeName, const string& value, const string& delimiter, LibType libType = RELEASE_LIB, bool bPrint = false); }; From f543c4ddb011fec0406a421fdfa25b8326dfc640 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 14 Oct 2024 16:22:24 -0300 Subject: [PATCH 45/55] visualStudioProject: removed some dev console printing. --- commandLine/src/projects/visualStudioProject.cpp | 14 +++++++------- commandLine/src/projects/visualStudioProject.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index da429e5b..63c3eecd 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -345,10 +345,10 @@ void addToAllNode(const pugi::xpath_node_set & nodes, string item, string delimi if(exclusiveAppend(values, item, delimiter)){ node.node().first_child().set_value(values.c_str()); - if(bPrint) { - string msg = "Adding To Node: " + string(node.node().first_child().value()); - alert(msg, 35); - } + // if(bPrint) { + // string msg = "Adding To Node: " + string(node.node().first_child().value()); + // alert(msg, 35); + // } } // std::vector < std::string > strings = ofSplitString(includes, delimiter); // bool bAdd = true; @@ -473,7 +473,7 @@ void visualStudioProject::addLibrary(const LibraryBinary & lib) { } -void visualStudioProject::addCompileOption(const string& nodeName, const string& value, const string& delimiter, LibType libType, bool bPrint){ +void visualStudioProject::addCompileOption(const string& nodeName, const string& value, const string& delimiter, LibType libType){ string configuration = ((libType == DEBUG_LIB)?"Debug":"Release"); string nodePath = "//ItemDefinitionGroup[contains(@Condition,'" + configuration + "')]/ClCompile/"+nodeName; @@ -484,7 +484,7 @@ void visualStudioProject::addCompileOption(const string& nodeName, const string& alert(" nodePath: " + nodePath, 33); } - addToAllNode(source, value, delimiter, bPrint); + addToAllNodes(source, value, delimiter); // pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); @@ -567,7 +567,7 @@ void visualStudioProject::addCPPFLAG(const string& cppflag, LibType libType){ void visualStudioProject::addDefine(const string& define, LibType libType) { - addCompileOption("PreprocessorDefinitions", define, ";", libType, true); + addCompileOption("PreprocessorDefinitions", define, ";", libType); // pugi::xpath_node_set items = doc.select_nodes("//ItemDefinitionGroup"); // for (auto & item : items) { // pugi::xml_node preprocessorDefinitions; diff --git a/commandLine/src/projects/visualStudioProject.h b/commandLine/src/projects/visualStudioProject.h index b359b50a..1fbe10c8 100644 --- a/commandLine/src/projects/visualStudioProject.h +++ b/commandLine/src/projects/visualStudioProject.h @@ -49,5 +49,5 @@ class visualStudioProject : public baseProject { protected: void addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder = true) override; - void addCompileOption(const string& nodeName, const string& value, const string& delimiter, LibType libType = RELEASE_LIB, bool bPrint = false); + void addCompileOption(const string& nodeName, const string& value, const string& delimiter, LibType libType = RELEASE_LIB); }; From 2a73311765ddbb9c3f38c23ace45f664e7f2b1eb Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 14 Oct 2024 16:23:33 -0300 Subject: [PATCH 46/55] visualStudioProject: fixed function name typo --- commandLine/src/projects/visualStudioProject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index 63c3eecd..7fb8867b 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -339,7 +339,7 @@ bool exclusiveAppend( string& values, string item, string delimiter = ";") { return false; } -void addToAllNode(const pugi::xpath_node_set & nodes, string item, string delimiter = ";", bool bPrint = false) { +void addToAllNodes(const pugi::xpath_node_set & nodes, string item, string delimiter = ";") { for (auto & node : nodes) { std::string values = node.node().first_child().value(); if(exclusiveAppend(values, item, delimiter)){ @@ -372,7 +372,7 @@ void visualStudioProject::addInclude(const fs::path & includeName){ //alert ("visualStudioProject::addInclude " + inc, 35); pugi::xpath_node_set source = doc.select_nodes("//ClCompile/AdditionalIncludeDirectories"); - addToAllNode(source, includeName.string()); + addToAllNodes(source, includeName.string()); // for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){ // pugi::xpath_node node = *it; @@ -462,11 +462,11 @@ void visualStudioProject::addLibrary(const LibraryBinary & lib) { if (!libFolderString.empty()) { pugi::xpath_node_set addlLibsDir = doc.select_nodes((linkPath + "AdditionalLibraryDirectories").c_str()); ofLogVerbose() << "adding " << lib.arch << " lib path " << linkPath; - addToAllNode(addlLibsDir, libFolderString); + addToAllNodes(addlLibsDir, libFolderString); } pugi::xpath_node_set addlDeps = doc.select_nodes((linkPath + "AdditionalDependencies").c_str()); - addToAllNode(addlDeps, libName.string()); + addToAllNodes(addlDeps, libName.string()); ofLogVerbose("visualStudioProject::addLibrary") << "adding lib path " << libFolder; ofLogVerbose("visualStudioProject::addLibrary") << "adding lib " << libName; From bdd200dbb62f8d8278a8c86c4ba938efd9b34d17 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 14 Oct 2024 16:54:20 -0300 Subject: [PATCH 47/55] commandLine: dont parse addons.make if there are addons passed as arguments --- commandLine/src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index d19188ae..f42a562b 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -685,11 +685,14 @@ int main(int argc, char ** argv) { // ofLogNotice() << "project path is: [" << projectPath << "]"; auto project = getTargetProject(t); project->create(projectPath, templateName); - project->parseAddons(); - - for (auto & addon : addons) { - project->addAddon(addon); + if(bAddonsPassedIn){ + for (auto & addon : addons) { + project->addAddon(addon); + } + }else{ + project->parseAddons(); } + for (auto & s : srcPaths) { project->addSrcRecursively(s); } From 39ee9b7c4c9a9c842d21a68988651a353fd6eab6 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 14 Oct 2024 17:32:40 -0300 Subject: [PATCH 48/55] frontEnd: getCurrentPlatform() returnis windows instead of vs when on windows. This fixes openInIde button not working on windows --- frontend/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/index.js b/frontend/index.js index 5fd28033..d1dade5d 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -68,7 +68,7 @@ function getCurrentPlatform() { let platform = "unknown"; if (/^win/.test(process.platform)) { - platform = 'vs'; + platform = 'windows'; } else if (process.platform === "darwin") { platform = 'osx'; } else if (process.platform === "linux") { From a97352e9289a9a51752a185e28c2140b6245ceb9 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 14 Oct 2024 17:36:52 -0300 Subject: [PATCH 49/55] commenting out printing --- commandLine/src/projects/visualStudioProject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index 7fb8867b..da1518ab 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -479,10 +479,10 @@ void visualStudioProject::addCompileOption(const string& nodeName, const string& string nodePath = "//ItemDefinitionGroup[contains(@Condition,'" + configuration + "')]/ClCompile/"+nodeName; pugi::xpath_node_set source = doc.select_nodes(nodePath.c_str()); - if(bPrint){ - alert("visualStudioProject::addCompileOption " + nodeName + " val: " + value + " del: " + delimiter, 33 ); - alert(" nodePath: " + nodePath, 33); - } + // if(bPrint){ + // alert("visualStudioProject::addCompileOption " + nodeName + " val: " + value + " del: " + delimiter, 33 ); + // alert(" nodePath: " + nodePath, 33); + // } addToAllNodes(source, value, delimiter); From e89d817d04fd2d86c1ee5ec63f62b0e2770a303c Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 21 Oct 2024 22:32:52 -0300 Subject: [PATCH 50/55] templated removeDuplicates function --- commandLine/src/utils/Utils.h | 55 ++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index ede4f33a..ba34ea41 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -103,31 +103,58 @@ inline bool isInVector(T item, std::vector & vec){ return bIsInVector; } +std::string toString(const std::string& str){ + return str; +} -inline void removeDuplicates(std::vector & vec){ - std::unordered_set seen; - std::vector output; - - for (const auto& value : vec) { - if (seen.insert(value).second) { // If insertion is successful (element not seen before) - output.push_back(value); - } - } - vec = std::move(output); +std::string toString(const fs::path& path){ + return ofPathToString(path); } -inline void removeDuplicates(std::vector & vec){ +std::string toString(const LibraryBinary& lib){ + return ofPathToString(lib.path); +} + +template +inline void removeDuplicates(std::vector & vec){ std::unordered_set seen; - std::vector output; + std::vector output; for (const auto& value : vec) { - if (seen.insert(value.string()).second) { // If insertion is successful (element not seen before) - output.emplace_back(value); + if (seen.insert(toString(value)).second) { // If insertion is successful (element not seen before) + output.push_back(value); } } vec = std::move(output); } +//inline void removeDuplicates(std::vector & vec){ +// std::unordered_set seen; +// std::vector output; +// +// for (const auto& value : vec) { +// if (seen.insert(value.string()).second) { // If insertion is successful (element not seen before) +// output.emplace_back(value); +// } +// } +// vec = std::move(output); +//} +// +//inline void removeDuplicates(std::vector & vec){ +// std::unordered_set seen; +// std::vector output; +// +// for (const auto& value : vec) { +// if (seen.insert(value.string()).second) { // If insertion is successful (element not seen before) +// output.emplace_back(value); +// } +// } +// vec = std::move(output); +//} + + + + string colorText(const string & s, int color = 32); void alert(string msg, int color=32); From b4aab464dd9065c756c68f9a7590fb4bb9424320 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 21 Oct 2024 22:34:01 -0300 Subject: [PATCH 51/55] LibraryBinary: parses its own path and sets its arch and target. Function to check if it is valid for arch and target --- commandLine/src/utils/LibraryBinary.cpp | 31 +++++++++++++++++++++++++ commandLine/src/utils/LibraryBinary.h | 14 +++++++++++ 2 files changed, 45 insertions(+) diff --git a/commandLine/src/utils/LibraryBinary.cpp b/commandLine/src/utils/LibraryBinary.cpp index 33e204a4..870efa20 100644 --- a/commandLine/src/utils/LibraryBinary.cpp +++ b/commandLine/src/utils/LibraryBinary.cpp @@ -2,3 +2,34 @@ const std::vector LibraryBinary::archs { "x86", "Win32", "x64", "armv7", "ARM64", "ARM64EC" }; const std::vector LibraryBinary::targets{ "Debug", "Release" }; + +LibraryBinary::LibraryBinary(fs::path p):path(p){ + findArch(path); + findTarget(path); +} + +std::string findStringsInPath(const std::vector & strings, const std::filesystem::path & path){ + for (const auto& part : path) { + auto p = ofPathToString(part); + if (std::find(strings.begin(), strings.end(), p) != strings.end()) { + return p; + } + } + return ""; +} + + +void LibraryBinary::findArch(const std::filesystem::path & path){ + this->arch = findStringsInPath(LibraryBinary::archs, path); +} + +void LibraryBinary::findTarget(const std::filesystem::path & path){ + this->target = findStringsInPath(LibraryBinary::targets, path); +} + +bool LibraryBinary::isValidFor(const std::string& _arch, const std::string& _target){ + bool targetOK = (_target.empty() || (_target == this->target)); + bool archOK = (_arch.empty() || (_arch == this->arch)); + return targetOK && archOK; +} + diff --git a/commandLine/src/utils/LibraryBinary.h b/commandLine/src/utils/LibraryBinary.h index bcbe31d8..a581f4ef 100644 --- a/commandLine/src/utils/LibraryBinary.h +++ b/commandLine/src/utils/LibraryBinary.h @@ -16,6 +16,7 @@ namespace fs = of::filesystem; class LibraryBinary { public: LibraryBinary(){} + LibraryBinary(fs::path p); LibraryBinary(fs::path p, std::string a, std::string t) { path = p; arch = a; @@ -28,8 +29,21 @@ class LibraryBinary { static const std::vector archs; static const std::vector targets; + #ifdef OFADDON_OUTPUT_JSON_DEBUG NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(LibraryBinary, path, arch, target) #endif + ///\ brief check if it is valid for the passed arch and target. + ///\param arch the architecture to check for. An empty string means any architecture + ///\param target the target to check for. An empty string means any target + ///\return true if valid false otherwise + bool isValidFor(const std::string& arch, const std::string& target); + +protected: + void findArch(const std::filesystem::path & path); + void findTarget(const std::filesystem::path & path); + + + }; From 57a19aa856344c8e63f38b3bbc0423f3d77951b2 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 21 Oct 2024 22:34:39 -0300 Subject: [PATCH 52/55] reworked getLibsRecursively --- commandLine/src/utils/Utils.cpp | 57 +++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 21b45ff1..5724feb9 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -358,6 +358,7 @@ void getDllsRecursively(const fs::path & path, std::vector & dlls, str } } + void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFiles, std::vector < LibraryBinary > & libLibs, string platform, string arch, string target) { // alert ("getLibsRecursively " + path.string(), 34); // alert ("platform " + platform, 34); @@ -380,40 +381,48 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil if ((f.extension() == ".framework") || (f.extension() == ".xcframework")) { it.disable_recursion_pending(); continue; - } else { - auto stem = f.stem(); - auto archFound = std::find(LibraryBinary::archs.begin(), LibraryBinary::archs.end(), stem); - if (archFound != LibraryBinary::archs.end()) { - arch = *archFound; - } else { - auto targetFound = std::find(LibraryBinary::targets.begin(), LibraryBinary::targets.end(), stem); - if (targetFound != LibraryBinary::targets.end()) { - target = *targetFound; - } - } - } + } + //else { +// auto stem = f.stem(); +// auto archFound = std::find(LibraryBinary::archs.begin(), LibraryBinary::archs.end(), stem); +// if (archFound != LibraryBinary::archs.end()) { +// arch = *archFound; +// alert ("arch found: " + arch, 34); +// } else { +// auto targetFound = std::find(LibraryBinary::targets.begin(), LibraryBinary::targets.end(), stem); +// if (targetFound != LibraryBinary::targets.end()) { +// target = *targetFound; +// alert ("target found: " + target, 34); +// } +// } +// } } else { - auto ext = f.extension(); + auto ext = ofPathToString(f.extension()); bool platformFound = false; - if(platform!=""){ - std::vector splittedPath = ofSplitString(f.string(), fs::path("/").make_preferred().string()); - for(size_t j=0;j splittedPath = ofSplitString(f.string(), fs::path("/").make_preferred().string()); +// for(size_t j=0;j Date: Mon, 21 Oct 2024 22:35:36 -0300 Subject: [PATCH 53/55] removing duplicate libs, adding libs to projectFolders. apply exclude rules to libfiles --- commandLine/src/addons/ofAddon.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index f93a8810..afc81fd9 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -730,6 +730,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo getXCFrameworksRecursively(libsPath, xcframeworks, "macos"); getXCFrameworksRecursively(libsPath, xcframeworks, "osx"); + removeDuplicates(libs); removeDuplicates(libFiles); removeDuplicates(frameworks); removeDuplicates(xcframeworks); @@ -767,6 +768,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo for (auto & l : libs) { // alert("fixpath before " + ofPathToString(l.path)); l.path = fixPath(l.path); + addToFolder(l.path , parentFolder); // alert("fixpath after " + ofPathToString(l.path)); } // } @@ -1006,12 +1008,17 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t exclude(frameworks, excludeFrameworks); exclude(xcframeworks, excludeXCFrameworks); excludeLibrary(libs, excludeLibs); + + excludePathStr(libFiles, excludeIncludes); + excludePathStr(libFiles, excludeSources); - ofLogVerbose("ofAddon") << "libs after exclusions " << libs.size(); + + +// ofLogVerbose("ofAddon") << "libs after exclusions " << libs.size(); - for (auto & lib: libs) { - ofLogVerbose("ofAddon") << lib.path.string(); - } +// for (auto & lib: libs) { +// ofLogVerbose("ofAddon") << lib.path.string(); +// } return true; } From 315f9c2d56b78ce72a467227d234a267608a6daf Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Mon, 21 Oct 2024 22:36:29 -0300 Subject: [PATCH 54/55] xcodeProj. adding Dylib with folder --- commandLine/src/projects/xcodeProject.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index bcf5e47b..57a30362 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -646,10 +646,15 @@ void xcodeProject::addAddonLibs(const ofAddon& addon){ addLibrary(e); fs::path dylibPath { e.path }; - fs::path folder = dylibPath.parent_path().lexically_relative(addon.pathToOF); + // cout << "dylibPath " << dylibPath << endl; if (dylibPath.extension() == ".dylib") { - addDylib(dylibPath, folder); + + if(addon.filesToFolders.find(dylibPath) == addon.filesToFolders.end()) { + addDylib(dylibPath, dylibPath.parent_path().lexically_relative(addon.pathToOF)); + }else{ + addDylib(dylibPath,addon.filesToFolders.at(dylibPath)); + } } } } From ac763b503b451c00b650d714b22ff9f0717cd3c1 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Tue, 22 Oct 2024 18:10:31 -0300 Subject: [PATCH 55/55] added missing include --- commandLine/src/utils/LibraryBinary.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/commandLine/src/utils/LibraryBinary.cpp b/commandLine/src/utils/LibraryBinary.cpp index 870efa20..815db084 100644 --- a/commandLine/src/utils/LibraryBinary.cpp +++ b/commandLine/src/utils/LibraryBinary.cpp @@ -1,4 +1,5 @@ #include "LibraryBinary.h" +#include "ofFileUtils.h" const std::vector LibraryBinary::archs { "x86", "Win32", "x64", "armv7", "ARM64", "ARM64EC" }; const std::vector LibraryBinary::targets{ "Debug", "Release" };