From 543b944a9e7c797c695d1fa3758d7f87e0bb2039 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 26 Nov 2024 20:37:33 -0300 Subject: [PATCH 01/17] local addons changes --- commandLine/src/addons/ofAddon.cpp | 9 +++++++-- commandLine/src/defines.h | 2 +- commandLine/src/projects/baseProject.cpp | 13 +++++++++---- commandLine/src/projects/visualStudioProject.cpp | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 80c24850..0c2b9988 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -886,7 +886,7 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t // 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"; @@ -899,7 +899,12 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t //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))){ + + fs::path localAddon { addonName }; + + if (localAddon.has_parent_path() && fs::exists(projectDir / addonName)) { + +// if(addonName[0] == '.' && fs::exists( ofFilePath::join(projectDir, addonName))){ this->addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); this->isLocalAddon = true; diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 60a52241..47fa3354 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 "87" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 79900364..9262213b 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -220,10 +220,14 @@ bool baseProject::create(const fs::path & _path, string templateName){ // CWD is already on projectDir. so with this we get relative paths getFilesRecursively("src", fileNames); - + 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" && @@ -302,12 +306,13 @@ 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 diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index a4214cae..0ad522e9 100644 --- a/commandLine/src/projects/visualStudioProject.cpp +++ b/commandLine/src/projects/visualStudioProject.cpp @@ -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); } From f4a7ab09c5d798108b972294983dfdb6b3105fd3 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 26 Nov 2024 23:10:26 -0300 Subject: [PATCH 02/17] changes --- commandLine/src/addons/ofAddon.cpp | 27 ++++++---- commandLine/src/main.cpp | 28 ++++++---- commandLine/src/projects/baseProject.cpp | 66 +++++------------------ commandLine/src/projects/xcodeProject.cpp | 35 +++++++----- commandLine/src/utils/Utils.cpp | 30 ++--------- 5 files changed, 75 insertions(+), 111 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 0c2b9988..cc7bdd80 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -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; } @@ -893,12 +894,8 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t 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. + // 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 fs::path localAddon { addonName }; @@ -906,7 +903,12 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t // if(addonName[0] == '.' && fs::exists( ofFilePath::join(projectDir, addonName))){ - this->addonPath = normalizePath(ofFilePath::join(projectDir, addonName)); + if (localAddon.is_absolute()) { + alert ("IS ABS ! " + localAddon.string(), 32); + this->addonPath = localAddon; + } else { + this->addonPath = normalizePath(projectDir / addonName); + } this->isLocalAddon = true; ofLogVerbose() << "Adding local addon: " << addonName; // addon.pathToProject = makeRelative(getOFRoot(), projectDir); @@ -914,9 +916,9 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t }else{ this->addonPath = fs::path { getOFRoot() / "addons" / addonName }; } - this->pathToOF = normalizePath(getOFRoot()); +// this->pathToOF = normalizePath(getOFRoot()); - this->addonPath = normalizePath(addonPath); +// this->addonPath = normalizePath(addonPath); this->pathToProject = projectDir; @@ -1058,9 +1060,16 @@ 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 */ +// alert("of:fixPath " + path.string(), 31); + if (path.is_absolute()) { + return path; + } + if(isLocalAddon){ +// alert ((normalizePath(( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename())).string()); return normalizePath(( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename()); }else{ return normalizePath(( pathToOF / fs::relative(path, getOFRoot()) ).parent_path() / path.filename()); + } } diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 485e3579..966bbee1 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -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; @@ -298,9 +299,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); } } @@ -354,11 +356,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); } @@ -474,7 +479,7 @@ int main(int argc, char ** argv) { if (options[OFPATH].arg != NULL) { setofPath(options[OFPATH].arg); ofLogVerbose() << "ofPath arg: [" << ofPath << "]"; - setofPath(normalizePath(ofPath)); + setofPath(ofPath); ofLogVerbose() << "ofPath normalised arg: [" << ofPath << "]"; } } @@ -584,8 +589,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 = normalizePath(fs::weakly_canonical(fs::current_path() / projectName)); + fs::path projectPath = "."; + fs::path projectNamePath = fs::current_path().filename(); projectName = projectNamePath.string(); @@ -593,6 +600,7 @@ 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) { @@ -621,6 +629,8 @@ int main(int argc, char ** argv) { messageError( "Invalid project path: {" + projectPath.string() + "}"); return EXIT_FAILURE; } + + // make folder if (!fs::exists(projectPath)) { try { diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 9262213b..321a5811 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -33,7 +33,7 @@ fs::path baseProject::getPlatformTemplateDir() { ) { folder = "vscode"; } - + // if ( target == "qtcreator" ) { // return getOFRoot() // } @@ -140,7 +140,8 @@ bool baseProject::create(const fs::path & _path, string templateName){ addons.clear(); extSrcPaths.clear(); - templatePath = normalizePath(getPlatformTemplateDir()); +// templatePath = normalizePath(getPlatformTemplateDir()); + templatePath = getPlatformTemplateDir(); ofLogNotice() << "templatePath: [" << templatePath << "]"; auto projectPath = fs::canonical(fs::current_path() / path); @@ -670,68 +671,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(); @@ -769,8 +728,8 @@ 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); @@ -785,7 +744,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); @@ -834,12 +793,13 @@ 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()) { // Load file, replace contents, write to destination. diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index c20a1656..92bd2435 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -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); } @@ -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,8 +718,10 @@ 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) { + alert ("aiaiaia absolute", 31); addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); if (fs::exists( projectDir / path )) { addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); @@ -724,9 +729,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)); diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 256db95d..24d05842 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -306,13 +306,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,39 +342,17 @@ 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 Date: Wed, 27 Nov 2024 00:51:02 -0300 Subject: [PATCH 03/17] updates --- commandLine/src/addons/ofAddon.cpp | 78 +++++++++++++--------- commandLine/src/defines.h | 2 +- commandLine/src/main.cpp | 80 ++++++++++------------- commandLine/src/projects/baseProject.cpp | 3 +- commandLine/src/projects/baseProject.h | 2 +- commandLine/src/projects/xcodeProject.cpp | 2 +- commandLine/src/utils/LibraryBinary.h | 2 +- commandLine/src/utils/Utils.cpp | 1 + 8 files changed, 91 insertions(+), 79 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index cc7bdd80..1b129b2f 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -837,7 +837,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo for (auto & s : libFiles) { // alert("fixpath before " + ofPathToString(s)); - s = fixPath(s); +// s = fixPath(s); // alert("fixpath after " + ofPathToString(s)); addToFolder(s, parentFolder); srcFiles.emplace_back(s); @@ -884,6 +884,9 @@ string ofAddon::cleanName(const string& name){ } bool ofAddon::load(string addonName, const fs::path& projectDir, const string& targetPlatform){ + + alert ("ofAddon::load " + addonName + " :projectDir:" + projectDir.string(), 37); + // 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; @@ -897,30 +900,41 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t // 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 - fs::path localAddon { addonName }; - - if (localAddon.has_parent_path() && fs::exists(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(addonName[0] == '.' && fs::exists( ofFilePath::join(projectDir, addonName))){ - - if (localAddon.is_absolute()) { - alert ("IS ABS ! " + localAddon.string(), 32); - this->addonPath = localAddon; - } else { - this->addonPath = normalizePath(projectDir / addonName); + 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->addonPath = normalizePath(addonPath); + alert ("TIGRE::"+this->addonPath.string(), 33); + if (!fs::exists(this->addonPath)) { + ofLogVerbose("ofAddon::load") << "addon does not exist!" << addonPath; + return false; + } + this->pathToProject = projectDir; this->platform = targetPlatform; @@ -931,15 +945,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)) { @@ -952,8 +961,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); } @@ -973,7 +984,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 ); } } @@ -981,7 +993,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 ); } } @@ -1064,12 +1077,17 @@ fs::path ofAddon::fixPath(const fs::path & path) { if (path.is_absolute()) { return path; } + + return path; - if(isLocalAddon){ -// alert ((normalizePath(( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename())).string()); - return normalizePath(( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename()); - }else{ - return normalizePath(( pathToOF / fs::relative(path, getOFRoot()) ).parent_path() / path.filename()); - - } +// 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/defines.h b/commandLine/src/defines.h index 47fa3354..28068156 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "87" +#define OFPROJECTGENERATOR_MINOR_VERSION "88" #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 966bbee1..a78bf728 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -1,8 +1,8 @@ #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" @@ -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; @@ -185,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"); @@ -590,8 +582,8 @@ int main(int argc, char ** argv) { } - // fs::path projectPath = normalizePath(fs::weakly_canonical(fs::current_path() / projectName)); - fs::path projectPath = "."; + fs::path projectPath = normalizePath(fs::weakly_canonical(fs::current_path() / projectName)); +// fs::path projectPath = ""; fs::path projectNamePath = fs::current_path().filename(); projectName = projectNamePath.string(); @@ -601,35 +593,35 @@ int main(int argc, char ** argv) { 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)) { diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 321a5811..25d16b6d 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -145,7 +145,8 @@ bool baseProject::create(const fs::path & _path, string templateName){ ofLogNotice() << "templatePath: [" << templatePath << "]"; auto projectPath = fs::canonical(fs::current_path() / path); - projectDir = path; +// projectDir = path; + projectDir = ""; projectPath = normalizePath(projectPath); ofLogNotice() << "projectPath: [" << projectPath << "]"; diff --git a/commandLine/src/projects/baseProject.h b/commandLine/src/projects/baseProject.h index 4f4cd18a..05303d7a 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 diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index 92bd2435..a43942c4 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -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. 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 24d05842..0222df71 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" From a1d059c97418b3f862ce578282a3bb95f7b90e27 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 27 Nov 2024 01:43:42 -0300 Subject: [PATCH 04/17] updates --- commandLine/src/addons/ofAddon.cpp | 45 +++++++----------- commandLine/src/projects/baseProject.cpp | 4 +- .../src/projects/visualStudioProject.cpp | 47 ++++++++++--------- commandLine/src/projects/xcodeProject.cpp | 1 - 4 files changed, 44 insertions(+), 53 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 1b129b2f..57fc8f76 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -823,22 +823,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); } @@ -883,9 +872,9 @@ 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(), 37); +// 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; @@ -901,34 +890,34 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t // addons/ofxMidi if there is no separator on path PG will search in $ofw/addons path 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; +// 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); - } +// 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); +// alert ("IS LOCAL ! " + addonNamePath.string(), 34); // addon.pathToProject = makeRelative(getOFRoot(), projectDir); // projectDir; } else { this->addonPath = fs::path { getOFRoot() / "addons" / addonName }; - alert ("NOT LOCAL ! " + this->addonPath.string(), 34); +// alert ("NOT LOCAL ! " + this->addonPath.string(), 34); } // this->pathToOF = normalizePath(getOFRoot()); // this->addonPath = normalizePath(addonPath); - alert ("TIGRE::"+this->addonPath.string(), 33); + //alert ("ADDON PATH::"+this->addonPath.string(), 33); if (!fs::exists(this->addonPath)) { ofLogVerbose("ofAddon::load") << "addon does not exist!" << addonPath; diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 25d16b6d..230580f7 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -142,13 +142,13 @@ bool baseProject::create(const fs::path & _path, string templateName){ // templatePath = normalizePath(getPlatformTemplateDir()); templatePath = getPlatformTemplateDir(); - ofLogNotice() << "templatePath: [" << templatePath << "]"; + ofLogNotice() << "templatePath: " << templatePath; auto projectPath = fs::canonical(fs::current_path() / path); // projectDir = path; projectDir = ""; projectPath = normalizePath(projectPath); - ofLogNotice() << "projectPath: [" << projectPath << "]"; + ofLogNotice() << "projectPath: " << projectPath; projectName = projectPath.filename().string(); diff --git a/commandLine/src/projects/visualStudioProject.cpp b/commandLine/src/projects/visualStudioProject.cpp index 0ad522e9..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", @@ -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 a43942c4..cf93f1b1 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -721,7 +721,6 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con // addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path.filename())); if (fp.absolute) { - alert ("aiaiaia absolute", 31); addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); if (fs::exists( projectDir / path )) { addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); From 99c82aa66e468f439286866c9427b39303c75615 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Dec 2024 12:18:27 -0300 Subject: [PATCH 05/17] std set --- commandLine/src/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index a78bf728..0efd14de 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -7,9 +7,8 @@ #include "ofFileUtils.h" #include "ofSystemUtils.h" #include "optionparser.h" -#include -#include #include +#include enum optionIndex { UNKNOWN, HELP, @@ -48,7 +47,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 } @@ -117,6 +116,7 @@ bool printTemplates() { auto templates = getTargetProject(target)->listAvailableTemplates(target); allPlatformsTemplates.emplace_back(templates); } + std::set commonTemplates; for (auto & templates : allPlatformsTemplates) { for (auto & t : templates) { @@ -263,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; @@ -348,10 +348,10 @@ int updateOFPath(fs::path path) { return EXIT_USAGE; } } - + // 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); } @@ -465,7 +465,7 @@ int main(int argc, char ** argv) { printVersion(); return EXIT_OK; } - + if (options[OFPATH].count() > 0) { if (options[OFPATH].arg != NULL) { @@ -581,7 +581,7 @@ int main(int argc, char ** argv) { return EXIT_USAGE; } - + fs::path projectPath = normalizePath(fs::weakly_canonical(fs::current_path() / projectName)); // fs::path projectPath = ""; fs::path projectNamePath = fs::current_path().filename(); @@ -621,7 +621,7 @@ int main(int argc, char ** argv) { // messageError( "Invalid project path: {" + projectPath.string() + "}"); // return EXIT_FAILURE; // } -// +// // make folder if (!fs::exists(projectPath)) { @@ -683,7 +683,7 @@ int main(int argc, char ** argv) { ofLogNotice() << "from -o option"; } - + for (auto & t : targets) { consoleSpace(); ofLogNotice() << "-----------------------------------------------"; From 7c45ec219b06085a0aadf708aee7be5243c9cc6e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 16 Dec 2024 07:21:33 -0300 Subject: [PATCH 06/17] disambiguate osx / macos --- .../commandLine.xcodeproj/project.pbxproj | 2 + commandLine/src/addons/ofAddon.cpp | 42 +++++++++++-------- commandLine/src/defines.h | 2 +- commandLine/src/main.cpp | 2 + 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/commandLine/commandLine.xcodeproj/project.pbxproj b/commandLine/commandLine.xcodeproj/project.pbxproj index 7822ac2b..b048827c 100644 --- a/commandLine/commandLine.xcodeproj/project.pbxproj +++ b/commandLine/commandLine.xcodeproj/project.pbxproj @@ -297,6 +297,8 @@ isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; buildActionMask = 2147483647; + files = ( + ); name = "Run Script"; runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 57fc8f76..85895518 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -782,26 +782,32 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo // alert ("parseLibsPath " + libsPath.string() + ", parent=" + parentFolder.string(), 35); +// 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, "osx"); +// +// // FIXME: This is not needed when we get libraries right. +// // if it was needed the best was change to std::set. +// removeDuplicates(libs); +// removeDuplicates(libFiles); +// removeDuplicates(frameworks); +// removeDuplicates(xcframeworks); +// +// } else { +// getLibsRecursively(libsPath, libFiles, libs, platform); +// } + + getLibsRecursively(libsPath, libFiles, libs, platform); 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, "osx"); - - // FIXME: This is not needed when we get libraries right. - // if it was needed the best was change to std::set. - removeDuplicates(libs); - removeDuplicates(libFiles); - removeDuplicates(frameworks); - removeDuplicates(xcframeworks); - - } else { - getLibsRecursively(libsPath, libFiles, libs, platform); + getFrameworksRecursively(libsPath, platform); } + if (//platform == "osx" || platform == "ios" || diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 28068156..a78714b2 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "88" +#define OFPROJECTGENERATOR_MINOR_VERSION "89" #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 0efd14de..05792c52 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -414,6 +414,8 @@ int main(int argc, char ** argv) { bRecursive = false; bHelpRequested = false; bListTemplates = false; + + std::cout << "getPlatformString() " << getPlatformString() << std::endl; targets.emplace_back(getPlatformString()); startTime = 0; From c1e5531965496fdfc660611797fd27046ec9d311 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 19 Dec 2024 13:06:05 -0300 Subject: [PATCH 07/17] v88 --- commandLine/src/projects/xcodeProject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index cf93f1b1..3364d857 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -904,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(); From 1b9a8e077b11cd2e015c6c9e2c7e7c14e1799e81 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 19 Dec 2024 13:10:03 -0300 Subject: [PATCH 08/17] put back the libs hack --- commandLine/src/addons/ofAddon.cpp | 70 ++++++++++++++++-------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 85895518..052f0b21 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), @@ -770,7 +770,7 @@ void ofAddon::addToFolder(const fs::path& path, const fs::path & parentFolder){ } else { folder = fs::relative(path.parent_path(), getOFRoot()); } - + filesToFolders[path] = folder; } @@ -781,33 +781,39 @@ 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"){ + // 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, "osx"); + + // FIXME: This is not needed when we get libraries right. + // if it was needed the best was change to std::set. + removeDuplicates(libs); + removeDuplicates(libFiles); + removeDuplicates(frameworks); + removeDuplicates(xcframeworks); + + } else { + getLibsRecursively(libsPath, libFiles, libs, platform); + } + +#else -// 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, "osx"); -// -// // FIXME: This is not needed when we get libraries right. -// // if it was needed the best was change to std::set. -// removeDuplicates(libs); -// removeDuplicates(libFiles); -// removeDuplicates(frameworks); -// removeDuplicates(xcframeworks); -// -// } else { -// getLibsRecursively(libsPath, libFiles, libs, platform); -// } - getLibsRecursively(libsPath, libFiles, libs, platform); if (platform == "osx" || platform == "macos"){ getFrameworksRecursively(libsPath, platform); } - + +#endif if (//platform == "osx" || platform == "ios" || @@ -881,7 +887,7 @@ string ofAddon::cleanName(const string& name){ // 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; @@ -894,7 +900,7 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t // 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 - + fs::path addonNamePath { addonName }; // alert ("addonNamePath " + addonNamePath.string(), 32); // alert("CWD: " + fs::current_path().string(), 34); @@ -902,7 +908,7 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t // 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); @@ -914,7 +920,7 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t // addon.pathToProject = makeRelative(getOFRoot(), projectDir); // projectDir; } - + else { this->addonPath = fs::path { getOFRoot() / "addons" / addonName }; // alert ("NOT LOCAL ! " + this->addonPath.string(), 34); @@ -929,7 +935,7 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t ofLogVerbose("ofAddon::load") << "addon does not exist!" << addonPath; return false; } - + this->pathToProject = projectDir; this->platform = targetPlatform; @@ -1072,7 +1078,7 @@ fs::path ofAddon::fixPath(const fs::path & path) { if (path.is_absolute()) { return path; } - + return path; // alert ("ow::pathToProject " + pathToProject.string(), 31); @@ -1083,6 +1089,6 @@ fs::path ofAddon::fixPath(const fs::path & path) { // return (( pathToProject / fs::relative(path, pathToProject) ).parent_path() / path.filename()); // }else{ // return (( pathToOF / fs::relative(path, getOFRoot()) ).parent_path() / path.filename()); -// +// // } } From a53d336b4851a464d2379c5be3485d118e78c66d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 19 Dec 2024 13:11:31 -0300 Subject: [PATCH 09/17] v88 --- commandLine/src/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index a78714b2..28068156 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "89" +#define OFPROJECTGENERATOR_MINOR_VERSION "88" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) From bb2e40018765b8f370dd91c13a7dd56f2d3e3da8 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 19 Dec 2024 15:38:53 -0300 Subject: [PATCH 10/17] comment out fix --- commandLine/src/addons/ofAddon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index 052f0b21..d0abe328 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -792,8 +792,8 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo getFrameworksRecursively(libsPath, "macos"); getFrameworksRecursively(libsPath, "osx"); -/ getXCFrameworksRecursively(libsPath, "macos"); -/ getXCFrameworksRecursively(libsPath, "osx"); +// getXCFrameworksRecursively(libsPath, "macos"); +// getXCFrameworksRecursively(libsPath, "osx"); // FIXME: This is not needed when we get libraries right. // if it was needed the best was change to std::set. From d900c48c9714760834593caee6bd9111a9554bf3 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 4 Jan 2025 19:15:38 -0300 Subject: [PATCH 11/17] add zed template --- commandLine/compile_flags.txt | 53 ++++++++ commandLine/src/main.cpp | 11 +- commandLine/src/projects/zedProject.cpp | 166 ++++++++++++++++++++++++ commandLine/src/projects/zedProject.h | 37 ++++++ 4 files changed, 262 insertions(+), 5 deletions(-) create mode 100644 commandLine/compile_flags.txt create mode 100644 commandLine/src/projects/zedProject.cpp create mode 100644 commandLine/src/projects/zedProject.h diff --git a/commandLine/compile_flags.txt b/commandLine/compile_flags.txt new file mode 100644 index 00000000..a9af7da1 --- /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 +-I../../../addons/ofxMicroUI/src +-I../../../addons/ofxTools/src +-I../../../addons/ofxTools/src/feature +-I../../../addons/ofxTools/src/fft diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 05792c52..2c8841c4 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -1,3 +1,4 @@ +#include #define TARGET_NO_SOUND #define TARGET_NODISPLAY @@ -116,7 +117,6 @@ bool printTemplates() { auto templates = getTargetProject(target)->listAvailableTemplates(target); allPlatformsTemplates.emplace_back(templates); } - std::set commonTemplates; for (auto & templates : allPlatformsTemplates) { for (auto & t : templates) { @@ -333,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 << "]"; + } } } @@ -414,8 +415,6 @@ int main(int argc, char ** argv) { bRecursive = false; bHelpRequested = false; bListTemplates = false; - - std::cout << "getPlatformString() " << getPlatformString() << std::endl; targets.emplace_back(getPlatformString()); startTime = 0; @@ -426,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 @@ -477,7 +478,7 @@ int main(int argc, char ** argv) { ofLogVerbose() << "ofPath normalised arg: [" << ofPath << "]"; } } - int updated = updateOFPath(ofPath); + // int updated = updateOFPath(ofPath); if (options[COMMAND].count() > 0) { if (options[COMMAND].arg != NULL) { diff --git a/commandLine/src/projects/zedProject.cpp b/commandLine/src/projects/zedProject.cpp new file mode 100644 index 00000000..7a875ab5 --- /dev/null +++ b/commandLine/src/projects/zedProject.cpp @@ -0,0 +1,166 @@ +/* + * zedProject.cpp + * + * Created on: 04/01/2025 + * Author: Dimitre Lima + */ + +#include "zedProject.h" +#include "ofLog.h" +#include "Utils.h" +#include + + +using json = nlohmann::json; + +struct fileJson { + fs::path fileName; + json data; + + // only works for workspace + void addPath(fs::path folder) { + std::string path = folder.is_absolute() ? folder.string() : "${workspaceRoot}/../" + folder.string(); + json object; + object["path"] = path; + json::json_pointer p = json::json_pointer("/folders"); + data[p].emplace_back( object ); + } + + void addToArray(string pointer, fs::path value) { + json::json_pointer p = json::json_pointer(pointer); + if (!data[p].is_array()) { + data[p] = json::array(); + } + + std::string path = fs::path(value).is_absolute() ? value.string() : "${workspaceRoot}/" + value.string(); + data[p].emplace_back( path ); + } + + void load() { + if (!fs::exists(fileName)) { + ofLogError(zedProject::LOG_NAME) << "JSON file not found " << fileName.string(); + return; + } + + std::ifstream ifs(fileName); + try { + data = json::parse(ifs); + } catch (json::parse_error& ex) { + ofLogError(zedProject::LOG_NAME) << "JSON parse error at byte" << ex.byte; + ofLogError(zedProject::LOG_NAME) << "fileName" << fileName.string(); + } + } + + void save() { +// alert ("saving now " + fileName.string(), 33); +// std::cout << data.dump(1, '\t') << std::endl; + std::ofstream jsonFile(fileName); + try { + jsonFile << data.dump(1, '\t'); + } catch(std::exception & e) { + ofLogError(zedProject::LOG_NAME) << "Error saving json to " << fileName.string() << ": " << e.what(); + } + } +}; + +fileJson workspace; +fileJson cppProperties; +std::string zedProject::LOG_NAME = "zedProject"; + +bool zedProject::createProjectFile(){ + + if (backupProjectFiles) { + createBackup({ projectDir / ".vscode" / "c_cpp_properties.json" }, projectDir); + createBackup({ projectDir / ".vscode" / "extensions.json" }, projectDir); + createBackup({ projectDir / ".vscode" / "launch.json" }, projectDir); + createBackup({ projectDir / ".vscode" / "tasks.json" }, projectDir); + createBackup({ projectDir / (projectName + ".code-workspace") }, projectDir); + createBackup({ projectDir / "addons.make" }, projectDir); + createBackup({ projectDir / "config.make" }, projectDir); + createBackup({ projectDir / "Makefile" }, projectDir); + } + +#if defined(__MINGW32__) || defined(__MINGW64__) + try { + fs::remove_all(projectDir / ".vscode"); + } catch(fs::filesystem_error& e) { + ofLogError(LOG_NAME) << "error removing folder .vscode " << e.what(); + return false; + } +#endif + + try { + fs::copy(templatePath / ".vscode", projectDir / ".vscode", 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; + } + + + workspace.fileName = fs::path { + projectDir / (projectName + ".code-workspace")}; + cppProperties.fileName = fs::path { + projectDir / ".vscode/c_cpp_properties.json" + }; + + copyTemplateFiles.push_back({ fs::path { templatePath / "Makefile" }, + fs::path { projectDir / "Makefile" } + }); + copyTemplateFiles.push_back({ fs::path { templatePath / "config.make" }, + fs::path { projectDir / "config.make" } + }); + copyTemplateFiles.push_back({ fs::path { templatePath / "emptyExample.code-workspace" }, + fs::path { projectDir / workspace.fileName } + }); + + 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; +} + + +bool zedProject::loadProjectFile(){ + workspace.load(); + cppProperties.load(); + return true; +} + +void zedProject::addAddonBegin(const ofAddon& addon) { +// alert("zedProject::addAddon() " + addon.name, 35); + + workspace.addPath(addon.addonPath); + + // examples of how to add entries to json arrays +// cppProperties.addToArray("/env/PROJECT_ADDON_INCLUDES", addon.addonPath); +// cppProperties.addToArray("/env/PROJECT_EXTRA_INCLUDES", addon.addonPath); + +} + + +bool zedProject::saveProjectFile(){ + workspace.data["openFrameworksProjectGeneratorVersion"] = getPGVersion(); + workspace.save(); + cppProperties.save(); + return true; +} + + +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 " + includeName, 34); + 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: + +}; From a030cb0d6eb31691f2d101bfdc12a0fb6a323089 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 4 Jan 2025 20:20:42 -0300 Subject: [PATCH 12/17] add ZED editor as a platform --- commandLine/src/projects/baseProject.cpp | 104 +++++++++--------- commandLine/src/projects/baseProject.h | 31 +++--- commandLine/src/projects/zedProject.cpp | 134 ++++------------------- commandLine/src/utils/Utils.cpp | 18 +-- 4 files changed, 102 insertions(+), 185 deletions(-) diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index 230580f7..acbbdb7d 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -37,7 +37,7 @@ fs::path baseProject::getPlatformTemplateDir() { // if ( target == "qtcreator" ) { // return getOFRoot() // } - + return getOFRoot() / templatesFolder / folder; } @@ -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; @@ -144,14 +144,14 @@ bool baseProject::create(const fs::path & _path, string templateName){ templatePath = getPlatformTemplateDir(); ofLogNotice() << "templatePath: " << templatePath; auto projectPath = fs::canonical(fs::current_path() / path); - + // projectDir = path; projectDir = ""; projectPath = normalizePath(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); @@ -160,7 +160,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; } else { @@ -173,7 +173,7 @@ bool baseProject::create(const fs::path & _path, string templateName){ ofLogNotice() << e.what(); } - + } } bool ret = createProjectFile(); @@ -195,7 +195,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); } @@ -222,14 +222,14 @@ bool baseProject::create(const fs::path & _path, string templateName){ // CWD is already on projectDir. so with this we get relative paths getFilesRecursively("src", fileNames); - + 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" && @@ -245,7 +245,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; @@ -311,7 +311,7 @@ bool baseProject::isAddonInCache(const string & addonPath, const string platform void baseProject::addAddon(const std::string & _addonName){ ofLogVerbose("baseProject::addAddon") << _addonName; // alert( "baseProject::addAddon " + _addonName ); - + // auto addonName = ofAddon::cleanName(_addonName); auto addonName = _addonName; @@ -321,23 +321,23 @@ void baseProject::addAddon(const std::string & _addonName){ // // 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. @@ -345,7 +345,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; @@ -355,21 +355,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 { @@ -377,10 +377,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{ @@ -397,22 +397,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) { @@ -427,10 +427,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... @@ -569,7 +569,7 @@ void baseProject::addAddon(ofAddon & addon){ addAddonBegin(addon); addAddonDllsToCopy(addon); - + addAddonLibsPaths(addon); addAddonIncludePaths(addon); addAddonLibs(addon); @@ -611,14 +611,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() + "]"; @@ -662,7 +662,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{""}; } @@ -713,7 +713,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() << "]"; @@ -731,7 +731,7 @@ void baseProject::addSrcRecursively(const fs::path & srcPath){ void baseProject::parseAddons(){ fs::path parseFile { "addons.make" }; // alert ("baseProject::parseAddons() " + parseFile.string(), 33); - + for (auto & line : fileToStrings(parseFile)) { auto addon = ofTrim(line); // alert("line " + addon); @@ -796,7 +796,7 @@ bool baseProject::recursiveCopy(const fs::path & srcDir, const fs::path & destDi bool baseProject::copyTemplateFile::run() { // 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; @@ -804,7 +804,7 @@ bool baseProject::copyTemplateFile::run() { if (findReplaces.size()) { // Load file, replace contents, write to destination. - + std::ifstream fileFrom(from); std::string contents((std::istreambuf_iterator(fileFrom)), std::istreambuf_iterator()); fileFrom.close(); @@ -817,7 +817,11 @@ bool baseProject::copyTemplateFile::run() { replaceAll(contents, f.first, f.second); ofLogVerbose() << "└─ Replacing " << f.first << " : " << f.second; } - + + for (auto & a : appends) { + contents += "\n" + a; + } + std::ofstream fileTo(to); try{ fileTo << contents; @@ -830,8 +834,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 05303d7a..a06c4d7e 100644 --- a/commandLine/src/projects/baseProject.h +++ b/commandLine/src/projects/baseProject.h @@ -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/zedProject.cpp b/commandLine/src/projects/zedProject.cpp index 7a875ab5..c54e95eb 100644 --- a/commandLine/src/projects/zedProject.cpp +++ b/commandLine/src/projects/zedProject.cpp @@ -9,99 +9,21 @@ #include "ofLog.h" #include "Utils.h" #include - - using json = nlohmann::json; -struct fileJson { - fs::path fileName; - json data; - - // only works for workspace - void addPath(fs::path folder) { - std::string path = folder.is_absolute() ? folder.string() : "${workspaceRoot}/../" + folder.string(); - json object; - object["path"] = path; - json::json_pointer p = json::json_pointer("/folders"); - data[p].emplace_back( object ); - } - - void addToArray(string pointer, fs::path value) { - json::json_pointer p = json::json_pointer(pointer); - if (!data[p].is_array()) { - data[p] = json::array(); - } - - std::string path = fs::path(value).is_absolute() ? value.string() : "${workspaceRoot}/" + value.string(); - data[p].emplace_back( path ); - } - - void load() { - if (!fs::exists(fileName)) { - ofLogError(zedProject::LOG_NAME) << "JSON file not found " << fileName.string(); - return; - } - - std::ifstream ifs(fileName); - try { - data = json::parse(ifs); - } catch (json::parse_error& ex) { - ofLogError(zedProject::LOG_NAME) << "JSON parse error at byte" << ex.byte; - ofLogError(zedProject::LOG_NAME) << "fileName" << fileName.string(); - } - } - - void save() { -// alert ("saving now " + fileName.string(), 33); -// std::cout << data.dump(1, '\t') << std::endl; - std::ofstream jsonFile(fileName); - try { - jsonFile << data.dump(1, '\t'); - } catch(std::exception & e) { - ofLogError(zedProject::LOG_NAME) << "Error saving json to " << fileName.string() << ": " << e.what(); - } - } -}; - -fileJson workspace; -fileJson cppProperties; std::string zedProject::LOG_NAME = "zedProject"; bool zedProject::createProjectFile(){ - - if (backupProjectFiles) { - createBackup({ projectDir / ".vscode" / "c_cpp_properties.json" }, projectDir); - createBackup({ projectDir / ".vscode" / "extensions.json" }, projectDir); - createBackup({ projectDir / ".vscode" / "launch.json" }, projectDir); - createBackup({ projectDir / ".vscode" / "tasks.json" }, projectDir); - createBackup({ projectDir / (projectName + ".code-workspace") }, projectDir); - createBackup({ projectDir / "addons.make" }, projectDir); - createBackup({ projectDir / "config.make" }, projectDir); - createBackup({ projectDir / "Makefile" }, projectDir); - } - -#if defined(__MINGW32__) || defined(__MINGW64__) - try { - fs::remove_all(projectDir / ".vscode"); - } catch(fs::filesystem_error& e) { - ofLogError(LOG_NAME) << "error removing folder .vscode " << e.what(); - return false; - } -#endif - try { - fs::copy(templatePath / ".vscode", projectDir / ".vscode", fs::copy_options::update_existing | fs::copy_options::recursive); + 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; } - - workspace.fileName = fs::path { - projectDir / (projectName + ".code-workspace")}; - cppProperties.fileName = fs::path { - projectDir / ".vscode/c_cpp_properties.json" - }; + 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" } @@ -109,9 +31,18 @@ bool zedProject::createProjectFile(){ copyTemplateFiles.push_back({ fs::path { templatePath / "config.make" }, fs::path { projectDir / "config.make" } }); - copyTemplateFiles.push_back({ fs::path { templatePath / "emptyExample.code-workspace" }, - fs::path { projectDir / workspace.fileName } - }); + return true; +} + + +bool zedProject::loadProjectFile(){ + // workspace.load(); + // cppProperties.load(); + return true; +} + +bool zedProject::saveProjectFile(){ + // workspace.data["openFrameworksProjectGeneratorVersion"] = getPGVersion(); for (auto & c : copyTemplateFiles) { try { @@ -121,34 +52,13 @@ bool zedProject::createProjectFile(){ return false; } } - - return true; -} - - -bool zedProject::loadProjectFile(){ - workspace.load(); - cppProperties.load(); return true; } void zedProject::addAddonBegin(const ofAddon& addon) { -// alert("zedProject::addAddon() " + addon.name, 35); - - workspace.addPath(addon.addonPath); - - // examples of how to add entries to json arrays -// cppProperties.addToArray("/env/PROJECT_ADDON_INCLUDES", addon.addonPath); -// cppProperties.addToArray("/env/PROJECT_EXTRA_INCLUDES", addon.addonPath); - -} - - -bool zedProject::saveProjectFile(){ - workspace.data["openFrameworksProjectGeneratorVersion"] = getPGVersion(); - workspace.save(); - cppProperties.save(); - return true; + alert("zedProject::addAddon() " + addon.name, 35); + std::string inc { "-I" + ofPathToString(addon.addonPath) }; + copyTemplateFiles[0].appends.emplace_back(inc); } @@ -157,8 +67,10 @@ void zedProject::addSrc(const fs::path & srcName, const fs::path & folder, SrcTy } void zedProject::addInclude(const fs::path & includeName){ -// alert ("addInclude " + includeName, 34); - cppProperties.addToArray("/env/PROJECT_EXTRA_INCLUDES", 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){ diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 0222df71..147980ed 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -16,6 +16,7 @@ #include "VSCodeProject.h" #include "qtcreatorproject.h" #include "xcodeProject.h" +#include "zedProject.h" #include "uuidxx.h" #include @@ -74,7 +75,7 @@ std::string getPlatformString() { if ( arch == "armv6l" || arch == "armv7l" || - arch == "aarch64" + arch == "aarch64" ) { return "linux" + arch; } @@ -282,7 +283,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); } @@ -344,7 +345,7 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil it.disable_recursion_pending(); continue; } - + } else { auto ext = ofPathToString(f.extension()); bool platformFound = false; @@ -355,7 +356,7 @@ void getLibsRecursively(const fs::path & path, std::vector < fs::path > & libFil if (ext == ".a" || ext == ".lib" || ext == ".dylib" || ext == ".so" || (ext == ".dll" && platform != "vs")) { if (platformFound){ - + LibraryBinary lib(f); if(lib.isValidFor(arch, target)){ // alert ("adding lib " + f.string() + " arch: " + arch + " target: " + target, 34); @@ -426,7 +427,7 @@ unique_ptr getTargetProject(const string & targ) { targ == "linuxaarch64" ) { return unique_ptr(new VSCodeProject(targ)); - } + } else if (targ == "android") { return unique_ptr(new AndroidStudioProject(targ)); } @@ -434,6 +435,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 { @@ -537,7 +540,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) }; } @@ -636,6 +639,3 @@ bool containsSourceFiles(const fs::path& dir) { // return fs::path(""); // } // } - - - From 7ae3e5fc0f6969338c729e37d33e04b403172f76 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 Jan 2025 13:07:11 -0300 Subject: [PATCH 13/17] update zed, xcode project --- commandLine/commandLine.xcodeproj/project.pbxproj | 6 ++++++ commandLine/compile_flags.txt | 2 +- commandLine/src/projects/baseProject.cpp | 3 ++- commandLine/src/projects/zedProject.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/commandLine/commandLine.xcodeproj/project.pbxproj b/commandLine/commandLine.xcodeproj/project.pbxproj index b048827c..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; @@ -355,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 index a9af7da1..f5f01a3c 100644 --- a/commandLine/compile_flags.txt +++ b/commandLine/compile_flags.txt @@ -46,7 +46,7 @@ objective-c++ -I./src/addons -I./src/projects -I./src/utils --I./src/uuidxx +-I./src/uuidxx/src -I../../../addons/ofxMicroUI/src -I../../../addons/ofxTools/src -I../../../addons/ofxTools/src/feature diff --git a/commandLine/src/projects/baseProject.cpp b/commandLine/src/projects/baseProject.cpp index acbbdb7d..8f3fe447 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -802,7 +802,7 @@ bool baseProject::copyTemplateFile::run() { 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); @@ -819,6 +819,7 @@ bool baseProject::copyTemplateFile::run() { } for (auto & a : appends) { + // alert(a, 35); contents += "\n" + a; } diff --git a/commandLine/src/projects/zedProject.cpp b/commandLine/src/projects/zedProject.cpp index c54e95eb..6abb0324 100644 --- a/commandLine/src/projects/zedProject.cpp +++ b/commandLine/src/projects/zedProject.cpp @@ -56,9 +56,9 @@ bool zedProject::saveProjectFile(){ } 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); + // alert("zedProject::addAddon() " + addon.name, 35); +// std::string inc { "-I" + ofPathToString(addon.addonPath) }; +// copyTemplateFiles[0].appends.emplace_back(inc); } @@ -67,7 +67,7 @@ void zedProject::addSrc(const fs::path & srcName, const fs::path & folder, SrcTy } void zedProject::addInclude(const fs::path & includeName){ - alert ("addInclude " + ofPathToString(includeName), 34); + // alert ("addInclude " + ofPathToString(includeName), 34); std::string inc { "-I" + ofPathToString(includeName) }; copyTemplateFiles[0].appends.emplace_back(inc); // cppProperties.addToArray("/env/PROJECT_EXTRA_INCLUDES", includeName); From 913d5416c73feab702e97945754f75812fbccc7f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 Jan 2025 13:49:19 -0300 Subject: [PATCH 14/17] check if platform exists. add zed and vscode as platforms --- commandLine/src/defines.h | 2 +- commandLine/src/main.cpp | 7 +++++++ commandLine/src/projects/baseProject.cpp | 6 ++++-- commandLine/src/utils/Utils.h | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 28068156..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 "88" +#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 2c8841c4..ee971be2 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -688,6 +688,13 @@ int main(int argc, char ** argv) { 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 8f3fe447..53d34dbc 100644 --- a/commandLine/src/projects/baseProject.cpp +++ b/commandLine/src/projects/baseProject.cpp @@ -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); @@ -142,6 +142,7 @@ bool baseProject::create(const fs::path & _path, string templateName){ // templatePath = normalizePath(getPlatformTemplateDir()); templatePath = getPlatformTemplateDir(); + ofLogNotice() << "templatePath: " << templatePath; auto projectPath = fs::canonical(fs::current_path() / path); @@ -149,7 +150,7 @@ bool baseProject::create(const fs::path & _path, string templateName){ projectDir = ""; projectPath = normalizePath(projectPath); ofLogNotice() << "projectPath: " << projectPath; - + projectName = projectPath.filename().string(); // we had this in some projects. if we decide to keep this is the place @@ -161,6 +162,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; } else { diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index d9e6a235..4874acfc 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -53,6 +53,9 @@ static std::vector < std::string > platformsOptions { "msys2", "osx", "vs", + + "vscode", + "zed", }; string generateUUID(const string & input); From 3ec5abd260f8fd2c93325a0525a585d799b126eb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 19 Jan 2025 23:40:14 -0300 Subject: [PATCH 15/17] platformoptions macos --- commandLine/src/utils/Utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index 4874acfc..00886b6b 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -51,9 +51,9 @@ static std::vector < std::string > platformsOptions { "linuxarmv7l", "linuxaarch64", "msys2", + "macos", "osx", "vs", - "vscode", "zed", }; From 321083470530f31e9a2501afe63972a5e7f4fc34 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 20 Jan 2025 01:01:34 -0300 Subject: [PATCH 16/17] up --- commandLine/src/utils/Utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index 00886b6b..32980979 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -31,13 +31,13 @@ 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" }, }; From 56ebc6923ea97e87d2d34b584f05dcdcb96675a4 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 20 Jan 2025 01:14:23 -0300 Subject: [PATCH 17/17] macos osx fixes --- commandLine/src/addons/ofAddon.cpp | 4 ++-- commandLine/src/addons/ofAddon.h | 4 ++-- commandLine/src/projects/xcodeProject.cpp | 6 +++--- commandLine/src/utils/Utils.cpp | 5 +++-- commandLine/src/utils/Utils.h | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/commandLine/src/addons/ofAddon.cpp b/commandLine/src/addons/ofAddon.cpp index d0abe328..5f900b2f 100644 --- a/commandLine/src/addons/ofAddon.cpp +++ b/commandLine/src/addons/ofAddon.cpp @@ -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(); @@ -785,7 +785,7 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo #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"); 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/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index 3364d857..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" }, @@ -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"); diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 147980ed..4bf48157 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -89,7 +89,8 @@ std::string getPlatformString() { return "vs"; #endif #elif defined(__APPLE_CC__) - return "osx"; +// return "osx"; + return "macos"; #else return {}; #endif @@ -219,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", diff --git a/commandLine/src/utils/Utils.h b/commandLine/src/utils/Utils.h index 32980979..56bbc3ed 100644 --- a/commandLine/src/utils/Utils.h +++ b/commandLine/src/utils/Utils.h @@ -43,6 +43,8 @@ static std::map platformsToString { }; static std::vector < std::string > platformsOptions { + "macos", + "osx", "android", "ios", "linux", @@ -51,8 +53,6 @@ static std::vector < std::string > platformsOptions { "linuxarmv7l", "linuxaarch64", "msys2", - "macos", - "osx", "vs", "vscode", "zed",