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.

1195 lines
49KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCER_PROJECTEXPORT_XCODE_JUCEHEADER__
  19. #define __JUCER_PROJECTEXPORT_XCODE_JUCEHEADER__
  20. #include "jucer_ProjectExporter.h"
  21. namespace
  22. {
  23. const char* const osxVersionDefault = "default";
  24. const char* const osxVersion10_4 = "10.4 SDK";
  25. const char* const osxVersion10_5 = "10.5 SDK";
  26. const char* const osxVersion10_6 = "10.6 SDK";
  27. const char* const osxVersion10_7 = "10.7 SDK";
  28. const char* const osxArch_Default = "default";
  29. const char* const osxArch_Native = "Native";
  30. const char* const osxArch_32BitUniversal = "32BitUniversal";
  31. const char* const osxArch_64BitUniversal = "64BitUniversal";
  32. const char* const osxArch_64Bit = "64BitIntel";
  33. }
  34. //==============================================================================
  35. class XCodeProjectExporter : public ProjectExporter
  36. {
  37. public:
  38. //==============================================================================
  39. static const char* getNameMac() { return "XCode (MacOSX)"; }
  40. static const char* getNameiOS() { return "XCode (iOS)"; }
  41. static const char* getValueTreeTypeName (bool iOS) { return iOS ? "XCODE_IPHONE" : "XCODE_MAC"; }
  42. //==============================================================================
  43. XCodeProjectExporter (Project& project_, const ValueTree& settings_, const bool iOS_)
  44. : ProjectExporter (project_, settings_),
  45. iOS (iOS_)
  46. {
  47. name = iOS ? getNameiOS() : getNameMac();
  48. if (getTargetLocationString().isEmpty())
  49. getTargetLocationValue() = getDefaultBuildsRootFolder() + (iOS ? "iOS" : "MacOSX");
  50. }
  51. static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings)
  52. {
  53. if (settings.hasType (getValueTreeTypeName (false)))
  54. return new XCodeProjectExporter (project, settings, false);
  55. else if (settings.hasType (getValueTreeTypeName (true)))
  56. return new XCodeProjectExporter (project, settings, true);
  57. return nullptr;
  58. }
  59. //==============================================================================
  60. Value getPListToMergeValue() { return getSetting ("customPList"); }
  61. String getPListToMergeString() const { return settings ["customPList"]; }
  62. Value getExtraFrameworksValue() { return getSetting (Ids::extraFrameworks); }
  63. String getExtraFrameworksString() const { return settings [Ids::extraFrameworks]; }
  64. Value getPostBuildScriptValue() { return getSetting (Ids::postbuildCommand); }
  65. String getPostBuildScript() const { return settings [Ids::postbuildCommand]; }
  66. int getLaunchPreferenceOrderForCurrentOS()
  67. {
  68. #if JUCE_MAC
  69. return iOS ? 1 : 2;
  70. #else
  71. return 0;
  72. #endif
  73. }
  74. bool isAvailableOnCurrentOS()
  75. {
  76. #if JUCE_MAC
  77. return true;
  78. #else
  79. return false;
  80. #endif
  81. }
  82. bool isPossibleForCurrentProject() { return projectType.isGUIApplication() || ! iOS; }
  83. bool usesMMFiles() const { return true; }
  84. bool isXcode() const { return true; }
  85. bool isOSX() const { return ! iOS; }
  86. bool canCopeWithDuplicateFiles() { return true; }
  87. void createPropertyEditors (PropertyListBuilder& props)
  88. {
  89. ProjectExporter::createPropertyEditors (props);
  90. if (projectType.isGUIApplication() && ! iOS)
  91. {
  92. props.add (new TextPropertyComponent (getSetting ("documentExtensions"), "Document file extensions", 128, false),
  93. "A comma-separated list of file extensions for documents that your app can open.");
  94. }
  95. else if (iOS)
  96. {
  97. props.add (new BooleanPropertyComponent (getSetting ("UIFileSharingEnabled"), "File Sharing Enabled", "Enabled"),
  98. "Enable this to expose your app's files to iTunes.");
  99. props.add (new BooleanPropertyComponent (getSetting ("UIStatusBarHidden"), "Status Bar Hidden", "Enabled"),
  100. "Enable this to disable the status bar in your app.");
  101. }
  102. props.add (new TextPropertyComponent (getPListToMergeValue(), "Custom PList", 8192, true),
  103. "You can paste the contents of an XML PList file in here, and the settings that it contains will override any "
  104. "settings that the Introjucer creates. BEWARE! When doing this, be careful to remove from the XML any "
  105. "values that you DO want the introjucer to change!");
  106. props.add (new TextPropertyComponent (getExtraFrameworksValue(), "Extra Frameworks", 2048, false),
  107. "A comma-separated list of extra frameworks that should be added to the build. "
  108. "(Don't include the .framework extension in the name)");
  109. if (projectType.isLibrary())
  110. {
  111. const char* const libTypes[] = { "Static Library (.a)", "Dynamic Library (.dylib)", 0 };
  112. const int libTypeValues[] = { 1, 2, 0 };
  113. props.add (new ChoicePropertyComponent (getLibraryType(), "Library Type",
  114. StringArray (libTypes), Array<var> (libTypeValues)));
  115. }
  116. props.add (new TextPropertyComponent (getPostBuildScriptValue(), "Post-build shell script", 32768, true),
  117. "Some shell-script that will be run after a build completes.");
  118. }
  119. void launchProject()
  120. {
  121. getProjectBundle().startAsProcess();
  122. }
  123. //==============================================================================
  124. void create (const OwnedArray<LibraryModule>&) const
  125. {
  126. infoPlistFile = getTargetFolder().getChildFile ("Info.plist");
  127. createIconFile();
  128. File projectBundle (getProjectBundle());
  129. createDirectoryOrThrow (projectBundle);
  130. createObjects();
  131. File projectFile (projectBundle.getChildFile ("project.pbxproj"));
  132. {
  133. MemoryOutputStream mo;
  134. writeProjectFile (mo);
  135. overwriteFileIfDifferentOrThrow (projectFile, mo);
  136. }
  137. writeInfoPlistFile();
  138. }
  139. protected:
  140. Value getLibraryType() { return getSetting (Ids::libraryType); }
  141. bool isStaticLibrary() const { return projectType.isLibrary() && (int) settings [Ids::libraryType] == 1; }
  142. //==============================================================================
  143. class XcodeBuildConfiguration : public BuildConfiguration
  144. {
  145. public:
  146. XcodeBuildConfiguration (Project& project, const ValueTree& settings, const bool iOS_)
  147. : BuildConfiguration (project, settings), iOS (iOS_)
  148. {
  149. }
  150. Value getMacSDKVersionValue() { return getValue (Ids::osxSDK); }
  151. String getMacSDKVersion() const { return config [Ids::osxSDK]; }
  152. Value getMacCompatibilityVersionValue() { return getValue (Ids::osxCompatibility); }
  153. String getMacCompatibilityVersion() const { return config [Ids::osxCompatibility]; }
  154. Value getiOSCompatibilityVersionValue() { return getValue (Ids::iosCompatibility); }
  155. String getiOSCompatibilityVersion() const { return config [Ids::iosCompatibility]; }
  156. Value getMacArchitectureValue() { return getValue (Ids::osxArchitecture); }
  157. String getMacArchitecture() const { return config [Ids::osxArchitecture]; }
  158. Value getCustomXcodeFlagsValue() { return getValue (Ids::customXcodeFlags); }
  159. String getCustomXcodeFlags() const { return config [Ids::customXcodeFlags]; }
  160. Value getCppLibTypeValue() { return getValue (Ids::cppLibType); }
  161. String getCppLibType() const { return config [Ids::cppLibType]; }
  162. void createPropertyEditors (PropertyListBuilder& props)
  163. {
  164. createBasicPropertyEditors (props);
  165. if (iOS)
  166. {
  167. if (getiOSCompatibilityVersion().isEmpty())
  168. getiOSCompatibilityVersionValue() = osxVersionDefault;
  169. const char* iosVersions[] = { "Use Default", "3.2", "4.0", "4.1", "4.2", "4.3", "5.0", "5.1", 0 };
  170. const char* iosVersionValues[] = { osxVersionDefault, "3.2", "4.0", "4.1", "4.2", "4.3", "5.0", "5.1", 0 };
  171. props.add (new ChoicePropertyComponent (getiOSCompatibilityVersionValue(), "iOS Deployment Target",
  172. StringArray (iosVersions), Array<var> (iosVersionValues)),
  173. "The minimum version of iOS that the target binary will run on.");
  174. }
  175. else
  176. {
  177. if (getMacSDKVersion().isEmpty())
  178. getMacSDKVersionValue() = osxVersionDefault;
  179. if (getMacCompatibilityVersion().isEmpty())
  180. getMacCompatibilityVersionValue() = osxVersionDefault;
  181. const char* osxVersions[] = { "Use Default", osxVersion10_5, osxVersion10_6, osxVersion10_7, 0 };
  182. const char* osxVersionValues[] = { osxVersionDefault, osxVersion10_5, osxVersion10_6, osxVersion10_7, 0 };
  183. props.add (new ChoicePropertyComponent (getMacSDKVersionValue(), "OSX Base SDK Version",
  184. StringArray (osxVersions), Array<var> (osxVersionValues)),
  185. "The version of OSX to link against in the XCode build.");
  186. props.add (new ChoicePropertyComponent (getMacCompatibilityVersionValue(), "OSX Compatibility Version",
  187. StringArray (osxVersions), Array<var> (osxVersionValues)),
  188. "The minimum version of OSX that the target binary will be compatible with.");
  189. if (getMacArchitecture().isEmpty())
  190. getMacArchitectureValue() = osxArch_Default;
  191. const char* osxArch[] = { "Use Default", "Native architecture of build machine",
  192. "Universal Binary (32-bit)", "Universal Binary (64-bit)", "64-bit Intel", 0 };
  193. const char* osxArchValues[] = { osxArch_Default, osxArch_Native, osxArch_32BitUniversal,
  194. osxArch_64BitUniversal, osxArch_64Bit, 0 };
  195. props.add (new ChoicePropertyComponent (getMacArchitectureValue(), "OSX Architecture",
  196. StringArray (osxArch), Array<var> (osxArchValues)),
  197. "The type of OSX binary that will be produced.");
  198. }
  199. props.add (new TextPropertyComponent (getCustomXcodeFlagsValue(), "Custom Xcode flags", 8192, false),
  200. "A comma-separated list of custom Xcode setting flags which will be appended to the list of generated flags, "
  201. "e.g. MACOSX_DEPLOYMENT_TARGET_i386 = 10.5, VALID_ARCHS = \"ppc i386 x86_64\"");
  202. const char* cppLibNames[] = { "Use Default", "Use LLVM libc++", 0 };
  203. Array<var> cppLibValues;
  204. cppLibValues.add (var::null);
  205. cppLibValues.add ("libc++");
  206. props.add (new ChoicePropertyComponent (getCppLibTypeValue(), "C++ Library", StringArray (cppLibNames), cppLibValues),
  207. "The type of C++ std lib that will be linked.");
  208. }
  209. bool iOS;
  210. };
  211. BuildConfiguration::Ptr createBuildConfig (const ValueTree& settings) const
  212. {
  213. return new XcodeBuildConfiguration (project, settings, iOS);
  214. }
  215. private:
  216. mutable OwnedArray<ValueTree> pbxBuildFiles, pbxFileReferences, pbxGroups, misc, projectConfigs, targetConfigs;
  217. mutable StringArray buildPhaseIDs, resourceIDs, sourceIDs, frameworkIDs;
  218. mutable StringArray frameworkFileIDs, rezFileIDs, resourceFileRefs;
  219. mutable File infoPlistFile, iconFile;
  220. const bool iOS;
  221. static String sanitisePath (const String& path)
  222. {
  223. if (path.startsWithChar ('~'))
  224. return "$(HOME)" + path.substring (1);
  225. return path;
  226. }
  227. File getProjectBundle() const { return getTargetFolder().getChildFile (project.getProjectFilenameRoot()).withFileExtension (".xcodeproj"); }
  228. //==============================================================================
  229. void createObjects() const
  230. {
  231. addFrameworks();
  232. addMainBuildProduct();
  233. if (xcodeCreatePList)
  234. {
  235. RelativePath plistPath (infoPlistFile, getTargetFolder(), RelativePath::buildTargetFolder);
  236. addFileReference (plistPath.toUnixStyle());
  237. resourceFileRefs.add (createFileRefID (plistPath));
  238. }
  239. if (iconFile.exists())
  240. {
  241. RelativePath iconPath (iconFile, getTargetFolder(), RelativePath::buildTargetFolder);
  242. addFileReference (iconPath.toUnixStyle());
  243. resourceIDs.add (addBuildFile (iconPath, false, false));
  244. resourceFileRefs.add (createFileRefID (iconPath));
  245. }
  246. {
  247. StringArray topLevelGroupIDs;
  248. for (int i = 0; i < groups.size(); ++i)
  249. if (groups.getReference(i).getNumChildren() > 0)
  250. topLevelGroupIDs.add (addProjectItem (groups.getReference(i)));
  251. { // Add 'resources' group
  252. String resourcesGroupID (createID ("__resources"));
  253. addGroup (resourcesGroupID, "Resources", resourceFileRefs);
  254. topLevelGroupIDs.add (resourcesGroupID);
  255. }
  256. { // Add 'frameworks' group
  257. String frameworksGroupID (createID ("__frameworks"));
  258. addGroup (frameworksGroupID, "Frameworks", frameworkFileIDs);
  259. topLevelGroupIDs.add (frameworksGroupID);
  260. }
  261. { // Add 'products' group
  262. String productsGroupID (createID ("__products"));
  263. StringArray products;
  264. products.add (createID ("__productFileID"));
  265. addGroup (productsGroupID, "Products", products);
  266. topLevelGroupIDs.add (productsGroupID);
  267. }
  268. addGroup (createID ("__mainsourcegroup"), "Source", topLevelGroupIDs);
  269. }
  270. for (ConstConfigIterator config (*this); config.next();)
  271. {
  272. const XcodeBuildConfiguration& xcodeConfig = dynamic_cast <const XcodeBuildConfiguration&> (*config);
  273. addProjectConfig (config->getName(), getProjectSettings (xcodeConfig));
  274. addTargetConfig (config->getName(), getTargetSettings (xcodeConfig));
  275. }
  276. addConfigList (projectConfigs, createID ("__projList"));
  277. addConfigList (targetConfigs, createID ("__configList"));
  278. if (! isStaticLibrary())
  279. addBuildPhase ("PBXResourcesBuildPhase", resourceIDs);
  280. if (rezFileIDs.size() > 0)
  281. addBuildPhase ("PBXRezBuildPhase", rezFileIDs);
  282. addBuildPhase ("PBXSourcesBuildPhase", sourceIDs);
  283. if (! isStaticLibrary())
  284. addBuildPhase ("PBXFrameworksBuildPhase", frameworkIDs);
  285. addShellScriptPhase();
  286. addTargetObject();
  287. addProjectObject();
  288. }
  289. static Image fixMacIconImageSize (Image& image)
  290. {
  291. const int validSizes[] = { 16, 32, 48, 128 };
  292. const int w = image.getWidth();
  293. const int h = image.getHeight();
  294. int bestSize = 16;
  295. for (int i = 0; i < numElementsInArray (validSizes); ++i)
  296. {
  297. if (w == h && w == validSizes[i])
  298. return image;
  299. if (jmax (w, h) > validSizes[i])
  300. bestSize = validSizes[i];
  301. }
  302. return rescaleImageForIcon (image, bestSize);
  303. }
  304. void writeIcnsFile (const Array<Image>& images, OutputStream& out) const
  305. {
  306. MemoryOutputStream data;
  307. for (int i = 0; i < images.size(); ++i)
  308. {
  309. Image image (fixMacIconImageSize (images.getReference (i)));
  310. const int w = image.getWidth();
  311. const int h = image.getHeight();
  312. jassert (w == h);
  313. const char* type = nullptr;
  314. const char* maskType = nullptr;
  315. if (w == 16) { type = "is32"; maskType = "s8mk"; }
  316. if (w == 32) { type = "il32"; maskType = "l8mk"; }
  317. if (w == 48) { type = "ih32"; maskType = "h8mk"; }
  318. if (w == 128) { type = "it32"; maskType = "t8mk"; }
  319. if (type != nullptr)
  320. {
  321. data.write (type, 4);
  322. data.writeIntBigEndian (8 + 4 * w * h);
  323. const Image::BitmapData bitmap (image, Image::BitmapData::readOnly);
  324. int y;
  325. for (y = 0; y < h; ++y)
  326. {
  327. for (int x = 0; x < w; ++x)
  328. {
  329. const Colour pixel (bitmap.getPixelColour (x, y));
  330. data.writeByte ((char) pixel.getAlpha());
  331. data.writeByte ((char) pixel.getRed());
  332. data.writeByte ((char) pixel.getGreen());
  333. data.writeByte ((char) pixel.getBlue());
  334. }
  335. }
  336. data.write (maskType, 4);
  337. data.writeIntBigEndian (8 + w * h);
  338. for (y = 0; y < h; ++y)
  339. {
  340. for (int x = 0; x < w; ++x)
  341. {
  342. const Colour pixel (bitmap.getPixelColour (x, y));
  343. data.writeByte ((char) pixel.getAlpha());
  344. }
  345. }
  346. }
  347. }
  348. jassert (data.getDataSize() > 0); // no suitable sized images?
  349. out.write ("icns", 4);
  350. out.writeIntBigEndian (data.getDataSize() + 8);
  351. out << data;
  352. }
  353. void createIconFile() const
  354. {
  355. Array<Image> images;
  356. Image bigIcon (getBigIcon());
  357. if (bigIcon.isValid())
  358. images.add (bigIcon);
  359. Image smallIcon (getSmallIcon());
  360. if (smallIcon.isValid())
  361. images.add (smallIcon);
  362. if (images.size() > 0)
  363. {
  364. MemoryOutputStream mo;
  365. writeIcnsFile (images, mo);
  366. iconFile = getTargetFolder().getChildFile ("Icon.icns");
  367. overwriteFileIfDifferentOrThrow (iconFile, mo);
  368. }
  369. }
  370. void writeInfoPlistFile() const
  371. {
  372. if (! xcodeCreatePList)
  373. return;
  374. ScopedPointer<XmlElement> plist (XmlDocument::parse (getPListToMergeString()));
  375. if (plist == nullptr || ! plist->hasTagName ("plist"))
  376. plist = new XmlElement ("plist");
  377. XmlElement* dict = plist->getChildByName ("dict");
  378. if (dict == nullptr)
  379. dict = plist->createNewChildElement ("dict");
  380. if (iOS)
  381. addPlistDictionaryKeyBool (dict, "LSRequiresIPhoneOS", true);
  382. addPlistDictionaryKey (dict, "CFBundleExecutable", "${EXECUTABLE_NAME}");
  383. addPlistDictionaryKey (dict, "CFBundleIconFile", iconFile.exists() ? iconFile.getFileName() : String::empty);
  384. addPlistDictionaryKey (dict, "CFBundleIdentifier", project.getBundleIdentifier().toString());
  385. addPlistDictionaryKey (dict, "CFBundleName", projectName);
  386. addPlistDictionaryKey (dict, "CFBundlePackageType", xcodePackageType);
  387. addPlistDictionaryKey (dict, "CFBundleSignature", xcodeBundleSignature);
  388. addPlistDictionaryKey (dict, "CFBundleShortVersionString", project.getVersionString());
  389. addPlistDictionaryKey (dict, "CFBundleVersion", project.getVersionString());
  390. addPlistDictionaryKey (dict, "NSHumanReadableCopyright", project.getCompanyName().toString());
  391. StringArray documentExtensions;
  392. documentExtensions.addTokens (replacePreprocessorDefs (getAllPreprocessorDefs(), settings ["documentExtensions"]),
  393. ",", String::empty);
  394. documentExtensions.trim();
  395. documentExtensions.removeEmptyStrings (true);
  396. if (documentExtensions.size() > 0)
  397. {
  398. dict->createNewChildElement ("key")->addTextElement ("CFBundleDocumentTypes");
  399. XmlElement* dict2 = dict->createNewChildElement ("array")->createNewChildElement ("dict");
  400. for (int i = 0; i < documentExtensions.size(); ++i)
  401. {
  402. String ex (documentExtensions[i]);
  403. if (ex.startsWithChar ('.'))
  404. ex = ex.substring (1);
  405. dict2->createNewChildElement ("key")->addTextElement ("CFBundleTypeExtensions");
  406. dict2->createNewChildElement ("array")->createNewChildElement ("string")->addTextElement (ex);
  407. addPlistDictionaryKey (dict2, "CFBundleTypeName", ex);
  408. addPlistDictionaryKey (dict2, "CFBundleTypeRole", "Editor");
  409. addPlistDictionaryKey (dict2, "NSPersistentStoreTypeKey", "XML");
  410. }
  411. }
  412. if (settings ["UIFileSharingEnabled"])
  413. addPlistDictionaryKeyBool (dict, "UIFileSharingEnabled", true);
  414. if (settings ["UIStatusBarHidden"])
  415. addPlistDictionaryKeyBool (dict, "UIStatusBarHidden", true);
  416. for (int i = 0; i < xcodeExtraPListEntries.size(); ++i)
  417. dict->addChildElement (new XmlElement (xcodeExtraPListEntries.getReference(i)));
  418. MemoryOutputStream mo;
  419. plist->writeToStream (mo, "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
  420. overwriteFileIfDifferentOrThrow (infoPlistFile, mo);
  421. }
  422. StringArray getHeaderSearchPaths (const BuildConfiguration& config) const
  423. {
  424. StringArray searchPaths (extraSearchPaths);
  425. searchPaths.addArray (config.getHeaderSearchPaths());
  426. searchPaths.removeDuplicates (false);
  427. return searchPaths;
  428. }
  429. void getLinkerFlagsForStaticLibrary (const RelativePath& library, StringArray& flags, StringArray& librarySearchPaths) const
  430. {
  431. jassert (library.getFileNameWithoutExtension().substring (0, 3) == "lib");
  432. flags.add ("-l" + library.getFileNameWithoutExtension().substring (3));
  433. String searchPath (library.toUnixStyle().upToLastOccurrenceOf ("/", false, false));
  434. if (! library.isAbsolute())
  435. {
  436. String srcRoot (rebaseFromProjectFolderToBuildTarget (RelativePath (".", RelativePath::projectFolder)).toUnixStyle());
  437. if (srcRoot.endsWith ("/.")) srcRoot = srcRoot.dropLastCharacters (2);
  438. if (! srcRoot.endsWithChar ('/')) srcRoot << '/';
  439. searchPath = srcRoot + searchPath;
  440. }
  441. librarySearchPaths.add (sanitisePath (searchPath));
  442. }
  443. void getLinkerFlags (const BuildConfiguration& config, StringArray& flags, StringArray& librarySearchPaths) const
  444. {
  445. if (xcodeIsBundle)
  446. flags.add ("-bundle");
  447. const Array<RelativePath>& extraLibs = config.isDebug() ? xcodeExtraLibrariesDebug
  448. : xcodeExtraLibrariesRelease;
  449. for (int i = 0; i < extraLibs.size(); ++i)
  450. getLinkerFlagsForStaticLibrary (extraLibs.getReference(i), flags, librarySearchPaths);
  451. flags.add (replacePreprocessorTokens (config, getExtraLinkerFlagsString()));
  452. flags.removeEmptyStrings (true);
  453. }
  454. StringArray getProjectSettings (const XcodeBuildConfiguration& config) const
  455. {
  456. StringArray s;
  457. s.add ("ALWAYS_SEARCH_USER_PATHS = NO");
  458. s.add ("GCC_C_LANGUAGE_STANDARD = c99");
  459. s.add ("GCC_WARN_ABOUT_RETURN_TYPE = YES");
  460. s.add ("GCC_WARN_CHECK_SWITCH_STATEMENTS = YES");
  461. s.add ("GCC_WARN_UNUSED_VARIABLE = YES");
  462. s.add ("GCC_WARN_MISSING_PARENTHESES = YES");
  463. s.add ("GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES");
  464. s.add ("GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES");
  465. s.add ("WARNING_CFLAGS = -Wreorder");
  466. s.add ("GCC_MODEL_TUNING = G5");
  467. if (projectType.isLibrary())
  468. {
  469. s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = NO");
  470. s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = NO");
  471. }
  472. else
  473. {
  474. s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = YES");
  475. }
  476. if (iOS)
  477. {
  478. s.add ("\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\"");
  479. s.add ("SDKROOT = iphoneos");
  480. s.add ("TARGETED_DEVICE_FAMILY = \"1,2\"");
  481. const String iosVersion (config.getiOSCompatibilityVersion());
  482. if (iosVersion.isNotEmpty() && iosVersion != osxVersionDefault)
  483. s.add ("IPHONEOS_DEPLOYMENT_TARGET = " + iosVersion);
  484. }
  485. s.add ("ZERO_LINK = NO");
  486. if (xcodeCanUseDwarf)
  487. s.add ("DEBUG_INFORMATION_FORMAT = \"dwarf\"");
  488. s.add ("PRODUCT_NAME = \"" + config.getTargetBinaryNameString() + "\"");
  489. return s;
  490. }
  491. StringArray getTargetSettings (const XcodeBuildConfiguration& config) const
  492. {
  493. StringArray s;
  494. const String arch (config.getMacArchitecture());
  495. if (arch == osxArch_Native) s.add ("ARCHS = \"$(ARCHS_NATIVE)\"");
  496. else if (arch == osxArch_32BitUniversal) s.add ("ARCHS = \"$(ARCHS_STANDARD_32_BIT)\"");
  497. else if (arch == osxArch_64BitUniversal) s.add ("ARCHS = \"$(ARCHS_STANDARD_32_64_BIT)\"");
  498. else if (arch == osxArch_64Bit) s.add ("ARCHS = \"$(ARCHS_STANDARD_64_BIT)\"");
  499. s.add ("HEADER_SEARCH_PATHS = \"" + replacePreprocessorTokens (config, getHeaderSearchPaths (config).joinIntoString (" ")) + " $(inherited)\"");
  500. s.add ("GCC_OPTIMIZATION_LEVEL = " + config.getGCCOptimisationFlag());
  501. s.add ("INFOPLIST_FILE = " + infoPlistFile.getFileName());
  502. const String extraFlags (replacePreprocessorTokens (config, getExtraCompilerFlagsString()).trim());
  503. if (extraFlags.isNotEmpty())
  504. s.add ("OTHER_CPLUSPLUSFLAGS = \"" + extraFlags + "\"");
  505. if (xcodeProductInstallPath.isNotEmpty())
  506. s.add ("INSTALL_PATH = \"" + xcodeProductInstallPath + "\"");
  507. if (xcodeIsBundle)
  508. {
  509. s.add ("LIBRARY_STYLE = Bundle");
  510. s.add ("WRAPPER_EXTENSION = " + xcodeBundleExtension.substring (1));
  511. s.add ("GENERATE_PKGINFO_FILE = YES");
  512. }
  513. if (xcodeOtherRezFlags.isNotEmpty())
  514. s.add ("OTHER_REZFLAGS = \"" + xcodeOtherRezFlags + "\"");
  515. if (projectType.isLibrary())
  516. {
  517. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  518. {
  519. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  520. binaryPath = binaryPath.rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder);
  521. s.add ("DSTROOT = " + sanitisePath (binaryPath.toUnixStyle()));
  522. s.add ("SYMROOT = " + sanitisePath (binaryPath.toUnixStyle()));
  523. }
  524. s.add ("CONFIGURATION_BUILD_DIR = \"$(BUILD_DIR)\"");
  525. s.add ("DEPLOYMENT_LOCATION = YES");
  526. }
  527. String gccVersion ("com.apple.compilers.llvm.clang.1_0");
  528. if (! iOS)
  529. {
  530. const String sdk (config.getMacSDKVersion());
  531. const String sdkCompat (config.getMacCompatibilityVersion());
  532. if (sdk == osxVersion10_5) s.add ("SDKROOT = macosx10.5");
  533. else if (sdk == osxVersion10_6) s.add ("SDKROOT = macosx10.6");
  534. else if (sdk == osxVersion10_7) s.add ("SDKROOT = macosx10.7");
  535. if (sdkCompat == osxVersion10_4) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.4");
  536. else if (sdkCompat == osxVersion10_5) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.5");
  537. else if (sdkCompat == osxVersion10_6) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.6");
  538. else if (sdkCompat == osxVersion10_7) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.7");
  539. s.add ("MACOSX_DEPLOYMENT_TARGET_ppc = 10.4");
  540. s.add ("SDKROOT_ppc = macosx10.5");
  541. if (xcodeExcludedFiles64Bit.isNotEmpty())
  542. {
  543. s.add ("EXCLUDED_SOURCE_FILE_NAMES = \"$(EXCLUDED_SOURCE_FILE_NAMES_$(CURRENT_ARCH))\"");
  544. s.add ("EXCLUDED_SOURCE_FILE_NAMES_x86_64 = " + xcodeExcludedFiles64Bit);
  545. }
  546. }
  547. s.add ("GCC_VERSION = " + gccVersion);
  548. s.add ("CLANG_CXX_LANGUAGE_STANDARD = \"c++0x\"");
  549. if (config.getCppLibType().isNotEmpty())
  550. s.add ("CLANG_CXX_LIBRARY = " + config.getCppLibType().quoted());
  551. {
  552. StringArray linkerFlags, librarySearchPaths;
  553. getLinkerFlags (config, linkerFlags, librarySearchPaths);
  554. if (linkerFlags.size() > 0)
  555. s.add ("OTHER_LDFLAGS = \"" + linkerFlags.joinIntoString (" ") + "\"");
  556. librarySearchPaths.addArray (config.getLibrarySearchPaths());
  557. librarySearchPaths.removeDuplicates (false);
  558. if (librarySearchPaths.size() > 0)
  559. {
  560. String libPaths ("LIBRARY_SEARCH_PATHS = (\"$(inherited)\"");
  561. for (int i = 0; i < librarySearchPaths.size(); ++i)
  562. libPaths += ", \"\\\"" + librarySearchPaths[i] + "\\\"\"";
  563. s.add (libPaths + ")");
  564. }
  565. }
  566. StringPairArray defines;
  567. if (config.isDebug())
  568. {
  569. defines.set ("_DEBUG", "1");
  570. defines.set ("DEBUG", "1");
  571. s.add ("ONLY_ACTIVE_ARCH = YES");
  572. s.add ("COPY_PHASE_STRIP = NO");
  573. s.add ("GCC_DYNAMIC_NO_PIC = NO");
  574. }
  575. else
  576. {
  577. defines.set ("_NDEBUG", "1");
  578. defines.set ("NDEBUG", "1");
  579. s.add ("GCC_GENERATE_DEBUGGING_SYMBOLS = NO");
  580. s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = YES");
  581. }
  582. {
  583. defines = mergePreprocessorDefs (defines, getAllPreprocessorDefs (config));
  584. StringArray defsList;
  585. for (int i = 0; i < defines.size(); ++i)
  586. {
  587. String def (defines.getAllKeys()[i]);
  588. const String value (defines.getAllValues()[i]);
  589. if (value.isNotEmpty())
  590. def << "=" << value;
  591. defsList.add (def.quoted());
  592. }
  593. s.add ("GCC_PREPROCESSOR_DEFINITIONS = (" + indentList (defsList, ",") + ")");
  594. }
  595. s.addTokens (config.getCustomXcodeFlags(), ",", "\"'");
  596. s.trim();
  597. s.removeEmptyStrings();
  598. s.removeDuplicates (false);
  599. return s;
  600. }
  601. void addFrameworks() const
  602. {
  603. if (! isStaticLibrary())
  604. {
  605. StringArray s (xcodeFrameworks);
  606. s.addTokens (getExtraFrameworksString(), ",;", "\"'");
  607. s.trim();
  608. s.removeDuplicates (true);
  609. s.sort (true);
  610. for (int i = 0; i < s.size(); ++i)
  611. addFramework (s[i]);
  612. }
  613. }
  614. //==============================================================================
  615. void writeProjectFile (OutputStream& output) const
  616. {
  617. output << "// !$*UTF8*$!\n{\n"
  618. "\tarchiveVersion = 1;\n"
  619. "\tclasses = {\n\t};\n"
  620. "\tobjectVersion = 46;\n"
  621. "\tobjects = {\n\n";
  622. Array <ValueTree*> objects;
  623. objects.addArray (pbxBuildFiles);
  624. objects.addArray (pbxFileReferences);
  625. objects.addArray (pbxGroups);
  626. objects.addArray (targetConfigs);
  627. objects.addArray (projectConfigs);
  628. objects.addArray (misc);
  629. for (int i = 0; i < objects.size(); ++i)
  630. {
  631. ValueTree& o = *objects.getUnchecked(i);
  632. output << "\t\t" << o.getType().toString() << " = { ";
  633. for (int j = 0; j < o.getNumProperties(); ++j)
  634. {
  635. const Identifier propertyName (o.getPropertyName(j));
  636. String val (o.getProperty (propertyName).toString());
  637. if (val.isEmpty() || (val.containsAnyOf (" \t;<>()=,&+-_\r\n")
  638. && ! (val.trimStart().startsWithChar ('(')
  639. || val.trimStart().startsWithChar ('{'))))
  640. val = val.quoted();
  641. output << propertyName.toString() << " = " << val << "; ";
  642. }
  643. output << "};\n";
  644. }
  645. output << "\t};\n\trootObject = " << createID ("__root") << ";\n}\n";
  646. }
  647. static void addPlistDictionaryKey (XmlElement* xml, const String& key, const String& value)
  648. {
  649. forEachXmlChildElementWithTagName (*xml, e, "key")
  650. {
  651. if (e->getAllSubText().trim().equalsIgnoreCase (key))
  652. {
  653. if (e->getNextElement() != nullptr && e->getNextElement()->hasTagName ("key"))
  654. {
  655. // try to fix broken plist format..
  656. xml->removeChildElement (e, true);
  657. break;
  658. }
  659. else
  660. {
  661. return; // (value already exists)
  662. }
  663. }
  664. }
  665. xml->createNewChildElement ("key") ->addTextElement (key);
  666. xml->createNewChildElement ("string")->addTextElement (value);
  667. }
  668. static void addPlistDictionaryKeyBool (XmlElement* xml, const String& key, const bool value)
  669. {
  670. xml->createNewChildElement ("key")->addTextElement (key);
  671. xml->createNewChildElement (value ? "true" : "false");
  672. }
  673. String addBuildFile (const String& path, const String& fileRefID, bool addToSourceBuildPhase, bool inhibitWarnings) const
  674. {
  675. String fileID (createID (path + "buildref"));
  676. if (addToSourceBuildPhase)
  677. sourceIDs.add (fileID);
  678. ValueTree* v = new ValueTree (fileID);
  679. v->setProperty ("isa", "PBXBuildFile", 0);
  680. v->setProperty ("fileRef", fileRefID, 0);
  681. if (inhibitWarnings)
  682. v->setProperty ("settings", "{COMPILER_FLAGS = \"-w\"; }", 0);
  683. pbxBuildFiles.add (v);
  684. return fileID;
  685. }
  686. String addBuildFile (const RelativePath& path, bool addToSourceBuildPhase, bool inhibitWarnings) const
  687. {
  688. return addBuildFile (path.toUnixStyle(), createFileRefID (path), addToSourceBuildPhase, inhibitWarnings);
  689. }
  690. String addFileReference (String pathString) const
  691. {
  692. String sourceTree ("SOURCE_ROOT");
  693. RelativePath path (pathString, RelativePath::unknown);
  694. if (pathString.startsWith ("${"))
  695. {
  696. sourceTree = pathString.substring (2).upToFirstOccurrenceOf ("}", false, false);
  697. pathString = pathString.fromFirstOccurrenceOf ("}/", false, false);
  698. }
  699. else if (path.isAbsolute())
  700. {
  701. sourceTree = "<absolute>";
  702. }
  703. const String fileRefID (createFileRefID (pathString));
  704. ScopedPointer<ValueTree> v (new ValueTree (fileRefID));
  705. v->setProperty ("isa", "PBXFileReference", 0);
  706. v->setProperty ("lastKnownFileType", getFileType (path), 0);
  707. v->setProperty (Ids::name, pathString.fromLastOccurrenceOf ("/", false, false), 0);
  708. v->setProperty ("path", sanitisePath (pathString), 0);
  709. v->setProperty ("sourceTree", sourceTree, 0);
  710. const int existing = pbxFileReferences.indexOfSorted (*this, v);
  711. if (existing >= 0)
  712. {
  713. // If this fails, there's either a string hash collision, or the same file is being added twice (incorrectly)
  714. jassert (pbxFileReferences.getUnchecked (existing)->isEquivalentTo (*v));
  715. }
  716. else
  717. {
  718. pbxFileReferences.addSorted (*this, v.release());
  719. }
  720. return fileRefID;
  721. }
  722. public:
  723. static int compareElements (const ValueTree* first, const ValueTree* second)
  724. {
  725. return first->getType().getCharPointer().compare (second->getType().getCharPointer());
  726. }
  727. private:
  728. static String getFileType (const RelativePath& file)
  729. {
  730. if (file.hasFileExtension ("cpp;cc;cxx")) return "sourcecode.cpp.cpp";
  731. else if (file.hasFileExtension (".mm")) return "sourcecode.cpp.objcpp";
  732. else if (file.hasFileExtension (".m")) return "sourcecode.c.objc";
  733. else if (file.hasFileExtension (headerFileExtensions)) return "sourcecode.c.h";
  734. else if (file.hasFileExtension (".framework")) return "wrapper.framework";
  735. else if (file.hasFileExtension (".jpeg;.jpg")) return "image.jpeg";
  736. else if (file.hasFileExtension ("png;gif")) return "image" + file.getFileExtension();
  737. else if (file.hasFileExtension ("html;htm")) return "text.html";
  738. else if (file.hasFileExtension ("xml;zip;wav")) return "file" + file.getFileExtension();
  739. else if (file.hasFileExtension ("txt;rtf")) return "text" + file.getFileExtension();
  740. else if (file.hasFileExtension ("plist")) return "text.plist.xml";
  741. else if (file.hasFileExtension ("app")) return "wrapper.application";
  742. else if (file.hasFileExtension ("component;vst;plugin")) return "wrapper.cfbundle";
  743. else if (file.hasFileExtension ("xcodeproj")) return "wrapper.pb-project";
  744. else if (file.hasFileExtension ("a")) return "archive.ar";
  745. return "file" + file.getFileExtension();
  746. }
  747. String addFile (const RelativePath& path, bool shouldBeCompiled, bool inhibitWarnings) const
  748. {
  749. const String pathAsString (path.toUnixStyle());
  750. const String refID (addFileReference (path.toUnixStyle()));
  751. if (shouldBeCompiled)
  752. {
  753. if (path.hasFileExtension (".r"))
  754. rezFileIDs.add (addBuildFile (pathAsString, refID, false, inhibitWarnings));
  755. else
  756. addBuildFile (pathAsString, refID, true, inhibitWarnings);
  757. }
  758. return refID;
  759. }
  760. String addProjectItem (const Project::Item& projectItem) const
  761. {
  762. if (projectItem.isGroup())
  763. {
  764. StringArray childIDs;
  765. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  766. {
  767. const String childID (addProjectItem (projectItem.getChild(i)));
  768. if (childID.isNotEmpty())
  769. childIDs.add (childID);
  770. }
  771. return addGroup (projectItem, childIDs);
  772. }
  773. else
  774. {
  775. if (projectItem.shouldBeAddedToTargetProject())
  776. {
  777. String itemPath (projectItem.getFilePath());
  778. bool inhibitWarnings = projectItem.shouldInhibitWarnings();
  779. if (itemPath.startsWith ("${"))
  780. {
  781. const RelativePath path (itemPath, RelativePath::unknown);
  782. return addFile (path, projectItem.shouldBeCompiled(), inhibitWarnings);
  783. }
  784. else
  785. {
  786. const RelativePath path (projectItem.getFile(), getTargetFolder(), RelativePath::buildTargetFolder);
  787. return addFile (path, projectItem.shouldBeCompiled(), inhibitWarnings);
  788. }
  789. }
  790. }
  791. return String::empty;
  792. }
  793. void addFramework (const String& frameworkName) const
  794. {
  795. const String path ("System/Library/Frameworks/" + frameworkName + ".framework");
  796. const String fileRefID (createFileRefID (path));
  797. addFileReference ("${SDKROOT}/" + path);
  798. frameworkIDs.add (addBuildFile (path, fileRefID, false, false));
  799. frameworkFileIDs.add (fileRefID);
  800. }
  801. void addGroup (const String& groupID, const String& groupName, const StringArray& childIDs) const
  802. {
  803. ValueTree* v = new ValueTree (groupID);
  804. v->setProperty ("isa", "PBXGroup", 0);
  805. v->setProperty ("children", "(" + indentList (childIDs, ",") + " )", 0);
  806. v->setProperty (Ids::name, groupName, 0);
  807. v->setProperty ("sourceTree", "<group>", 0);
  808. pbxGroups.add (v);
  809. }
  810. String addGroup (const Project::Item& item, StringArray& childIDs) const
  811. {
  812. const String groupName (item.getName());
  813. const String groupID (getIDForGroup (item));
  814. addGroup (groupID, groupName, childIDs);
  815. return groupID;
  816. }
  817. void addMainBuildProduct() const
  818. {
  819. jassert (xcodeFileType.isNotEmpty());
  820. jassert (xcodeBundleExtension.isEmpty() || xcodeBundleExtension.startsWithChar('.'));
  821. String productName (getConfiguration(0)->getTargetBinaryName().toString());
  822. if (xcodeFileType == "archive.ar")
  823. productName = getLibbedFilename (productName);
  824. else
  825. productName += xcodeBundleExtension;
  826. addBuildProduct (xcodeFileType, productName);
  827. }
  828. void addBuildProduct (const String& fileType, const String& binaryName) const
  829. {
  830. ValueTree* v = new ValueTree (createID ("__productFileID"));
  831. v->setProperty ("isa", "PBXFileReference", 0);
  832. v->setProperty ("explicitFileType", fileType, 0);
  833. v->setProperty ("includeInIndex", (int) 0, 0);
  834. v->setProperty ("path", sanitisePath (binaryName), 0);
  835. v->setProperty ("sourceTree", "BUILT_PRODUCTS_DIR", 0);
  836. pbxFileReferences.add (v);
  837. }
  838. void addTargetConfig (const String& configName, const StringArray& buildSettings) const
  839. {
  840. ValueTree* v = new ValueTree (createID ("targetconfigid_" + configName));
  841. v->setProperty ("isa", "XCBuildConfiguration", 0);
  842. v->setProperty ("buildSettings", "{" + indentList (buildSettings, ";") + " }", 0);
  843. v->setProperty (Ids::name, configName, 0);
  844. targetConfigs.add (v);
  845. }
  846. void addProjectConfig (const String& configName, const StringArray& buildSettings) const
  847. {
  848. ValueTree* v = new ValueTree (createID ("projectconfigid_" + configName));
  849. v->setProperty ("isa", "XCBuildConfiguration", 0);
  850. v->setProperty ("buildSettings", "{" + indentList (buildSettings, ";") + " }", 0);
  851. v->setProperty (Ids::name, configName, 0);
  852. projectConfigs.add (v);
  853. }
  854. void addConfigList (const OwnedArray <ValueTree>& configsToUse, const String& listID) const
  855. {
  856. StringArray configIDs;
  857. for (int i = 0; i < configsToUse.size(); ++i)
  858. configIDs.add (configsToUse[i]->getType().toString());
  859. ValueTree* v = new ValueTree (listID);
  860. v->setProperty ("isa", "XCConfigurationList", 0);
  861. v->setProperty ("buildConfigurations", "(" + indentList (configIDs, ",") + " )", 0);
  862. v->setProperty ("defaultConfigurationIsVisible", (int) 0, 0);
  863. if (configsToUse[0] != nullptr)
  864. v->setProperty ("defaultConfigurationName", configsToUse[0]->getProperty (Ids::name), 0);
  865. misc.add (v);
  866. }
  867. ValueTree* addBuildPhase (const String& phaseType, const StringArray& fileIds) const
  868. {
  869. String phaseId (createID (phaseType + "resbuildphase"));
  870. buildPhaseIDs.add (phaseId);
  871. ValueTree* v = new ValueTree (phaseId);
  872. v->setProperty ("isa", phaseType, 0);
  873. v->setProperty ("buildActionMask", "2147483647", 0);
  874. v->setProperty ("files", "(" + indentList (fileIds, ",") + " )", 0);
  875. v->setProperty ("runOnlyForDeploymentPostprocessing", (int) 0, 0);
  876. misc.add (v);
  877. return v;
  878. }
  879. void addTargetObject() const
  880. {
  881. ValueTree* const v = new ValueTree (createID ("__target"));
  882. v->setProperty ("isa", "PBXNativeTarget", 0);
  883. v->setProperty ("buildConfigurationList", createID ("__configList"), 0);
  884. v->setProperty ("buildPhases", "(" + indentList (buildPhaseIDs, ",") + " )", 0);
  885. v->setProperty ("buildRules", "( )", 0);
  886. v->setProperty ("dependencies", "( )", 0);
  887. v->setProperty (Ids::name, projectName, 0);
  888. v->setProperty ("productName", projectName, 0);
  889. v->setProperty ("productReference", createID ("__productFileID"), 0);
  890. if (xcodeProductInstallPath.isNotEmpty())
  891. v->setProperty ("productInstallPath", xcodeProductInstallPath, 0);
  892. jassert (xcodeProductType.isNotEmpty());
  893. v->setProperty ("productType", xcodeProductType, 0);
  894. misc.add (v);
  895. }
  896. void addProjectObject() const
  897. {
  898. ValueTree* const v = new ValueTree (createID ("__root"));
  899. v->setProperty ("isa", "PBXProject", 0);
  900. v->setProperty ("buildConfigurationList", createID ("__projList"), 0);
  901. v->setProperty ("compatibilityVersion", "Xcode 3.2", 0);
  902. v->setProperty ("hasScannedForEncodings", (int) 0, 0);
  903. v->setProperty ("mainGroup", createID ("__mainsourcegroup"), 0);
  904. v->setProperty ("projectDirPath", "\"\"", 0);
  905. v->setProperty ("projectRoot", "\"\"", 0);
  906. v->setProperty ("targets", "( " + createID ("__target") + " )", 0);
  907. misc.add (v);
  908. }
  909. void addShellScriptPhase() const
  910. {
  911. if (getPostBuildScript().isNotEmpty())
  912. {
  913. ValueTree* const v = addBuildPhase ("PBXShellScriptBuildPhase", StringArray());
  914. v->setProperty (Ids::name, "Post-build script", 0);
  915. v->setProperty ("shellPath", "/bin/sh", 0);
  916. v->setProperty ("shellScript", getPostBuildScript().replace ("\\", "\\\\")
  917. .replace ("\"", "\\\"")
  918. .replace ("\r\n", "\\n")
  919. .replace ("\n", "\\n"), 0);
  920. }
  921. }
  922. //==============================================================================
  923. static String indentList (const StringArray& list, const String& separator)
  924. {
  925. if (list.size() == 0)
  926. return " ";
  927. return "\n\t\t\t\t" + list.joinIntoString (separator + "\n\t\t\t\t")
  928. + (separator == ";" ? separator : String::empty);
  929. }
  930. String createID (String rootString) const
  931. {
  932. if (rootString.startsWith ("${"))
  933. rootString = rootString.fromFirstOccurrenceOf ("}/", false, false);
  934. rootString += project.getProjectUID();
  935. return MD5 (rootString.toUTF8()).toHexString().substring (0, 24).toUpperCase();
  936. }
  937. String createFileRefID (const RelativePath& path) const
  938. {
  939. return createFileRefID (path.toUnixStyle());
  940. }
  941. String createFileRefID (const String& path) const
  942. {
  943. return createID ("__fileref_" + path);
  944. }
  945. String getIDForGroup (const Project::Item& item) const
  946. {
  947. return createID (item.getID());
  948. }
  949. bool shouldFileBeCompiledByDefault (const RelativePath& file) const
  950. {
  951. return file.hasFileExtension (sourceFileExtensions);
  952. }
  953. };
  954. #endif // __JUCER_PROJECTEXPORT_XCODE_JUCEHEADER__