1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

CMake: Ensure version numbers in AU/AUv3 plists are correctly formatted

AU and AUv3 plugins only support version numbers with up to 3 parts.
This commit is contained in:
reuk 2021-07-19 18:59:18 +01:00
parent 19e1488e18
commit 366a626894
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
6 changed files with 21 additions and 13 deletions

View file

@ -85,7 +85,6 @@ namespace build_tools
xml.createNewChildElement ("integer")->addTextElement (String (value));
}
//==============================================================================
static void addArrayToPlist (XmlElement& dict, String arrayKey, const StringArray& arrayElements)
{
dict.createNewChildElement ("key")->addTextElement (arrayKey);
@ -95,6 +94,14 @@ namespace build_tools
plistStringArray->createNewChildElement ("string")->addTextElement (e);
}
static int getAUVersionAsHexInteger (const PlistOptions& opts)
{
const auto segments = getVersionSegments (opts.marketingVersion);
const StringArray trimmed (segments.strings.getRawDataPointer(), jmin (segments.size(), 3));
return getVersionAsHexIntegerFromParts (trimmed);
}
//==============================================================================
void PlistOptions::write (const File& infoPlistFile) const
{
writeStreamToFile (infoPlistFile, [&] (MemoryOutputStream& mo) { write (mo); });
@ -160,7 +167,7 @@ namespace build_tools
addPlistDictionaryKey (*dict, "CFBundleShortVersionString", marketingVersion);
addPlistDictionaryKey (*dict, "CFBundleVersion", currentProjectVersion);
addPlistDictionaryKey (*dict, "NSHumanReadableCopyright", companyCopyright);
addPlistDictionaryKey (*dict, "NSHighResolutionCapable", true);
addPlistDictionaryKey (*dict, "NSHighResolutionCapable", true);
if (applicationCategory.isNotEmpty())
addPlistDictionaryKey (*dict, "LSApplicationCategoryType", applicationCategory);
@ -229,7 +236,7 @@ namespace build_tools
addPlistDictionaryKey (*audioComponentsDict, "manufacturer", pluginManufacturerCode.substring (0, 4));
addPlistDictionaryKey (*audioComponentsDict, "type", IAATypeCode);
addPlistDictionaryKey (*audioComponentsDict, "subtype", pluginCode.substring (0, 4));
addPlistDictionaryKey (*audioComponentsDict, "version", versionAsHex);
addPlistDictionaryKey (*audioComponentsDict, "version", getVersionAsHexInteger (marketingVersion));
dict->addChildElement (new XmlElement (audioComponentsPlistEntry));
}
@ -295,7 +302,7 @@ namespace build_tools
addPlistDictionaryKey (*dict, "manufacturer", truncatedCode);
addPlistDictionaryKey (*dict, "type", auMainType.removeCharacters ("'"));
addPlistDictionaryKey (*dict, "subtype", pluginSubType);
addPlistDictionaryKey (*dict, "version", versionAsHex);
addPlistDictionaryKey (*dict, "version", getAUVersionAsHexInteger (*this));
if (isAuSandboxSafe)
{
@ -336,7 +343,7 @@ namespace build_tools
addPlistDictionaryKey (*componentDict, "manufacturer", pluginManufacturerCode.substring (0, 4));
addPlistDictionaryKey (*componentDict, "type", auMainType.removeCharacters ("'"));
addPlistDictionaryKey (*componentDict, "subtype", pluginCode.substring (0, 4));
addPlistDictionaryKey (*componentDict, "version", versionAsHex);
addPlistDictionaryKey (*componentDict, "version", getAUVersionAsHexInteger (*this));
addPlistDictionaryKey (*componentDict, "sandboxSafe", true);
componentDict->createNewChildElement ("key")->addTextElement ("tags");

View file

@ -81,7 +81,6 @@ namespace build_tools
String pluginManufacturerCode;
String IAATypeCode;
String pluginCode;
int versionAsHex = 0;
StringArray iPhoneScreenOrientations;
StringArray iPadScreenOrientations;

View file

@ -35,13 +35,11 @@ namespace build_tools
return segments;
}
int getVersionAsHexInteger (juce::StringRef versionString)
int getVersionAsHexIntegerFromParts (const StringArray& segments)
{
auto segments = getVersionSegments (versionString);
auto value = (segments[0].getIntValue() << 16)
+ (segments[1].getIntValue() << 8)
+ segments[2].getIntValue();
+ (segments[1].getIntValue() << 8)
+ segments[2].getIntValue();
if (segments.size() > 3)
value = (value << 8) + segments[3].getIntValue();
@ -49,6 +47,11 @@ namespace build_tools
return value;
}
int getVersionAsHexInteger (juce::StringRef versionString)
{
return getVersionAsHexIntegerFromParts (getVersionSegments (versionString));
}
String getVersionAsHex (juce::StringRef versionString)
{
return "0x" + String::toHexString (getVersionAsHexInteger (versionString));

View file

@ -29,6 +29,7 @@ namespace build_tools
{
StringArray getVersionSegments (juce::StringRef p);
int getVersionAsHexIntegerFromParts (const StringArray& versionString);
int getVersionAsHexInteger (juce::StringRef versionString);
String getVersionAsHex (juce::StringRef versionString);

View file

@ -275,7 +275,6 @@ juce::build_tools::PlistOptions parsePlistOptions (const juce::File& file,
updateField ("ICON_FILE", result.iconFile);
result.type = type;
result.versionAsHex = juce::build_tools::getVersionAsHexInteger (result.marketingVersion);
if (result.storyboardName.isNotEmpty())
result.storyboardName = result.storyboardName.fromLastOccurrenceOf ("/", false, false)

View file

@ -1814,7 +1814,6 @@ public:
options.pluginManufacturerCode = owner.project.getPluginManufacturerCodeString();
options.IAATypeCode = owner.project.getIAATypeCode();
options.pluginCode = owner.project.getPluginCodeString();
options.versionAsHex = owner.project.getVersionAsHexInteger();
options.iPhoneScreenOrientations = owner.getiPhoneScreenOrientations();
options.iPadScreenOrientations = owner.getiPadScreenOrientations();