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.

1189 lines
48KB

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