| @@ -30,58 +30,9 @@ | |||
| #include "../Application/jucer_Application.h" | |||
| //============================================================================== | |||
| static var parseModuleDesc (const StringArray& lines) | |||
| { | |||
| DynamicObject* o = new DynamicObject(); | |||
| var result (o); | |||
| for (auto line : lines) | |||
| { | |||
| line = trimCommentCharsFromStartOfLine (line); | |||
| auto colon = line.indexOfChar (':'); | |||
| if (colon >= 0) | |||
| { | |||
| auto key = line.substring (0, colon).trim(); | |||
| auto value = line.substring (colon + 1).trim(); | |||
| o->setProperty (key, value); | |||
| } | |||
| } | |||
| return result; | |||
| } | |||
| static var parseModuleDesc (const File& header) | |||
| { | |||
| StringArray lines; | |||
| header.readLines (lines); | |||
| for (int i = 0; i < lines.size(); ++i) | |||
| { | |||
| if (trimCommentCharsFromStartOfLine (lines[i]).startsWith ("BEGIN_JUCE_MODULE_DECLARATION")) | |||
| { | |||
| StringArray desc; | |||
| for (int j = i + 1; j < lines.size(); ++j) | |||
| { | |||
| if (trimCommentCharsFromStartOfLine (lines[j]).startsWith ("END_JUCE_MODULE_DECLARATION")) | |||
| return parseModuleDesc (desc); | |||
| desc.add (lines[j]); | |||
| } | |||
| break; | |||
| } | |||
| } | |||
| return {}; | |||
| } | |||
| ModuleDescription::ModuleDescription (const File& folder) | |||
| : moduleFolder (folder), | |||
| moduleInfo (parseModuleDesc (getHeader())) | |||
| moduleInfo (parseJUCEHeaderMetadata (getHeader())) | |||
| { | |||
| } | |||
| @@ -384,3 +384,73 @@ bool isValidJUCEExamplesDirectory (const File& directory) noexcept | |||
| return directory.getChildFile ("Assets").getChildFile ("juce_icon.png").existsAsFile(); | |||
| } | |||
| //============================================================================== | |||
| static var parseJUCEHeaderMetadata (const StringArray& lines) | |||
| { | |||
| auto* o = new DynamicObject(); | |||
| var result (o); | |||
| for (auto& line : lines) | |||
| { | |||
| line = trimCommentCharsFromStartOfLine (line); | |||
| auto colon = line.indexOfChar (':'); | |||
| if (colon >= 0) | |||
| { | |||
| auto key = line.substring (0, colon).trim(); | |||
| auto value = line.substring (colon + 1).trim(); | |||
| o->setProperty (key, value); | |||
| } | |||
| } | |||
| return result; | |||
| } | |||
| static String parseMetadataItem (const StringArray& lines, int& index) | |||
| { | |||
| String result = lines[index++]; | |||
| while (index < lines.size()) | |||
| { | |||
| auto continuationLine = trimCommentCharsFromStartOfLine (lines[index]); | |||
| if (continuationLine.isEmpty() || continuationLine.indexOfChar (':') != -1 | |||
| || continuationLine.startsWith ("END_JUCE_")) | |||
| break; | |||
| result += continuationLine; | |||
| ++index; | |||
| } | |||
| return result; | |||
| } | |||
| var parseJUCEHeaderMetadata (const File& file) | |||
| { | |||
| StringArray lines; | |||
| file.readLines (lines); | |||
| for (int i = 0; i < lines.size(); ++i) | |||
| { | |||
| auto trimmedLine = trimCommentCharsFromStartOfLine (lines[i]); | |||
| if (trimmedLine.startsWith ("BEGIN_JUCE_")) | |||
| { | |||
| StringArray desc; | |||
| auto j = i + 1; | |||
| while (j < lines.size()) | |||
| { | |||
| if (trimCommentCharsFromStartOfLine (lines[j]).startsWith ("END_JUCE_")) | |||
| return parseJUCEHeaderMetadata (desc); | |||
| desc.add (parseMetadataItem (lines, j)); | |||
| } | |||
| } | |||
| } | |||
| return {}; | |||
| } | |||
| @@ -31,6 +31,8 @@ | |||
| const char* getPreferredLinefeed(); | |||
| String joinLinesIntoSourceFile (StringArray& lines); | |||
| var parseJUCEHeaderMetadata (const File&); | |||
| String trimCommentCharsFromStartOfLine (const String& line); | |||
| String hexString8Digits (int value); | |||
| @@ -102,7 +102,7 @@ PIPGenerator::PIPGenerator (const File& pip, const File& output, const File& juc | |||
| : pipFile (pip), | |||
| juceModulesPath (jucePath), | |||
| userModulesPaths (userPaths), | |||
| metadata (parsePIPMetadata()) | |||
| metadata (parseJUCEHeaderMetadata (pipFile)) | |||
| { | |||
| if (output != File()) | |||
| { | |||
| @@ -167,75 +167,6 @@ Result PIPGenerator::createMainCpp() | |||
| return Result::ok(); | |||
| } | |||
| //============================================================================== | |||
| var PIPGenerator::parsePIPMetadata (const StringArray& lines) | |||
| { | |||
| auto* o = new DynamicObject(); | |||
| var result (o); | |||
| for (auto& line : lines) | |||
| { | |||
| line = trimCommentCharsFromStartOfLine (line); | |||
| auto colon = line.indexOfChar (':'); | |||
| if (colon >= 0) | |||
| { | |||
| auto key = line.substring (0, colon).trim(); | |||
| auto value = line.substring (colon + 1).trim(); | |||
| o->setProperty (key, value); | |||
| } | |||
| } | |||
| return result; | |||
| } | |||
| static String parseMetadataItem (const StringArray& lines, int& index) | |||
| { | |||
| String result = lines[index++]; | |||
| while (index < lines.size()) | |||
| { | |||
| auto continuationLine = trimCommentCharsFromStartOfLine (lines[index]); | |||
| if (continuationLine.indexOfChar (':') != -1 || continuationLine.startsWith ("END_JUCE_PIP_METADATA")) | |||
| break; | |||
| result += continuationLine; | |||
| ++index; | |||
| } | |||
| return result; | |||
| } | |||
| var PIPGenerator::parsePIPMetadata() | |||
| { | |||
| StringArray lines; | |||
| pipFile.readLines (lines); | |||
| for (int i = 0; i < lines.size(); ++i) | |||
| { | |||
| auto trimmedLine = trimCommentCharsFromStartOfLine (lines[i]); | |||
| if (trimmedLine.startsWith ("BEGIN_JUCE_PIP_METADATA")) | |||
| { | |||
| StringArray desc; | |||
| auto j = i + 1; | |||
| while (j < lines.size()) | |||
| { | |||
| if (trimCommentCharsFromStartOfLine (lines[j]).startsWith ("END_JUCE_PIP_METADATA")) | |||
| return parsePIPMetadata (desc); | |||
| desc.add (parseMetadataItem (lines, j)); | |||
| } | |||
| } | |||
| } | |||
| return {}; | |||
| } | |||
| //============================================================================== | |||
| void PIPGenerator::addFileToTree (ValueTree& groupTree, const String& name, bool compile, const String& path) | |||
| { | |||
| @@ -49,10 +49,6 @@ public: | |||
| Result createMainCpp(); | |||
| private: | |||
| //============================================================================== | |||
| var parsePIPMetadata (const StringArray& lines); | |||
| var parsePIPMetadata(); | |||
| //============================================================================== | |||
| void addFileToTree (ValueTree& groupTree, const String& name, bool compile, const String& path); | |||
| void createFiles (ValueTree& jucerTree); | |||