Skip to content

Commit

Permalink
macOS changes / addons / xcframeworks fixes [bleeding test] (#527)
Browse files Browse the repository at this point in the history
* macOS changes. Fixes for addons target platform paths. Added macOS

* v49
  • Loading branch information
danoli3 authored Jun 25, 2024
1 parent fdb7762 commit 567076f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 37 deletions.
13 changes: 7 additions & 6 deletions commandLine/src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,18 @@ void ofAddon::parseConfig(){

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;
}


getLibsRecursively(libsPath, libFiles, libs, platform);
if (platform == "osx" || platform == "ios"){
getFrameworksRecursively(libsPath, frameworks, platform);
getXCFrameworksRecursively(libsPath, xcframeworks, platform);
if (platform == "osx" ||
platform == "ios" ||
platform == "tvos" ||
platform == "macos"){
getFrameworksRecursively(libsPath, frameworks, platform);
getXCFrameworksRecursively(libsPath, xcframeworks, platform);
}

if (platform == "vs" || platform == "msys2"
Expand All @@ -496,7 +497,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
|| platform == "linuxarmv7l"
|| platform == "linuxaarch64"
) {
getDllsRecursively(libsPath, dllsToCopy, platform);
getDllsRecursively(libsPath, dllsToCopy, platform);
}


Expand Down
1 change: 1 addition & 0 deletions commandLine/src/addons/ofAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const vector<string> parseStates {
"ios",
"osx",
"tvos",
"macos",
"watchos",
"visionos",
};
Expand Down
1 change: 0 additions & 1 deletion commandLine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ int main(int argc, char ** argv) {
ofPath = fs::canonical(fs::current_path() / ofPath);
//alert ("ofPath canonical " + ofPath.string());
}

if (ofIsPathInPath(projectPath, ofPath)) {
ofPath = fs::relative(ofPath, projectPath);
}
Expand Down
2 changes: 1 addition & 1 deletion commandLine/src/projects/baseProject.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define PG_VERSION "48"
#define PG_VERSION "49"

#include "ofAddon.h"
#include "pugixml.hpp"
Expand Down
4 changes: 2 additions & 2 deletions commandLine/src/projects/xcodeProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool xcodeProject::createProjectFile(){
{ rootReplacements }
});

if (target == "osx") {
if (target == "osx" || target == "macos") {
// TODO: TEST
for (auto & f : { "openFrameworks-Info.plist", "of.entitlements" }) {
copyTemplateFiles.push_back({ templatePath / f, projectDir / f });
Expand All @@ -113,7 +113,7 @@ bool xcodeProject::createProjectFile(){

saveScheme();

if(target == "osx"){
if(target == "osx" || target == "macos"){
saveMakefile();
}

Expand Down
47 changes: 22 additions & 25 deletions commandLine/src/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ bool isFolderNotCurrentPlatform(const string & folderName, const string & platfo
"msys2",
"vs",
"ios",
"macos",
"tvos",
"linux",
"linux64",
"linuxarmv6l",
Expand Down Expand Up @@ -198,12 +200,6 @@ void getFoldersRecursively(const fs::path & path, std::vector < fs::path > & fol

// TODO: This can be converted to recursive_directory, but we have to review if the function isFolderNotCurrentPlatform works correctly in this case.

// for (const auto & entry : fs::recursive_directory_iterator(path)) {
// auto f = entry.path();
// if (f.filename().c_str()[0] == '.') continue;
// if (f.extension() == ".framework") continue;
// }

// TODO: disable recursion pending... it is not recursive yet.
if ((path.extension() != ".framework") || (path.extension() != ".xcframework")) {
for (const auto & entry : fs::directory_iterator(path)) {
Expand All @@ -224,20 +220,32 @@ void getFrameworksRecursively(const fs::path & path, std::vector < string > & fr
for (const auto & f : dirList(path)) {
if (fs::is_directory(f)) {
if (f.extension() == ".framework") {
frameworks.emplace_back(f.string());
bool platformFound = false;
if (!platform.empty() && f.string().find(platform) != std::string::npos) {
platformFound = true;
}
if(platformFound) {
frameworks.emplace_back(f.string());
}
}
}
}
}

void getXCFrameworksRecursively(const fs::path & path, std::vector<string> & frameworks, string platform) {
void getXCFrameworksRecursively(const fs::path & path, std::vector<string> & xcframeworks, string platform) {
// alert("getXCFrameworksRecursively " + 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() == ".xcframework") {
frameworks.emplace_back(f.string());
bool platformFound = false;
if (!platform.empty() && f.string().find(platform) != std::string::npos) {
platformFound = true;
}
if(platformFound) {
xcframeworks.emplace_back(f.string());
}
}
}
}
Expand Down Expand Up @@ -297,8 +305,6 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil
continue;
} else {
auto stem = f.stem();

// cout << "STEM " << stem << endl;
auto archFound = std::find(LibraryBinary::archs.begin(), LibraryBinary::archs.end(), stem);
if (archFound != LibraryBinary::archs.end()) {
arch = *archFound;
Expand All @@ -321,24 +327,15 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil
}
}
}

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

if (ext == ".a" || ext == ".lib" || ext == ".dylib" || ext == ".so" || ext == ".xcframework" ||
if (ext == ".a" || ext == ".lib" || ext == ".dylib" || ext == ".so" || ext == ".xcframework" || ext == ".framework" ||
(ext == ".dll" && platform != "vs")){
if (platformFound){
// libLibs.emplace_back( f, arch, target );
libLibs.push_back({ f.string(), arch, target });

//TODO: THEO hack
if( platform == "ios" ){ //this is so we can add the osx libs for the simulator builds
string currentPath = f.string();
//TODO: THEO double hack this is why we need install.xml - custom ignore ofxOpenCv
if( currentPath.find("ofxOpenCv") == string::npos ){
ofStringReplace(currentPath, "ios", "osx");
if( fs::exists(currentPath) ){
libLibs.push_back({ currentPath, arch, target });
}
}
}
}
} else if (ext == ".h" || ext == ".hpp" || ext == ".c" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" || ext == ".m" || ext == ".mm"){
libFiles.emplace_back(f);
Expand Down
2 changes: 1 addition & 1 deletion commandLine/src/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void getFilesRecursively(const fs::path & path, std::vector < string > & fileNam
void getFilesRecursively(const fs::path & path, std::vector < fs::path > & fileNames);
void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFiles, std::vector < LibraryBinary > & libLibs, string platform = "", string arch = "", string target = "");
void getFrameworksRecursively(const fs::path & path, std::vector < string > & frameworks, string platform = "" );
void getXCFrameworksRecursively(const fs::path & path, std::vector<string> & frameworks, string platform = "");
void getXCFrameworksRecursively(const fs::path & path, std::vector<string> & xcframeworks, string platform = "");
void getPropsRecursively(const fs::path & path, std::vector < fs::path > & props, const string & platform);
void getDllsRecursively(const fs::path & path, std::vector < string > & dlls, string platform);

Expand Down
3 changes: 2 additions & 1 deletion frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const platforms = {
"vs": "Windows (Visual Studio)",
"msys2": "Windows (msys2/mingw)",
"ios": "iOS (Xcode)",
"macos": "Mega iOS/tvOS/macOS (Xcode)",
"android": "Android (Android Studio)",
"linux64": "Linux 64 (VS Code/Make)",
"linuxarmv6l": "Arm 32 (VS Code/Make)",
Expand Down Expand Up @@ -1096,7 +1097,7 @@ ipcMain.on('launchProjectinIDE', (event, arg) => {
}

// // launch xcode
if( arg.platform == 'osx' || arg.platform == 'ios'){
if( arg.platform == 'osx' || arg.platform == 'ios' || arg.platform == 'macos' || || arg.platform == 'tvos' ){
if(hostplatform == 'osx'){
let osxPath = path.join(fullPath, projectName + '.xcodeproj');
console.log( osxPath );
Expand Down

0 comments on commit 567076f

Please sign in to comment.