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

V88 - fix for projects outside "myApps" folder #597

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions commandLine/commandLine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
03433CF32BF3B842001412CF /* android2024.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03433CF22BF3B842001412CF /* android2024.cpp */; };
03B57CDD2AC5B1C6005F56E0 /* VSCodeProject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03B57CDB2AC5B1C6005F56E0 /* VSCodeProject.cpp */; };
03CED5022D2C344F00075C8E /* zedProject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03CED5012D2C344F00075C8E /* zedProject.cpp */; };
"1A7D4C46-3FD3-4E35-9025-D0E93ECAD7DD" /* qtcreatorproject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = "C5A3016A-B663-4FE7-B6E6-421C5F168447" /* qtcreatorproject.cpp */; };
"200CCA92-FAEE-4CEB-903B-ABB0D56B991F" /* ofAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = "41F34CBC-2E3E-4C3D-B106-F9D6746B6FF0" /* ofAddon.cpp */; };
"2BC33EEF-CBDE-4E2E-9E0C-DB9AA6E0FE66" /* uuidxx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = "4CB92F80-3CD1-41B1-BD98-26F35C9C7A6E" /* uuidxx.cpp */; };
Expand Down Expand Up @@ -54,6 +55,8 @@
03433CF22BF3B842001412CF /* android2024.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = android2024.cpp; sourceTree = "<group>"; };
03B57CDB2AC5B1C6005F56E0 /* VSCodeProject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VSCodeProject.cpp; sourceTree = "<group>"; };
03B57CDC2AC5B1C6005F56E0 /* VSCodeProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VSCodeProject.h; sourceTree = "<group>"; };
03CED5002D2C344F00075C8E /* zedProject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = zedProject.h; sourceTree = "<group>"; };
03CED5012D2C344F00075C8E /* zedProject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = zedProject.cpp; sourceTree = "<group>"; };
"0C9DC8B7-7304-4A82-BAED-18F7A422ECA1" /* xcodeProject.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = xcodeProject.h; path = src/projects/xcodeProject.h; sourceTree = SOURCE_ROOT; };
191CD6FA2847E21E0085CBB6 /* of.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = of.entitlements; sourceTree = "<group>"; };
191EF70929D778A400F35F26 /* openFrameworks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = openFrameworks; path = ../../../libs/openFrameworks; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -159,6 +162,8 @@
03B57CDC2AC5B1C6005F56E0 /* VSCodeProject.h */,
"4CC7F503-61FC-435C-BA93-F9C1E6D46ABE" /* xcodeProject.cpp */,
"0C9DC8B7-7304-4A82-BAED-18F7A422ECA1" /* xcodeProject.h */,
03CED5002D2C344F00075C8E /* zedProject.h */,
03CED5012D2C344F00075C8E /* zedProject.cpp */,
);
name = projects;
path = src/projects;
Expand Down Expand Up @@ -297,6 +302,8 @@
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
name = "Run Script";
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -353,6 +360,7 @@
"7F2BBCD1-F22D-454A-9100-33D1C12BEA70" /* androidStudioProject.cpp in Sources */,
"E79B31E1-CF27-4D77-B2F2-6AEC329A9F50" /* baseProject.cpp in Sources */,
"1A7D4C46-3FD3-4E35-9025-D0E93ECAD7DD" /* qtcreatorproject.cpp in Sources */,
03CED5022D2C344F00075C8E /* zedProject.cpp in Sources */,
03433CF32BF3B842001412CF /* android2024.cpp in Sources */,
"C2428661-BDEC-41D7-8150-C9BA5EE86C0C" /* visualStudioProject.cpp in Sources */,
"DBD7E2AC-672A-4FD9-B0A4-DF24111D17FB" /* xcodeProject.cpp in Sources */,
Expand Down
53 changes: 53 additions & 0 deletions commandLine/compile_flags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-Wno-c++11-extensions
-std=c17
-std=c++2b
-fobjc-arc
-lstdc++fs
-stdlib=libc++
-mmacosx-version-min=12.0
-MMD
-MP
-MF
-O3
-mtune=native
-DNDEBUG
-Wall
-Werror=return-type
-fexceptions
-fpascal-strings
-x
objective-c++
-I../../../libs/openFrameworks
-I../../../libs/openFrameworks/3d
-I../../../libs/openFrameworks/app
-I../../../libs/openFrameworks/communication
-I../../../libs/openFrameworks/events
-I../../../libs/openFrameworks/gl
-I../../../libs/openFrameworks/graphics
-I../../../libs/openFrameworks/math
-I../../../libs/openFrameworks/sound
-I../../../libs/openFrameworks/types
-I../../../libs/openFrameworks/utils
-I../../../libs/openFrameworks/video
-I../../../libs/FreeImage/include
-I../../../libs/cairo/include
-I../../../libs/curl/include
-I../../../libs/freetype/include
-I../../../libs/glew/include
-I../../../libs/glfw/include/GLFW
-I../../../libs/glm/include
-I../../../libs/json/include
-I../../../libs/pugixml/include
-I../../../libs/rtAudio/include
-I../../../libs/tess2/include
-I../../../libs/uriparser/include/uriparser
-I../../../libs/utf8/include
-I./src
-I./src/addons
-I./src/projects
-I./src/utils
-I./src/uuidxx/src
-I../../../addons/ofxMicroUI/src
-I../../../addons/ofxTools/src
-I../../../addons/ofxTools/src/feature
-I../../../addons/ofxTools/src/fft
125 changes: 79 additions & 46 deletions commandLine/src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void ofAddon::getFrameworksRecursively(const fs::path & path, string platform) {
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;
Expand Down Expand Up @@ -87,7 +87,7 @@ vector<string> splitStringOnceByLeft(const string &source, const string &delimit
// = std::unordered_map<fs::path, fs::path>();
//}

ofAddon::ofAddon(const ofAddon& other):
ofAddon::ofAddon(const ofAddon& other):
additionalLibsFolder(other.additionalLibsFolder),
libFiles(other.libFiles),
filesToFolders(other.filesToFolders),
Expand Down Expand Up @@ -152,7 +152,7 @@ bool ofAddon::checkCorrectVariable(const string & variable, const string & state
AddonMetaVariables.end(),
variable) != AddonMetaVariables.end();
}
else if (state == "osx") {// Why only checking for osx?
else if ( state == "osx" || state == "macos" ) {// Why only checking for osx?
return std::find(AddonProjectVariables.begin(),
AddonProjectVariables.end(),
variable) != AddonProjectVariables.end();
Expand Down Expand Up @@ -770,6 +770,7 @@ void ofAddon::addToFolder(const fs::path& path, const fs::path & parentFolder){
} else {
folder = fs::relative(path.parent_path(), getOFRoot());
}

filesToFolders[path] = folder;
}

Expand All @@ -780,15 +781,18 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
}
// alert ("parseLibsPath " + libsPath.string() + ", parent=" + parentFolder.string(), 35);

// FIXME: Remove This
#define MERGE_MAC_LIBS_HACK
#ifdef MERGE_MAC_LIBS_HACK

if (platform == "osx" || platform == "macos"){
if ( platform == "osx" || platform == "macos" ){
// Horrible hack to make it work with the bad idea of renaming osx to macos
getLibsRecursively(libsPath, libFiles, libs, "macos");
getLibsRecursively(libsPath, libFiles, libs, "osx");

getFrameworksRecursively(libsPath, "macos");
getFrameworksRecursively(libsPath, "osx");
// getXCFrameworksRecursively(libsPath, "macos");
// getXCFrameworksRecursively(libsPath, "macos");
// getXCFrameworksRecursively(libsPath, "osx");

// FIXME: This is not needed when we get libraries right.
Expand All @@ -802,6 +806,15 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
getLibsRecursively(libsPath, libFiles, libs, platform);
}

#else

getLibsRecursively(libsPath, libFiles, libs, platform);
if (platform == "osx" || platform == "macos"){
getFrameworksRecursively(libsPath, platform);
}

#endif

if (//platform == "osx" ||
platform == "ios" ||
platform == "tvos"){//} ||
Expand All @@ -822,22 +835,11 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
getDllsRecursively(libsPath, dllsToCopy, platform);
}

// TODO: this is not needed even if it is local addon but project is outside OF root path
// Absolute paths will be used in this case too.
// Maybe it is the same situation for all others fixPath occurences?
// if (!isLocalAddon) {
for (auto & l : libs) {
// alert("fixpath before " + ofPathToString(l.path));
// l.path = fixPath(l.path);
addToFolder(l.path , parentFolder);
// alert("fixpath after " + ofPathToString(l.path));
}
// }
for (auto & l : libs) {
addToFolder(l.path , parentFolder);
}

for (auto & s : libFiles) {
// alert("fixpath before " + ofPathToString(s));
s = fixPath(s);
// alert("fixpath after " + ofPathToString(s));
addToFolder(s, parentFolder);
srcFiles.emplace_back(s);
}
Expand Down Expand Up @@ -882,37 +884,57 @@ string ofAddon::cleanName(const string& name){
return addonName;
}

// FIXME: change this. second parameter is not needed, projectDir is always CWD
bool ofAddon::load(string addonName, const fs::path& projectDir, const string& targetPlatform){
// alert ("ofAddon::load " + addonName + " :projectDir:" + projectDir.string(), 36);

// we want to set addonMakeName before cleaning the addon name, so it is preserved in the exact same way as it was passed, and the addons.make file can be (re)constructed properly
this->addonMakeName = addonName;

addonName = cleanName(addonName);
// addonName = cleanName(addonName);

if(addonName.empty()){
ofLogError("baseProject::addAddon") << "cant add addon with empty name";
return false;
}

//This should be the only instance where we check if the addon is either local or not.
//being local just means that the addon name is a filepath and it starts with a dot.
//otherwise it will look in the addons folder.
//A local addon is not restricted to one that lives in folder with the name local_addons, should be any valid addon on the filesystem.
//Parsing will generate the correct path to both OF and the project.
//Everything else should be treated exactly in the same way, regardless of it being local or not.
if(addonName[0] == '.' && fs::exists( ofFilePath::join(projectDir, addonName))){
// a local addon can be added but it should have at least one parent folder, like
// addons/ofxMidi if there is no separator on path PG will search in $ofw/addons path

this->addonPath = normalizePath(ofFilePath::join(projectDir, addonName));
fs::path addonNamePath { addonName };
// alert ("addonNamePath " + addonNamePath.string(), 32);
// alert("CWD: " + fs::current_path().string(), 34);
// alert("addonNamePath: has_parent_path " , 33);
// cout << addonNamePath.has_parent_path() << endl;
// alert("fs::exists " + addonNamePath.string(), 33);
// cout << fs::exists(addonNamePath) << endl;

if (addonNamePath.has_parent_path() && fs::exists(fs::current_path() / addonNamePath)) {
// if (addonNamePath.is_absolute()) {
// alert ("IS ABS ! " + addonNamePath.string(), 32);
// }
this->addonPath = addonNamePath;
this->isLocalAddon = true;
ofLogVerbose() << "Adding local addon: " << addonName;
// alert ("IS LOCAL ! " + addonNamePath.string(), 34);
// addon.pathToProject = makeRelative(getOFRoot(), projectDir);
// projectDir;
}else{
}

else {
this->addonPath = fs::path { getOFRoot() / "addons" / addonName };
// alert ("NOT LOCAL ! " + this->addonPath.string(), 34);
}
this->pathToOF = normalizePath(getOFRoot());
// this->pathToOF = normalizePath(getOFRoot());

this->addonPath = normalizePath(addonPath);
// this->addonPath = normalizePath(addonPath);

//alert ("ADDON PATH::"+this->addonPath.string(), 33);

if (!fs::exists(this->addonPath)) {
ofLogVerbose("ofAddon::load") << "addon does not exist!" << addonPath;
return false;
}

this->pathToProject = projectDir;

Expand All @@ -924,15 +946,10 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t

// alert("ofAddon::fromFS path : " + addonPath.string(), 33);

if (!fs::exists(addonPath)) {
ofLogVerbose("ofAddon::load") << "addon does not exist!" << addonPath;
return false;
}

clear();
fs::path addonNamePath { addonName};

name = isLocalAddon ? ofPathToString(addonNamePath.stem()) : ofPathToString(addonNamePath.filename());
// name = isLocalAddon ? ofPathToString(addonNamePath.stem()) : ofPathToString(addonNamePath.filename());
name = ofPathToString(addonNamePath.filename());

fs::path srcPath { addonPath / "src" };
if (fs::exists(srcPath)) {
Expand All @@ -945,8 +962,10 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t
fs::path parentFolder { addonPath.parent_path() };

for (auto & s : srcFiles) {
fs::path sFS { fixPath(s) };
s = sFS;
// alert ("s BFR fixpath " + s.string(), 32);
// s = fixPath(s);
// alert ("s AFT fixpath " + s.string(), 33);

addToFolder(s, parentFolder);
}

Expand All @@ -966,15 +985,17 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t
vector < fs::path > libFolders;
getFoldersRecursively(libsPath, libFolders, platform);
for (auto & path : libFolders) {
paths.emplace_back( fixPath(path) );
// paths.emplace_back( fixPath(path) );
paths.emplace_back( path );
}
}

if (fs::exists(srcPath)) {
vector < fs::path > srcFolders;
getFoldersRecursively(srcPath, srcFolders, platform);
for (auto & path : srcFolders) {
paths.emplace_back( fixPath(path) );
// paths.emplace_back( fixPath(path) );
paths.emplace_back( path );
}
}

Expand Down Expand Up @@ -1053,9 +1074,21 @@ fs::path ofAddon::fixPath(const fs::path & path) {
but the problem is fs::relative actually calculate symlink paths, modifying filename.
which is not good for macos dylibs, like ofxHapPlayer, so I had to replace with the original filename back
*/
if(isLocalAddon){
return normalizePath(( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename());
}else{
return normalizePath(( pathToOF / fs::relative(path, getOFRoot()) ).parent_path() / path.filename());
// alert("of:fixPath " + path.string(), 31);
if (path.is_absolute()) {
return path;
}

return path;

// alert ("ow::pathToProject " + pathToProject.string(), 31);
// alert ("ow::pathToOF " + pathToOF.string(), 31);

// if(isLocalAddon){
//// alert ((normalizePath(( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename())).string());
// return (( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename());
// }else{
// return (( pathToOF / fs::relative(path, getOFRoot()) ).parent_path() / path.filename());
//
// }
}
4 changes: 2 additions & 2 deletions commandLine/src/addons/ofAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const vector<string> parseStates {
"android/x86_64",
"emscripten",
"android",
"ios",
"macos",
"osx",
"ios",
"tvos",
"macos",
"watchos",
"visionos",
};
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 "86"
#define OFPROJECTGENERATOR_MINOR_VERSION "88b"
#define OFPROJECTGENERATOR_PATCH_VERSION "0"

#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)
Expand Down
Loading
Loading