From a742c1fdb869983f7a6a813e69514aea62e89af5 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 2 Nov 2024 18:53:54 -0300 Subject: [PATCH] pg small fixes to build using make (#583) alerts cleanup, fix some warnings --- .github/workflows/build-linux.yml | 4 +- commandLine/config.make | 2 +- commandLine/src/addons/ofAddon.cpp | 473 ++++++++++++---------- commandLine/src/addons/ofAddon.h | 72 ++-- commandLine/src/defines.h | 2 +- commandLine/src/projects/baseProject.cpp | 2 +- commandLine/src/projects/xcodeProject.cpp | 9 +- commandLine/src/utils/Utils.cpp | 4 +- commandLine/src/utils/Utils.h | 31 +- 9 files changed, 302 insertions(+), 297 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index ca14601e..453db887 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -26,8 +26,8 @@ jobs: env: TARGET: ${{ matrix.cfg.target }} steps: - - name: Install libunwind - run: sudo apt-get install libunwind-dev wget2 + # - name: Install libunwind + # run: sudo apt-get install libunwind-dev wget2 - uses: actions/checkout@v4 diff --git a/commandLine/config.make b/commandLine/config.make index ba6d49c9..d43f10b9 100644 --- a/commandLine/config.make +++ b/commandLine/config.make @@ -153,7 +153,7 @@ PLATFORM_CORE_EXCLUSIONS += ../../../libs/openFrameworks/events PLATFORM_CORE_EXCLUSIONS += ../../../libs/openFrameworks/gl PLATFORM_CORE_EXCLUSIONS += ../../../libs/openFrameworks/graphics #PLATFORM_CORE_EXCLUSIONS += ../../../libs/openFrameworks/math -PLATFORM_CORE_EXCLUSIONS += ../../../libs/openFrameworks/types +#PLATFORM_CORE_EXCLUSIONS += ../../../libs/openFrameworks/types PLATFORM_CORE_EXCLUSIONS += ../../../libs/openFrameworks/video PLATFORM_CORE_EXCLUSIONS += ../../../libs/boost% diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 845484d5..745a34ce 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -11,6 +11,33 @@ #include #include + +static std::string toString(const std::string& str){ + return str; +} + +static std::string toString(const fs::path& path){ + return ofPathToString(path); +} + +static std::string toString(const LibraryBinary& lib){ + return ofPathToString(lib.path); +} + +template +static inline void removeDuplicates(std::vector & vec){ + std::unordered_set seen; + std::vector output; + + for (const auto& value : vec) { + if (seen.insert(toString(value)).second) { // If insertion is successful (element not seen before) + output.push_back(value); + } + } + vec = std::move(output); +} + + vector splitStringOnceByLeft(const string &source, const string &delimiter) { size_t pos = source.find(delimiter); vector res; @@ -31,48 +58,48 @@ vector splitStringOnceByLeft(const string &source, const string &delimit // = std::unordered_map(); //} -ofAddon::ofAddon(const ofAddon& other) - : additionalLibsFolder(other.additionalLibsFolder), - libFiles(other.libFiles), - filesToFolders(other.filesToFolders), - srcFiles(other.srcFiles), - csrcFiles(other.csrcFiles), - cppsrcFiles(other.cppsrcFiles), - headersrcFiles(other.headersrcFiles), - objcsrcFiles(other.objcsrcFiles), - propsFiles(other.propsFiles), - libs(other.libs), - dllsToCopy(other.dllsToCopy), - includePaths(other.includePaths), - libsPaths(other.libsPaths), - dependencies(other.dependencies), - cflags(other.cflags), - cppflags(other.cppflags), - ldflags(other.ldflags), - pkgConfigLibs(other.pkgConfigLibs), - frameworks(other.frameworks), - xcframeworks(other.xcframeworks), - data(other.data), - defines(other.defines), - definesCMAKE(other.definesCMAKE), - name(other.name), - addonPath(other.addonPath), - description(other.description), - author(other.author), - tags(other.tags), - url(other.url), - pathToOF(other.pathToOF), - pathToProject(other.pathToProject), - isLocalAddon(other.isLocalAddon), - currentParseState(other.currentParseState), - emptyString(other.emptyString), - platform(other.platform), - excludeLibs(other.excludeLibs), - excludeSources(other.excludeSources), - excludeIncludes(other.excludeIncludes), - excludeFrameworks(other.excludeFrameworks), - excludeXCFrameworks(other.excludeXCFrameworks), - addonMakeName(other.addonMakeName) +ofAddon::ofAddon(const ofAddon& other): + additionalLibsFolder(other.additionalLibsFolder), + libFiles(other.libFiles), + filesToFolders(other.filesToFolders), + srcFiles(other.srcFiles), + csrcFiles(other.csrcFiles), + cppsrcFiles(other.cppsrcFiles), + headersrcFiles(other.headersrcFiles), + objcsrcFiles(other.objcsrcFiles), + propsFiles(other.propsFiles), + libs(other.libs), + dllsToCopy(other.dllsToCopy), + includePaths(other.includePaths), + libsPaths(other.libsPaths), + dependencies(other.dependencies), + cflags(other.cflags), + cppflags(other.cppflags), + ldflags(other.ldflags), + pkgConfigLibs(other.pkgConfigLibs), + frameworks(other.frameworks), + xcframeworks(other.xcframeworks), + data(other.data), + defines(other.defines), + definesCMAKE(other.definesCMAKE), + name(other.name), + addonPath(other.addonPath), + description(other.description), + author(other.author), + tags(other.tags), + url(other.url), + pathToOF(other.pathToOF), + pathToProject(other.pathToProject), + isLocalAddon(other.isLocalAddon), + addonMakeName(other.addonMakeName), + currentParseState(other.currentParseState), + emptyString(other.emptyString), + platform(other.platform), + excludeLibs(other.excludeLibs), + excludeSources(other.excludeSources), + excludeIncludes(other.excludeIncludes), + excludeFrameworks(other.excludeFrameworks), + excludeXCFrameworks(other.excludeXCFrameworks) { } @@ -96,7 +123,7 @@ bool ofAddon::checkCorrectVariable(const string & variable, const string & state AddonMetaVariables.end(), variable) != AddonMetaVariables.end(); } - else if (state == "osx") {// Why only checking for osx? + else if (state == "osx") {// Why only checking for osx? return std::find(AddonProjectVariables.begin(), AddonProjectVariables.end(), variable) != AddonProjectVariables.end(); @@ -339,7 +366,7 @@ void ofAddon::addReplaceStringVectorPath(std::vector &variable, c //} void ofAddon::parseVariableValue(const string & variable, const string & value, bool addToValue, const string & line, int lineNum){ - + if (variable == "ADDON_NAME"){ if (value != name){ @@ -350,14 +377,14 @@ void ofAddon::parseVariableValue(const string & variable, const string & value, return; } - fs::path addonRelPath = makeRelative(pathToProject, addonPath); - std::string addonRelPathStr = ofPathToString(addonRelPath); - + fs::path addonRelPath = makeRelative(pathToProject, addonPath); + std::string addonRelPathStr = ofPathToString(addonRelPath); + if (variable == ADDON_ADDITIONAL_LIBS) { additionalLibsFolder.emplace_back(fs::path { value }); return; } - + else if (variable == ADDON_DESCRIPTION) { addReplaceString(description, value, addToValue); return; @@ -450,10 +477,10 @@ void ofAddon::parseVariableValue(const string & variable, const string & value, else if(variable == ADDON_LIBS_EXCLUDE){ addReplaceStringVector(excludeLibs,value,emptyString,addToValue); } - - else if(variable == ADDON_LIBS_DIR){ + + else if(variable == ADDON_LIBS_DIR){ addReplaceStringVectorPath(libsPaths, value, addonRelPathStr, addToValue); - } + } else if(variable == ADDON_SOURCES_EXCLUDE){ addReplaceStringVector(excludeSources,value,emptyString,addToValue); @@ -474,20 +501,20 @@ void ofAddon::parseVariableValue(const string & variable, const string & value, template void exclude(std::vector& variables, vector exclusions){ - for(auto & exclusion: exclusions){ - ofStringReplace(exclusion,"\\","/"); - ofStringReplace(exclusion,".","\\."); - ofStringReplace(exclusion,"%",".*"); - exclusion =".*"+ exclusion; - - std::regex findVar(exclusion); - std::smatch varMatch; - variables.erase(std::remove_if(variables.begin(), variables.end(), [&](const T & variable){ - std::string forwardSlashedVariable = ofPathToString(variable); - ofStringReplace(forwardSlashedVariable, "\\", "/"); - return std::regex_search(forwardSlashedVariable, varMatch, findVar); - }), variables.end()); - } + for(auto & exclusion: exclusions){ + ofStringReplace(exclusion,"\\","/"); + ofStringReplace(exclusion,".","\\."); + ofStringReplace(exclusion,"%",".*"); + exclusion =".*"+ exclusion; + + std::regex findVar(exclusion); + std::smatch varMatch; + variables.erase(std::remove_if(variables.begin(), variables.end(), [&](const T & variable){ + std::string forwardSlashedVariable = ofPathToString(variable); + ofStringReplace(forwardSlashedVariable, "\\", "/"); + return std::regex_search(forwardSlashedVariable, varMatch, findVar); + }), variables.end()); + } } //template //void exclude(vector & variables, vector exclusions){ @@ -582,10 +609,10 @@ void exclude(std::vector& variables, vector exclusions){ //// ofLogError() << "ofAddon::parseConfig() " << fileName << " not found " << ofPathToString(fileName); // return; // } -// +// // for (auto & line : fileToStrings(fileName)) { // line = ofTrim(line); -// +// // if (line[0]=='#' || line == "") { // continue; // } // discard comments @@ -595,7 +622,7 @@ void exclude(std::vector& variables, vector exclusions){ // if (line.back() == ':'){ // ofStringReplace(line, ":", ""); // currentParseState = line; -// +// // if (std::find(parseStates.begin(), parseStates.end(), currentParseState) == parseStates.end()) { // ofLogError() << "Error parsing " << name << " addon_config.mk" << "\n\t\t" //// << "line " << lineNum << ": " << originalLine << "\n\t\t" @@ -603,7 +630,7 @@ void exclude(std::vector& variables, vector exclusions){ // } // continue; // } -// +// // // found Variable // if (line.find("=") != string::npos){ //// bool addToValue = false; @@ -629,7 +656,7 @@ void exclude(std::vector& variables, vector exclusions){ // << "variable " << variable << " not recognized for section " << currentParseState; // continue; // } -// +// // if (variable == ADDON_ADDITIONAL_LIBS) { // additionalLibsFolder.emplace_back(fs::path { value }); // // return; @@ -665,7 +692,7 @@ void ofAddon::parseConfig(){ ofStringReplace(line,":",""); // FIXME: Remove currentParseState = line; - + if (std::find(parseStates.begin(), parseStates.end(), currentParseState) == parseStates.end()) { ofLogError() << "Error parsing " << name << " addon_config.mk" << "\n\t\t" << "line " << lineNum << ": " << originalLine << "\n\t\t" @@ -700,21 +727,21 @@ void ofAddon::parseConfig(){ << "variable " << variable << " not recognized for section " << currentParseState; continue; } - + parseVariableValue(variable, value, addToValue, originalLine, lineNum); } } } 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; + + 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) { @@ -724,36 +751,36 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo return; } - - 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"); - - removeDuplicates(libs); - removeDuplicates(libFiles); - removeDuplicates(frameworks); - removeDuplicates(xcframeworks); - - }else{ - - getLibsRecursively(libsPath, libFiles, libs, platform); - } - - if (//platform == "osx" || - platform == "ios" || - platform == "tvos"){//} || - //platform == "macos"){ - - getFrameworksRecursively(libsPath, frameworks, platform); - getXCFrameworksRecursively(libsPath, xcframeworks, platform); - } - + + 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"); + + removeDuplicates(libs); + removeDuplicates(libFiles); + removeDuplicates(frameworks); + removeDuplicates(xcframeworks); + + }else{ + + getLibsRecursively(libsPath, libFiles, libs, platform); + } + + if (//platform == "osx" || + platform == "ios" || + platform == "tvos"){//} || + //platform == "macos"){ + + getFrameworksRecursively(libsPath, frameworks, platform); + getXCFrameworksRecursively(libsPath, xcframeworks, platform); + } + if (platform == "vs" || platform == "msys2" || platform == "vscode" || platform == "linux" @@ -762,7 +789,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo || platform == "linuxarmv7l" || platform == "linuxaarch64" ) { - getDllsRecursively(libsPath, dllsToCopy, platform); + getDllsRecursively(libsPath, dllsToCopy, platform); } // TODO: this is not needed even if it is local addon but project is outside OF root path @@ -772,16 +799,16 @@ 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); + addToFolder(l.path , parentFolder); // alert("fixpath after " + ofPathToString(l.path)); } // } for (auto & s : libFiles) { // alert("fixpath before " + ofPathToString(s)); - s = fixPath(s); + s = fixPath(s); // alert("fixpath after " + ofPathToString(s)); - addToFolder(s, parentFolder); + addToFolder(s, parentFolder); // fs::path folder; // if (isLocalAddon) { // folder = fs::path { "local_addons" } / fs::relative(s.parent_path(), parentFolder); @@ -817,12 +844,12 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo // } // // filesToFolders[f] = folder; - addToFolder(f, parentFolder); + addToFolder(f, parentFolder); } } for (const auto & f : xcframeworks) { - + // fs::path rel = fs::relative(f, isLocalAddon ? pathToProject : pathToOF); // fs::path folder = rel.parent_path(); // @@ -832,94 +859,94 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo // } // // filesToFolders[f] = folder; - addToFolder(f, parentFolder); + addToFolder(f, parentFolder); } } string ofAddon::cleanName(const string& name){ - auto addonName = name; + auto addonName = name; #ifdef TARGET_WIN32 - // std::replace( addonName.begin(), addonName.end(), '/', '\\' ); + // 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; + + { + // 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 - this->addonMakeName = addonName; - - addonName = cleanName(addonName); - - 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))){ - - this->addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); - this->isLocalAddon = true; - ofLogVerbose() << "Adding local addon: " << addonName; - // addon.pathToProject = makeRelative(getOFRoot(), projectDir); - // projectDir; - }else{ - this->addonPath = fs::path { getOFRoot() / "addons" / addonName }; - } - this->pathToOF = normalizePath(getOFRoot()); - - this->addonPath = normalizePath(addonPath); - - - this->pathToProject = projectDir; - - this->platform = targetPlatform; - - ofLogVerbose() << "addonPath to: [" << addonPath.string() << "]"; - ofLogVerbose() << "pathToOF: [" << pathToOF.string() << "]"; - - - alert("ofAddon::fromFS path : " + addonPath.string(), 33); - + // we want to set addonMakeName before cleaning the addon name, so it is preserved in the exact same way as it was passed, and the addons.make file can be (re)constructed properly + this->addonMakeName = addonName; + + addonName = cleanName(addonName); + + 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))){ + + this->addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); + this->isLocalAddon = true; + ofLogVerbose() << "Adding local addon: " << addonName; + // addon.pathToProject = makeRelative(getOFRoot(), projectDir); + // projectDir; + }else{ + this->addonPath = fs::path { getOFRoot() / "addons" / addonName }; + } + this->pathToOF = normalizePath(getOFRoot()); + + this->addonPath = normalizePath(addonPath); + + + this->pathToProject = projectDir; + + this->platform = targetPlatform; + + ofLogVerbose() << "addonPath to: [" << addonPath.string() << "]"; + ofLogVerbose() << "pathToOF: [" << pathToOF.string() << "]"; + + +// alert("ofAddon::fromFS path : " + addonPath.string(), 33); + if (!fs::exists(addonPath)) { - ofLogVerbose("ofAddon::load") << "addon does not exist!" << addonPath; + ofLogVerbose("ofAddon::load") << "addon does not exist!" << addonPath; return false; } - + clear(); - fs::path addonNamePath { addonName}; - + fs::path addonNamePath { addonName}; + name = isLocalAddon ? ofPathToString(addonNamePath.stem()) : ofPathToString(addonNamePath.filename()); fs::path srcPath { addonPath / "src" }; if (fs::exists(srcPath)) { getFilesRecursively(srcPath, srcFiles); } - + // printPaths(srcFiles, "srcFiles", 34); - + fs::path parentFolder { addonPath.parent_path() }; - - for (auto & s : srcFiles) { - fs::path sFS { fixPath(s) }; - s = sFS; - addToFolder(s, parentFolder); - } - + + for (auto & s : srcFiles) { + fs::path sFS { fixPath(s) }; + s = sFS; + addToFolder(s, parentFolder); + } + if (platform == "vs" || platform == "msys2") { // here addonPath is the same as path. getPropsRecursively(addonPath, propsFiles, platform); @@ -931,44 +958,44 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t std::list < fs::path > paths; // get every folder in addon/src and addon/libs - - if (fs::exists(libsPath)) { - vector < fs::path > libFolders; + + if (fs::exists(libsPath)) { + vector < fs::path > libFolders; getFoldersRecursively(libsPath, libFolders, platform); for (auto & path : libFolders) { - paths.emplace_back( fixPath(path) ); + paths.emplace_back( fixPath(path) ); } } - - if (fs::exists(srcPath)) { - vector < fs::path > srcFolders; + + if (fs::exists(srcPath)) { + vector < fs::path > srcFolders; getFoldersRecursively(srcPath, srcFolders, platform); for (auto & path : srcFolders) { - paths.emplace_back( fixPath(path) ); + paths.emplace_back( fixPath(path) ); } } - - paths.sort([](const fs::path & a, const fs::path & b) { - return a.string() < b.string(); - }); - - for (auto & p : paths) { - includePaths.emplace_back(p); - } - - - // FIXME: MARK: - HACK: + + paths.sort([](const fs::path & a, const fs::path & b) { + return a.string() < b.string(); + }); + + for (auto & p : paths) { + includePaths.emplace_back(p); + } + + + // FIXME: MARK: - HACK: // preParseConfig(); - parseConfig(); + parseConfig(); parseLibsPath(libsPath, parentFolder); - - // lib paths are directories to parse for libs - for (auto & a : libsPaths) { + + // lib paths are directories to parse for libs + for (auto & a : libsPaths) { // alert(a, 33); - parseLibsPath((addonPath / a), parentFolder); - } + parseLibsPath((addonPath / a), parentFolder); + } for (auto & a : additionalLibsFolder) { // parseLibsPath(fs::weakly_canonical(path / a), parentFolder); @@ -977,16 +1004,16 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t exclude(includePaths, excludeIncludes); - + // Dimitre. I've added this here to exclude some srcFiles from addons, // ofxAssimpModelLoader was adding some files from libs/assimp/include/assimp/port/AndroidJNI // even when the folder was excluded from includePaths - // Roy: The purpose of not excluding the includes from srcFiles is to be able to keep a folder path out of the include paths but still have those in the IDE. - // Which was the behaviour we had before. If an addon needs to exclude something from the src folder on a platform specific way it should use the - // ADDON_SOURCES_EXCLUDE exclude field of the addon_config.mk file - + // Roy: The purpose of not excluding the includes from srcFiles is to be able to keep a folder path out of the include paths but still have those in the IDE. + // Which was the behaviour we had before. If an addon needs to exclude something from the src folder on a platform specific way it should use the + // ADDON_SOURCES_EXCLUDE exclude field of the addon_config.mk file + // excludePathStr(srcFiles, excludeIncludes); - + exclude(srcFiles, excludeSources); exclude(csrcFiles, excludeSources); exclude(cppsrcFiles, excludeSources); @@ -996,11 +1023,11 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t exclude(frameworks, excludeFrameworks); exclude(xcframeworks, excludeXCFrameworks); exclude(libs, excludeLibs); - - exclude(libFiles, excludeIncludes); - exclude(libFiles, excludeSources); - + exclude(libFiles, excludeIncludes); + exclude(libFiles, excludeSources); + + return true; } @@ -1012,7 +1039,7 @@ void ofAddon::clear(){ propsFiles.clear(); libs.clear(); includePaths.clear(); - libsPaths.clear(); + libsPaths.clear(); name.clear(); } @@ -1023,9 +1050,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 */ - 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()); - } + 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/addons/ofAddon.h b/commandLine/src/addons/ofAddon.h index 7dcb0d48..f24478cc 100644 --- a/commandLine/src/addons/ofAddon.h +++ b/commandLine/src/addons/ofAddon.h @@ -36,11 +36,11 @@ const vector parseStates { "android/x86", "android/x86_64", "emscripten", - "android", + "android", "ios", "osx", "tvos", - "macos", + "macos", "watchos", "visionos", }; @@ -86,11 +86,11 @@ const string ADDON_TAGS = "ADDON_TAGS"; const string ADDON_URL = "ADDON_URL"; const vector AddonMetaVariables { - ADDON_NAME, - ADDON_DESCRIPTION, - ADDON_AUTHOR, - ADDON_TAGS, - ADDON_URL, + ADDON_NAME, + ADDON_DESCRIPTION, + ADDON_AUTHOR, + ADDON_TAGS, + ADDON_URL, }; const vector AddonProjectVariables = { @@ -110,7 +110,7 @@ const vector AddonProjectVariables = { ADDON_OBJC_SOURCES, ADDON_LIBS_EXCLUDE, - ADDON_LIBS_DIR, + ADDON_LIBS_DIR, ADDON_SOURCES_EXCLUDE, ADDON_INCLUDES_EXCLUDE, ADDON_FRAMEWORKS_EXCLUDE, @@ -120,7 +120,7 @@ const vector AddonProjectVariables = { ADDON_PKG_CONFIG_LIBRARIES, ADDON_FRAMEWORKS, ADDON_DLLS_TO_COPY, - ADDON_ADDITIONAL_LIBS, + ADDON_ADDITIONAL_LIBS, }; class ofAddon { @@ -130,11 +130,11 @@ class ofAddon { ofAddon() = default; ofAddon(const ofAddon& other); - static string cleanName(const string& name); - - bool load(string addonName, const fs::path& projectDir, const string& targetPlatform); - - + static string cleanName(const string& name); + + bool load(string addonName, const fs::path& projectDir, const string& targetPlatform); + + void clear(); vector additionalLibsFolder; @@ -153,7 +153,7 @@ class ofAddon { vector < LibraryBinary > libs; vector < fs::path > dllsToCopy; vector < fs::path > includePaths; - vector < fs::path > libsPaths; + vector < fs::path > libsPaths; // From addon_config.mk vector < string > dependencies; @@ -165,8 +165,8 @@ class ofAddon { vector < string > xcframeworks; // osx only vector < string > data; vector < string > defines; - - vector < string > definesCMAKE; + + vector < string > definesCMAKE; // metadata string name; @@ -175,7 +175,7 @@ class ofAddon { string author; vector tags; string url; - + fs::path pathToOF = fs::path { "../../../ "}; fs::path pathToProject = fs::path { "." }; bool isLocalAddon = false; // set to true if the addon path is realtive to the project instead of in OF/addons/ @@ -183,34 +183,34 @@ class ofAddon { bool operator <(const ofAddon & addon) const{ return addon.name < name; } - string addonMakeName; - - - + string addonMakeName; + + + private: - - void parseLibsPath(const fs::path & path, const fs::path & parentFolder); - - void addToFolder(const fs::path& path, const fs::path & parentFolder); - + + void parseLibsPath(const fs::path & path, const fs::path & parentFolder); + + void addToFolder(const fs::path& path, const fs::path & parentFolder); + string currentParseState { "" }; string emptyString = { "" }; // void preParseConfig(); void parseConfig(); void parseVariableValue(const string & variable, const string & value, bool addToValue, const string & line, int lineNum); - + void addReplaceString(std::string &variable, const std::string &value, bool addToVariable); // void addReplaceStringPath(fs::path &variable, const std::string & value, bool addToVariable); void addReplaceStringVector(std::vector &variable, const std::string &value, const std::string &prefix, bool addToVariable); // void addReplaceStringVectorPre(std::vector &variable, const std::string &value, fs::path &prefix, bool addToVariable); void addReplaceStringVectorPathStr(std::vector & variable, fs::path & value, const std::string & prefix, bool addToVariable); - + void addReplaceStringVectorPath(std::vector &variable, const std::string &value, const std::string &prefix, bool addToVariable); // void addReplaceStringVectorPathAll(std::vector & variable, fs::path & value, fs::path & prefix, bool addToVariable); // void addReplaceStringVectorPathPrefix(std::vector &variable, const std::string &value, fs::path &prefix, bool addToVariable); - + // void addReplaceStringVectorLibrary(std::vector & variable, const std::string & value, const std::string & prefix, bool addToVariable); - + void addReplaceStringVectorPath(std::vector &variable, const std::string &value, const fs::path &prefix, bool addToVariable); // void exclude(vector & variable, vector exclusions); @@ -229,7 +229,7 @@ class ofAddon { vector excludeXCFrameworks; fs::path fixPath(const fs::path & path); - + fs::path normalizePath(const fs::path& path) { try { // auto value = fs::weakly_canonical(path); @@ -241,10 +241,12 @@ 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) + + 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 eb86191d..7ca147be 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "80" +#define OFPROJECTGENERATOR_MINOR_VERSION "81" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 5fad85d7..f6cbe87a 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -524,7 +524,7 @@ void baseProject::addAddonDllsToCopy(ofAddon& addon){ // 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 void baseProject::addAddon(ofAddon & addon){ - alert("baseProject::addAddon ofAddon & addon :: " + addon.name); +// alert("baseProject::addAddon ofAddon & addon :: " + addon.name); // FIXME: Duplicate Code for (auto & a : addons) { diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index 79a38daf..e05c65c8 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -249,7 +249,7 @@ fs::path getPathTo(fs::path path, string limit){ for(auto & f: folders){ p /= f; if(f.string() == limit){ - alert("getPathTo "+ p.string(), 33); +// alert("getPathTo "+ p.string(), 33); return p; } } @@ -742,7 +742,7 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con // if (fs::exists( projectDir / path )) { // cout << "OK exists" << endl; - bool isFolder = false; +// bool isFolder = false; string fileType { "file" }; fileType = extensionToFileType[path.extension()]; @@ -750,7 +750,7 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con if (fileType == "") { if (fs::is_directory(path) || fp.isGroupWithoutFolder) { fileType = "folder"; - isFolder = true; +// isFolder = true; } else { // Break here if fileType is not set. and it is not a folder return {}; @@ -813,7 +813,8 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con // } // Eventually remove isFolder and base parameter - std::string folderUUID { getFolderUUID(folder, path)};//, isFolder) }; + std::string folderUUID { getFolderUUID(folder, path)}; + //, isFolder) }; addCommand("# ---- addFileToFolder UUID : " + ofPathToString(folder)); diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 29096b13..d114a79a 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -57,9 +57,9 @@ std::string execute_popen(const char* cmd) { } #ifdef _WIN32 - auto rc = _pclose(pipe); + _pclose(pipe); #else - auto rc = pclose(pipe); + pclose(pipe); #endif // trim last line break diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index 4ed55ef2..9c112c9a 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -31,7 +31,7 @@ static std::map platformsToString { { OF_TARGET_ANDROID, "android" }, // { OF_TARGET_EMSCRIPTEN, "" }, { OF_TARGET_IOS, "ios" }, - { OF_TARGET_MACOS, "macos" }, + { OF_TARGET_MACOS, "macos" }, { OF_TARGET_LINUX, "linux" }, { OF_TARGET_LINUX64, "linux64" }, { OF_TARGET_LINUXARMV6L, "linuxarmv6l" }, @@ -103,35 +103,10 @@ inline bool isInVector(T item, std::vector & vec){ return bIsInVector; } -std::string toString(const std::string& str){ - return str; -} - -std::string toString(const fs::path& path){ - return ofPathToString(path); -} - -std::string toString(const LibraryBinary& lib){ - return ofPathToString(lib.path); -} - -template -inline void removeDuplicates(std::vector & vec){ - std::unordered_set seen; - std::vector output; - - for (const auto& value : vec) { - 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); @@ -143,7 +118,7 @@ inline void removeDuplicates(std::vector & vec){ //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);