Skip to content

Commit c6503b0

Browse files
authored
V82 - Simplify Local SDK Frameworks handling in osx (#586)
* SDK Frameworks change * SDK Frameworks OK * remove addAddonXCFrameworks * add frameworks by parameter
1 parent 6db1628 commit c6503b0

10 files changed

Lines changed: 128 additions & 182 deletions

File tree

commandLine/src/addons/ofAddon.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@
1212
#include <regex>
1313

1414

15+
16+
void ofAddon::getFrameworksRecursively(const fs::path & path, string platform) {
17+
// alert ("getFrameworksRecursively " + path.string(), 34);
18+
if (!fs::exists(path) || !fs::is_directory(path)) return;
19+
20+
for (const auto & f : dirList(path)) {
21+
if (fs::is_directory(f)) {
22+
if (f.extension() == ".framework" || f.extension() == ".xcframework") {
23+
bool platformFound = false;
24+
if (!platform.empty() && f.string().find(platform) != std::string::npos) {
25+
platformFound = true;
26+
}
27+
if(platformFound) {
28+
if (f.extension() == ".framework") {
29+
frameworks.emplace_back(f.string());
30+
}
31+
if (f.extension() == ".xcframework") {
32+
xcframeworks.emplace_back(f.string());
33+
}
34+
}
35+
}
36+
}
37+
}
38+
}
39+
1540
static std::string toString(const std::string& str){
1641
return str;
1742
}
@@ -757,10 +782,10 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
757782
getLibsRecursively(libsPath, libFiles, libs, "macos");
758783
getLibsRecursively(libsPath, libFiles, libs, "osx");
759784

760-
getFrameworksRecursively(libsPath, frameworks, "macos");
761-
getFrameworksRecursively(libsPath, frameworks, "osx");
762-
getXCFrameworksRecursively(libsPath, xcframeworks, "macos");
763-
getXCFrameworksRecursively(libsPath, xcframeworks, "osx");
785+
getFrameworksRecursively(libsPath, "macos");
786+
getFrameworksRecursively(libsPath, "osx");
787+
// getXCFrameworksRecursively(libsPath, "macos");
788+
// getXCFrameworksRecursively(libsPath, "osx");
764789

765790
removeDuplicates(libs);
766791
removeDuplicates(libFiles);
@@ -777,8 +802,8 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
777802
platform == "tvos"){//} ||
778803
//platform == "macos"){
779804

780-
getFrameworksRecursively(libsPath, frameworks, platform);
781-
getXCFrameworksRecursively(libsPath, xcframeworks, platform);
805+
getFrameworksRecursively(libsPath, platform);
806+
// getXCFrameworksRecursively(libsPath, platform);
782807
}
783808

784809
if (platform == "vs" || platform == "msys2"

commandLine/src/addons/ofAddon.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ class ofAddon {
130130
ofAddon() = default;
131131
ofAddon(const ofAddon& other);
132132

133+
void getFrameworksRecursively(const fs::path & path, string platform = "");
134+
133135
static string cleanName(const string& name);
134136

135137
bool load(string addonName, const fs::path& projectDir, const string& targetPlatform);
@@ -162,7 +164,7 @@ class ofAddon {
162164
vector < string > ldflags;
163165
vector < string > pkgConfigLibs; // linux only
164166
vector < string > frameworks; // osx only
165-
vector < string > xcframeworks; // osx only
167+
vector < string > xcframeworks; // osx only
166168
vector < string > data;
167169
vector < string > defines;
168170

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 "81"
2+
#define OFPROJECTGENERATOR_MINOR_VERSION "82"
33
#define OFPROJECTGENERATOR_PATCH_VERSION "0"
44

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

commandLine/src/main.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum optionIndex { UNKNOWN,
2828
GET_HOST_PLATFORM,
2929
COMMAND,
3030
BACKUP_PROJECT_FILES,
31+
FRAMEWORKS
3132
};
3233

3334
constexpr option::Descriptor usage[] = {
@@ -47,6 +48,9 @@ constexpr option::Descriptor usage[] = {
4748
{ GET_HOST_PLATFORM, 0, "i", "platform", option::Arg::None, " --getplatform, -i \treturn the current host platform" },
4849
{ COMMAND, 0, "c", "command", option::Arg::None, " --command, -c \truns command" },
4950
{ BACKUP_PROJECT_FILES, 0, "b", "backup", option::Arg::None, " --backup, -b \tbackup project files when replacing with template" },
51+
52+
{ FRAMEWORKS, 0, "f", "frameworks", option::Arg::Optional, " --frameworks, -f \tframeworks list (such as Vision,ARKit)" },
53+
5054
{ 0, 0, 0, 0, 0, 0 }
5155
};
5256

@@ -72,6 +76,7 @@ fs::path ofPath;
7276
vector<string> addons;
7377
vector<fs::path> srcPaths;
7478
vector<string> targets;
79+
vector<string> frameworks;
7580
string ofPathEnv;
7681
string templateName;
7782

@@ -460,6 +465,7 @@ int main(int argc, char ** argv) {
460465
printVersion();
461466
return EXIT_OK;
462467
}
468+
463469

464470
if (options[OFPATH].count() > 0) {
465471
if (options[OFPATH].arg != NULL) {
@@ -541,6 +547,13 @@ int main(int argc, char ** argv) {
541547
}
542548
#endif
543549

550+
if (options[FRAMEWORKS].count() > 0) {
551+
bAddonsPassedIn = true; // could be empty
552+
if (options[FRAMEWORKS].arg != NULL) {
553+
frameworks = ofSplitString(options[FRAMEWORKS].arg, ",", true, true);
554+
cout << "frameworks " << options[FRAMEWORKS].arg << endl;
555+
}
556+
}
544557

545558

546559
if (parse.nonOptionsCount() > 0) {
@@ -688,7 +701,10 @@ int main(int argc, char ** argv) {
688701
if(bAddonsPassedIn){
689702
for (auto & addon : addons) {
690703
project->addAddon(addon);
691-
}
704+
}
705+
for (auto & f : frameworks) {
706+
project->addFramework(f, "", true);
707+
}
692708
}else{
693709
project->parseAddons();
694710
}

commandLine/src/projects/baseProject.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ void baseProject::addAddon(ofAddon & addon){
584584

585585

586586
addAddonDefines(addon);
587-
addAddonFrameworks(addon);
588-
589-
addAddonXCFrameworks(addon);
587+
588+
addAddonFrameworks(addon);
589+
// addAddonXCFrameworks(addon);
590590

591591
copyAddonData(addon);
592592

commandLine/src/projects/baseProject.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class baseProject {
9696

9797
bool bOverwrite = true;
9898

99+
virtual void addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK = false){};
100+
99101

100102
#ifdef OFADDON_OUTPUT_JSON_DEBUG
101103
void saveAddonsToJson(){
@@ -124,7 +126,7 @@ class baseProject {
124126
protected:
125127

126128
virtual void addAddonFrameworks(const ofAddon& addon){}
127-
virtual void addAddonXCFrameworks(const ofAddon& addon){}
129+
// virtual void addAddonXCFrameworks(const ofAddon& addon){}
128130
virtual void addAddonBegin(const ofAddon& addon){}
129131
virtual void addAddonLibsPaths(const ofAddon& addon);
130132
virtual void addAddonIncludePaths(const ofAddon& addon);
@@ -151,7 +153,6 @@ class baseProject {
151153
virtual void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) = 0; // CXX_FLAGS
152154
virtual void addAfterRule(const std::string& script) = 0;
153155
virtual void addDefine(const std::string& define, LibType libType = RELEASE_LIB) = 0;
154-
155156

156157
void copyAddonData(ofAddon& addon);
157158

0 commit comments

Comments
 (0)