Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V82 - Simplify Local SDK Frameworks handling in osx #586

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions commandLine/src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@
#include <regex>



void ofAddon::getFrameworksRecursively(const fs::path & path, string platform) {
// alert ("getFrameworksRecursively " + 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") {
bool platformFound = false;
if (!platform.empty() && f.string().find(platform) != std::string::npos) {
platformFound = true;
}
if(platformFound) {
if (f.extension() == ".framework") {
frameworks.emplace_back(f.string());
}
if (f.extension() == ".xcframework") {
xcframeworks.emplace_back(f.string());
}
}
}
}
}
}

static std::string toString(const std::string& str){
return str;
}
Expand Down Expand Up @@ -757,10 +782,10 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
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");
getFrameworksRecursively(libsPath, "macos");
getFrameworksRecursively(libsPath, "osx");
// getXCFrameworksRecursively(libsPath, "macos");
// getXCFrameworksRecursively(libsPath, "osx");

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

getFrameworksRecursively(libsPath, frameworks, platform);
getXCFrameworksRecursively(libsPath, xcframeworks, platform);
getFrameworksRecursively(libsPath, platform);
// getXCFrameworksRecursively(libsPath, platform);
}

if (platform == "vs" || platform == "msys2"
Expand Down
4 changes: 3 additions & 1 deletion commandLine/src/addons/ofAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class ofAddon {
ofAddon() = default;
ofAddon(const ofAddon& other);

void getFrameworksRecursively(const fs::path & path, string platform = "");

static string cleanName(const string& name);

bool load(string addonName, const fs::path& projectDir, const string& targetPlatform);
Expand Down Expand Up @@ -162,7 +164,7 @@ class ofAddon {
vector < string > ldflags;
vector < string > pkgConfigLibs; // linux only
vector < string > frameworks; // osx only
vector < string > xcframeworks; // osx only
vector < string > xcframeworks; // osx only
vector < string > data;
vector < string > defines;

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

#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)
Expand Down
18 changes: 17 additions & 1 deletion commandLine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum optionIndex { UNKNOWN,
GET_HOST_PLATFORM,
COMMAND,
BACKUP_PROJECT_FILES,
FRAMEWORKS
};

constexpr option::Descriptor usage[] = {
Expand All @@ -47,6 +48,9 @@ constexpr option::Descriptor usage[] = {
{ GET_HOST_PLATFORM, 0, "i", "platform", option::Arg::None, " --getplatform, -i \treturn the current host platform" },
{ COMMAND, 0, "c", "command", option::Arg::None, " --command, -c \truns command" },
{ BACKUP_PROJECT_FILES, 0, "b", "backup", option::Arg::None, " --backup, -b \tbackup project files when replacing with template" },

{ FRAMEWORKS, 0, "f", "frameworks", option::Arg::Optional, " --frameworks, -f \tframeworks list (such as Vision,ARKit)" },

{ 0, 0, 0, 0, 0, 0 }
};

Expand All @@ -72,6 +76,7 @@ fs::path ofPath;
vector<string> addons;
vector<fs::path> srcPaths;
vector<string> targets;
vector<string> frameworks;
string ofPathEnv;
string templateName;

Expand Down Expand Up @@ -460,6 +465,7 @@ int main(int argc, char ** argv) {
printVersion();
return EXIT_OK;
}


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

if (options[FRAMEWORKS].count() > 0) {
bAddonsPassedIn = true; // could be empty
if (options[FRAMEWORKS].arg != NULL) {
frameworks = ofSplitString(options[FRAMEWORKS].arg, ",", true, true);
cout << "frameworks " << options[FRAMEWORKS].arg << endl;
}
}


if (parse.nonOptionsCount() > 0) {
Expand Down Expand Up @@ -688,7 +701,10 @@ int main(int argc, char ** argv) {
if(bAddonsPassedIn){
for (auto & addon : addons) {
project->addAddon(addon);
}
}
for (auto & f : frameworks) {
project->addFramework(f, "", true);
}
}else{
project->parseAddons();
}
Expand Down
6 changes: 3 additions & 3 deletions commandLine/src/projects/baseProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ void baseProject::addAddon(ofAddon & addon){


addAddonDefines(addon);
addAddonFrameworks(addon);

addAddonXCFrameworks(addon);

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

copyAddonData(addon);

Expand Down
5 changes: 3 additions & 2 deletions commandLine/src/projects/baseProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class baseProject {

bool bOverwrite = true;

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


#ifdef OFADDON_OUTPUT_JSON_DEBUG
void saveAddonsToJson(){
Expand Down Expand Up @@ -124,7 +126,7 @@ class baseProject {
protected:

virtual void addAddonFrameworks(const ofAddon& addon){}
virtual void addAddonXCFrameworks(const ofAddon& addon){}
// virtual void addAddonXCFrameworks(const ofAddon& addon){}
virtual void addAddonBegin(const ofAddon& addon){}
virtual void addAddonLibsPaths(const ofAddon& addon);
virtual void addAddonIncludePaths(const ofAddon& addon);
Expand All @@ -151,7 +153,6 @@ class baseProject {
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);

Expand Down
Loading