diff --git a/extras/Introjucer/Source/Application/jucer_CommandLine.cpp b/extras/Introjucer/Source/Application/jucer_CommandLine.cpp index 239eb68f5c..bff0f51f5e 100644 --- a/extras/Introjucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Introjucer/Source/Application/jucer_CommandLine.cpp @@ -36,9 +36,9 @@ namespace return File::getCurrentWorkingDirectory().getChildFile (filename.unquoted()); } - bool checkArgumentCount (const StringArray& tokens, int minNumArgs) + bool checkArgumentCount (const StringArray& args, int minNumArgs) { - if (tokens.size() < minNumArgs) + if (args.size() < minNumArgs) { std::cout << "Not enough arguments!" << std::endl; return false; @@ -51,34 +51,43 @@ namespace /* Running a command-line of the form "introjucer --resave foobar.jucer" will try to load that project and re-export all of its targets. */ - int resaveProject (const File& file) + int resaveProject (const StringArray& args, bool justSaveResources) { - if (! file.exists()) + if (! checkArgumentCount (args, 2)) + return 1; + + const File projectFile (getFile (args[1])); + + if (! projectFile.exists()) { - std::cout << "The file " << file.getFullPathName() << " doesn't exist!" << std::endl; + std::cout << "The file " << projectFile.getFullPathName() << " doesn't exist!" << std::endl; return 1; } - if (! file.hasFileExtension (Project::projectFileExtension)) + if (! projectFile.hasFileExtension (Project::projectFileExtension)) { - std::cout << file.getFullPathName() << " isn't a valid jucer project file!" << std::endl; + std::cout << projectFile.getFullPathName() << " isn't a valid jucer project file!" << std::endl; return 1; } - Project newDoc (file); + Project proj (projectFile); - if (! newDoc.loadFrom (file, true)) + if (! proj.loadFrom (projectFile, true)) { - std::cout << "Failed to load the project file: " << file.getFullPathName() << std::endl; + std::cout << "Failed to load the project file: " << projectFile.getFullPathName() << std::endl; return 1; } - std::cout << "The Introjucer - Re-saving file: " << file.getFullPathName() << std::endl; - String error (newDoc.saveDocument (file)); + std::cout << (justSaveResources ? "The Introjucer - Re-saving project resources: " + : "The Introjucer - Re-saving file: ") + << projectFile.getFullPathName() << std::endl; + + String error (justSaveResources ? proj.saveResourcesOnly (projectFile) + : proj.saveDocument (projectFile)); if (error.isNotEmpty()) { - std::cout << "Error when writing project: " << error << std::endl; + std::cout << "Error when saving: " << error << std::endl; return 1; } @@ -134,12 +143,12 @@ namespace return 0; } - int buildModules (const StringArray& tokens, const bool buildAllWithIndex) + int buildModules (const StringArray& args, const bool buildAllWithIndex) { - if (! checkArgumentCount (tokens, 3)) + if (! checkArgumentCount (args, 3)) return 1; - const File targetFolder (getFile (tokens[1])); + const File targetFolder (getFile (args[1])); if (! targetFolder.isDirectory()) { @@ -149,7 +158,7 @@ namespace if (buildAllWithIndex) { - const File folderToSearch (getFile (tokens[2])); + const File folderToSearch (getFile (args[2])); DirectoryIterator i (folderToSearch, false, "*", File::findDirectories); var infoList; @@ -177,9 +186,9 @@ namespace } else { - for (int i = 2; i < tokens.size(); ++i) + for (int i = 2; i < args.size(); ++i) { - const int result = zipModule (targetFolder, getFile (tokens[i])); + const int result = zipModule (targetFolder, getFile (args[i])); if (result != 0) return result; @@ -197,7 +206,7 @@ namespace for (int i = 0; i < list.modules.size(); ++i) { - ModuleList::Module* m = list.modules.getUnchecked(i); + const ModuleList::Module* m = list.modules.getUnchecked(i); std::cout << m->uid << ": " << m->version << std::endl; } @@ -205,12 +214,12 @@ namespace return 0; } - int showStatus (const StringArray& tokens) + int showStatus (const StringArray& args) { - if (! checkArgumentCount (tokens, 2)) + if (! checkArgumentCount (args, 2)) return 1; - const File projectFile (getFile (tokens[1])); + const File projectFile (getFile (args[1])); Project proj (projectFile); @@ -235,29 +244,58 @@ namespace return 0; } + + bool matchArgument (const String& arg, const String& possible) + { + return arg == possible + || arg == "-" + possible + || arg == "--" + possible; + } + + //============================================================================== + int showHelp() + { + std::cout << "The Introjucer!" << std::endl + << std::endl + << "Usage: " << std::endl + << std::endl + << " introjucer --resave project_file" << std::endl + << " Resaves all files and resources in a project." << std::endl + << std::endl + << " introjucer --resave-resources project_file" << std::endl + << " Resaves just the binary resources for a project." << std::endl + << std::endl + << " introjucer --listmodules" << std::endl + << " Displays a list of modules available from the website." << std::endl + << std::endl + << " introjucer --status project_file" << std::endl + << " Displays information about a project." << std::endl + << std::endl + << " introjucer --buildmodule target_folder module_folder" << std::endl + << " Zips a module into a downloadable file format." << std::endl + << std::endl + << " introjucer --buildallmodules target_folder module_folder" << std::endl + << " Zips all modules in a given folder and creates an index for them." << std::endl + << std::endl; + + return 0; + } } //============================================================================== int performCommandLine (const String& commandLine) { - StringArray tokens; - tokens.addTokens (commandLine, true); - tokens.trim(); - - if (tokens[0] == "-resave" || tokens[0] == "--resave" || tokens[0] == "resave") - return resaveProject (getFile (tokens[1])); - - if (tokens[0] == "buildmodule") - return buildModules (tokens, false); - - if (tokens[0] == "buildallmodules") - return buildModules (tokens, true); - - if (tokens[0] == "listmodules") - return listModules(); - - if (tokens[0] == "status") - return showStatus (tokens); + StringArray args; + args.addTokens (commandLine, true); + args.trim(); + + if (matchArgument (args[0], "help")) return showHelp(); + if (matchArgument (args[0], "resave")) return resaveProject (args, false); + if (matchArgument (args[0], "resave-resources")) return resaveProject (args, true); + if (matchArgument (args[0], "buildmodule")) return buildModules (args, false); + if (matchArgument (args[0], "buildallmodules")) return buildModules (args, true); + if (matchArgument (args[0], "listmodules")) return listModules(); + if (matchArgument (args[0], "status")) return showStatus (args); return commandLineNotPerformed; } diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h index b3e0dbf608..cdb57cbd18 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h @@ -42,16 +42,14 @@ public: generatedFilesGroup (Project::Item::createGroup (project, getJuceCodeGroupName(), "__generatedcode__")) { generatedFilesGroup.setID (getGeneratedGroupID()); - - if (generatedCodeFolder.exists()) - deleteNonHiddenFilesIn (generatedCodeFolder); } Project& getProject() noexcept { return project; } String save() { - jassert (generatedFilesGroup.getNumChildren() == 0); // this method can't be called more than once! + if (generatedCodeFolder.exists()) + deleteNonHiddenFilesIn (generatedCodeFolder); const File oldFile (project.getFile()); project.setFile (projectFile); @@ -90,6 +88,12 @@ public: return errors[0]; } + String saveResourcesOnly() + { + writeBinaryDataFiles(); + return errors[0]; + } + Project::Item saveGeneratedFile (const String& filePath, const MemoryOutputStream& newData) { if (! generatedCodeFolder.createDirectory()) diff --git a/extras/Introjucer/Source/Project/jucer_Project.cpp b/extras/Introjucer/Source/Project/jucer_Project.cpp index d3be5d44de..b722bd1d3d 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.cpp +++ b/extras/Introjucer/Source/Project/jucer_Project.cpp @@ -245,6 +245,12 @@ const String Project::saveDocument (const File& file) return saver.save(); } +String Project::saveResourcesOnly (const File& file) +{ + ProjectSaver saver (*this, file); + return saver.saveResourcesOnly(); +} + //============================================================================== File Project::lastDocumentOpened; diff --git a/extras/Introjucer/Source/Project/jucer_Project.h b/extras/Introjucer/Source/Project/jucer_Project.h index 3e69cc26ed..beb8e4d3d8 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.h +++ b/extras/Introjucer/Source/Project/jucer_Project.h @@ -46,6 +46,7 @@ public: const String getDocumentTitle(); const String loadDocument (const File& file); const String saveDocument (const File& file); + String saveResourcesOnly (const File& file); const File getLastDocumentOpened(); void setLastDocumentOpened (const File& file); diff --git a/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h b/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h index a942404e43..fcb9e02fcb 100644 --- a/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h +++ b/modules/juce_audio_plugin_client/utility/juce_CheckSettingMacros.h @@ -26,7 +26,7 @@ // The following checks should cause a compile error if you've forgotten to // define all your plugin settings properly.. -#if ! (JucePlugin_Build_VST || JucePlugin_Build_AU || JucePlugin_Build_RTAS || JucePlugin_Build_Standalone) +#if ! (JucePlugin_Build_VST || JucePlugin_Build_AU || JucePlugin_Build_RTAS || JucePlugin_Build_Standalone || JucePlugin_Build_LV2) #error "You need to enable at least one plugin format!" #endif