Skip to content

Commit 0d4e7c3

Browse files
authored
V86 - fix adding xcframeworks to projects (#594)
1 parent e45431a commit 0d4e7c3

File tree

4 files changed

+23
-44
lines changed

4 files changed

+23
-44
lines changed

commandLine/src/addons/ofAddon.cpp

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@
1414

1515

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

2020
for (const auto & f : dirList(path)) {
2121
if (fs::is_directory(f)) {
2222
if (f.extension() == ".framework" || f.extension() == ".xcframework") {
23+
// alert ("found XCF " + f.string(), 31);
2324
bool platformFound = false;
25+
26+
// if (ofIsStringInString(platform), f.string()) {
2427
if (!platform.empty() && f.string().find(platform) != std::string::npos) {
2528
platformFound = true;
2629
}
30+
2731
if(platformFound) {
2832
if (f.extension() == ".framework") {
2933
frameworks.emplace_back(f.string());
@@ -770,11 +774,11 @@ void ofAddon::addToFolder(const fs::path& path, const fs::path & parentFolder){
770774
}
771775

772776
void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFolder) {
773-
// alert ("parseLibsPath " + libsPath.string(), 35);
774777
if (!fs::exists(libsPath)) {
775778
// alert("file not found " + libsPath.string(), 35);
776779
return;
777780
}
781+
// alert ("parseLibsPath " + libsPath.string() + ", parent=" + parentFolder.string(), 35);
778782

779783

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

794+
// FIXME: This is not needed when we get libraries right.
795+
// if it was needed the best was change to std::set.
790796
removeDuplicates(libs);
791797
removeDuplicates(libFiles);
792798
removeDuplicates(frameworks);
793799
removeDuplicates(xcframeworks);
794800

795-
}else{
796-
801+
} else {
797802
getLibsRecursively(libsPath, libFiles, libs, platform);
798803
}
799804

@@ -834,15 +839,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
834839
s = fixPath(s);
835840
// alert("fixpath after " + ofPathToString(s));
836841
addToFolder(s, parentFolder);
837-
// fs::path folder;
838-
// if (isLocalAddon) {
839-
// folder = fs::path { "local_addons" } / fs::relative(s.parent_path(), parentFolder);
840-
// } else {
841-
// folder = fs::relative(s.parent_path(), getOFRoot());
842-
843-
// }
844842
srcFiles.emplace_back(s);
845-
// filesToFolders[s] = folder;
846843
}
847844

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

859856
if (bIsSystemFramework){
860857
; // do we need to do anything here?
861858
} else {
862-
// 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
863-
// fs::path rel = fs::relative (f, isLocalAddon ? pathToProject : pathToOF);
864-
// fs::path folder = rel.parent_path();
865-
//
866-
// if (isLocalAddon) {
867-
// fs::path fFS { f };
868-
// folder = fs::path { "local_addons" } / fs::relative(fFS.parent_path(), parentFolder);
869-
// }
870-
//
871-
// filesToFolders[f] = folder;
872859
addToFolder(f, parentFolder);
873860
}
874861
}
875862

876863
for (const auto & f : xcframeworks) {
877-
878-
// fs::path rel = fs::relative(f, isLocalAddon ? pathToProject : pathToOF);
879-
// fs::path folder = rel.parent_path();
880-
//
881-
// if (isLocalAddon) {
882-
// fs::path fFS { f };
883-
// folder = fs::path { "local_addons" } / fs::relative(fFS.parent_path(), parentFolder);
884-
// }
885-
//
886-
// filesToFolders[f] = folder;
887864
addToFolder(f, parentFolder);
888865
}
889866
}
867+
890868
string ofAddon::cleanName(const string& name){
891869
auto addonName = name;
892870
#ifdef TARGET_WIN32

commandLine/src/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define OFPROJECTGENERATOR_MAJOR_VERSION "0"
2-
#define OFPROJECTGENERATOR_MINOR_VERSION "85"
2+
#define OFPROJECTGENERATOR_MINOR_VERSION "86"
33
#define OFPROJECTGENERATOR_PATCH_VERSION "0"
44

55
#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)

commandLine/src/projects/baseProject.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -576,21 +576,14 @@ void baseProject::addAddon(ofAddon & addon){
576576
addAddonHeadersrcFiles(addon);
577577

578578

579-
580579
addAddonDefines(addon);
581-
582580
addAddonFrameworks(addon);
583581
// addAddonXCFrameworks(addon);
584-
585582
copyAddonData(addon);
586-
587583
addAddonProps(addon);
588-
589584
}
590585

591586

592-
593-
594587
void baseProject::addAddonLibsPaths(const ofAddon& addon){
595588
if(addon.libsPaths.size()){
596589
ofLogWarning("baseProject::addAddonLibsPaths") << "this is not implemented!";
@@ -600,6 +593,7 @@ void baseProject::addAddonLibsPaths(const ofAddon& addon){
600593
}
601594
}
602595

596+
603597
void baseProject::addAddonIncludePaths(const ofAddon& addon){
604598
for (auto & e : addon.includePaths) {
605599
ofLogVerbose("baseProject") << "----------------------------------------------------------------";

commandLine/src/projects/xcodeProject.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void xcodeProject::addCompileFlagsForMMFile(const fs::path & srcFile) {
487487

488488
void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK){
489489
ofLogVerbose() << "Adding framework " << ofPathToString(path) << " folder: " << folder;
490-
// alert( "xcodeProject::addFramework " + ofPathToString(path) + " : " + ofPathToString(folder) , 33);
490+
// alert( "xcodeProject::addFramework " + ofPathToString(path) + " : " + ofPathToString(folder) , 33);
491491
// path = the full path (w name) of this framework
492492
// 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);
493493

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

644-
for (auto & f : addon.frameworks) {
644+
std::vector <std::string> allFrameworks;
645+
allFrameworks.reserve( addon.frameworks.size() + addon.xcframeworks.size() );
646+
allFrameworks.insert( allFrameworks.end(), addon.frameworks.begin(), addon.frameworks.end() );
647+
allFrameworks.insert( allFrameworks.end(), addon.xcframeworks.begin(), addon.xcframeworks.end() );
648+
649+
for (auto & f : allFrameworks) {
650+
// for (auto & f : addon.frameworks) {
645651
ofLogVerbose() << "adding addon frameworks: " << f;
646-
652+
// alert ("ADD ADDON FRAMEWORKS " + f, 33);
653+
647654
auto path = f;
648655
// The only addon I've found using fixed path to system Frameworks is ofxCoreLocation
649656
// https://github.com/robotconscience/ofxCoreLocation/blob/533ee4b0d380a4a1aafbe1c5923ae66c26b92d53/addon_config.mk#L32

0 commit comments

Comments
 (0)