From 9b02982f4e0a6cbf57048d14575cfc7380e452ef Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 9 Jun 2017 11:29:52 +0100 Subject: [PATCH] Projucer: added support for Xcode's INFOPLIST_PREFIX_HEADER, INFOPLIST_PREPROCESS, INFOPLIST_PREPROCESSOR_DEFINITIONS to allow pre-processing of info plists --- .../jucer_ProjectExport_XCode.h | 81 ++++++++++++++----- .../Projucer/Source/Utility/jucer_PresetIDs.h | 6 ++ 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 163e1aaaf3..8fd6cac27e 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -79,8 +79,14 @@ public: } //============================================================================== - Value getPListToMergeValue() { return getSetting ("customPList"); } - String getPListToMergeString() const { return settings ["customPList"]; } + Value getPListToMergeValue() { return getSetting ("customPList"); } + String getPListToMergeString() const { return settings ["customPList"]; } + + Value getPListPrefixHeaderValue() { return getSetting ("PListPrefixHeader"); } + String getPListPrefixHeaderString() const { return settings ["PListPrefixHeader"]; } + + Value getPListPreprocessValue() { return getSetting ("PListPreprocess"); } + bool isPListPreprocessEnabled() const { return settings ["PListPreprocess"]; } Value getExtraFrameworksValue() { return getSetting (Ids::extraFrameworks); } String getExtraFrameworksString() const { return settings [Ids::extraFrameworks]; } @@ -209,6 +215,14 @@ public: "settings that the Projucer creates. BEWARE! When doing this, be careful to remove from the XML any " "values that you DO want the Projucer to change!"); + props.add (new BooleanPropertyComponent (getPListPreprocessValue(), "PList Preprocess", "Enabled"), + "Enable this to preprocess PList file. This will allow you to set values to preprocessor defines," + " for instance if you define: #define MY_FLAG 1 in a prefix header file (see PList prefix header), you can have" + " a key with MY_FLAG value and it will be replaced with 1."); + + props.add (new TextPropertyComponent (getPListPrefixHeaderValue(), "PList Prefix Header", 512, false), + "Header file containing definitions used in plist file (see PList Preprocess)."); + props.add (new TextPropertyComponent (getExtraFrameworksValue(), "Extra Frameworks", 2048, false), "A comma-separated list of extra frameworks that should be added to the build. " "(Don't include the .framework extension in the name)"); @@ -331,22 +345,23 @@ protected: XcodeBuildConfiguration (Project& p, const ValueTree& t, const bool isIOS, const ProjectExporter& e) : BuildConfiguration (p, t, e), iOS (isIOS), - osxSDKVersion (config, Ids::osxSDK, nullptr, "default"), - osxDeploymentTarget (config, Ids::osxCompatibility, nullptr, "default"), - iosDeploymentTarget (config, Ids::iosCompatibility, nullptr, "default"), - osxArchitecture (config, Ids::osxArchitecture, nullptr, "default"), - customXcodeFlags (config, Ids::customXcodeFlags, nullptr), - cppLanguageStandard (config, Ids::cppLanguageStandard, nullptr), - cppStandardLibrary (config, Ids::cppLibType, nullptr), - codeSignIdentity (config, Ids::codeSigningIdentity, nullptr, iOS ? "iPhone Developer" : "Mac Developer"), - fastMathEnabled (config, Ids::fastMath, nullptr), - linkTimeOptimisationEnabled (config, Ids::linkTimeOptimisation, nullptr), - stripLocalSymbolsEnabled (config, Ids::stripLocalSymbols, nullptr), - vstBinaryLocation (config, Ids::xcodeVstBinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/VST/"), - vst3BinaryLocation (config, Ids::xcodeVst3BinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/VST3/"), - auBinaryLocation (config, Ids::xcodeAudioUnitBinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/Components/"), - rtasBinaryLocation (config, Ids::xcodeRtasBinaryLocation, nullptr, "/Library/Application Support/Digidesign/Plug-Ins/"), - aaxBinaryLocation (config, Ids::xcodeAaxBinaryLocation, nullptr, "/Library/Application Support/Avid/Audio/Plug-Ins/") + osxSDKVersion (config, Ids::osxSDK, nullptr, "default"), + osxDeploymentTarget (config, Ids::osxCompatibility, nullptr, "default"), + iosDeploymentTarget (config, Ids::iosCompatibility, nullptr, "default"), + osxArchitecture (config, Ids::osxArchitecture, nullptr, "default"), + customXcodeFlags (config, Ids::customXcodeFlags, nullptr), + plistPreprocessorDefinitions (config, Ids::plistPreprocessorDefinitions, nullptr), + cppLanguageStandard (config, Ids::cppLanguageStandard, nullptr), + cppStandardLibrary (config, Ids::cppLibType, nullptr), + codeSignIdentity (config, Ids::codeSigningIdentity, nullptr, iOS ? "iPhone Developer" : "Mac Developer"), + fastMathEnabled (config, Ids::fastMath, nullptr), + linkTimeOptimisationEnabled (config, Ids::linkTimeOptimisation, nullptr), + stripLocalSymbolsEnabled (config, Ids::stripLocalSymbols, nullptr), + vstBinaryLocation (config, Ids::xcodeVstBinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/VST/"), + vst3BinaryLocation (config, Ids::xcodeVst3BinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/VST3/"), + auBinaryLocation (config, Ids::xcodeAudioUnitBinaryLocation, nullptr, "$(HOME)/Library/Audio/Plug-Ins/Components/"), + rtasBinaryLocation (config, Ids::xcodeRtasBinaryLocation, nullptr, "/Library/Application Support/Digidesign/Plug-Ins/"), + aaxBinaryLocation (config, Ids::xcodeAaxBinaryLocation, nullptr, "/Library/Application Support/Avid/Audio/Plug-Ins/") { } @@ -354,7 +369,8 @@ protected: bool iOS; CachedValue osxSDKVersion, osxDeploymentTarget, iosDeploymentTarget, osxArchitecture, - customXcodeFlags, cppLanguageStandard, cppStandardLibrary, codeSignIdentity; + customXcodeFlags, plistPreprocessorDefinitions, + cppLanguageStandard, cppStandardLibrary, codeSignIdentity; CachedValue fastMathEnabled, linkTimeOptimisationEnabled, stripLocalSymbolsEnabled; CachedValue vstBinaryLocation, vst3BinaryLocation, auBinaryLocation, rtasBinaryLocation, aaxBinaryLocation; @@ -411,6 +427,9 @@ protected: "A comma-separated list of custom Xcode setting flags which will be appended to the list of generated flags, " "e.g. MACOSX_DEPLOYMENT_TARGET_i386 = 10.5, VALID_ARCHS = \"ppc i386 x86_64\""); + props.add (new TextPropertyComponent (plistPreprocessorDefinitions.getPropertyAsValue(), "PList Preprocessor Definitions", 2048, true), + "Preprocessor definitions used during PList preprocessing (see PList Preprocess)."); + const char* cppLanguageStandardNames[] = { "Use Default", "C++11", "GNU++11", "C++14", "GNU++14", nullptr }; Array cppLanguageStandardValues; cppLanguageStandardValues.add (var()); @@ -807,8 +826,32 @@ public: s.add ("GCC_OPTIMIZATION_LEVEL = " + config.getGCCOptimisationFlag()); if (shouldCreatePList()) + { s.add ("INFOPLIST_FILE = " + infoPlistFile.getFileName()); + if (owner.getPListPrefixHeaderString().isNotEmpty()) + s.add ("INFOPLIST_PREFIX_HEADER = " + owner.getPListPrefixHeaderString()); + + s.add ("INFOPLIST_PREPROCESS = " + (owner.isPListPreprocessEnabled() ? String ("YES") : String ("NO"))); + + auto plistDefs = parsePreprocessorDefs (config.plistPreprocessorDefinitions.get()); + StringArray defsList; + + for (int i = 0; i < plistDefs.size(); ++i) + { + String def (plistDefs.getAllKeys()[i]); + const String value (plistDefs.getAllValues()[i]); + + if (value.isNotEmpty()) + def << "=" << value.replace ("\"", "\\\\\\\""); + + defsList.add ("\"" + def + "\""); + } + + if (defsList.size() > 0) + s.add ("INFOPLIST_PREPROCESSOR_DEFINITIONS = " + indentParenthesisedList (defsList)); + } + if (config.linkTimeOptimisationEnabled.get()) s.add ("LLVM_LTO = YES"); diff --git a/extras/Projucer/Source/Utility/jucer_PresetIDs.h b/extras/Projucer/Source/Utility/jucer_PresetIDs.h index 3924e702b6..3b04c95b38 100644 --- a/extras/Projucer/Source/Utility/jucer_PresetIDs.h +++ b/extras/Projucer/Source/Utility/jucer_PresetIDs.h @@ -93,6 +93,7 @@ namespace Ids DECLARE_ID (customXcodeFlags); DECLARE_ID (customXcassetsFolder); DECLARE_ID (customXcodeResourceFolders); + DECLARE_ID (plistPreprocessorDefinitions); DECLARE_ID (cppLanguageStandard); DECLARE_ID (cppLibType); DECLARE_ID (codeSigningIdentity); @@ -162,6 +163,9 @@ namespace Ids DECLARE_ID (useLocalCopy); DECLARE_ID (overwriteOnSave); DECLARE_ID (microphonePermissionNeeded); + DECLARE_ID (androidRepositories); + DECLARE_ID (androidDependencies); + DECLARE_ID (androidAdditionalXmlValueResources); DECLARE_ID (androidActivityClass); DECLARE_ID (androidActivitySubClassName); DECLARE_ID (androidVersionCode); @@ -169,6 +173,8 @@ namespace Ids DECLARE_ID (androidNDKPath); DECLARE_ID (androidInternetNeeded); DECLARE_ID (androidArchitectures); + DECLARE_ID (androidManifestCustomXmlElements); + DECLARE_ID (androidCustomStringXmlElements); DECLARE_ID (androidBluetoothNeeded); DECLARE_ID (androidExternalReadNeeded); DECLARE_ID (androidExternalWriteNeeded);