From 7b34880d1bcb125320fc9c9d0067cc5a31083607 Mon Sep 17 00:00:00 2001 From: Manos Lefakis Date: Sun, 11 Feb 2024 16:21:32 +0200 Subject: [PATCH 1/5] New feature: add-file functionality to Projucer Added new subcommand to Projucer command line. Projucer --add-file jucerfile.jucer path/to/file/or/directory/to/add/project --- .../Source/Application/jucer_CommandLine.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/extras/Projucer/Source/Application/jucer_CommandLine.cpp b/extras/Projucer/Source/Application/jucer_CommandLine.cpp index 3f861e8911af..35757d2de172 100644 --- a/extras/Projucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Projucer/Source/Application/jucer_CommandLine.cpp @@ -152,6 +152,11 @@ namespace modules.tryToFixMissingDependencies (m); } + void addFile (const File& file) + { + project->getMainGroup().addFileRetainingSortOrder (file, true); + } + std::unique_ptr project; }; @@ -171,6 +176,23 @@ namespace proj.save (justSaveResources, args.containsOption ("--fix-missing-dependencies")); } + static void addFile (const ArgumentList& args) + { + args.checkMinNumArguments (3); + LoadedProject proj (args[1]); + auto fileToAdd = args[2].resolveAsExistingFile(); + + std::cout << "Adding File: " + << fileToAdd.getFileName() << std::endl; + + proj.addFile (fileToAdd.getFullPathName()); + + std::cout << "Re-saving file: " + << proj.project->getFile().getFullPathName() << std::endl; + + proj.save (false, args.containsOption ("--fix-missing-dependencies")); + } + //============================================================================== static void getVersion (const ArgumentList& args) { @@ -824,6 +846,8 @@ namespace << std::endl << "Usage: " << std::endl << std::endl + << " " << appName << " --add-file project_file path_to_file_to_add" << std::endl + << " Adds an existing file or directory to a project." << std::endl << " " << appName << " --resave project_file" << std::endl << " Resaves all files and resources in a project. Add the \"--fix-missing-dependencies\" option to automatically fix any missing module dependencies." << std::endl << std::endl @@ -906,6 +930,7 @@ int performCommandLine (const ArgumentList& args) if (matchCommand ("help")) { showHelp(); return 0; } if (matchCommand ("h")) { showHelp(); return 0; } if (matchCommand ("resave")) { resaveProject (args, false); return 0; } + if (matchCommand ("add-file")) { addFile (args); return 0; } if (matchCommand ("resave-resources")) { resaveProject (args, true); return 0; } if (matchCommand ("get-version")) { getVersion (args); return 0; } if (matchCommand ("set-version")) { setVersion (args); return 0; } From 4a353a4f8c2da8cf25152b4ec8a89c2ac8116779 Mon Sep 17 00:00:00 2001 From: Manos Lefakis Date: Mon, 12 Feb 2024 04:10:07 +0200 Subject: [PATCH 2/5] New feature: add-file functionality to Projucer Added new subcommand to Projucer command line. Projucer --clear-maingroup jucerfile.jucer --- .../Source/Application/jucer_CommandLine.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/extras/Projucer/Source/Application/jucer_CommandLine.cpp b/extras/Projucer/Source/Application/jucer_CommandLine.cpp index 35757d2de172..3b3b2c44c97a 100644 --- a/extras/Projucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Projucer/Source/Application/jucer_CommandLine.cpp @@ -152,6 +152,17 @@ namespace modules.tryToFixMissingDependencies (m); } + void clearMainGroup() + { + auto mainGroup = project->getMainGroup(); + auto mainGrouID = mainGroup.getID(); + + mainGroup.removeItemFromProject(); + Project::Item cleanMainGroup (*project, ValueTree ("MAINGROUP"), false); + cleanMainGroup.setID(mainGrouID); + project->getProjectRoot().addChild (cleanMainGroup.state, 0, nullptr); + } + void addFile (const File& file) { project->getMainGroup().addFileRetainingSortOrder (file, true); @@ -176,6 +187,22 @@ namespace proj.save (justSaveResources, args.containsOption ("--fix-missing-dependencies")); } + static void clearMainGroup (const ArgumentList& args) + { + args.checkMinNumArguments (2); + LoadedProject proj (args[1]); + + std::cout << "Clearing MAINGROUP: " + << std::endl; + + proj.clearMainGroup (); + + std::cout << "Re-saving file: " + << proj.project->getFile().getFullPathName() << std::endl; + + proj.save (true, args.containsOption ("--fix-missing-dependencies")); + } + static void addFile (const ArgumentList& args) { args.checkMinNumArguments (3); @@ -846,8 +873,12 @@ namespace << std::endl << "Usage: " << std::endl << std::endl + << " " << appName << " --clear-maingroup project_file" << std::endl + << " Removes all resource file references from a project." << std::endl + << std::endl << " " << appName << " --add-file project_file path_to_file_to_add" << std::endl << " Adds an existing file or directory to a project." << std::endl + << std::endl << " " << appName << " --resave project_file" << std::endl << " Resaves all files and resources in a project. Add the \"--fix-missing-dependencies\" option to automatically fix any missing module dependencies." << std::endl << std::endl @@ -930,6 +961,7 @@ int performCommandLine (const ArgumentList& args) if (matchCommand ("help")) { showHelp(); return 0; } if (matchCommand ("h")) { showHelp(); return 0; } if (matchCommand ("resave")) { resaveProject (args, false); return 0; } + if (matchCommand ("clear-maingroup")) { clearMainGroup (args); return 0; } if (matchCommand ("add-file")) { addFile (args); return 0; } if (matchCommand ("resave-resources")) { resaveProject (args, true); return 0; } if (matchCommand ("get-version")) { getVersion (args); return 0; } From 749f7585b7a3d8749c15dd79bff30f027e86b49e Mon Sep 17 00:00:00 2001 From: Manos Lefakis Date: Mon, 12 Feb 2024 04:14:25 +0200 Subject: [PATCH 3/5] Change add-file resave functionality to just save resources. --- extras/Projucer/Source/Application/jucer_CommandLine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/Projucer/Source/Application/jucer_CommandLine.cpp b/extras/Projucer/Source/Application/jucer_CommandLine.cpp index 3b3b2c44c97a..75a374e5a1c0 100644 --- a/extras/Projucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Projucer/Source/Application/jucer_CommandLine.cpp @@ -217,7 +217,7 @@ namespace std::cout << "Re-saving file: " << proj.project->getFile().getFullPathName() << std::endl; - proj.save (false, args.containsOption ("--fix-missing-dependencies")); + proj.save (true, args.containsOption ("--fix-missing-dependencies")); } //============================================================================== From d5e6bfc143294c1a40ce0663632c45d7dde35394 Mon Sep 17 00:00:00 2001 From: Manos Lefakis Date: Mon, 12 Feb 2024 04:17:20 +0200 Subject: [PATCH 4/5] Move help messages about clear-maingroup and add-file down --- .../Source/Application/jucer_CommandLine.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extras/Projucer/Source/Application/jucer_CommandLine.cpp b/extras/Projucer/Source/Application/jucer_CommandLine.cpp index 75a374e5a1c0..555a80289064 100644 --- a/extras/Projucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Projucer/Source/Application/jucer_CommandLine.cpp @@ -873,18 +873,18 @@ namespace << std::endl << "Usage: " << std::endl << std::endl - << " " << appName << " --clear-maingroup project_file" << std::endl - << " Removes all resource file references from a project." << std::endl - << std::endl - << " " << appName << " --add-file project_file path_to_file_to_add" << std::endl - << " Adds an existing file or directory to a project." << std::endl - << std::endl << " " << appName << " --resave project_file" << std::endl << " Resaves all files and resources in a project. Add the \"--fix-missing-dependencies\" option to automatically fix any missing module dependencies." << std::endl << std::endl << " " << appName << " --resave-resources project_file" << std::endl << " Resaves just the binary resources for a project." << std::endl << std::endl + << " " << appName << " --clear-maingroup project_file" << std::endl + << " Removes all resource file references from a project." << std::endl + << std::endl + << " " << appName << " --add-file project_file path_to_file_to_add" << std::endl + << " Adds an existing file or directory to a project." << std::endl + << std::endl << " " << appName << " --get-version project_file" << std::endl << " Returns the version number of a project." << std::endl << std::endl From 642e53249b75d6a4d49b9c8429844a39637f4175 Mon Sep 17 00:00:00 2001 From: Manos Lefakis Date: Mon, 12 Feb 2024 05:06:21 +0200 Subject: [PATCH 5/5] Revert last change. add-file and clear-maingroup do not just save resources --- extras/Projucer/Source/Application/jucer_CommandLine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/Projucer/Source/Application/jucer_CommandLine.cpp b/extras/Projucer/Source/Application/jucer_CommandLine.cpp index 555a80289064..71e2bbfc53a5 100644 --- a/extras/Projucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Projucer/Source/Application/jucer_CommandLine.cpp @@ -200,7 +200,7 @@ namespace std::cout << "Re-saving file: " << proj.project->getFile().getFullPathName() << std::endl; - proj.save (true, args.containsOption ("--fix-missing-dependencies")); + proj.save (false, args.containsOption ("--fix-missing-dependencies")); } static void addFile (const ArgumentList& args) @@ -217,7 +217,7 @@ namespace std::cout << "Re-saving file: " << proj.project->getFile().getFullPathName() << std::endl; - proj.save (true, args.containsOption ("--fix-missing-dependencies")); + proj.save (false, args.containsOption ("--fix-missing-dependencies")); } //==============================================================================