Skip to content

Commit

Permalink
V86 - fix adding xcframeworks to projects (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitre authored Nov 19, 2024
1 parent e45431a commit 0d4e7c3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 44 deletions.
44 changes: 11 additions & 33 deletions commandLine/src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@


void ofAddon::getFrameworksRecursively(const fs::path & path, string platform) {
// alert ("getFrameworksRecursively " + path.string(), 34);
// alert ("getFrameworksRecursively for " + platform + " : " + path.string(), 34);
if (!fs::exists(path) || !fs::is_directory(path)) return;

for (const auto & f : dirList(path)) {
if (fs::is_directory(f)) {
if (f.extension() == ".framework" || f.extension() == ".xcframework") {
// alert ("found XCF " + f.string(), 31);
bool platformFound = false;

// if (ofIsStringInString(platform), f.string()) {
if (!platform.empty() && f.string().find(platform) != std::string::npos) {
platformFound = true;
}

if(platformFound) {
if (f.extension() == ".framework") {
frameworks.emplace_back(f.string());
Expand Down Expand Up @@ -770,11 +774,11 @@ 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);
if (!fs::exists(libsPath)) {
// alert("file not found " + libsPath.string(), 35);
return;
}
// alert ("parseLibsPath " + libsPath.string() + ", parent=" + parentFolder.string(), 35);


if (platform == "osx" || platform == "macos"){
Expand All @@ -787,13 +791,14 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
// getXCFrameworksRecursively(libsPath, "macos");
// getXCFrameworksRecursively(libsPath, "osx");

// FIXME: This is not needed when we get libraries right.
// if it was needed the best was change to std::set.
removeDuplicates(libs);
removeDuplicates(libFiles);
removeDuplicates(frameworks);
removeDuplicates(xcframeworks);

}else{

} else {
getLibsRecursively(libsPath, libFiles, libs, platform);
}

Expand Down Expand Up @@ -834,15 +839,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
s = fixPath(s);
// alert("fixpath after " + ofPathToString(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());

// }
srcFiles.emplace_back(s);
// filesToFolders[s] = folder;
}

// so addons will never be system.
Expand All @@ -853,40 +850,21 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
size_t foundWindowsPath = f.find('\\');
if (foundUnixPath==string::npos &&
foundWindowsPath==string::npos){
bIsSystemFramework = true; // we have no "path" so we are system
bIsSystemFramework = true; // we have no "path" so we are system
}

if (bIsSystemFramework){
; // 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;
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;
addToFolder(f, parentFolder);
}
}

string ofAddon::cleanName(const string& name){
auto addonName = name;
#ifdef TARGET_WIN32
Expand Down
2 changes: 1 addition & 1 deletion commandLine/src/defines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define OFPROJECTGENERATOR_MAJOR_VERSION "0"
#define OFPROJECTGENERATOR_MINOR_VERSION "85"
#define OFPROJECTGENERATOR_MINOR_VERSION "86"
#define OFPROJECTGENERATOR_PATCH_VERSION "0"

#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)
Expand Down
8 changes: 1 addition & 7 deletions commandLine/src/projects/baseProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,21 +576,14 @@ void baseProject::addAddon(ofAddon & addon){
addAddonHeadersrcFiles(addon);



addAddonDefines(addon);

addAddonFrameworks(addon);
// addAddonXCFrameworks(addon);

copyAddonData(addon);

addAddonProps(addon);

}




void baseProject::addAddonLibsPaths(const ofAddon& addon){
if(addon.libsPaths.size()){
ofLogWarning("baseProject::addAddonLibsPaths") << "this is not implemented!";
Expand All @@ -600,6 +593,7 @@ void baseProject::addAddonLibsPaths(const ofAddon& addon){
}
}


void baseProject::addAddonIncludePaths(const ofAddon& addon){
for (auto & e : addon.includePaths) {
ofLogVerbose("baseProject") << "----------------------------------------------------------------";
Expand Down
13 changes: 10 additions & 3 deletions commandLine/src/projects/xcodeProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void xcodeProject::addCompileFlagsForMMFile(const fs::path & srcFile) {

void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK){
ofLogVerbose() << "Adding framework " << ofPathToString(path) << " folder: " << folder;
// alert( "xcodeProject::addFramework " + ofPathToString(path) + " : " + ofPathToString(folder) , 33);
// 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);

Expand Down Expand Up @@ -641,9 +641,16 @@ void xcodeProject::addAddonSrcFiles(ofAddon& addon){
void xcodeProject::addAddonFrameworks(const ofAddon& addon){
ofLogVerbose("xcodeProject::addAddonFrameworks") << addon.name;

for (auto & f : addon.frameworks) {
std::vector <std::string> allFrameworks;
allFrameworks.reserve( addon.frameworks.size() + addon.xcframeworks.size() );
allFrameworks.insert( allFrameworks.end(), addon.frameworks.begin(), addon.frameworks.end() );
allFrameworks.insert( allFrameworks.end(), addon.xcframeworks.begin(), addon.xcframeworks.end() );

for (auto & f : allFrameworks) {
// for (auto & f : addon.frameworks) {
ofLogVerbose() << "adding addon frameworks: " << f;

// alert ("ADD ADDON FRAMEWORKS " + f, 33);

auto path = f;
// The only addon I've found using fixed path to system Frameworks is ofxCoreLocation
// https://github.com/robotconscience/ofxCoreLocation/blob/533ee4b0d380a4a1aafbe1c5923ae66c26b92d53/addon_config.mk#L32
Expand Down

0 comments on commit 0d4e7c3

Please sign in to comment.