diff --git a/commandLine/commandLine.xcodeproj/project.pbxproj b/commandLine/commandLine.xcodeproj/project.pbxproj index 7822ac2b..b0d6380a 100644 --- a/commandLine/commandLine.xcodeproj/project.pbxproj +++ b/commandLine/commandLine.xcodeproj/project.pbxproj @@ -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 */; }; @@ -54,6 +55,8 @@ 03433CF22BF3B842001412CF /* android2024.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = android2024.cpp; sourceTree = ""; }; 03B57CDB2AC5B1C6005F56E0 /* VSCodeProject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VSCodeProject.cpp; sourceTree = ""; }; 03B57CDC2AC5B1C6005F56E0 /* VSCodeProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VSCodeProject.h; sourceTree = ""; }; + 03CED5002D2C344F00075C8E /* zedProject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = zedProject.h; sourceTree = ""; }; + 03CED5012D2C344F00075C8E /* zedProject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = zedProject.cpp; sourceTree = ""; }; "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 = ""; }; 191EF70929D778A400F35F26 /* openFrameworks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = openFrameworks; path = ../../../libs/openFrameworks; sourceTree = SOURCE_ROOT; }; @@ -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; @@ -297,6 +302,8 @@ isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; buildActionMask = 2147483647; + files = ( + ); name = "Run Script"; runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -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 */, diff --git a/commandLine/compile_flags.txt b/commandLine/compile_flags.txt new file mode 100644 index 00000000..f5f01a3c --- /dev/null +++ b/commandLine/compile_flags.txt @@ -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 diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 80c24850..5f900b2f 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -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; @@ -87,7 +87,7 @@ vector splitStringOnceByLeft(const string &source, const string &delimit // = std::unordered_map(); //} -ofAddon::ofAddon(const ofAddon& other): +ofAddon::ofAddon(const ofAddon& other): additionalLibsFolder(other.additionalLibsFolder), libFiles(other.libFiles), filesToFolders(other.filesToFolders), @@ -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(); @@ -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; } @@ -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. @@ -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"){//} || @@ -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); } @@ -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; @@ -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)) { @@ -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); } @@ -966,7 +985,8 @@ 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 ); } } @@ -974,7 +994,8 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t 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 ); } } @@ -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()); +// +// } } diff --git a/commandLine/src/addons/ofAddon.h b/commandLine/src/addons/ofAddon.h index a4a9352e..8ba7ba83 100644 --- a/commandLine/src/addons/ofAddon.h +++ b/commandLine/src/addons/ofAddon.h @@ -37,10 +37,10 @@ const vector parseStates { "android/x86_64", "emscripten", "android", - "ios", + "macos", "osx", + "ios", "tvos", - "macos", "watchos", "visionos", }; diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 60a52241..d4fbcebd 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -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) diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 485e3579..ee971be2 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -1,15 +1,15 @@ +#include #define TARGET_NO_SOUND #define TARGET_NODISPLAY -#include "Utils.h" #include "defines.h" +#include "Utils.h" #include "ofUtils.h" #include "ofFileUtils.h" #include "ofSystemUtils.h" #include "optionparser.h" -#include -#include #include +#include enum optionIndex { UNKNOWN, HELP, @@ -48,7 +48,7 @@ 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 } @@ -70,7 +70,7 @@ int nProjectsUpdated; int nProjectsCreated; fs::path projectPath; -fs::path defaultAppPath = { "apps/myApps" }; +//fs::path defaultAppPath = { "apps/myApps" }; fs::path generatorPath; fs::path ofPath; vector addons; @@ -103,6 +103,7 @@ void printOFPath() { std::cout << ofPath.string() << endl; } +// no way this is a repeptition of setOFRoot void setofPath(const fs::path& path) { ofLogVerbose() << " setofPath: [" << path << "] "; ofPath = path; @@ -184,19 +185,11 @@ void addPlatforms(const string & value) { } } -bool containsFolder(fs::path path, string folderName) { - bool contains = false; - for (const auto & entry : fs::directory_iterator(path)) { - auto f = entry.path(); - if (f.filename() == folderName) { - contains = true; - break; - } - } - return contains; +bool containsFolder(const fs::path & path, const fs::path & folder) { + return fs::exists(path / folder); } -bool isGoodProjectPath(fs::path path) { +bool isGoodProjectPath(const fs::path & path) { // TODO: think of a way of detecting make obj folders which creates a structure similar to project // like this assimp3DModelLoaderExample/obj/osx/Release/src return fs::exists(path / "src"); @@ -270,7 +263,7 @@ void recursiveUpdate(const fs::path & path, const string & target) { // FIXME: remove // alert("recursiveUpdate :[" + path.string() + "]"); ofLogNotice() << "recursiveUpdate " << path; - + if (!fs::is_directory(path)) return; vector folders; @@ -298,9 +291,10 @@ void recursiveUpdate(const fs::path & path, const string & target) { nProjectsUpdated++; if (!ofPath.is_absolute()) { - setofPath(ofCalcPath); if (ofIsPathInPath(path, ofPath)) { setofPath(fs::relative(ofCalcPath, path)); + } else { + setofPath(ofCalcPath); } } @@ -339,10 +333,11 @@ int updateOFPath(fs::path path) { if (!ofPath.empty() && isGoodOFPath(ofPath)) { ofLogNotice() << "ofPath set and valid using [" << ofPath << "]"; } else { - if(isGoodOFPath(foundOFPath)) + if(isGoodOFPath(foundOFPath)) { setofPath(foundOFPath); setOFRoot(foundOFPath); ofLogVerbose() << "ofPath auto-found and valid using [" << ofPath << "]"; + } } } @@ -354,11 +349,14 @@ int updateOFPath(fs::path path) { return EXIT_USAGE; } } -// if (ofIsPathInPath(projectPath, ofPath)) { -// fs::path path = fs::relative(ofPath, projectPath); -// ofPath = path.string(); -// } - ofPath = normalizePath(ofPath); + + // This make ofPath relative if it is inside project path, and avoid lots of fs::relative down the line + // it is important because we can detect if some path needs to be absolute in the project. + + if (ofIsPathInPath(projectPath, ofPath)) { + ofPath = fs::relative(ofPath, projectPath); + } +// ofPath = normalizePath(ofPath); setOFRoot(ofPath); } @@ -427,6 +425,8 @@ int main(int argc, char ** argv) { // ofPath = ""; templateName = ""; + + // ------------------------------------------------------ parse args argc -= (argc > 0); argv += (argc > 0); // skip program name argv[0] if present @@ -468,17 +468,17 @@ int main(int argc, char ** argv) { printVersion(); return EXIT_OK; } - + if (options[OFPATH].count() > 0) { if (options[OFPATH].arg != NULL) { setofPath(options[OFPATH].arg); ofLogVerbose() << "ofPath arg: [" << ofPath << "]"; - setofPath(normalizePath(ofPath)); + setofPath(ofPath); ofLogVerbose() << "ofPath normalised arg: [" << ofPath << "]"; } } - int updated = updateOFPath(ofPath); + // int updated = updateOFPath(ofPath); if (options[COMMAND].count() > 0) { if (options[COMMAND].arg != NULL) { @@ -584,8 +584,10 @@ int main(int argc, char ** argv) { return EXIT_USAGE; } + fs::path projectPath = normalizePath(fs::weakly_canonical(fs::current_path() / projectName)); - fs::path projectNamePath = projectPath.filename(); +// fs::path projectPath = ""; + fs::path projectNamePath = fs::current_path().filename(); projectName = projectNamePath.string(); @@ -593,34 +595,37 @@ int main(int argc, char ** argv) { ofLogVerbose() << " ofPath path: [" << ofPath << "]"; ofLogVerbose() << " ofRoot path: [" << getOFRoot() << "]"; - if(projectPath == projectPath.root_path()) { - ofLogVerbose() << " !! projectPath == projectPath.root_path() "; - } else if(normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )) == projectPath) { - ofLogVerbose() << " !! normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )) == projectPath "; - ofLogVerbose() << " !! fs::weakly_canonical( projectPath.root_path() / projectName )):=" << fs::weakly_canonical( projectPath.root_path() / projectName ); - ofLogVerbose() << " !! normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )):=" << normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )); - ofLogVerbose() << " !! projectPath:=" << projectPath; - } else if(normalizePath(fs::weakly_canonical( generatorPath / projectName )) == projectPath) { - ofLogVerbose() << " !! normalizePath(fs::weakly_canonical( generatorPath / projectName )) == projectPath "; - } - if(projectPath.empty() ) { - projectPath = normalizePath(fs::weakly_canonical( getOFRoot() / defaultAppPath / projectName)); - ofLogNotice() << " projectPath.empty() path now: [" << projectPath << "]"; - } else if(projectPath == projectPath.root_path() || // if projectPath == "/" - normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )) == projectPath || // or /projectName - normalizePath(fs::weakly_canonical( generatorPath / projectName )) == projectPath // or generatorPath/projectName - ){ - ofLogVerbose() << " fs::weakly_canonical( [" << fs::weakly_canonical( projectPath.root_path() / projectName ) << "]"; - ofLogVerbose() << " projectPath.root_path(): [" << projectPath.root_path() << "]"; - projectPath = normalizePath(fs::weakly_canonical( getOFRoot() / defaultAppPath / projectName)); - ofLogNotice() << " projectPath issue managed, path now: [" << projectPath << "]"; - } else { - ofLogVerbose() << " projectPath path: [" << projectPath << "]"; - } - if(projectPath.empty()) { - messageError( "Invalid project path: {" + projectPath.string() + "}"); - return EXIT_FAILURE; - } + +// if(projectPath == projectPath.root_path()) { +// ofLogVerbose() << " !! projectPath == projectPath.root_path() "; +// } else if(normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )) == projectPath) { +// ofLogVerbose() << " !! normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )) == projectPath "; +// ofLogVerbose() << " !! fs::weakly_canonical( projectPath.root_path() / projectName )):=" << fs::weakly_canonical( projectPath.root_path() / projectName ); +// ofLogVerbose() << " !! normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )):=" << normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )); +// ofLogVerbose() << " !! projectPath:=" << projectPath; +// } else if(normalizePath(fs::weakly_canonical( generatorPath / projectName )) == projectPath) { +// ofLogVerbose() << " !! normalizePath(fs::weakly_canonical( generatorPath / projectName )) == projectPath "; +// } +// if(projectPath.empty() ) { +// projectPath = normalizePath(fs::weakly_canonical( getOFRoot() / defaultAppPath / projectName)); +// ofLogNotice() << " projectPath.empty() path now: [" << projectPath << "]"; +// } else if(projectPath == projectPath.root_path() || // if projectPath == "/" +// normalizePath(fs::weakly_canonical( projectPath.root_path() / projectName )) == projectPath || // or /projectName +// normalizePath(fs::weakly_canonical( generatorPath / projectName )) == projectPath // or generatorPath/projectName +// ){ +// ofLogVerbose() << " fs::weakly_canonical( [" << fs::weakly_canonical( projectPath.root_path() / projectName ) << "]"; +// ofLogVerbose() << " projectPath.root_path(): [" << projectPath.root_path() << "]"; +// projectPath = normalizePath(fs::weakly_canonical( getOFRoot() / defaultAppPath / projectName)); +// ofLogNotice() << " projectPath issue managed, path now: [" << projectPath << "]"; +// } else { +// ofLogVerbose() << " projectPath path: [" << projectPath << "]"; +// } +// if(projectPath.empty()) { +// messageError( "Invalid project path: {" + projectPath.string() + "}"); +// return EXIT_FAILURE; +// } +// + // make folder if (!fs::exists(projectPath)) { try { @@ -681,8 +686,15 @@ int main(int argc, char ** argv) { ofLogNotice() << "from -o option"; } - + for (auto & t : targets) { + if(std::find(platformsOptions.begin(), platformsOptions.end(), t) != platformsOptions.end()) { +// alert ("target platform found " + t, 33); + } else { + alert ("target platform not found " + t, 35); + continue; + } + consoleSpace(); ofLogNotice() << "-----------------------------------------------"; ofLogNotice() << "target platform is: [" << t << "]"; diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 79900364..53d34dbc 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -33,11 +33,11 @@ fs::path baseProject::getPlatformTemplateDir() { ) { folder = "vscode"; } - + // if ( target == "qtcreator" ) { // return getOFRoot() // } - + return getOFRoot() / templatesFolder / folder; } @@ -115,7 +115,7 @@ vector baseProject::listAvailableTemplates(string target) } bool baseProject::create(const fs::path & _path, string templateName){ -// alert("baseProject::create " + path.string() + " : " + templateName, 35); +// alert("baseProject::create " + _path.string() + " : " + templateName, 35); auto path = _path; // just because it is const fs::current_path(path); @@ -125,7 +125,7 @@ bool baseProject::create(const fs::path & _path, string templateName){ // alert("getOFRoot() " + fs::weakly_canonical(fs::absolute(getOFRoot())).string()); // alert("path " + path.string()); // alert("path " + fs::weakly_canonical(fs::absolute(path)).string()); - + // cout << endl; // ofLogNotice() << "create project " << path; @@ -140,16 +140,19 @@ bool baseProject::create(const fs::path & _path, string templateName){ addons.clear(); extSrcPaths.clear(); - templatePath = normalizePath(getPlatformTemplateDir()); - ofLogNotice() << "templatePath: [" << templatePath << "]"; +// templatePath = normalizePath(getPlatformTemplateDir()); + templatePath = getPlatformTemplateDir(); + + ofLogNotice() << "templatePath: " << templatePath; auto projectPath = fs::canonical(fs::current_path() / path); - - projectDir = path; + +// projectDir = path; + projectDir = ""; projectPath = normalizePath(projectPath); - ofLogNotice() << "projectPath: [" << projectPath << "]"; + ofLogNotice() << "projectPath: " << projectPath; projectName = projectPath.filename().string(); - + // we had this in some projects. if we decide to keep this is the place // if (!fs::exists(projectDir)) { // fs::create_directory(projectDir); @@ -158,6 +161,7 @@ bool baseProject::create(const fs::path & _path, string templateName){ // it can be only "src" fs::path projectSrc { projectDir / "src" }; + if (fs::exists(projectSrc) && fs::is_directory(projectSrc)) { bDoesSrcDirExist = true; @@ -171,7 +175,7 @@ bool baseProject::create(const fs::path & _path, string templateName){ ofLogNotice() << e.what(); } - + } } bool ret = createProjectFile(); @@ -193,7 +197,7 @@ bool baseProject::create(const fs::path & _path, string templateName){ for(auto & rename: templateConfig->renames){ auto from = projectDir / rename.first; auto to = projectDir / rename.second; - + if (fs::exists(to)) { fs::remove(to); } @@ -224,6 +228,10 @@ bool baseProject::create(const fs::path & _path, string templateName){ std::sort(fileNames.begin(), fileNames.end(), [](const fs::path & a, const fs::path & b) { return a.string() < b.string(); }); + + // FIXME: I think we should remove this logic and remove the files from default project. + // only the files present are added to the project + for (const auto & f : fileNames) { if (f != "src/ofApp.cpp" && f != "src/ofApp.h" && @@ -239,7 +247,7 @@ bool baseProject::create(const fs::path & _path, string templateName){ for (auto & f : fileNames) { uniquePaths.insert(f.parent_path()); } - + for (auto & p : uniquePaths) { if (containsSourceFiles(p)) { ofLogVerbose() << "[prjFiles-addIncludeDir] contains src - Adding dir: " << p; @@ -302,35 +310,36 @@ bool baseProject::isAddonInCache(const string & addonPath, const string platform return addonsCache[platform].find(addonPath) != addonsCache[platform].end(); } -void baseProject::addAddon(const std::string& _addonName){ +void baseProject::addAddon(const std::string & _addonName){ ofLogVerbose("baseProject::addAddon") << _addonName; // alert( "baseProject::addAddon " + _addonName ); - - auto addonName = ofAddon::cleanName(_addonName); - + +// auto addonName = ofAddon::cleanName(_addonName); + auto addonName = _addonName; + // FIXME : not target, yes platform. //#ifdef TARGET_WIN32 // // std::replace( addonName.begin(), addonName.end(), '/', '\\' ); // fixSlashOrder(addonName); //#endif -// - +// + // addon.addonMakeName = addonName; -// +// // { // auto s = ofSplitString(addonName, "#"); // if(s.size()){ // addonName = s[0]; // } // } -// - +// + if(addonName.empty()){ ofLogError("baseProject::addAddon") << "cant add addon with empty name"; return; } - + //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. @@ -338,7 +347,7 @@ void baseProject::addAddon(const std::string& _addonName){ //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))){ -// +// // addon.addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); // addon.isLocalAddon = true; // ofLogVerbose() << "Adding local addon: " << addonName; @@ -348,21 +357,21 @@ void baseProject::addAddon(const std::string& _addonName){ // addon.addonPath = fs::path { getOFRoot() / "addons" / addonName }; // } // addon.pathToOF = getOFRoot(); -// -// -// +// +// +// // addon.pathToOF = normalizePath(addon.pathToOF); // addon.addonPath = normalizePath(addon.addonPath); -// +// // addon.pathToProject = projectDir; - + ofAddon addon; - + // bool addonOK = false; // bool inCache = isAddonInCache(addonName, target); - + // fs::path addonPath { addonName }; - + // if (fs::exists(addonPath)) { // addon.isLocalAddon = true; // } else { @@ -370,10 +379,10 @@ void baseProject::addAddon(const std::string& _addonName){ // addon.isLocalAddon = false; // addon.addonPath = addonPath; // } - + // ofLogVerbose() << "addon.addonPath to: [" << addon.addonPath.string() << "]"; // ofLogVerbose() << "addon.pathToOF: [" << addon.pathToOF.string() << "]"; - + if(isAddonInCache(addonName, target)){ addon = addonsCache[target][addonName]; }else{ @@ -390,22 +399,22 @@ void baseProject::addAddon(const std::string& _addonName){ // addon = addonsCache[target][addonName]; // addonOK = true; // } - + // if(!addonOK){ // ofLogVerbose() << "Ignoring addon that doesn't seem to exist: " << addonName; // return; //if addon does not exist, stop early // } - + // if(!inCache){ // //cache the addon so we dont have to be reading form disk all the time // addonsCache[target][addonName] = addon; // } -// +// // for (auto & a : addons) { // if (a.name == addon.name) return; // } -// -// +// +// // for (auto & d : addon.dependencies) { // bool found = false; // for (auto & a : addons) { @@ -420,10 +429,10 @@ void baseProject::addAddon(const std::string& _addonName){ // ofLogVerbose() << "trying to add duplicated addon dependency! skipping: " << d; // } // } -// - +// + ofLogNotice() << "adding addon: " << addon.name; - + // MARK: - SPECIFIC for each project. // XCode and VS override the base addAddon. other templates will use baseproject::addAddon(ofAddon... @@ -562,7 +571,7 @@ void baseProject::addAddon(ofAddon & addon){ addAddonBegin(addon); addAddonDllsToCopy(addon); - + addAddonLibsPaths(addon); addAddonIncludePaths(addon); addAddonLibs(addon); @@ -604,14 +613,14 @@ void baseProject::addAddonIncludePaths(const ofAddon& addon){ ofLogVerbose() << "[addon.includePaths] contains src - Adding dir: [" << normalizedDir.string() << "]"; // fs::path ofpathChanged = ofRelativeToOFPATH(projectDir); // ofLogVerbose() << "[addon.includePaths] OFPATH: rel include dir: [" << ofpathChanged.string() << "]"; - + addInclude(normalizedDir); } else { ofLogVerbose() << "[addon.includePaths] no src - not adding: [" << normalizedDir.string() << "]"; } } - - + + // for (auto & a : addon.includePaths) { // fs::path normalizedDir = makeRelative(projectDir, a); // ofLogVerbose() << "adding addon include path: [" << normalizedDir.string() + "]"; @@ -655,7 +664,7 @@ void baseProject::addAddonLdflags(const ofAddon& addon){ } void baseProject::addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder){ - for (auto &s : filepaths) { + for (auto &s : filepaths) { if (bFindInFilesToFolder && (addon.filesToFolders.find(s) == addon.filesToFolders.end())) { addon.filesToFolders[s] = fs::path{""}; } @@ -665,68 +674,26 @@ void baseProject::addSrcFiles(ofAddon& addon, const vector &filepaths, } } -void baseProject::addAddonSrcFiles( ofAddon& addon){ +void baseProject::addAddonSrcFiles( ofAddon& addon){ addSrcFiles(addon, addon.srcFiles, DEFAULT); - - // for (auto & a : addon.srcFiles) { - // fs::path normalizedDir = makeRelative(getOFRoot(), a); - // ofLogVerbose("baseProject") << "adding addon srcFiles: " << normalizedDir.string(); - // addSrc(normalizedDir, addon.filesToFolders.at(a)); - // } } -void baseProject::addAddonCsrcFiles(ofAddon& addon){ - // for (auto & a : addon.csrcFiles) { - // fs::path normalizedDir = makeRelative(getOFRoot(), a); - // ofLogVerbose("baseProject") << "adding addon c srcFiles: " << normalizedDir.string(); - // addSrc(normalizedDir, addon.filesToFolders.at(a), C); - // } +void baseProject::addAddonCsrcFiles(ofAddon& addon){ addSrcFiles(addon, addon.csrcFiles, C); } - - void baseProject::addAddonCppsrcFiles(ofAddon& addon) { addSrcFiles(addon, addon.cppsrcFiles, CPP); } + void baseProject::addAddonObjcsrcFiles(ofAddon& addon) { addSrcFiles(addon, addon.objcsrcFiles, OBJC); } + void baseProject::addAddonHeadersrcFiles(ofAddon& addon) { addSrcFiles(addon, addon.headersrcFiles, HEADER); } -// void baseProject::addAddonCppsrcFiles(const ofAddon& addon){ -// for (auto & a : addon.cppsrcFiles) { -// fs::path normalizedDir = makeRelative(getOFRoot(), a); -// ofLogVerbose("baseProject") << "adding addon cpp srcFiles: " << normalizedDir.string(); -// addSrc(normalizedDir, addon.filesToFolders.at(a),CPP); -// } -// } - -// void baseProject::addAddonObjcsrcFiles(const ofAddon& addon){ -// for (auto & a : addon.objcsrcFiles) { -// fs::path normalizedDir = makeRelative(getOFRoot(), a); -// ofLogVerbose("baseProject") << "adding addon objc srcFiles: " << normalizedDir.string(); -// addSrc(normalizedDir, addon.filesToFolders.at(a),OBJC); -// } -// } - -// void baseProject::addAddonHeadersrcFiles(const ofAddon& addon){ -// for (auto & a : addon.headersrcFiles) { -// fs::path normalizedDir = makeRelative(getOFRoot(), a); -// ofLogVerbose("baseProject") << "adding addon header srcFiles: [" << normalizedDir.string() << "]"; -// addSrc(normalizedDir, addon.filesToFolders.at(a),HEADER); -// } -// } - - - - - - - - void baseProject::addSrcRecursively(const fs::path & srcPath){ // alert("addSrcRecursively " + srcPath.string(), 32); ofLog() << "[addSrcRecursively] using additional source folder " << srcPath.string(); @@ -748,7 +715,7 @@ void baseProject::addSrcRecursively(const fs::path & srcPath){ uniqueIncludeFolders.insert(parent); } } - + for(auto & i : uniqueIncludeFolders){ fs::path normalizedDir = normalizePath(projectDir); ofLogVerbose() << "[addSrcRecursively] search include paths for folder: [" << normalizedDir.string() << "]"; @@ -764,9 +731,9 @@ void baseProject::addSrcRecursively(const fs::path & srcPath){ void baseProject::parseAddons(){ - fs::path parseFile { fs::relative(projectDir / "addons.make") }; -// alert (parseFile.string(), 31); - + fs::path parseFile { "addons.make" }; +// alert ("baseProject::parseAddons() " + parseFile.string(), 33); + for (auto & line : fileToStrings(parseFile)) { auto addon = ofTrim(line); // alert("line " + addon); @@ -780,7 +747,7 @@ void baseProject::parseAddons(){ } void baseProject::parseConfigMake(){ - fs::path parseFile { fs::relative(projectDir / "config.make") }; + fs::path parseFile { "config.make" }; for (auto & line : fileToStrings(parseFile)) { auto config = ofTrim(line); @@ -829,16 +796,17 @@ bool baseProject::recursiveCopy(const fs::path & srcDir, const fs::path & destDi // FIXME: Avoid copying duplicate files like Makefile / config.make when using multiple templates (ex. vscode / osx) bool baseProject::copyTemplateFile::run() { - from = fs::relative(from); - to = fs::relative(to); - +// from = fs::relative(from); +// to = fs::relative(to); + // needed for mingw only. maybe a ifdef here. if (fs::exists(from)) { ofLogVerbose() << "copyTemplateFile from: " << from << " to: " << to; +// alert("base::copyTemplateFile from: " + from.string() + " to: " + to.string(), 33); - if (findReplaces.size()) { + if (findReplaces.size() || appends.size()) { // Load file, replace contents, write to destination. - + std::ifstream fileFrom(from); std::string contents((std::istreambuf_iterator(fileFrom)), std::istreambuf_iterator()); fileFrom.close(); @@ -851,7 +819,12 @@ bool baseProject::copyTemplateFile::run() { replaceAll(contents, f.first, f.second); ofLogVerbose() << "└─ Replacing " << f.first << " : " << f.second; } - + + for (auto & a : appends) { + // alert(a, 35); + contents += "\n" + a; + } + std::ofstream fileTo(to); try{ fileTo << contents; @@ -864,8 +837,8 @@ bool baseProject::copyTemplateFile::run() { return false; } - - + + } else { // straight copy try { diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index 4f4cd18a..a06c4d7e 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -1,6 +1,6 @@ #pragma once -#include "defines.h" +//#include "defines.h" #include "ofAddon.h" #include "pugixml.hpp" #include @@ -72,7 +72,7 @@ class baseProject { void addAddon(const std::string& addon); void addAddon(ofAddon & addon); virtual void addSrcRecursively(const fs::path & srcPath); - + virtual void restoreBackup(const fs::path & srcPath){}; bool isPlatformName(const string & platform); @@ -93,7 +93,7 @@ class baseProject { std::string target; // bool bMakeRelative = false; - + bool bOverwrite = true; virtual void addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK = false){}; @@ -103,28 +103,28 @@ class baseProject { void saveAddonsToJson(){ auto dir = ofFilePath::join(projectDir, "addonsJson"); ofDirectory::createDirectory(dir, false, true); - + for(auto& a: addons){ ofJson j = a; ofSavePrettyJson(ofFilePath::join(dir, a.name+".json"), j); } } #endif - + // this shouldn't be called by anyone. call "create(...), save" etc private: virtual bool createProjectFile()=0; virtual bool loadProjectFile()=0; virtual bool saveProjectFile()=0; - - + + // virtual void renameProject(); // this should get called at the end. protected: - + virtual void addAddonFrameworks(const ofAddon& addon){} // virtual void addAddonXCFrameworks(const ofAddon& addon){} virtual void addAddonBegin(const ofAddon& addon){} @@ -153,25 +153,25 @@ 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); - - + + virtual void addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder = true); - - + + void recursiveCopyContents(const fs::path & srcDir, const fs::path & destDir); void recursiveTemplateCopy(const fs::path & srcDir, const fs::path & destDir); bool recursiveCopy(const fs::path & srcDir, const fs::path & destDir); std::vector addons; std::vector extSrcPaths; - + //cached addons - if an addon is requested more than once, avoid loading from disk as it's quite slow std::map> addonsCache; //indexed by [platform][supplied path] bool isAddonInCache(const std::string & addonPath, const std::string platform); //is this addon in the mem cache? - + static void replaceAll(std::string& str, const std::string& from, const std::string& to) { if(from.empty()) return; @@ -187,7 +187,8 @@ class baseProject { fs::path from; fs::path to; std::vector > findReplaces; - + std::vector appends; + bool run(); }; diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index a4214cae..06671673 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -17,7 +17,7 @@ bool visualStudioProject::createProjectFile(){ createBackup({ projectDir / "Makefile" }, projectDir); createBackup({ projectDir / (projectName + ".vcxproj") }, projectDir); } - + // FIXME: this will insert an empty pair std::pair replacementsForward, replacementsBack; if (!fs::equivalent(getOFRoot(), fs::path{ "../../.." })) { @@ -39,7 +39,7 @@ bool visualStudioProject::createProjectFile(){ replacementsBack } }); - + // project copyTemplateFiles.push_back({ templatePath / "emptyExample.vcxproj", @@ -51,7 +51,7 @@ bool visualStudioProject::createProjectFile(){ } }); - + // user copyTemplateFiles.push_back({ templatePath / "emptyExample.vcxproj.user", @@ -214,8 +214,7 @@ void visualStudioProject::appendFilter(string folderName){ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type){ -// alert("addSrc file: " + srcFile.string(), 35); -// alert("addSrc folder: " + folder.string(), 35); +// alert("addSrc file: " + srcFile.string() + " folder: " + folder.string(), 35); // I had an empty ClCompile field causing errors if (srcFile.empty()) { @@ -239,6 +238,7 @@ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & fold for (std::size_t i = 0; i < folderSubNames.size(); i++){ if (i != 0) folderName += "\\"; folderName += folderSubNames[i]; +// alert("appendFilter: " + folderName, 34); appendFilter(folderName); } @@ -477,10 +477,10 @@ void visualStudioProject::addCompileOption(const string& nodeName, const string& string configuration = ((libType == DEBUG_LIB)?"Debug":"Release"); string nodePath = "//ItemDefinitionGroup[contains(@Condition,'" + configuration + "')]/ClCompile/"+nodeName; - + pugi::xpath_node_set source = doc.select_nodes(nodePath.c_str()); // if(bPrint){ - // alert("visualStudioProject::addCompileOption " + nodeName + " val: " + value + " del: " + delimiter, 33 ); + // alert("visualStudioProject::addCompileOption " + nodeName + " val: " + value + " del: " + delimiter, 33 ); // alert(" nodePath: " + nodePath, 33); // } @@ -625,37 +625,41 @@ void visualStudioProject::addAddonBegin(const ofAddon& addon){ } } } - + void visualStudioProject::addAddonIncludePaths(const ofAddon& addon) { std::set uniqueIncludeDirs; - for (const auto &dir : addon.includePaths) { - fs::path normalizedDir = normalizePath(dir); - std::string dirStr = normalizedDir.string(); + for (const auto & dir : addon.includePaths) { + std::string dirStr = ofPathToString(dir); // this dont work if (dirStr.find("lib\\vs") == std::string::npos && dirStr.find("\\license") == std::string::npos && dirStr.find("lib\\\\vs") == std::string::npos && - dirStr.find("lib\\AndroidJNI") == std::string::npos && - dirStr.find("\\bin\\") == std::string::npos) { - uniqueIncludeDirs.insert(normalizedDir); + dirStr.find("lib\\AndroidJNI") == std::string::npos && + dirStr.find("\\bin\\") == std::string::npos + ) { + if (!dir.empty()) { + uniqueIncludeDirs.insert(dir); + } } else { ofLogVerbose() << "include dir - not adding vs: [" << dir.string() << "]"; } } for (const auto &dir : uniqueIncludeDirs) { - if( (dir.string().size() && dir.string()[0] == '$')){ - addInclude(dir.string()); + alert ("visualSP::DIR " + dir.string(), 33); + if( dir.string()[0] == '$'){ + addInclude(ofPathToString(dir)); } else{ - fs::path normalizedDir = normalizePath(dir); - if (containsSourceFiles(normalizedDir)) { - normalizedDir = makeRelative(projectDir, dir); - ofLogVerbose() << "[vsproject]-uniqueIncludeDirs] contains src - Adding dir:: [" << normalizedDir.string() << "]"; - addInclude(normalizedDir); + +// fs::path normalizedDir = normalizePath(dir); + if (containsSourceFiles(dir)) { +// normalizedDir = makeRelative(projectDir, dir); +// ofLogVerbose() << "[vsproject]-uniqueIncludeDirs] contains src - Adding dir:: [" << normalizedDir.string() << "]"; + addInclude(ofPathToString(dir)); } else { - ofLogVerbose() << "[vsproject]-uniqueIncludeDirs] no src - not adding [" << normalizedDir.string() << "]"; +// ofLogVerbose() << "[vsproject]-uniqueIncludeDirs] no src - not adding [" << normalizedDir.string() << "]"; } } } @@ -689,7 +693,7 @@ void visualStudioProject::addAddonCppflags(const ofAddon& addon) { void visualStudioProject::addSrcFiles(ofAddon& addon, const vector &filepaths, SrcType type, bool bFindInFilesToFolder){ for (auto &s : filepaths) { - + if (bFindInFilesToFolder && (addon.filesToFolders.find(s) == addon.filesToFolders.end())) { addon.filesToFolders[s] = fs::path{""}; } @@ -732,4 +736,3 @@ void visualStudioProject::addAddonProps(const ofAddon& addon){ addProps(normalizedDir); } } - diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index c20a1656..78fdbf51 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -17,7 +17,7 @@ string xcodeProject::LOG_NAME = "xcodeProjectFile"; xcodeProject::xcodeProject(const string & target) : baseProject(target){ // TODO: remove unused variables - if( target == "osx" ){ + if( target == "osx" || target == "macos" ){ folderUUID = { { "src", "E4B69E1C0A3A1BDC003C02F2" }, { "addons", "BB4B014C10F69532006C3DED" }, @@ -85,28 +85,28 @@ bool xcodeProject::createProjectFile(){ copyTemplateFiles.push_back({ - normalizePath(templatePath / "emptyExample.xcodeproj" / "project.pbxproj"), - normalizePath(xcodeProject / "project.pbxproj"), + templatePath / "emptyExample.xcodeproj" / "project.pbxproj", + xcodeProject / "project.pbxproj", {{"emptyExample", projectName}, rootReplacements} }); copyTemplateFiles.push_back({ - normalizePath(templatePath / "Project.xcconfig"), - normalizePath(projectDir / "Project.xcconfig"), + templatePath / "Project.xcconfig", + projectDir / "Project.xcconfig", {rootReplacements} }); if (target == "osx" || target == "macos") { for (auto & f : {"openFrameworks-Info.plist", "of.entitlements"}) { - copyTemplateFiles.push_back({normalizePath(templatePath / f), normalizePath(projectDir / f)}); + copyTemplateFiles.push_back({templatePath / f, projectDir / f}); } } else if (target == "ios" || target == "macos") { for (auto & f : {"ofxiOS-Info.plist", "ofxiOS_Prefix.pch"}) { - copyTemplateFiles.push_back({normalizePath(templatePath / f), normalizePath(projectDir / f)}); + copyTemplateFiles.push_back({ templatePath / f, projectDir / f }); try { - fs::path from = normalizePath(templatePath / "mediaAssets"); - fs::path to = normalizePath(projectDir / "mediaAssets"); + fs::path from = templatePath / "mediaAssets"; + fs::path to = projectDir / "mediaAssets"; if (!fs::exists(to)) { fs::copy(from, to, fs::copy_options::recursive | fs::copy_options::update_existing); } @@ -186,7 +186,7 @@ void xcodeProject::saveScheme(){ } fs::create_directories(schemeFolder); - if (target == "osx") { + if ( target == "osx" || target == "macos" ) { for (auto & f : { "Release", "Debug" }) { copyTemplateFiles.push_back({ templatePath / ("emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample " + string(f) + ".xcscheme"), @@ -236,7 +236,7 @@ void xcodeProject::renameProject(){ //base addCommand("Set :objects:"+buildConfigurationListUUID+":name " + projectName); // Just OSX here, debug app naming. - if( target == "osx" ){ + if( target == "osx" || target == "macos" ){ // TODO: Hardcode to variable // FIXME: Debug needed in name? addCommand("Set :objects:E4B69B5B0A3A1756003C02F2:path " + projectName + "Debug.app"); @@ -259,7 +259,7 @@ fs::path getPathTo(fs::path path, string limit){ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, bool isFolder, fs::path base) { -// alert ("xcodeProject::getFolderUUID "+folder.string());//+" : isfolder="+ofToString(isFolder)+" : base="+ base.string()); +// alert ("xcodeProject::getFolderUUID " + folder.string() + " base:" + base.string());//+" : isfolder="+ofToString(isFolder)+" : base="+ base.string()); // TODO: Change key of folderUUID to base + folder, so "src" in additional source folders // doesn't get confused with "src" from project. @@ -343,8 +343,10 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b if (folderName == "external_sources" || folderName == "local_addons") { - addCommand("Add :objects:"+thisUUID+":sourceTree string SOURCE_ROOT"); - addCommand("Add :objects:"+thisUUID+":path string "); +// addCommand("Add :objects:"+thisUUID+":sourceTree string SOURCE_ROOT"); +// addCommand("Add :objects:"+thisUUID+":path string "); + addCommand("Add :objects:"+thisUUID+":sourceTree string "); + bFolderPathSet = true; } else { @@ -675,6 +677,7 @@ void xcodeProject::addAddonFrameworks(const ofAddon& addon){ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, const fileProperties & fp) { string UUID { "" }; +// alert("xc::addFile " + path.string() + " :folder:" + folder.string(), 31); // cout << "will check if exists " << (projectDir / path) << endl; // if (fs::exists( projectDir / path )) { @@ -715,6 +718,7 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con } addCommand("Add :objects:"+UUID+":lastKnownFileType string " + fileType); addCommand("Add :objects:"+UUID+":name string " + ofPathToString(path.filename())); +// addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path.filename())); if (fp.absolute) { addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); @@ -724,9 +728,13 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con } else { if(folder.begin()->string() == "local_addons" || folder.begin()->string() == "external_sources"){ -// if(path.is_absolute()){ - addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); - addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); + if (path.is_absolute()) { + addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); + addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); + } else { + addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path.filename())); + addCommand("Add :objects:"+UUID+":sourceTree string "); + } // }else{ // if (fs::exists( projectDir / path )) { // addCommand("Add :objects:"+UUID+":path string " + ofPathToString(projectDir /path)); @@ -896,8 +904,11 @@ bool xcodeProject::saveProjectFile(){ // } } catch (json::parse_error & ex) { - ofLogError(xcodeProject::LOG_NAME) << "JSON parse error at byte" << ex.byte; - ofLogError(xcodeProject::LOG_NAME) << "fileName" << fileName; + ofLogError(xcodeProject::LOG_NAME) << "JSON parse error at byte " << ex.byte; + ofLogError(xcodeProject::LOG_NAME) << "fileName " << fileName; + ofLogError(xcodeProject::LOG_NAME) << contents.rdbuf(); + + } contents.close(); diff --git a/commandLine/src/projects/zedProject.cpp b/commandLine/src/projects/zedProject.cpp new file mode 100644 index 00000000..6abb0324 --- /dev/null +++ b/commandLine/src/projects/zedProject.cpp @@ -0,0 +1,78 @@ +/* + * zedProject.cpp + * + * Created on: 04/01/2025 + * Author: Dimitre Lima + */ + +#include "zedProject.h" +#include "ofLog.h" +#include "Utils.h" +#include +using json = nlohmann::json; + +std::string zedProject::LOG_NAME = "zedProject"; + +bool zedProject::createProjectFile(){ + try { + fs::copy(templatePath / ".zed", projectDir / ".zed", fs::copy_options::update_existing | fs::copy_options::recursive); + } catch(fs::filesystem_error& e) { + ofLogError(LOG_NAME) << "error copying folder " << templatePath.string() << " : " << projectDir.string() << " : " << e.what(); + return false; + } + + copyTemplateFiles.push_back({ fs::path { templatePath / "compile_flags.txt" }, + fs::path { projectDir / "compile_flags.txt" } + }); + + copyTemplateFiles.push_back({ fs::path { templatePath / "Makefile" }, + fs::path { projectDir / "Makefile" } + }); + copyTemplateFiles.push_back({ fs::path { templatePath / "config.make" }, + fs::path { projectDir / "config.make" } + }); + return true; +} + + +bool zedProject::loadProjectFile(){ + // workspace.load(); + // cppProperties.load(); + return true; +} + +bool zedProject::saveProjectFile(){ + // workspace.data["openFrameworksProjectGeneratorVersion"] = getPGVersion(); + + for (auto & c : copyTemplateFiles) { + try { + c.run(); + } catch (const std::exception& e) { + std::cerr << "Error running copy template files: " << e.what() << std::endl; + return false; + } + } + return true; +} + +void zedProject::addAddonBegin(const ofAddon& addon) { + // alert("zedProject::addAddon() " + addon.name, 35); +// std::string inc { "-I" + ofPathToString(addon.addonPath) }; +// copyTemplateFiles[0].appends.emplace_back(inc); +} + + +void zedProject::addSrc(const fs::path & srcName, const fs::path & folder, SrcType type){ +// alert ("addSrc " + srcName.string(), 33); +} + +void zedProject::addInclude(const fs::path & includeName){ + // alert ("addInclude " + ofPathToString(includeName), 34); + std::string inc { "-I" + ofPathToString(includeName) }; + copyTemplateFiles[0].appends.emplace_back(inc); + // cppProperties.addToArray("/env/PROJECT_EXTRA_INCLUDES", includeName); +} + +void zedProject::addLibrary(const LibraryBinary & lib){ +// alert ("addLibrary " + lib.path, 35); +} diff --git a/commandLine/src/projects/zedProject.h b/commandLine/src/projects/zedProject.h new file mode 100644 index 00000000..529790b9 --- /dev/null +++ b/commandLine/src/projects/zedProject.h @@ -0,0 +1,37 @@ +/* + * VSCodeProject.h + * + * Created on: 28/09/2023 + * Author: Dimitre Lima + */ + +#pragma once + +#include "baseProject.h" + +class zedProject: public baseProject { +public: + zedProject(const std::string & target) : baseProject(target) {}; + + bool createProjectFile() override; + bool loadProjectFile() override; + bool saveProjectFile() override; + + void addSrc(const fs::path & srcName, const fs::path & folder, SrcType type=DEFAULT) override; + void addInclude(const fs::path & includeName) override; + void addLibrary(const LibraryBinary & lib) override; + + void addLDFLAG(const std::string& ldflag, LibType libType = RELEASE_LIB) override {} + void addCFLAG(const std::string& cflag, LibType libType = RELEASE_LIB) override {} + void addCPPFLAG(const std::string& cppflag, LibType libType = RELEASE_LIB) override {} + void addAfterRule(const std::string& script) override {} + void addDefine(const std::string& define, LibType libType = RELEASE_LIB) override {} + + + void addAddonBegin(const ofAddon& addon) override; + + static std::string LOG_NAME; + +private: + +}; diff --git a/commandLine/src/utils/LibraryBinary.h b/commandLine/src/utils/LibraryBinary.h index 027d85c1..478a7e03 100644 --- a/commandLine/src/utils/LibraryBinary.h +++ b/commandLine/src/utils/LibraryBinary.h @@ -5,7 +5,7 @@ #include "ofConstants.h" -#include "defines.h" +//#include "defines.h" #ifdef OFADDON_OUTPUT_JSON_DEBUG // defined in defines.h. only for dev debugging #include "ofJson.h" diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 256db95d..4bf48157 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -5,6 +5,7 @@ * Author: arturo */ +#include "defines.h" #include "Utils.h" #include "ofUtils.h" @@ -15,6 +16,7 @@ #include "VSCodeProject.h" #include "qtcreatorproject.h" #include "xcodeProject.h" +#include "zedProject.h" #include "uuidxx.h" #include @@ -73,7 +75,7 @@ std::string getPlatformString() { if ( arch == "armv6l" || arch == "armv7l" || - arch == "aarch64" + arch == "aarch64" ) { return "linux" + arch; } @@ -87,7 +89,8 @@ std::string getPlatformString() { return "vs"; #endif #elif defined(__APPLE_CC__) - return "osx"; +// return "osx"; + return "macos"; #else return {}; #endif @@ -217,11 +220,11 @@ static std::vector platforms; bool isFolderNotCurrentPlatform(const string & folderName, const string & platform){ if( platforms.size() == 0 ){ platforms = { + "macos", "osx", "msys2", "vs", "ios", - "macos", "tvos", "linux", "linux64", @@ -281,7 +284,7 @@ void getFoldersRecursively(const fs::path & path, std::vector < fs::path > & fol shouldCheckPlatform = false; // cout << "getFoldersRecursively shouldCheckPlatform = false : " << f.filename().string() << endl; } - + if (fs::is_directory(f) && (!shouldCheckPlatform || !isFolderNotCurrentPlatform(f.filename().string(), platform))) { getFoldersRecursively(f, folderNames, platform); } @@ -306,13 +309,11 @@ void getPropsRecursively(const fs::path & path, std::vector < fs::path > & props void getDllsRecursively(const fs::path & path, std::vector & dlls, string platform) { // alert ("getDllsRecursively " + path.string(), 34); -// if (!fs::exists(path) || !fs::is_directory(path)) return; if (!fs::exists(path) || !fs::is_directory(path)) { // alert ("not found!"); return; } - for (const auto & f : dirList(path)) { if (fs::is_regular_file(f) && (f.extension() == ".dll" || f.extension() == ".so")) { dlls.emplace_back(f.string()); @@ -344,41 +345,19 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil if ((f.extension() == ".framework") || (f.extension() == ".xcframework")) { it.disable_recursion_pending(); continue; - } - //else { -// auto stem = f.stem(); -// auto archFound = std::find(LibraryBinary::archs.begin(), LibraryBinary::archs.end(), stem); -// if (archFound != LibraryBinary::archs.end()) { -// arch = *archFound; -// alert ("arch found: " + arch, 34); -// } else { -// auto targetFound = std::find(LibraryBinary::targets.begin(), LibraryBinary::targets.end(), stem); -// if (targetFound != LibraryBinary::targets.end()) { -// target = *targetFound; -// alert ("target found: " + target, 34); -// } -// } -// } + } + } else { auto ext = ofPathToString(f.extension()); bool platformFound = false; -// if(platform!=""){ -// std::vector splittedPath = ofSplitString(f.string(), fs::path("/").make_preferred().string()); -// for(size_t j=0;j getTargetProject(const string & targ) { targ == "linuxaarch64" ) { return unique_ptr(new VSCodeProject(targ)); - } + } else if (targ == "android") { return unique_ptr(new AndroidStudioProject(targ)); } @@ -457,6 +436,8 @@ unique_ptr getTargetProject(const string & targ) { return unique_ptr(new android2024Project(targ)); } else if (targ == "vscode") { return unique_ptr(new VSCodeProject(targ)); + } else if (targ == "zed") { + return unique_ptr(new zedProject(targ)); } else if (targ == "qtcreator") { return unique_ptr(new QtCreatorProject(targ)); } else { @@ -560,7 +541,7 @@ void createBackup(const fs::path & path, const fs::path & backupPath) { std::string datetimeStr = ofGetTimestampString("%Y-%m-%d"); fs::path backupDir = { backupPath / "backups" / datetimeStr }; - if (fs::exists(backupDir)) { + if (fs::exists(backupDir)) { std::string hour = ofGetTimestampString("%H-%M"); backupDir = { backupPath / "backups" / (datetimeStr + "_" + hour) }; } @@ -659,6 +640,3 @@ bool containsSourceFiles(const fs::path& dir) { // return fs::path(""); // } // } - - - diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index d9e6a235..56bbc3ed 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -31,18 +31,20 @@ static std::map platformsToString { { OF_TARGET_ANDROID, "android" }, // { OF_TARGET_EMSCRIPTEN, "" }, { OF_TARGET_IOS, "ios" }, - { OF_TARGET_MACOS, "macos" }, { OF_TARGET_LINUX, "linux" }, { OF_TARGET_LINUX64, "linux64" }, { OF_TARGET_LINUXARMV6L, "linuxarmv6l" }, { OF_TARGET_LINUXARMV7L, "linuxarmv7l" }, { OF_TARGET_LINUXAARCH64, "linuxaarch64" }, { OF_TARGET_MINGW, "msys2" }, + { OF_TARGET_MACOS, "macos" }, { OF_TARGET_OSX, "osx" }, { OF_TARGET_WINVS, "vs" }, }; static std::vector < std::string > platformsOptions { + "macos", + "osx", "android", "ios", "linux", @@ -51,8 +53,9 @@ static std::vector < std::string > platformsOptions { "linuxarmv7l", "linuxaarch64", "msys2", - "osx", "vs", + "vscode", + "zed", }; string generateUUID(const string & input);