From cd8c25b0c105ecb98574b1c0dda878424537a7bf Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 23 Aug 2018 15:53:08 +0100 Subject: [PATCH] Projucer: Added an optional command-line argument when generating a project from a PIP to specify a JUCE modules directory to be used instead of the global default --- .../Source/Application/jucer_CommandLine.cpp | 14 ++++++++++++-- .../Source/Utility/PIPs/jucer_PIPGenerator.cpp | 7 ++++--- .../Source/Utility/PIPs/jucer_PIPGenerator.h | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/extras/Projucer/Source/Application/jucer_CommandLine.cpp b/extras/Projucer/Source/Application/jucer_CommandLine.cpp index 965abed923..a2239924c4 100644 --- a/extras/Projucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Projucer/Source/Application/jucer_CommandLine.cpp @@ -718,7 +718,17 @@ namespace std::cout << "Creating directory " << outputDir.getFullPathName() << std::endl; } - PIPGenerator generator (pipFile, outputDir); + File juceDir; + + if (args.size() > 3) + { + juceDir = args[3].resolveAsFile(); + + if (! juceDir.exists()) + ConsoleApplication::fail ("Specified JUCE modules directory doesn't exist."); + } + + PIPGenerator generator (pipFile, outputDir, juceDir); auto createJucerFileResult = generator.createJucerFile(); @@ -797,7 +807,7 @@ namespace << " Sets the global path for a specified os and identifier. The os should be either osx, windows or linux and the identifiers can be any of the following: " << "defaultJuceModulePath, defaultUserModulePath, vst3Path, aaxPath (not valid on linux), rtasPath (not valid on linux), androidSDKPath or androidNDKPath." << std::endl << std::endl - << " " << appName << " --create-project-from-pip path/to/PIP path/to/output" << std::endl + << " " << appName << " --create-project-from-pip path/to/PIP path/to/output path/to/JUCE/modules (optional)" << std::endl << " Generates a JUCE project from a PIP file." << std::endl << std::endl << "Note that for any of the file-rewriting commands, add the option \"--lf\" if you want it to use LF linefeeds instead of CRLF" << std::endl diff --git a/extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.cpp b/extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.cpp index 882d5974ea..05a09774b9 100644 --- a/extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.cpp +++ b/extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.cpp @@ -97,8 +97,9 @@ static bool isMobileExporter (const String& exporterName) } //============================================================================== -PIPGenerator::PIPGenerator (const File& pip, const File& output) +PIPGenerator::PIPGenerator (const File& pip, const File& output, const File& juceDir) : pipFile (pip), + juceDirectory (juceDir), metadata (parsePIPMetadata()) { if (output != File()) @@ -290,7 +291,7 @@ ValueTree PIPGenerator::createModulePathChild (const String& moduleID) ValueTree modulePath (Ids::MODULEPATH); modulePath.setProperty (Ids::ID, moduleID, nullptr); - modulePath.setProperty (Ids::path, {}, nullptr); + modulePath.setProperty (Ids::path, juceDirectory.getFullPathName(), nullptr); return modulePath; } @@ -367,7 +368,7 @@ ValueTree PIPGenerator::createModuleChild (const String& moduleID) module.setProperty (Ids::ID, moduleID, nullptr); module.setProperty (Ids::showAllCode, 1, nullptr); module.setProperty (Ids::useLocalCopy, 0, nullptr); - module.setProperty (Ids::useGlobalPath, 1, nullptr); + module.setProperty (Ids::useGlobalPath, (juceDirectory == File() ? 1 : 0), nullptr); return module; } diff --git a/extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.h b/extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.h index ac3608489b..a039588bcf 100644 --- a/extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.h +++ b/extras/Projucer/Source/Utility/PIPs/jucer_PIPGenerator.h @@ -32,7 +32,7 @@ class PIPGenerator { public: - PIPGenerator (const File& pipFile, const File& outputDirectory = {}); + PIPGenerator (const File& pipFile, const File& outputDirectory = {}, const File& juceDirectory = {}); //============================================================================== bool hasValidPIP() const noexcept { return ! metadata[Ids::name].toString().isEmpty(); } @@ -78,7 +78,7 @@ private: StringArray getPluginCharacteristics() const; //============================================================================== - File pipFile, outputDirectory; + File pipFile, outputDirectory, juceDirectory; var metadata; bool isTemp = false;