The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1719 lines
73KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. namespace
  18. {
  19. const char* const osxVersionDefault = "default";
  20. const int oldestSDKVersion = 5;
  21. const int currentSDKVersion = 11;
  22. const char* const osxArch_Default = "default";
  23. const char* const osxArch_Native = "Native";
  24. const char* const osxArch_32BitUniversal = "32BitUniversal";
  25. const char* const osxArch_64BitUniversal = "64BitUniversal";
  26. const char* const osxArch_64Bit = "64BitIntel";
  27. }
  28. //==============================================================================
  29. class XCodeProjectExporter : public ProjectExporter
  30. {
  31. public:
  32. //==============================================================================
  33. static const char* getNameMac() { return "Xcode (MacOSX)"; }
  34. static const char* getNameiOS() { return "Xcode (iOS)"; }
  35. static const char* getValueTreeTypeName (bool iOS) { return iOS ? "XCODE_IPHONE" : "XCODE_MAC"; }
  36. //==============================================================================
  37. XCodeProjectExporter (Project& p, const ValueTree& t, const bool isIOS)
  38. : ProjectExporter (p, t),
  39. iOS (isIOS)
  40. {
  41. name = iOS ? getNameiOS() : getNameMac();
  42. if (getTargetLocationString().isEmpty())
  43. getTargetLocationValue() = getDefaultBuildsRootFolder() + (iOS ? "iOS" : "MacOSX");
  44. initialiseDependencyPathValues();
  45. if (getScreenOrientationValue().toString().isEmpty())
  46. getScreenOrientationValue() = "portraitlandscape";
  47. }
  48. static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings)
  49. {
  50. if (settings.hasType (getValueTreeTypeName (false))) return new XCodeProjectExporter (project, settings, false);
  51. if (settings.hasType (getValueTreeTypeName (true))) return new XCodeProjectExporter (project, settings, true);
  52. return nullptr;
  53. }
  54. //==============================================================================
  55. Value getPListToMergeValue() { return getSetting ("customPList"); }
  56. String getPListToMergeString() const { return settings ["customPList"]; }
  57. Value getExtraFrameworksValue() { return getSetting (Ids::extraFrameworks); }
  58. String getExtraFrameworksString() const { return settings [Ids::extraFrameworks]; }
  59. Value getPostBuildScriptValue() { return getSetting (Ids::postbuildCommand); }
  60. String getPostBuildScript() const { return settings [Ids::postbuildCommand]; }
  61. Value getPreBuildScriptValue() { return getSetting (Ids::prebuildCommand); }
  62. String getPreBuildScript() const { return settings [Ids::prebuildCommand]; }
  63. Value getScreenOrientationValue() { return getSetting (Ids::iosScreenOrientation); }
  64. String getScreenOrientationString() const { return settings [Ids::iosScreenOrientation]; }
  65. Value getCustomResourceFoldersValue() { return getSetting (Ids::customXcodeResourceFolders); }
  66. String getCustomResourceFoldersString() const { return getSettingString (Ids::customXcodeResourceFolders).replaceCharacters ("\r\n", "::"); }
  67. Value getCustomXcassetsFolderValue() { return getSetting (Ids::customXcassetsFolder); }
  68. String getCustomXcassetsFolderString() const { return settings [Ids::customXcassetsFolder]; }
  69. Value getInAppPurchasesValue() { return getSetting (Ids::iosInAppPurchases); }
  70. bool isInAppPurchasesEnabled() const { return settings [Ids::iosInAppPurchases]; }
  71. Value getBackgroundAudioValue() { return getSetting (Ids::iosBackgroundAudio); }
  72. bool isBackgroundAudioEnabled() const { return settings [Ids::iosBackgroundAudio]; }
  73. Value getBackgroundBleValue() { return getSetting (Ids::iosBackgroundBle); }
  74. bool isBackgroundBleEnabled() const { return settings [Ids::iosBackgroundBle]; }
  75. Value getIosDevelopmentTeamIDValue() { return getSetting (Ids::iosDevelopmentTeamID); }
  76. String getIosDevelopmentTeamIDString() const { return settings [Ids::iosDevelopmentTeamID]; }
  77. bool usesMMFiles() const override { return true; }
  78. bool isXcode() const override { return true; }
  79. bool isOSX() const override { return ! iOS; }
  80. bool canCopeWithDuplicateFiles() override { return true; }
  81. void createExporterProperties (PropertyListBuilder& props) override
  82. {
  83. if (iOS)
  84. {
  85. props.add (new TextPropertyComponent (getCustomXcassetsFolderValue(), "Custom Xcassets folder", 128, false),
  86. "If this field is not empty, your Xcode project will use the custom xcassets folder specified here "
  87. "for the app icons and launchimages, and will ignore the Icon files specified above.");
  88. }
  89. props.add (new TextPropertyComponent (getCustomResourceFoldersValue(), "Custom Xcode Resource folders", 8192, true),
  90. "You can specify a list of custom resource folders here (separated by newlines or whitespace). "
  91. "References to these folders will then be added to the Xcode resources. "
  92. "This way you can specify them for OS X and iOS separately, and modify the content of the resource folders "
  93. "without re-saving the Introjucer project.");
  94. if (iOS)
  95. {
  96. static const char* orientations[] = { "Portrait and Landscape", "Portrait", "Landscape", nullptr };
  97. static const char* orientationValues[] = { "portraitlandscape", "portrait", "landscape", nullptr };
  98. props.add (new ChoicePropertyComponent (getScreenOrientationValue(), "Screen orientation",StringArray (orientations), Array<var> (orientationValues)),
  99. "The screen orientations that this app should support");
  100. props.add (new BooleanPropertyComponent (getSetting ("UIFileSharingEnabled"), "File Sharing Enabled", "Enabled"),
  101. "Enable this to expose your app's files to iTunes.");
  102. props.add (new BooleanPropertyComponent (getSetting ("UIStatusBarHidden"), "Status Bar Hidden", "Enabled"),
  103. "Enable this to disable the status bar in your app.");
  104. props.add (new BooleanPropertyComponent (getInAppPurchasesValue(), "In-App purchases capability", "Enabled"),
  105. "Enable this to grant your app the capability for in-app purchases. "
  106. "This option requires that you specify a valid Development Team ID.");
  107. props.add (new BooleanPropertyComponent (getBackgroundAudioValue(), "Audio background capability", "Enabled"),
  108. "Enable this to grant your app the capability to access audio when in background mode.");
  109. props.add (new BooleanPropertyComponent (getBackgroundBleValue(), "Bluetooth MIDI background capability", "Enabled"),
  110. "Enable this to grant your app the capability to connect to Bluetooth LE devices when in background mode.");
  111. }
  112. else if (projectType.isGUIApplication())
  113. {
  114. props.add (new TextPropertyComponent (getSetting ("documentExtensions"), "Document file extensions", 128, false),
  115. "A comma-separated list of file extensions for documents that your app can open. "
  116. "Using a leading '.' is optional, and the extensions are not case-sensitive.");
  117. }
  118. props.add (new TextPropertyComponent (getPListToMergeValue(), "Custom PList", 8192, true),
  119. "You can paste the contents of an XML PList file in here, and the settings that it contains will override any "
  120. "settings that the Introjucer creates. BEWARE! When doing this, be careful to remove from the XML any "
  121. "values that you DO want the introjucer to change!");
  122. props.add (new TextPropertyComponent (getExtraFrameworksValue(), "Extra Frameworks", 2048, false),
  123. "A comma-separated list of extra frameworks that should be added to the build. "
  124. "(Don't include the .framework extension in the name)");
  125. props.add (new TextPropertyComponent (getPreBuildScriptValue(), "Pre-build shell script", 32768, true),
  126. "Some shell-script that will be run before a build starts.");
  127. props.add (new TextPropertyComponent (getPostBuildScriptValue(), "Post-build shell script", 32768, true),
  128. "Some shell-script that will be run after a build completes.");
  129. if (iOS)
  130. {
  131. props.add (new TextPropertyComponent (getIosDevelopmentTeamIDValue(), "Development Team ID", 10, false),
  132. "The Development Team ID to be used for setting up code-signing your iOS app. This is a ten-character "
  133. "string (for example, \"S7B6T5XJ2Q\") that describes the distribution certificate Apple issued to you. "
  134. "You can find this string in the OS X app Keychain Access under \"Certificates\".");
  135. }
  136. }
  137. bool launchProject() override
  138. {
  139. #if JUCE_MAC
  140. return getProjectBundle().startAsProcess();
  141. #else
  142. return false;
  143. #endif
  144. }
  145. bool canLaunchProject() override
  146. {
  147. #if JUCE_MAC
  148. return true;
  149. #else
  150. return false;
  151. #endif
  152. }
  153. //==============================================================================
  154. void create (const OwnedArray<LibraryModule>&) const override
  155. {
  156. infoPlistFile = getTargetFolder().getChildFile ("Info.plist");
  157. menuNibFile = getTargetFolder().getChildFile ("RecentFilesMenuTemplate.nib");
  158. createIconFile();
  159. File projectBundle (getProjectBundle());
  160. createDirectoryOrThrow (projectBundle);
  161. createObjects();
  162. File projectFile (projectBundle.getChildFile ("project.pbxproj"));
  163. {
  164. MemoryOutputStream mo;
  165. writeProjectFile (mo);
  166. overwriteFileIfDifferentOrThrow (projectFile, mo);
  167. }
  168. writeInfoPlistFile();
  169. // Deleting the .rsrc files can be needed to force Xcode to update the version number.
  170. deleteRsrcFiles();
  171. }
  172. protected:
  173. //==============================================================================
  174. class XcodeBuildConfiguration : public BuildConfiguration
  175. {
  176. public:
  177. XcodeBuildConfiguration (Project& p, const ValueTree& t, const bool isIOS, const ProjectExporter& e)
  178. : BuildConfiguration (p, t, e), iOS (isIOS)
  179. {
  180. if (iOS)
  181. {
  182. if (getiOSCompatibilityVersion().isEmpty())
  183. getiOSCompatibilityVersionValue() = osxVersionDefault;
  184. }
  185. else
  186. {
  187. if (getMacSDKVersion().isEmpty())
  188. getMacSDKVersionValue() = osxVersionDefault;
  189. if (getMacCompatibilityVersion().isEmpty())
  190. getMacCompatibilityVersionValue() = osxVersionDefault;
  191. if (getMacArchitecture().isEmpty())
  192. getMacArchitectureValue() = osxArch_Default;
  193. }
  194. }
  195. Value getMacSDKVersionValue() { return getValue (Ids::osxSDK); }
  196. String getMacSDKVersion() const { return config [Ids::osxSDK]; }
  197. Value getMacCompatibilityVersionValue() { return getValue (Ids::osxCompatibility); }
  198. String getMacCompatibilityVersion() const { return config [Ids::osxCompatibility]; }
  199. Value getiOSCompatibilityVersionValue() { return getValue (Ids::iosCompatibility); }
  200. String getiOSCompatibilityVersion() const { return config [Ids::iosCompatibility]; }
  201. Value getMacArchitectureValue() { return getValue (Ids::osxArchitecture); }
  202. String getMacArchitecture() const { return config [Ids::osxArchitecture]; }
  203. Value getCustomXcodeFlagsValue() { return getValue (Ids::customXcodeFlags); }
  204. String getCustomXcodeFlags() const { return config [Ids::customXcodeFlags]; }
  205. Value getCppLanguageStandardValue() { return getValue (Ids::cppLanguageStandard); }
  206. String getCppLanguageStandard() const { return config [Ids::cppLanguageStandard]; }
  207. Value getCppLibTypeValue() { return getValue (Ids::cppLibType); }
  208. String getCppLibType() const { return config [Ids::cppLibType]; }
  209. Value getCodeSignIdentityValue() { return getValue (Ids::codeSigningIdentity); }
  210. String getCodeSignIdentity() const { return config [Ids::codeSigningIdentity]; }
  211. Value getFastMathValue() { return getValue (Ids::fastMath); }
  212. bool isFastMathEnabled() const { return config [Ids::fastMath]; }
  213. Value getLinkTimeOptimisationValue() { return getValue (Ids::linkTimeOptimisation); }
  214. bool isLinkTimeOptimisationEnabled() const { return config [Ids::linkTimeOptimisation]; }
  215. var getDefaultOptimisationLevel() const override { return var ((int) (isDebug() ? gccO0 : gccO3)); }
  216. void createConfigProperties (PropertyListBuilder& props) override
  217. {
  218. addGCCOptimisationProperty (props);
  219. if (iOS)
  220. {
  221. const char* iosVersions[] = { "Use Default", "7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "8.4", "9.0", "9.1", "9.2", 0 };
  222. const char* iosVersionValues[] = { osxVersionDefault, "7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "8.4", "9.0", "9.1", "9.2", 0 };
  223. props.add (new ChoicePropertyComponent (getiOSCompatibilityVersionValue(), "iOS Deployment Target",
  224. StringArray (iosVersions), Array<var> (iosVersionValues)),
  225. "The minimum version of iOS that the target binary will run on.");
  226. }
  227. else
  228. {
  229. StringArray sdkVersionNames, osxVersionNames;
  230. Array<var> versionValues;
  231. sdkVersionNames.add ("Use Default");
  232. osxVersionNames.add ("Use Default");
  233. versionValues.add (osxVersionDefault);
  234. for (int ver = oldestSDKVersion; ver <= currentSDKVersion; ++ver)
  235. {
  236. sdkVersionNames.add (getSDKName (ver));
  237. osxVersionNames.add (getOSXVersionName (ver));
  238. versionValues.add (getSDKName (ver));
  239. }
  240. props.add (new ChoicePropertyComponent (getMacSDKVersionValue(), "OSX Base SDK Version", sdkVersionNames, versionValues),
  241. "The version of OSX to link against in the XCode build.");
  242. props.add (new ChoicePropertyComponent (getMacCompatibilityVersionValue(), "OSX Deployment Target", osxVersionNames, versionValues),
  243. "The minimum version of OSX that the target binary will be compatible with.");
  244. const char* osxArch[] = { "Use Default", "Native architecture of build machine",
  245. "Universal Binary (32-bit)", "Universal Binary (32/64-bit)", "64-bit Intel", 0 };
  246. const char* osxArchValues[] = { osxArch_Default, osxArch_Native, osxArch_32BitUniversal,
  247. osxArch_64BitUniversal, osxArch_64Bit, 0 };
  248. props.add (new ChoicePropertyComponent (getMacArchitectureValue(), "OSX Architecture",
  249. StringArray (osxArch), Array<var> (osxArchValues)),
  250. "The type of OSX binary that will be produced.");
  251. }
  252. props.add (new TextPropertyComponent (getCustomXcodeFlagsValue(), "Custom Xcode flags", 8192, false),
  253. "A comma-separated list of custom Xcode setting flags which will be appended to the list of generated flags, "
  254. "e.g. MACOSX_DEPLOYMENT_TARGET_i386 = 10.5, VALID_ARCHS = \"ppc i386 x86_64\"");
  255. const char* cppLanguageStandardNames[] = { "Use Default", "C++98", "GNU++98", "C++11", "GNU++11", "C++14", "GNU++14", nullptr };
  256. Array<var> cppLanguageStandardValues;
  257. cppLanguageStandardValues.add (var::null);
  258. cppLanguageStandardValues.add ("c++98");
  259. cppLanguageStandardValues.add ("gnu++98");
  260. cppLanguageStandardValues.add ("c++11");
  261. cppLanguageStandardValues.add ("gnu++11");
  262. cppLanguageStandardValues.add ("c++14");
  263. cppLanguageStandardValues.add ("gnu++14");
  264. props.add (new ChoicePropertyComponent (getCppLanguageStandardValue(), "C++ Language Standard", StringArray (cppLanguageStandardNames), cppLanguageStandardValues),
  265. "The standard of the C++ language that will be used for compilation.");
  266. const char* cppLibNames[] = { "Use Default", "LLVM libc++", "GNU libstdc++", nullptr };
  267. Array<var> cppLibValues;
  268. cppLibValues.add (var::null);
  269. cppLibValues.add ("libc++");
  270. cppLibValues.add ("libstdc++");
  271. props.add (new ChoicePropertyComponent (getCppLibTypeValue(), "C++ Library", StringArray (cppLibNames), cppLibValues),
  272. "The type of C++ std lib that will be linked.");
  273. props.add (new TextPropertyComponent (getCodeSignIdentityValue(), "Code-signing Identity", 8192, false),
  274. "The name of a code-signing identity for Xcode to apply.");
  275. props.add (new BooleanPropertyComponent (getFastMathValue(), "Relax IEEE compliance", "Enabled"),
  276. "Enable this to use FAST_MATH non-IEEE mode. (Warning: this can have unexpected results!)");
  277. props.add (new BooleanPropertyComponent (getLinkTimeOptimisationValue(), "Link-Time Optimisation", "Enabled"),
  278. "Enable this to perform link-time code generation. This is recommended for release builds.");
  279. }
  280. bool iOS;
  281. };
  282. BuildConfiguration::Ptr createBuildConfig (const ValueTree& v) const override
  283. {
  284. return new XcodeBuildConfiguration (project, v, iOS, *this);
  285. }
  286. private:
  287. mutable OwnedArray<ValueTree> pbxBuildFiles, pbxFileReferences, pbxGroups, misc, projectConfigs, targetConfigs;
  288. mutable StringArray buildPhaseIDs, resourceIDs, sourceIDs, frameworkIDs;
  289. mutable StringArray frameworkFileIDs, rezFileIDs, resourceFileRefs;
  290. mutable File infoPlistFile, menuNibFile, iconFile;
  291. const bool iOS;
  292. static String sanitisePath (const String& path)
  293. {
  294. if (path.startsWithChar ('~'))
  295. return "$(HOME)" + path.substring (1);
  296. return path;
  297. }
  298. static String addQuotesIfContainsSpace (const String& s)
  299. {
  300. return s.containsChar (' ') ? s.quoted() : s;
  301. }
  302. File getProjectBundle() const { return getTargetFolder().getChildFile (project.getProjectFilenameRoot()).withFileExtension (".xcodeproj"); }
  303. //==============================================================================
  304. void createObjects() const
  305. {
  306. addFrameworks();
  307. addCustomResourceFolders();
  308. addMainBuildProduct();
  309. if (xcodeCreatePList)
  310. {
  311. RelativePath plistPath (infoPlistFile, getTargetFolder(), RelativePath::buildTargetFolder);
  312. addFileReference (plistPath.toUnixStyle());
  313. resourceFileRefs.add (createFileRefID (plistPath));
  314. }
  315. if (iOS)
  316. {
  317. if (! projectType.isStaticLibrary())
  318. {
  319. String customXcassetsPath = getCustomXcassetsFolderString();
  320. if (customXcassetsPath.isEmpty())
  321. createXcassetsFolderFromIcons();
  322. else
  323. addCustomResourceFolder (customXcassetsPath, "folder.assetcatalog");
  324. }
  325. }
  326. else
  327. {
  328. MemoryOutputStream nib;
  329. nib.write (BinaryData::RecentFilesMenuTemplate_nib, BinaryData::RecentFilesMenuTemplate_nibSize);
  330. overwriteFileIfDifferentOrThrow (menuNibFile, nib);
  331. RelativePath menuNibPath (menuNibFile, getTargetFolder(), RelativePath::buildTargetFolder);
  332. addFileReference (menuNibPath.toUnixStyle());
  333. resourceIDs.add (addBuildFile (menuNibPath, false, false));
  334. resourceFileRefs.add (createFileRefID (menuNibPath));
  335. }
  336. if (iconFile.exists())
  337. {
  338. RelativePath iconPath (iconFile, getTargetFolder(), RelativePath::buildTargetFolder);
  339. addFileReference (iconPath.toUnixStyle());
  340. resourceIDs.add (addBuildFile (iconPath, false, false));
  341. resourceFileRefs.add (createFileRefID (iconPath));
  342. }
  343. {
  344. StringArray topLevelGroupIDs;
  345. for (int i = 0; i < getAllGroups().size(); ++i)
  346. {
  347. const Project::Item& group = getAllGroups().getReference(i);
  348. if (group.getNumChildren() > 0)
  349. topLevelGroupIDs.add (addProjectItem (group));
  350. }
  351. { // Add 'resources' group
  352. String resourcesGroupID (createID ("__resources"));
  353. addGroup (resourcesGroupID, "Resources", resourceFileRefs);
  354. topLevelGroupIDs.add (resourcesGroupID);
  355. }
  356. { // Add 'frameworks' group
  357. String frameworksGroupID (createID ("__frameworks"));
  358. addGroup (frameworksGroupID, "Frameworks", frameworkFileIDs);
  359. topLevelGroupIDs.add (frameworksGroupID);
  360. }
  361. { // Add 'products' group
  362. String productsGroupID (createID ("__products"));
  363. StringArray products;
  364. products.add (createID ("__productFileID"));
  365. addGroup (productsGroupID, "Products", products);
  366. topLevelGroupIDs.add (productsGroupID);
  367. }
  368. addGroup (createID ("__mainsourcegroup"), "Source", topLevelGroupIDs);
  369. }
  370. for (ConstConfigIterator config (*this); config.next();)
  371. {
  372. const XcodeBuildConfiguration& xcodeConfig = dynamic_cast<const XcodeBuildConfiguration&> (*config);
  373. addProjectConfig (config->getName(), getProjectSettings (xcodeConfig));
  374. addTargetConfig (config->getName(), getTargetSettings (xcodeConfig));
  375. }
  376. addConfigList (projectConfigs, createID ("__projList"));
  377. addConfigList (targetConfigs, createID ("__configList"));
  378. addShellScriptBuildPhase ("Pre-build script", getPreBuildScript());
  379. if (! projectType.isStaticLibrary())
  380. addBuildPhase ("PBXResourcesBuildPhase", resourceIDs);
  381. if (rezFileIDs.size() > 0)
  382. addBuildPhase ("PBXRezBuildPhase", rezFileIDs);
  383. addBuildPhase ("PBXSourcesBuildPhase", sourceIDs);
  384. if (! projectType.isStaticLibrary())
  385. addBuildPhase ("PBXFrameworksBuildPhase", frameworkIDs);
  386. addShellScriptBuildPhase ("Post-build script", getPostBuildScript());
  387. addTargetObject();
  388. addProjectObject();
  389. }
  390. static Image fixMacIconImageSize (Drawable& image)
  391. {
  392. const int validSizes[] = { 16, 32, 48, 128, 256, 512, 1024 };
  393. const int w = image.getWidth();
  394. const int h = image.getHeight();
  395. int bestSize = 16;
  396. for (int i = 0; i < numElementsInArray (validSizes); ++i)
  397. {
  398. if (w == h && w == validSizes[i])
  399. {
  400. bestSize = w;
  401. break;
  402. }
  403. if (jmax (w, h) > validSizes[i])
  404. bestSize = validSizes[i];
  405. }
  406. return rescaleImageForIcon (image, bestSize);
  407. }
  408. static void writeOldIconFormat (MemoryOutputStream& out, const Image& image, const char* type, const char* maskType)
  409. {
  410. const int w = image.getWidth();
  411. const int h = image.getHeight();
  412. out.write (type, 4);
  413. out.writeIntBigEndian (8 + 4 * w * h);
  414. const Image::BitmapData bitmap (image, Image::BitmapData::readOnly);
  415. for (int y = 0; y < h; ++y)
  416. {
  417. for (int x = 0; x < w; ++x)
  418. {
  419. const Colour pixel (bitmap.getPixelColour (x, y));
  420. out.writeByte ((char) pixel.getAlpha());
  421. out.writeByte ((char) pixel.getRed());
  422. out.writeByte ((char) pixel.getGreen());
  423. out.writeByte ((char) pixel.getBlue());
  424. }
  425. }
  426. out.write (maskType, 4);
  427. out.writeIntBigEndian (8 + w * h);
  428. for (int y = 0; y < h; ++y)
  429. {
  430. for (int x = 0; x < w; ++x)
  431. {
  432. const Colour pixel (bitmap.getPixelColour (x, y));
  433. out.writeByte ((char) pixel.getAlpha());
  434. }
  435. }
  436. }
  437. static void writeNewIconFormat (MemoryOutputStream& out, const Image& image, const char* type)
  438. {
  439. MemoryOutputStream pngData;
  440. PNGImageFormat pngFormat;
  441. pngFormat.writeImageToStream (image, pngData);
  442. out.write (type, 4);
  443. out.writeIntBigEndian (8 + (int) pngData.getDataSize());
  444. out << pngData;
  445. }
  446. void writeIcnsFile (const OwnedArray<Drawable>& images, OutputStream& out) const
  447. {
  448. MemoryOutputStream data;
  449. int smallest = 0x7fffffff;
  450. Drawable* smallestImage = nullptr;
  451. for (int i = 0; i < images.size(); ++i)
  452. {
  453. const Image image (fixMacIconImageSize (*images.getUnchecked(i)));
  454. jassert (image.getWidth() == image.getHeight());
  455. if (image.getWidth() < smallest)
  456. {
  457. smallest = image.getWidth();
  458. smallestImage = images.getUnchecked(i);
  459. }
  460. switch (image.getWidth())
  461. {
  462. case 16: writeOldIconFormat (data, image, "is32", "s8mk"); break;
  463. case 32: writeOldIconFormat (data, image, "il32", "l8mk"); break;
  464. case 48: writeOldIconFormat (data, image, "ih32", "h8mk"); break;
  465. case 128: writeOldIconFormat (data, image, "it32", "t8mk"); break;
  466. case 256: writeNewIconFormat (data, image, "ic08"); break;
  467. case 512: writeNewIconFormat (data, image, "ic09"); break;
  468. case 1024: writeNewIconFormat (data, image, "ic10"); break;
  469. default: break;
  470. }
  471. }
  472. jassert (data.getDataSize() > 0); // no suitable sized images?
  473. // If you only supply a 1024 image, the file doesn't work on 10.8, so we need
  474. // to force a smaller one in there too..
  475. if (smallest > 512 && smallestImage != nullptr)
  476. writeNewIconFormat (data, rescaleImageForIcon (*smallestImage, 512), "ic09");
  477. out.write ("icns", 4);
  478. out.writeIntBigEndian ((int) data.getDataSize() + 8);
  479. out << data;
  480. }
  481. void getIconImages (OwnedArray<Drawable>& images) const
  482. {
  483. ScopedPointer<Drawable> bigIcon (getBigIcon());
  484. if (bigIcon != nullptr)
  485. images.add (bigIcon.release());
  486. ScopedPointer<Drawable> smallIcon (getSmallIcon());
  487. if (smallIcon != nullptr)
  488. images.add (smallIcon.release());
  489. }
  490. void createiOSIconFiles (File appIconSet) const
  491. {
  492. const Array<AppIconType> types (getiOSAppIconTypes());
  493. OwnedArray<Drawable> images;
  494. getIconImages (images);
  495. if (images.size() > 0)
  496. {
  497. for (int i = 0; i < types.size(); ++i)
  498. {
  499. const AppIconType type = types.getUnchecked(i);
  500. const Image image (rescaleImageForIcon (*images.getFirst(), type.size));
  501. MemoryOutputStream pngData;
  502. PNGImageFormat pngFormat;
  503. pngFormat.writeImageToStream (image, pngData);
  504. overwriteFileIfDifferentOrThrow (appIconSet.getChildFile (type.filename), pngData);
  505. }
  506. }
  507. }
  508. void createIconFile() const
  509. {
  510. OwnedArray<Drawable> images;
  511. getIconImages (images);
  512. if (images.size() > 0)
  513. {
  514. MemoryOutputStream mo;
  515. writeIcnsFile (images, mo);
  516. iconFile = getTargetFolder().getChildFile ("Icon.icns");
  517. overwriteFileIfDifferentOrThrow (iconFile, mo);
  518. }
  519. }
  520. void writeInfoPlistFile() const
  521. {
  522. if (! xcodeCreatePList)
  523. return;
  524. ScopedPointer<XmlElement> plist (XmlDocument::parse (getPListToMergeString()));
  525. if (plist == nullptr || ! plist->hasTagName ("plist"))
  526. plist = new XmlElement ("plist");
  527. XmlElement* dict = plist->getChildByName ("dict");
  528. if (dict == nullptr)
  529. dict = plist->createNewChildElement ("dict");
  530. if (iOS)
  531. {
  532. addPlistDictionaryKeyBool (dict, "LSRequiresIPhoneOS", true);
  533. addPlistDictionaryKeyBool (dict, "UIViewControllerBasedStatusBarAppearance", false);
  534. }
  535. addPlistDictionaryKey (dict, "CFBundleExecutable", "${EXECUTABLE_NAME}");
  536. if (! iOS) // (NB: on iOS this causes error ITMS-90032 during publishing)
  537. addPlistDictionaryKey (dict, "CFBundleIconFile", iconFile.exists() ? iconFile.getFileName() : String());
  538. addPlistDictionaryKey (dict, "CFBundleIdentifier", "$(PRODUCT_BUNDLE_IDENTIFIER)");
  539. addPlistDictionaryKey (dict, "CFBundleName", projectName);
  540. addPlistDictionaryKey (dict, "CFBundlePackageType", xcodePackageType);
  541. addPlistDictionaryKey (dict, "CFBundleSignature", xcodeBundleSignature);
  542. addPlistDictionaryKey (dict, "CFBundleShortVersionString", project.getVersionString());
  543. addPlistDictionaryKey (dict, "CFBundleVersion", project.getVersionString());
  544. addPlistDictionaryKey (dict, "NSHumanReadableCopyright", project.getCompanyName().toString());
  545. addPlistDictionaryKeyBool (dict, "NSHighResolutionCapable", true);
  546. StringArray documentExtensions;
  547. documentExtensions.addTokens (replacePreprocessorDefs (getAllPreprocessorDefs(), settings ["documentExtensions"]),
  548. ",", StringRef());
  549. documentExtensions.trim();
  550. documentExtensions.removeEmptyStrings (true);
  551. if (documentExtensions.size() > 0)
  552. {
  553. dict->createNewChildElement ("key")->addTextElement ("CFBundleDocumentTypes");
  554. XmlElement* dict2 = dict->createNewChildElement ("array")->createNewChildElement ("dict");
  555. XmlElement* arrayTag = nullptr;
  556. for (int i = 0; i < documentExtensions.size(); ++i)
  557. {
  558. String ex (documentExtensions[i]);
  559. if (ex.startsWithChar ('.'))
  560. ex = ex.substring (1);
  561. if (arrayTag == nullptr)
  562. {
  563. dict2->createNewChildElement ("key")->addTextElement ("CFBundleTypeExtensions");
  564. arrayTag = dict2->createNewChildElement ("array");
  565. addPlistDictionaryKey (dict2, "CFBundleTypeName", ex);
  566. addPlistDictionaryKey (dict2, "CFBundleTypeRole", "Editor");
  567. addPlistDictionaryKey (dict2, "CFBundleTypeIconFile", "Icon");
  568. addPlistDictionaryKey (dict2, "NSPersistentStoreTypeKey", "XML");
  569. }
  570. arrayTag->createNewChildElement ("string")->addTextElement (ex);
  571. }
  572. }
  573. if (settings ["UIFileSharingEnabled"])
  574. addPlistDictionaryKeyBool (dict, "UIFileSharingEnabled", true);
  575. if (settings ["UIStatusBarHidden"])
  576. addPlistDictionaryKeyBool (dict, "UIStatusBarHidden", true);
  577. if (iOS)
  578. {
  579. // Forcing full screen disables the split screen feature and prevents error ITMS-90475
  580. addPlistDictionaryKeyBool (dict, "UIRequiresFullScreen", true);
  581. addIosScreenOrientations (dict);
  582. addIosBackgroundModes (dict);
  583. }
  584. for (int i = 0; i < xcodeExtraPListEntries.size(); ++i)
  585. dict->addChildElement (new XmlElement (xcodeExtraPListEntries.getReference(i)));
  586. MemoryOutputStream mo;
  587. plist->writeToStream (mo, "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
  588. overwriteFileIfDifferentOrThrow (infoPlistFile, mo);
  589. }
  590. void addIosScreenOrientations (XmlElement* dict) const
  591. {
  592. String screenOrientation = getScreenOrientationString();
  593. StringArray iOSOrientations;
  594. if (screenOrientation.contains ("portrait")) { iOSOrientations.add ("UIInterfaceOrientationPortrait"); }
  595. if (screenOrientation.contains ("landscape")) { iOSOrientations.add ("UIInterfaceOrientationLandscapeLeft"); iOSOrientations.add ("UIInterfaceOrientationLandscapeRight"); }
  596. addArrayToPlist (dict, "UISupportedInterfaceOrientations", iOSOrientations);
  597. }
  598. void addIosBackgroundModes (XmlElement* dict) const
  599. {
  600. StringArray iosBackgroundModes;
  601. if (isBackgroundAudioEnabled()) iosBackgroundModes.add ("audio");
  602. if (isBackgroundBleEnabled()) iosBackgroundModes.add ("bluetooth-central");
  603. addArrayToPlist (dict, "UIBackgroundModes", iosBackgroundModes);
  604. }
  605. static void addArrayToPlist (XmlElement* dict, String arrayKey, const StringArray& arrayElements)
  606. {
  607. dict->createNewChildElement ("key")->addTextElement (arrayKey);
  608. XmlElement* plistStringArray = dict->createNewChildElement ("array");
  609. for (int i = 0; i < arrayElements.size(); ++i)
  610. plistStringArray->createNewChildElement ("string")->addTextElement (arrayElements[i]);
  611. }
  612. void deleteRsrcFiles() const
  613. {
  614. for (DirectoryIterator di (getTargetFolder().getChildFile ("build"), true, "*.rsrc", File::findFiles); di.next();)
  615. di.getFile().deleteFile();
  616. }
  617. String getHeaderSearchPaths (const BuildConfiguration& config) const
  618. {
  619. StringArray paths (extraSearchPaths);
  620. paths.addArray (config.getHeaderSearchPaths());
  621. paths.add ("$(inherited)");
  622. paths = getCleanedStringArray (paths);
  623. for (int i = 0; i < paths.size(); ++i)
  624. {
  625. String& s = paths.getReference(i);
  626. s = replacePreprocessorTokens (config, s);
  627. if (s.containsChar (' '))
  628. s = "\"\\\"" + s + "\\\"\""; // crazy double quotes required when there are spaces..
  629. else
  630. s = "\"" + s + "\"";
  631. }
  632. return "(" + paths.joinIntoString (", ") + ")";
  633. }
  634. static String getLinkerFlagForLib (String library)
  635. {
  636. if (library.substring (0, 3) == "lib")
  637. library = library.substring (3);
  638. return "-l" + library.upToLastOccurrenceOf (".", false, false);
  639. }
  640. void getLinkerFlagsForStaticLibrary (const RelativePath& library, StringArray& flags, StringArray& librarySearchPaths) const
  641. {
  642. flags.add (getLinkerFlagForLib (library.getFileNameWithoutExtension()));
  643. String searchPath (library.toUnixStyle().upToLastOccurrenceOf ("/", false, false));
  644. if (! library.isAbsolute())
  645. {
  646. String srcRoot (rebaseFromProjectFolderToBuildTarget (RelativePath (".", RelativePath::projectFolder)).toUnixStyle());
  647. if (srcRoot.endsWith ("/.")) srcRoot = srcRoot.dropLastCharacters (2);
  648. if (! srcRoot.endsWithChar ('/')) srcRoot << '/';
  649. searchPath = srcRoot + searchPath;
  650. }
  651. librarySearchPaths.add (sanitisePath (searchPath));
  652. }
  653. void getLinkerFlags (const BuildConfiguration& config, StringArray& flags, StringArray& librarySearchPaths) const
  654. {
  655. if (xcodeIsBundle)
  656. flags.add ("-bundle");
  657. const Array<RelativePath>& extraLibs = config.isDebug() ? xcodeExtraLibrariesDebug
  658. : xcodeExtraLibrariesRelease;
  659. for (int i = 0; i < extraLibs.size(); ++i)
  660. getLinkerFlagsForStaticLibrary (extraLibs.getReference(i), flags, librarySearchPaths);
  661. flags.add (replacePreprocessorTokens (config, getExtraLinkerFlagsString()));
  662. flags.add (getExternalLibraryFlags (config));
  663. for (int i = 0; i < xcodeLibs.size(); ++i)
  664. flags.add (getLinkerFlagForLib (xcodeLibs[i]));
  665. flags = getCleanedStringArray (flags);
  666. }
  667. StringArray getProjectSettings (const XcodeBuildConfiguration& config) const
  668. {
  669. StringArray s;
  670. s.add ("ALWAYS_SEARCH_USER_PATHS = NO");
  671. s.add ("GCC_C_LANGUAGE_STANDARD = c99");
  672. s.add ("GCC_WARN_ABOUT_RETURN_TYPE = YES");
  673. s.add ("GCC_WARN_CHECK_SWITCH_STATEMENTS = YES");
  674. s.add ("GCC_WARN_UNUSED_VARIABLE = YES");
  675. s.add ("GCC_WARN_MISSING_PARENTHESES = YES");
  676. s.add ("GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES");
  677. s.add ("GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES");
  678. s.add ("WARNING_CFLAGS = -Wreorder");
  679. s.add ("GCC_MODEL_TUNING = G5");
  680. if (projectType.isStaticLibrary())
  681. {
  682. s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = NO");
  683. s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = NO");
  684. }
  685. else
  686. {
  687. s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = YES");
  688. }
  689. if (config.isDebug())
  690. {
  691. s.add ("ENABLE_TESTABILITY = YES");
  692. if (config.getMacArchitecture() == osxArch_Default || config.getMacArchitecture().isEmpty())
  693. s.add ("ONLY_ACTIVE_ARCH = YES");
  694. }
  695. if (iOS)
  696. {
  697. s.add ("\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\"");
  698. s.add ("SDKROOT = iphoneos");
  699. s.add ("TARGETED_DEVICE_FAMILY = \"1,2\"");
  700. const String iosVersion (config.getiOSCompatibilityVersion());
  701. if (iosVersion.isNotEmpty() && iosVersion != osxVersionDefault)
  702. s.add ("IPHONEOS_DEPLOYMENT_TARGET = " + iosVersion);
  703. }
  704. s.add ("ZERO_LINK = NO");
  705. if (xcodeCanUseDwarf)
  706. s.add ("DEBUG_INFORMATION_FORMAT = \"dwarf\"");
  707. s.add ("PRODUCT_NAME = \"" + replacePreprocessorTokens (config, config.getTargetBinaryNameString()) + "\"");
  708. return s;
  709. }
  710. StringArray getTargetSettings (const XcodeBuildConfiguration& config) const
  711. {
  712. StringArray s;
  713. s.add ("PRODUCT_BUNDLE_IDENTIFIER = " + project.getBundleIdentifier().toString());
  714. const String arch (config.getMacArchitecture());
  715. if (arch == osxArch_Native) s.add ("ARCHS = \"$(NATIVE_ARCH_ACTUAL)\"");
  716. else if (arch == osxArch_32BitUniversal) s.add ("ARCHS = \"$(ARCHS_STANDARD_32_BIT)\"");
  717. else if (arch == osxArch_64BitUniversal) s.add ("ARCHS = \"$(ARCHS_STANDARD_32_64_BIT)\"");
  718. else if (arch == osxArch_64Bit) s.add ("ARCHS = \"$(ARCHS_STANDARD_64_BIT)\"");
  719. s.add ("HEADER_SEARCH_PATHS = " + getHeaderSearchPaths (config));
  720. s.add ("GCC_OPTIMIZATION_LEVEL = " + config.getGCCOptimisationFlag());
  721. s.add ("INFOPLIST_FILE = " + infoPlistFile.getFileName());
  722. if (config.isLinkTimeOptimisationEnabled())
  723. s.add ("LLVM_LTO = YES");
  724. if (config.isFastMathEnabled())
  725. s.add ("GCC_FAST_MATH = YES");
  726. const String extraFlags (replacePreprocessorTokens (config, getExtraCompilerFlagsString()).trim());
  727. if (extraFlags.isNotEmpty())
  728. s.add ("OTHER_CPLUSPLUSFLAGS = \"" + extraFlags + "\"");
  729. if (xcodeProductInstallPath.isNotEmpty())
  730. s.add ("INSTALL_PATH = \"" + xcodeProductInstallPath + "\"");
  731. if (xcodeIsBundle)
  732. {
  733. s.add ("LIBRARY_STYLE = Bundle");
  734. s.add ("WRAPPER_EXTENSION = " + xcodeBundleExtension.substring (1));
  735. s.add ("GENERATE_PKGINFO_FILE = YES");
  736. }
  737. if (xcodeOtherRezFlags.isNotEmpty())
  738. s.add ("OTHER_REZFLAGS = \"" + xcodeOtherRezFlags + "\"");
  739. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  740. {
  741. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  742. binaryPath = binaryPath.rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder);
  743. s.add ("DSTROOT = " + addQuotesIfContainsSpace (sanitisePath (binaryPath.toUnixStyle())));
  744. s.add ("SYMROOT = " + addQuotesIfContainsSpace (sanitisePath (binaryPath.toUnixStyle())));
  745. }
  746. else
  747. {
  748. s.add ("CONFIGURATION_BUILD_DIR = \"$(PROJECT_DIR)/build/$(CONFIGURATION)\"");
  749. }
  750. String gccVersion ("com.apple.compilers.llvm.clang.1_0");
  751. if (iOS)
  752. {
  753. s.add ("ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon");
  754. s.add ("ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage");
  755. }
  756. else
  757. {
  758. const String sdk (config.getMacSDKVersion());
  759. const String sdkCompat (config.getMacCompatibilityVersion());
  760. for (int ver = oldestSDKVersion; ver <= currentSDKVersion; ++ver)
  761. {
  762. if (sdk == getSDKName (ver)) s.add ("SDKROOT = macosx10." + String (ver));
  763. if (sdkCompat == getSDKName (ver)) s.add ("MACOSX_DEPLOYMENT_TARGET = 10." + String (ver));
  764. }
  765. s.add ("MACOSX_DEPLOYMENT_TARGET_ppc = 10.4");
  766. s.add ("SDKROOT_ppc = macosx10.5");
  767. if (xcodeExcludedFiles64Bit.isNotEmpty())
  768. {
  769. s.add ("EXCLUDED_SOURCE_FILE_NAMES = \"$(EXCLUDED_SOURCE_FILE_NAMES_$(CURRENT_ARCH))\"");
  770. s.add ("EXCLUDED_SOURCE_FILE_NAMES_x86_64 = " + xcodeExcludedFiles64Bit);
  771. }
  772. }
  773. s.add ("GCC_VERSION = " + gccVersion);
  774. s.add ("CLANG_CXX_LANGUAGE_STANDARD = \"c++0x\"");
  775. s.add ("CLANG_LINK_OBJC_RUNTIME = NO");
  776. if (config.getCodeSignIdentity().isNotEmpty())
  777. s.add ("CODE_SIGN_IDENTITY = " + config.getCodeSignIdentity().quoted());
  778. if (config.getCppLanguageStandard().isNotEmpty())
  779. s.add ("CLANG_CXX_LANGUAGE_STANDARD = " + config.getCppLanguageStandard().quoted());
  780. if (config.getCppLibType().isNotEmpty())
  781. s.add ("CLANG_CXX_LIBRARY = " + config.getCppLibType().quoted());
  782. s.add ("COMBINE_HIDPI_IMAGES = YES");
  783. {
  784. StringArray linkerFlags, librarySearchPaths;
  785. getLinkerFlags (config, linkerFlags, librarySearchPaths);
  786. if (linkerFlags.size() > 0)
  787. s.add ("OTHER_LDFLAGS = \"" + linkerFlags.joinIntoString (" ") + "\"");
  788. librarySearchPaths.addArray (config.getLibrarySearchPaths());
  789. librarySearchPaths = getCleanedStringArray (librarySearchPaths);
  790. if (librarySearchPaths.size() > 0)
  791. {
  792. String libPaths ("LIBRARY_SEARCH_PATHS = (\"$(inherited)\"");
  793. for (int i = 0; i < librarySearchPaths.size(); ++i)
  794. libPaths += ", \"\\\"" + librarySearchPaths[i] + "\\\"\"";
  795. s.add (libPaths + ")");
  796. }
  797. }
  798. StringPairArray defines;
  799. if (config.isDebug())
  800. {
  801. defines.set ("_DEBUG", "1");
  802. defines.set ("DEBUG", "1");
  803. s.add ("COPY_PHASE_STRIP = NO");
  804. s.add ("GCC_DYNAMIC_NO_PIC = NO");
  805. }
  806. else
  807. {
  808. defines.set ("_NDEBUG", "1");
  809. defines.set ("NDEBUG", "1");
  810. s.add ("GCC_GENERATE_DEBUGGING_SYMBOLS = NO");
  811. s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = YES");
  812. s.add ("DEAD_CODE_STRIPPING = YES");
  813. }
  814. {
  815. defines = mergePreprocessorDefs (defines, getAllPreprocessorDefs (config));
  816. StringArray defsList;
  817. for (int i = 0; i < defines.size(); ++i)
  818. {
  819. String def (defines.getAllKeys()[i]);
  820. const String value (defines.getAllValues()[i]);
  821. if (value.isNotEmpty())
  822. def << "=" << value.replace ("\"", "\\\"");
  823. defsList.add ("\"" + def + "\"");
  824. }
  825. s.add ("GCC_PREPROCESSOR_DEFINITIONS = " + indentParenthesisedList (defsList));
  826. }
  827. s.addTokens (config.getCustomXcodeFlags(), ",", "\"'");
  828. return getCleanedStringArray (s);
  829. }
  830. void addFrameworks() const
  831. {
  832. if (! projectType.isStaticLibrary())
  833. {
  834. StringArray s (xcodeFrameworks);
  835. s.addTokens (getExtraFrameworksString(), ",;", "\"'");
  836. if (iOS && isInAppPurchasesEnabled())
  837. s.addIfNotAlreadyThere ("StoreKit");
  838. if (project.getConfigFlag ("JUCE_QUICKTIME") == Project::configFlagDisabled)
  839. s.removeString ("QuickTime");
  840. s.trim();
  841. s.removeDuplicates (true);
  842. s.sort (true);
  843. for (int i = 0; i < s.size(); ++i)
  844. addFramework (s[i]);
  845. }
  846. }
  847. void addCustomResourceFolders() const
  848. {
  849. StringArray crf;
  850. crf.addTokens (getCustomResourceFoldersString(), ":", "");
  851. crf.trim();
  852. for (int i = 0; i < crf.size(); ++i)
  853. addCustomResourceFolder (crf[i]);
  854. }
  855. void addCustomResourceFolder (String folderPathRelativeToProjectFolder, const String fileType = "folder") const
  856. {
  857. String folderPath = RelativePath (folderPathRelativeToProjectFolder, RelativePath::projectFolder)
  858. .rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder)
  859. .toUnixStyle();
  860. const String fileRefID (createFileRefID (folderPath));
  861. addFileOrFolderReference (folderPath, "<group>", fileType);
  862. resourceIDs.add (addBuildFile (folderPath, fileRefID, false, false));
  863. resourceFileRefs.add (createFileRefID (folderPath));
  864. }
  865. //==============================================================================
  866. void writeProjectFile (OutputStream& output) const
  867. {
  868. output << "// !$*UTF8*$!\n{\n"
  869. "\tarchiveVersion = 1;\n"
  870. "\tclasses = {\n\t};\n"
  871. "\tobjectVersion = 46;\n"
  872. "\tobjects = {\n\n";
  873. Array <ValueTree*> objects;
  874. objects.addArray (pbxBuildFiles);
  875. objects.addArray (pbxFileReferences);
  876. objects.addArray (pbxGroups);
  877. objects.addArray (targetConfigs);
  878. objects.addArray (projectConfigs);
  879. objects.addArray (misc);
  880. for (int i = 0; i < objects.size(); ++i)
  881. {
  882. ValueTree& o = *objects.getUnchecked(i);
  883. output << "\t\t" << o.getType().toString() << " = {";
  884. for (int j = 0; j < o.getNumProperties(); ++j)
  885. {
  886. const Identifier propertyName (o.getPropertyName(j));
  887. String val (o.getProperty (propertyName).toString());
  888. if (val.isEmpty() || (val.containsAnyOf (" \t;<>()=,&+-_@~\r\n\\#%^`*")
  889. && ! (val.trimStart().startsWithChar ('(')
  890. || val.trimStart().startsWithChar ('{'))))
  891. val = "\"" + val + "\"";
  892. output << propertyName.toString() << " = " << val << "; ";
  893. }
  894. output << "};\n";
  895. }
  896. output << "\t};\n\trootObject = " << createID ("__root") << ";\n}\n";
  897. }
  898. String addBuildFile (const String& path, const String& fileRefID, bool addToSourceBuildPhase, bool inhibitWarnings) const
  899. {
  900. String fileID (createID (path + "buildref"));
  901. if (addToSourceBuildPhase)
  902. sourceIDs.add (fileID);
  903. ValueTree* v = new ValueTree (fileID);
  904. v->setProperty ("isa", "PBXBuildFile", nullptr);
  905. v->setProperty ("fileRef", fileRefID, nullptr);
  906. if (inhibitWarnings)
  907. v->setProperty ("settings", "{COMPILER_FLAGS = \"-w\"; }", nullptr);
  908. pbxBuildFiles.add (v);
  909. return fileID;
  910. }
  911. String addBuildFile (const RelativePath& path, bool addToSourceBuildPhase, bool inhibitWarnings) const
  912. {
  913. return addBuildFile (path.toUnixStyle(), createFileRefID (path), addToSourceBuildPhase, inhibitWarnings);
  914. }
  915. String addFileReference (String pathString) const
  916. {
  917. String sourceTree ("SOURCE_ROOT");
  918. RelativePath path (pathString, RelativePath::unknown);
  919. if (pathString.startsWith ("${"))
  920. {
  921. sourceTree = pathString.substring (2).upToFirstOccurrenceOf ("}", false, false);
  922. pathString = pathString.fromFirstOccurrenceOf ("}/", false, false);
  923. }
  924. else if (path.isAbsolute())
  925. {
  926. sourceTree = "<absolute>";
  927. }
  928. String fileType = getFileType (path);
  929. return addFileOrFolderReference (pathString, sourceTree, fileType);
  930. }
  931. String addFileOrFolderReference (String pathString, String sourceTree, String fileType) const
  932. {
  933. const String fileRefID (createFileRefID (pathString));
  934. ScopedPointer<ValueTree> v (new ValueTree (fileRefID));
  935. v->setProperty ("isa", "PBXFileReference", nullptr);
  936. v->setProperty ("lastKnownFileType", fileType, nullptr);
  937. v->setProperty (Ids::name, pathString.fromLastOccurrenceOf ("/", false, false), nullptr);
  938. v->setProperty ("path", sanitisePath (pathString), nullptr);
  939. v->setProperty ("sourceTree", sourceTree, nullptr);
  940. const int existing = pbxFileReferences.indexOfSorted (*this, v);
  941. if (existing >= 0)
  942. {
  943. // If this fails, there's either a string hash collision, or the same file is being added twice (incorrectly)
  944. jassert (pbxFileReferences.getUnchecked (existing)->isEquivalentTo (*v));
  945. }
  946. else
  947. {
  948. pbxFileReferences.addSorted (*this, v.release());
  949. }
  950. return fileRefID;
  951. }
  952. public:
  953. static int compareElements (const ValueTree* first, const ValueTree* second)
  954. {
  955. return first->getType().getCharPointer().compare (second->getType().getCharPointer());
  956. }
  957. private:
  958. static String getFileType (const RelativePath& file)
  959. {
  960. if (file.hasFileExtension (cppFileExtensions)) return "sourcecode.cpp.cpp";
  961. if (file.hasFileExtension (".mm")) return "sourcecode.cpp.objcpp";
  962. if (file.hasFileExtension (".m")) return "sourcecode.c.objc";
  963. if (file.hasFileExtension (".c")) return "sourcecode.c.c";
  964. if (file.hasFileExtension (headerFileExtensions)) return "sourcecode.c.h";
  965. if (file.hasFileExtension (asmFileExtensions)) return "sourcecode.c.asm";
  966. if (file.hasFileExtension (".framework")) return "wrapper.framework";
  967. if (file.hasFileExtension (".jpeg;.jpg")) return "image.jpeg";
  968. if (file.hasFileExtension ("png;gif")) return "image" + file.getFileExtension();
  969. if (file.hasFileExtension ("html;htm")) return "text.html";
  970. if (file.hasFileExtension ("xml;zip;wav")) return "file" + file.getFileExtension();
  971. if (file.hasFileExtension ("txt;rtf")) return "text" + file.getFileExtension();
  972. if (file.hasFileExtension ("plist")) return "text.plist.xml";
  973. if (file.hasFileExtension ("app")) return "wrapper.application";
  974. if (file.hasFileExtension ("component;vst;plugin")) return "wrapper.cfbundle";
  975. if (file.hasFileExtension ("xcodeproj")) return "wrapper.pb-project";
  976. if (file.hasFileExtension ("a")) return "archive.ar";
  977. if (file.hasFileExtension ("xcassets")) return "folder.assetcatalog";
  978. return "file" + file.getFileExtension();
  979. }
  980. String addFile (const RelativePath& path, bool shouldBeCompiled, bool shouldBeAddedToBinaryResources, bool shouldBeAddedToXcodeResources, bool inhibitWarnings) const
  981. {
  982. const String pathAsString (path.toUnixStyle());
  983. const String refID (addFileReference (path.toUnixStyle()));
  984. if (shouldBeCompiled)
  985. {
  986. if (path.hasFileExtension (".r"))
  987. rezFileIDs.add (addBuildFile (pathAsString, refID, false, inhibitWarnings));
  988. else
  989. addBuildFile (pathAsString, refID, true, inhibitWarnings);
  990. }
  991. else if (! shouldBeAddedToBinaryResources || shouldBeAddedToXcodeResources)
  992. {
  993. const String fileType (getFileType (path));
  994. if (shouldBeAddedToXcodeResources || fileType.startsWith ("image.") || fileType.startsWith ("text.") || fileType.startsWith ("file."))
  995. {
  996. resourceIDs.add (addBuildFile (pathAsString, refID, false, false));
  997. resourceFileRefs.add (refID);
  998. }
  999. }
  1000. return refID;
  1001. }
  1002. String addProjectItem (const Project::Item& projectItem) const
  1003. {
  1004. if (projectItem.isGroup())
  1005. {
  1006. StringArray childIDs;
  1007. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  1008. {
  1009. const String childID (addProjectItem (projectItem.getChild(i)));
  1010. if (childID.isNotEmpty())
  1011. childIDs.add (childID);
  1012. }
  1013. return addGroup (projectItem, childIDs);
  1014. }
  1015. if (projectItem.shouldBeAddedToTargetProject())
  1016. {
  1017. const String itemPath (projectItem.getFilePath());
  1018. RelativePath path;
  1019. if (itemPath.startsWith ("${"))
  1020. path = RelativePath (itemPath, RelativePath::unknown);
  1021. else
  1022. path = RelativePath (projectItem.getFile(), getTargetFolder(), RelativePath::buildTargetFolder);
  1023. return addFile (path, projectItem.shouldBeCompiled(),
  1024. projectItem.shouldBeAddedToBinaryResources(),
  1025. projectItem.shouldBeAddedToXcodeResources(),
  1026. projectItem.shouldInhibitWarnings());
  1027. }
  1028. return String();
  1029. }
  1030. void addFramework (const String& frameworkName) const
  1031. {
  1032. String path (frameworkName);
  1033. if (! File::isAbsolutePath (path))
  1034. path = "System/Library/Frameworks/" + path;
  1035. if (! path.endsWithIgnoreCase (".framework"))
  1036. path << ".framework";
  1037. const String fileRefID (createFileRefID (path));
  1038. addFileReference ((File::isAbsolutePath (frameworkName) ? "" : "${SDKROOT}/") + path);
  1039. frameworkIDs.add (addBuildFile (path, fileRefID, false, false));
  1040. frameworkFileIDs.add (fileRefID);
  1041. }
  1042. void addGroup (const String& groupID, const String& groupName, const StringArray& childIDs) const
  1043. {
  1044. ValueTree* v = new ValueTree (groupID);
  1045. v->setProperty ("isa", "PBXGroup", nullptr);
  1046. v->setProperty ("children", indentParenthesisedList (childIDs), nullptr);
  1047. v->setProperty (Ids::name, groupName, nullptr);
  1048. v->setProperty ("sourceTree", "<group>", nullptr);
  1049. pbxGroups.add (v);
  1050. }
  1051. String addGroup (const Project::Item& item, StringArray& childIDs) const
  1052. {
  1053. const String groupName (item.getName());
  1054. const String groupID (getIDForGroup (item));
  1055. addGroup (groupID, groupName, childIDs);
  1056. return groupID;
  1057. }
  1058. void addMainBuildProduct() const
  1059. {
  1060. jassert (xcodeFileType.isNotEmpty());
  1061. jassert (xcodeBundleExtension.isEmpty() || xcodeBundleExtension.startsWithChar ('.'));
  1062. if (ProjectExporter::BuildConfiguration::Ptr config = getConfiguration(0))
  1063. {
  1064. String productName (replacePreprocessorTokens (*config, config->getTargetBinaryNameString()));
  1065. if (xcodeFileType == "archive.ar")
  1066. productName = getLibbedFilename (productName);
  1067. else
  1068. productName += xcodeBundleExtension;
  1069. addBuildProduct (xcodeFileType, productName);
  1070. }
  1071. }
  1072. void addBuildProduct (const String& fileType, const String& binaryName) const
  1073. {
  1074. ValueTree* v = new ValueTree (createID ("__productFileID"));
  1075. v->setProperty ("isa", "PBXFileReference", nullptr);
  1076. v->setProperty ("explicitFileType", fileType, nullptr);
  1077. v->setProperty ("includeInIndex", (int) 0, nullptr);
  1078. v->setProperty ("path", sanitisePath (binaryName), nullptr);
  1079. v->setProperty ("sourceTree", "BUILT_PRODUCTS_DIR", nullptr);
  1080. pbxFileReferences.add (v);
  1081. }
  1082. void addTargetConfig (const String& configName, const StringArray& buildSettings) const
  1083. {
  1084. ValueTree* v = new ValueTree (createID ("targetconfigid_" + configName));
  1085. v->setProperty ("isa", "XCBuildConfiguration", nullptr);
  1086. v->setProperty ("buildSettings", indentBracedList (buildSettings), nullptr);
  1087. v->setProperty (Ids::name, configName, nullptr);
  1088. targetConfigs.add (v);
  1089. }
  1090. void addProjectConfig (const String& configName, const StringArray& buildSettings) const
  1091. {
  1092. ValueTree* v = new ValueTree (createID ("projectconfigid_" + configName));
  1093. v->setProperty ("isa", "XCBuildConfiguration", nullptr);
  1094. v->setProperty ("buildSettings", indentBracedList (buildSettings), nullptr);
  1095. v->setProperty (Ids::name, configName, nullptr);
  1096. projectConfigs.add (v);
  1097. }
  1098. void addConfigList (const OwnedArray <ValueTree>& configsToUse, const String& listID) const
  1099. {
  1100. StringArray configIDs;
  1101. for (int i = 0; i < configsToUse.size(); ++i)
  1102. configIDs.add (configsToUse[i]->getType().toString());
  1103. ValueTree* v = new ValueTree (listID);
  1104. v->setProperty ("isa", "XCConfigurationList", nullptr);
  1105. v->setProperty ("buildConfigurations", indentParenthesisedList (configIDs), nullptr);
  1106. v->setProperty ("defaultConfigurationIsVisible", (int) 0, nullptr);
  1107. if (configsToUse[0] != nullptr)
  1108. v->setProperty ("defaultConfigurationName", configsToUse[0]->getProperty (Ids::name), nullptr);
  1109. misc.add (v);
  1110. }
  1111. ValueTree& addBuildPhase (const String& phaseType, const StringArray& fileIds) const
  1112. {
  1113. String phaseId (createID (phaseType + "resbuildphase"));
  1114. int n = 0;
  1115. while (buildPhaseIDs.contains (phaseId))
  1116. phaseId = createID (phaseType + "resbuildphase" + String (++n));
  1117. buildPhaseIDs.add (phaseId);
  1118. ValueTree* v = new ValueTree (phaseId);
  1119. v->setProperty ("isa", phaseType, nullptr);
  1120. v->setProperty ("buildActionMask", "2147483647", nullptr);
  1121. v->setProperty ("files", indentParenthesisedList (fileIds), nullptr);
  1122. v->setProperty ("runOnlyForDeploymentPostprocessing", (int) 0, nullptr);
  1123. misc.add (v);
  1124. return *v;
  1125. }
  1126. void addTargetObject() const
  1127. {
  1128. ValueTree* const v = new ValueTree (createID ("__target"));
  1129. v->setProperty ("isa", "PBXNativeTarget", nullptr);
  1130. v->setProperty ("buildConfigurationList", createID ("__configList"), nullptr);
  1131. v->setProperty ("buildPhases", indentParenthesisedList (buildPhaseIDs), nullptr);
  1132. v->setProperty ("buildRules", "( )", nullptr);
  1133. v->setProperty ("dependencies", "( )", nullptr);
  1134. v->setProperty (Ids::name, projectName, nullptr);
  1135. v->setProperty ("productName", projectName, nullptr);
  1136. v->setProperty ("productReference", createID ("__productFileID"), nullptr);
  1137. if (xcodeProductInstallPath.isNotEmpty())
  1138. v->setProperty ("productInstallPath", xcodeProductInstallPath, nullptr);
  1139. jassert (xcodeProductType.isNotEmpty());
  1140. v->setProperty ("productType", xcodeProductType, nullptr);
  1141. misc.add (v);
  1142. }
  1143. void addProjectObject() const
  1144. {
  1145. ValueTree* const v = new ValueTree (createID ("__root"));
  1146. v->setProperty ("isa", "PBXProject", nullptr);
  1147. v->setProperty ("buildConfigurationList", createID ("__projList"), nullptr);
  1148. v->setProperty ("attributes", getProjectObjectAttributes(), nullptr);
  1149. v->setProperty ("compatibilityVersion", "Xcode 3.2", nullptr);
  1150. v->setProperty ("hasScannedForEncodings", (int) 0, nullptr);
  1151. v->setProperty ("mainGroup", createID ("__mainsourcegroup"), nullptr);
  1152. v->setProperty ("projectDirPath", "\"\"", nullptr);
  1153. v->setProperty ("projectRoot", "\"\"", nullptr);
  1154. v->setProperty ("targets", "( " + createID ("__target") + " )", nullptr);
  1155. misc.add (v);
  1156. }
  1157. void addShellScriptBuildPhase (const String& phaseName, const String& script) const
  1158. {
  1159. if (script.trim().isNotEmpty())
  1160. {
  1161. ValueTree& v = addBuildPhase ("PBXShellScriptBuildPhase", StringArray());
  1162. v.setProperty (Ids::name, phaseName, nullptr);
  1163. v.setProperty ("shellPath", "/bin/sh", nullptr);
  1164. v.setProperty ("shellScript", script.replace ("\\", "\\\\")
  1165. .replace ("\"", "\\\"")
  1166. .replace ("\r\n", "\\n")
  1167. .replace ("\n", "\\n"), nullptr);
  1168. }
  1169. }
  1170. //==============================================================================
  1171. struct AppIconType
  1172. {
  1173. const char* idiom;
  1174. const char* sizeString;
  1175. const char* filename;
  1176. const char* scale;
  1177. int size;
  1178. };
  1179. static Array<AppIconType> getiOSAppIconTypes()
  1180. {
  1181. AppIconType types[] =
  1182. {
  1183. { "iphone", "29x29", "Icon-29.png", "1x", 29 },
  1184. { "iphone", "29x29", "Icon-29@2x.png", "2x", 58 },
  1185. { "iphone", "29x29", "Icon-29@3x.png", "3x", 87 },
  1186. { "iphone", "40x40", "Icon-Spotlight-40@2x.png", "2x", 80 },
  1187. { "iphone", "40x40", "Icon-Spotlight-40@3x.png", "3x", 120 },
  1188. { "iphone", "57x57", "Icon.png", "1x", 57 },
  1189. { "iphone", "57x57", "Icon@2x.png", "2x", 114 },
  1190. { "iphone", "60x60", "Icon-60@2x.png", "2x", 120 },
  1191. { "iphone", "60x60", "Icon-@3x.png", "3x", 180 },
  1192. { "ipad", "29x29", "Icon-Small-1.png", "1x", 29 },
  1193. { "ipad", "29x29", "Icon-Small@2x-1.png", "2x", 58 },
  1194. { "ipad", "40x40", "Icon-Spotlight-40.png", "1x", 40 },
  1195. { "ipad", "40x40", "Icon-Spotlight-40@2x-1.png", "2x", 80 },
  1196. { "ipad", "50x50", "Icon-Small-50.png", "1x", 50 },
  1197. { "ipad", "50x50", "Icon-Small-50@2x.png", "2x", 100 },
  1198. { "ipad", "72x72", "Icon-72.png", "1x", 72 },
  1199. { "ipad", "72x72", "Icon-72@2x.png", "2x", 144 },
  1200. { "ipad", "76x76", "Icon-76.png", "1x", 76 },
  1201. { "ipad", "76x76", "Icon-76@2x.png", "2x", 152 },
  1202. { "ipad", "83.5x83.5", "Icon-83.5@2x.png", "2x", 167 }
  1203. };
  1204. return Array<AppIconType> (types, numElementsInArray (types));
  1205. }
  1206. static String getiOSAppIconContents()
  1207. {
  1208. const Array<AppIconType> types (getiOSAppIconTypes());
  1209. var images;
  1210. for (int i = 0; i < types.size(); ++i)
  1211. {
  1212. AppIconType type = types.getUnchecked(i);
  1213. DynamicObject::Ptr d = new DynamicObject();
  1214. d->setProperty ("idiom", type.idiom);
  1215. d->setProperty ("size", type.sizeString);
  1216. d->setProperty ("filename", type.filename);
  1217. d->setProperty ("scale", type.scale);
  1218. images.append (var (d));
  1219. }
  1220. return getiOSAssetContents (images);
  1221. }
  1222. String getProjectObjectAttributes() const
  1223. {
  1224. String attributes;
  1225. attributes << "{ LastUpgradeCheck = 0440; ";
  1226. if (iOS && isInAppPurchasesEnabled())
  1227. {
  1228. attributes << "TargetAttributes = { " << createID ("__target") << " = { ";
  1229. attributes << "DevelopmentTeam = " << getIosDevelopmentTeamIDString() << "; ";
  1230. attributes << "SystemCapabilities = { com.apple.InAppPurchase = { enabled = 1; }; }; }; };";
  1231. }
  1232. attributes << "}";
  1233. return attributes;
  1234. }
  1235. //==============================================================================
  1236. struct ImageType
  1237. {
  1238. const char* orientation;
  1239. const char* idiom;
  1240. const char* subtype;
  1241. const char* extent;
  1242. const char* scale;
  1243. const char* filename;
  1244. int width;
  1245. int height;
  1246. };
  1247. static Array<ImageType> getiOSLaunchImageTypes()
  1248. {
  1249. ImageType types[] =
  1250. {
  1251. { "portrait", "iphone", nullptr, "full-screen", "2x", "LaunchImage-iphone-2x.png", 640, 960 },
  1252. { "portrait", "iphone", "retina4", "full-screen", "2x", "LaunchImage-iphone-retina4.png", 640, 1136 },
  1253. { "portrait", "ipad", nullptr, "full-screen", "1x", "LaunchImage-ipad-portrait-1x.png", 768, 1024 },
  1254. { "landscape","ipad", nullptr, "full-screen", "1x", "LaunchImage-ipad-landscape-1x.png", 1024, 768 },
  1255. { "portrait", "ipad", nullptr, "full-screen", "2x", "LaunchImage-ipad-portrait-2x.png", 1536, 2048 },
  1256. { "landscape","ipad", nullptr, "full-screen", "2x", "LaunchImage-ipad-landscape-2x.png", 2048, 1536 }
  1257. };
  1258. return Array<ImageType> (types, numElementsInArray (types));
  1259. }
  1260. static String getiOSLaunchImageContents()
  1261. {
  1262. const Array<ImageType> types (getiOSLaunchImageTypes());
  1263. var images;
  1264. for (int i = 0; i < types.size(); ++i)
  1265. {
  1266. const ImageType& type = types.getReference(i);
  1267. DynamicObject::Ptr d = new DynamicObject();
  1268. d->setProperty ("orientation", type.orientation);
  1269. d->setProperty ("idiom", type.idiom);
  1270. d->setProperty ("extent", type.extent);
  1271. d->setProperty ("minimum-system-version", "7.0");
  1272. d->setProperty ("scale", type.scale);
  1273. d->setProperty ("filename", type.filename);
  1274. if (type.subtype != nullptr)
  1275. d->setProperty ("subtype", type.subtype);
  1276. images.append (var (d));
  1277. }
  1278. return getiOSAssetContents (images);
  1279. }
  1280. static void createiOSLaunchImageFiles (const File& launchImageSet)
  1281. {
  1282. const Array<ImageType> types (getiOSLaunchImageTypes());
  1283. for (int i = 0; i < types.size(); ++i)
  1284. {
  1285. const ImageType& type = types.getReference(i);
  1286. Image image (Image::ARGB, type.width, type.height, true); // (empty black image)
  1287. image.clear (image.getBounds(), Colours::black);
  1288. MemoryOutputStream pngData;
  1289. PNGImageFormat pngFormat;
  1290. pngFormat.writeImageToStream (image, pngData);
  1291. overwriteFileIfDifferentOrThrow (launchImageSet.getChildFile (type.filename), pngData);
  1292. }
  1293. }
  1294. //==============================================================================
  1295. static String getiOSAssetContents (var images)
  1296. {
  1297. DynamicObject::Ptr v (new DynamicObject());
  1298. var info (new DynamicObject());
  1299. info.getDynamicObject()->setProperty ("version", 1);
  1300. info.getDynamicObject()->setProperty ("author", "xcode");
  1301. v->setProperty ("images", images);
  1302. v->setProperty ("info", info);
  1303. return JSON::toString (var (v));
  1304. }
  1305. void createXcassetsFolderFromIcons() const
  1306. {
  1307. const File assets (getTargetFolder().getChildFile (project.getProjectFilenameRoot())
  1308. .getChildFile ("Images.xcassets"));
  1309. const File iconSet (assets.getChildFile ("AppIcon.appiconset"));
  1310. const File launchImage (assets.getChildFile ("LaunchImage.launchimage"));
  1311. overwriteFileIfDifferentOrThrow (iconSet.getChildFile ("Contents.json"), getiOSAppIconContents());
  1312. createiOSIconFiles (iconSet);
  1313. overwriteFileIfDifferentOrThrow (launchImage.getChildFile ("Contents.json"), getiOSLaunchImageContents());
  1314. createiOSLaunchImageFiles (launchImage);
  1315. RelativePath assetsPath (assets, getTargetFolder(), RelativePath::buildTargetFolder);
  1316. addFileReference (assetsPath.toUnixStyle());
  1317. resourceIDs.add (addBuildFile (assetsPath, false, false));
  1318. resourceFileRefs.add (createFileRefID (assetsPath));
  1319. }
  1320. //==============================================================================
  1321. static String indentBracedList (const StringArray& list) { return "{" + indentList (list, ";", 0, true) + " }"; }
  1322. static String indentParenthesisedList (const StringArray& list) { return "(" + indentList (list, ",", 1, false) + " )"; }
  1323. static String indentList (const StringArray& list, const String& separator, int extraTabs, bool shouldSort)
  1324. {
  1325. if (list.size() == 0)
  1326. return " ";
  1327. const String tabs ("\n" + String::repeatedString ("\t", extraTabs + 4));
  1328. if (shouldSort)
  1329. {
  1330. StringArray sorted (list);
  1331. sorted.sort (true);
  1332. return tabs + sorted.joinIntoString (separator + tabs) + separator;
  1333. }
  1334. return tabs + list.joinIntoString (separator + tabs) + separator;
  1335. }
  1336. String createID (String rootString) const
  1337. {
  1338. if (rootString.startsWith ("${"))
  1339. rootString = rootString.fromFirstOccurrenceOf ("}/", false, false);
  1340. rootString += project.getProjectUID();
  1341. return MD5 (rootString.toUTF8()).toHexString().substring (0, 24).toUpperCase();
  1342. }
  1343. String createFileRefID (const RelativePath& path) const { return createFileRefID (path.toUnixStyle()); }
  1344. String createFileRefID (const String& path) const { return createID ("__fileref_" + path); }
  1345. String getIDForGroup (const Project::Item& item) const { return createID (item.getID()); }
  1346. bool shouldFileBeCompiledByDefault (const RelativePath& file) const override
  1347. {
  1348. return file.hasFileExtension (sourceFileExtensions);
  1349. }
  1350. static String getOSXVersionName (int version)
  1351. {
  1352. jassert (version >= 4);
  1353. return "10." + String (version);
  1354. }
  1355. static String getSDKName (int version)
  1356. {
  1357. return getOSXVersionName (version) + " SDK";
  1358. }
  1359. void initialiseDependencyPathValues()
  1360. {
  1361. vst2Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vstFolder), Ids::vst2Path, TargetOS::osx)));
  1362. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), Ids::vst3Path, TargetOS::osx)));
  1363. aaxPath. referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder), Ids::aaxPath, TargetOS::osx)));
  1364. rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder), Ids::rtasPath, TargetOS::osx)));
  1365. }
  1366. };