OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 This module contains classes that help to emulate xcodebuild behavior on top of | 6 This module contains classes that help to emulate xcodebuild behavior on top of |
7 other build systems, such as make and ninja. | 7 other build systems, such as make and ninja. |
8 """ | 8 """ |
9 | 9 |
10 import copy | 10 import copy |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 return os.path.join(self.GetWrapperName(), 'Contents') | 305 return os.path.join(self.GetWrapperName(), 'Contents') |
306 | 306 |
307 def GetBundleResourceFolder(self): | 307 def GetBundleResourceFolder(self): |
308 """Returns the qualified path to the bundle's resource folder. E.g. | 308 """Returns the qualified path to the bundle's resource folder. E.g. |
309 Chromium.app/Contents/Resources. Only valid for bundles.""" | 309 Chromium.app/Contents/Resources. Only valid for bundles.""" |
310 assert self._IsBundle() | 310 assert self._IsBundle() |
311 if self.isIOS: | 311 if self.isIOS: |
312 return self.GetBundleContentsFolderPath() | 312 return self.GetBundleContentsFolderPath() |
313 return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') | 313 return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') |
314 | 314 |
| 315 def GetBundleExecutableFolderPath(self): |
| 316 """Returns the qualified path to the bundle's executables folder. E.g. |
| 317 Chromium.app/Contents/MacOS. Only valid for bundles.""" |
| 318 assert self._IsBundle() |
| 319 if self.spec['type'] in ('shared_library') or self.isIOS: |
| 320 return self.GetBundleContentsFolderPath() |
| 321 elif self.spec['type'] in ('executable', 'loadable_module'): |
| 322 return os.path.join(self.GetBundleContentsFolderPath(), 'MacOS') |
| 323 |
| 324 def GetBundleJavaFolderPath(self): |
| 325 """Returns the qualified path to the bundle's Java resource folder. |
| 326 E.g. Chromium.app/Contents/Resources/Java. Only valid for bundles.""" |
| 327 assert self._IsBundle() |
| 328 return os.path.join(self.GetBundleResourceFolder(), 'Java') |
| 329 |
| 330 def GetBundleFrameworksFolderPath(self): |
| 331 """Returns the qualified path to the bundle's frameworks folder. E.g, |
| 332 Chromium.app/Contents/Frameworks. Only valid for bundles.""" |
| 333 assert self._IsBundle() |
| 334 return os.path.join(self.GetBundleContentsFolderPath(), 'Frameworks') |
| 335 |
| 336 def GetBundleSharedFrameworksFolderPath(self): |
| 337 """Returns the qualified path to the bundle's frameworks folder. E.g, |
| 338 Chromium.app/Contents/SharedFrameworks. Only valid for bundles.""" |
| 339 assert self._IsBundle() |
| 340 return os.path.join(self.GetBundleContentsFolderPath(), |
| 341 'SharedFrameworks') |
| 342 |
| 343 def GetBundleSharedSupportFolderPath(self): |
| 344 """Returns the qualified path to the bundle's shared support folder. E.g, |
| 345 Chromium.app/Contents/SharedSupport. Only valid for bundles.""" |
| 346 assert self._IsBundle() |
| 347 if self.spec['type'] == 'shared_library': |
| 348 return self.GetBundleResourceFolder() |
| 349 else: |
| 350 return os.path.join(self.GetBundleContentsFolderPath(), |
| 351 'SharedSupport') |
| 352 |
| 353 def GetBundlePlugInsFolderPath(self): |
| 354 """Returns the qualified path to the bundle's plugins folder. E.g, |
| 355 Chromium.app/Contents/PlugIns. Only valid for bundles.""" |
| 356 assert self._IsBundle() |
| 357 return os.path.join(self.GetBundleContentsFolderPath(), 'PlugIns') |
| 358 |
| 359 def GetBundleXPCServicesFolderPath(self): |
| 360 """Returns the qualified path to the bundle's XPC services folder. E.g, |
| 361 Chromium.app/Contents/XPCServices. Only valid for bundles.""" |
| 362 assert self._IsBundle() |
| 363 return os.path.join(self.GetBundleContentsFolderPath(), 'XPCServices') |
| 364 |
315 def GetBundlePlistPath(self): | 365 def GetBundlePlistPath(self): |
316 """Returns the qualified path to the bundle's plist file. E.g. | 366 """Returns the qualified path to the bundle's plist file. E.g. |
317 Chromium.app/Contents/Info.plist. Only valid for bundles.""" | 367 Chromium.app/Contents/Info.plist. Only valid for bundles.""" |
318 assert self._IsBundle() | 368 assert self._IsBundle() |
319 if self.spec['type'] in ('executable', 'loadable_module') or \ | 369 if self.spec['type'] in ('executable', 'loadable_module') or \ |
320 self.IsIosFramework(): | 370 self.IsIosFramework(): |
321 return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist') | 371 return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist') |
322 else: | 372 else: |
323 return os.path.join(self.GetBundleContentsFolderPath(), | 373 return os.path.join(self.GetBundleContentsFolderPath(), |
324 'Resources', 'Info.plist') | 374 'Resources', 'Info.plist') |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 'executable': 'mh_execute', | 414 'executable': 'mh_execute', |
365 'static_library': 'staticlib', | 415 'static_library': 'staticlib', |
366 'shared_library': 'mh_dylib', | 416 'shared_library': 'mh_dylib', |
367 'loadable_module': 'mh_bundle', | 417 'loadable_module': 'mh_bundle', |
368 }[self.spec['type']] | 418 }[self.spec['type']] |
369 | 419 |
370 def _GetBundleBinaryPath(self): | 420 def _GetBundleBinaryPath(self): |
371 """Returns the name of the bundle binary of by this target. | 421 """Returns the name of the bundle binary of by this target. |
372 E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles.""" | 422 E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles.""" |
373 assert self._IsBundle() | 423 assert self._IsBundle() |
374 if self.spec['type'] in ('shared_library') or self.isIOS: | 424 return os.path.join(self.GetBundleExecutableFolderPath(), \ |
375 path = self.GetBundleContentsFolderPath() | 425 self.GetExecutableName()) |
376 elif self.spec['type'] in ('executable', 'loadable_module'): | |
377 path = os.path.join(self.GetBundleContentsFolderPath(), 'MacOS') | |
378 return os.path.join(path, self.GetExecutableName()) | |
379 | 426 |
380 def _GetStandaloneExecutableSuffix(self): | 427 def _GetStandaloneExecutableSuffix(self): |
381 if 'product_extension' in self.spec: | 428 if 'product_extension' in self.spec: |
382 return '.' + self.spec['product_extension'] | 429 return '.' + self.spec['product_extension'] |
383 return { | 430 return { |
384 'executable': '', | 431 'executable': '', |
385 'static_library': '.a', | 432 'static_library': '.a', |
386 'shared_library': '.dylib', | 433 'shared_library': '.dylib', |
387 'loadable_module': '.so', | 434 'loadable_module': '.so', |
388 }[self.spec['type']] | 435 }[self.spec['type']] |
(...skipping 30 matching lines...) Expand all Loading... |
419 | 466 |
420 def GetExecutableName(self): | 467 def GetExecutableName(self): |
421 """Returns the executable name of the bundle represented by this target. | 468 """Returns the executable name of the bundle represented by this target. |
422 E.g. Chromium.""" | 469 E.g. Chromium.""" |
423 if self._IsBundle(): | 470 if self._IsBundle(): |
424 return self.spec.get('product_name', self.spec['target_name']) | 471 return self.spec.get('product_name', self.spec['target_name']) |
425 else: | 472 else: |
426 return self._GetStandaloneBinaryPath() | 473 return self._GetStandaloneBinaryPath() |
427 | 474 |
428 def GetExecutablePath(self): | 475 def GetExecutablePath(self): |
429 """Returns the directory name of the bundle represented by this target. E.g. | 476 """Returns the qualified path to the primary executable of the bundle |
430 Chromium.app/Contents/MacOS/Chromium.""" | 477 represented by this target. E.g. Chromium.app/Contents/MacOS/Chromium.""" |
431 if self._IsBundle(): | 478 if self._IsBundle(): |
432 return self._GetBundleBinaryPath() | 479 return self._GetBundleBinaryPath() |
433 else: | 480 else: |
434 return self._GetStandaloneBinaryPath() | 481 return self._GetStandaloneBinaryPath() |
435 | 482 |
436 def GetActiveArchs(self, configname): | 483 def GetActiveArchs(self, configname): |
437 """Returns the architectures this target should be built for.""" | 484 """Returns the architectures this target should be built for.""" |
438 config_settings = self.xcode_settings[configname] | 485 config_settings = self.xcode_settings[configname] |
439 xcode_archs_default = GetXcodeArchsDefault() | 486 xcode_archs_default = GetXcodeArchsDefault() |
440 return xcode_archs_default.ActiveArchs( | 487 return xcode_archs_default.ActiveArchs( |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 | 1581 |
1535 Args: | 1582 Args: |
1536 xcode_settings: An XcodeSettings object. If this is None, this function | 1583 xcode_settings: An XcodeSettings object. If this is None, this function |
1537 returns an empty dict. | 1584 returns an empty dict. |
1538 built_products_dir: Absolute path to the built products dir. | 1585 built_products_dir: Absolute path to the built products dir. |
1539 srcroot: Absolute path to the source root. | 1586 srcroot: Absolute path to the source root. |
1540 configuration: The build configuration name. | 1587 configuration: The build configuration name. |
1541 additional_settings: An optional dict with more values to add to the | 1588 additional_settings: An optional dict with more values to add to the |
1542 result. | 1589 result. |
1543 """ | 1590 """ |
| 1591 |
1544 if not xcode_settings: return {} | 1592 if not xcode_settings: return {} |
1545 | 1593 |
1546 # This function is considered a friend of XcodeSettings, so let it reach into | 1594 # This function is considered a friend of XcodeSettings, so let it reach into |
1547 # its implementation details. | 1595 # its implementation details. |
1548 spec = xcode_settings.spec | 1596 spec = xcode_settings.spec |
1549 | 1597 |
1550 # These are filled in on a as-needed basis. | 1598 # These are filled in on an as-needed basis. |
1551 env = { | 1599 env = { |
1552 'BUILT_FRAMEWORKS_DIR' : built_products_dir, | 1600 'BUILT_FRAMEWORKS_DIR' : built_products_dir, |
1553 'BUILT_PRODUCTS_DIR' : built_products_dir, | 1601 'BUILT_PRODUCTS_DIR' : built_products_dir, |
1554 'CONFIGURATION' : configuration, | 1602 'CONFIGURATION' : configuration, |
1555 'PRODUCT_NAME' : xcode_settings.GetProductName(), | 1603 'PRODUCT_NAME' : xcode_settings.GetProductName(), |
1556 # See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifica
tions/MacOSX\ Product\ Types.xcspec for FULL_PRODUCT_NAME | 1604 # See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifica
tions/MacOSX\ Product\ Types.xcspec for FULL_PRODUCT_NAME |
1557 'SRCROOT' : srcroot, | 1605 'SRCROOT' : srcroot, |
1558 'SOURCE_ROOT': '${SRCROOT}', | 1606 'SOURCE_ROOT': '${SRCROOT}', |
1559 # This is not true for static libraries, but currently the env is only | 1607 # This is not true for static libraries, but currently the env is only |
1560 # written for bundles: | 1608 # written for bundles: |
(...skipping 12 matching lines...) Expand all Loading... |
1573 if spec['type'] in ( | 1621 if spec['type'] in ( |
1574 'executable', 'static_library', 'shared_library', 'loadable_module'): | 1622 'executable', 'static_library', 'shared_library', 'loadable_module'): |
1575 env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName() | 1623 env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName() |
1576 env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath() | 1624 env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath() |
1577 env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName() | 1625 env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName() |
1578 mach_o_type = xcode_settings.GetMachOType() | 1626 mach_o_type = xcode_settings.GetMachOType() |
1579 if mach_o_type: | 1627 if mach_o_type: |
1580 env['MACH_O_TYPE'] = mach_o_type | 1628 env['MACH_O_TYPE'] = mach_o_type |
1581 env['PRODUCT_TYPE'] = xcode_settings.GetProductType() | 1629 env['PRODUCT_TYPE'] = xcode_settings.GetProductType() |
1582 if xcode_settings._IsBundle(): | 1630 if xcode_settings._IsBundle(): |
| 1631 # xcodeproj_file.py sets the same Xcode subfolder value for this as for |
| 1632 # FRAMEWORKS_FOLDER_PATH so Xcode builds will actually use FFP's value. |
| 1633 env['BUILT_FRAMEWORKS_DIR'] = \ |
| 1634 os.path.join(built_products_dir + os.sep \ |
| 1635 + xcode_settings.GetBundleFrameworksFolderPath()) |
1583 env['CONTENTS_FOLDER_PATH'] = \ | 1636 env['CONTENTS_FOLDER_PATH'] = \ |
1584 xcode_settings.GetBundleContentsFolderPath() | 1637 xcode_settings.GetBundleContentsFolderPath() |
| 1638 env['EXECUTABLE_FOLDER_PATH'] = \ |
| 1639 xcode_settings.GetBundleExecutableFolderPath() |
1585 env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \ | 1640 env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \ |
1586 xcode_settings.GetBundleResourceFolder() | 1641 xcode_settings.GetBundleResourceFolder() |
| 1642 env['JAVA_FOLDER_PATH'] = xcode_settings.GetBundleJavaFolderPath() |
| 1643 env['FRAMEWORKS_FOLDER_PATH'] = \ |
| 1644 xcode_settings.GetBundleFrameworksFolderPath() |
| 1645 env['SHARED_FRAMEWORKS_FOLDER_PATH'] = \ |
| 1646 xcode_settings.GetBundleSharedFrameworksFolderPath() |
| 1647 env['SHARED_SUPPORT_FOLDER_PATH'] = \ |
| 1648 xcode_settings.GetBundleSharedSupportFolderPath() |
| 1649 env['PLUGINS_FOLDER_PATH'] = xcode_settings.GetBundlePlugInsFolderPath() |
| 1650 env['XPCSERVICES_FOLDER_PATH'] = \ |
| 1651 xcode_settings.GetBundleXPCServicesFolderPath() |
1587 env['INFOPLIST_PATH'] = xcode_settings.GetBundlePlistPath() | 1652 env['INFOPLIST_PATH'] = xcode_settings.GetBundlePlistPath() |
1588 env['WRAPPER_NAME'] = xcode_settings.GetWrapperName() | 1653 env['WRAPPER_NAME'] = xcode_settings.GetWrapperName() |
1589 | 1654 |
1590 install_name = xcode_settings.GetInstallName() | 1655 install_name = xcode_settings.GetInstallName() |
1591 if install_name: | 1656 if install_name: |
1592 env['LD_DYLIB_INSTALL_NAME'] = install_name | 1657 env['LD_DYLIB_INSTALL_NAME'] = install_name |
1593 install_name_base = xcode_settings.GetInstallNameBase() | 1658 install_name_base = xcode_settings.GetInstallNameBase() |
1594 if install_name_base: | 1659 if install_name_base: |
1595 env['DYLIB_INSTALL_NAME_BASE'] = install_name_base | 1660 env['DYLIB_INSTALL_NAME_BASE'] = install_name_base |
1596 if XcodeVersion() >= '0500' and not env.get('SDKROOT'): | 1661 if XcodeVersion() >= '0500' and not env.get('SDKROOT'): |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 simulator_config_dict['xcode_settings']['SDKROOT'] = 'iphonesimulator' | 1785 simulator_config_dict['xcode_settings']['SDKROOT'] = 'iphonesimulator' |
1721 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' | 1786 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' |
1722 return targets | 1787 return targets |
1723 | 1788 |
1724 def CloneConfigurationForDeviceAndEmulator(target_dicts): | 1789 def CloneConfigurationForDeviceAndEmulator(target_dicts): |
1725 """If |target_dicts| contains any iOS targets, automatically create -iphoneos | 1790 """If |target_dicts| contains any iOS targets, automatically create -iphoneos |
1726 targets for iOS device builds.""" | 1791 targets for iOS device builds.""" |
1727 if _HasIOSTarget(target_dicts): | 1792 if _HasIOSTarget(target_dicts): |
1728 return _AddIOSDeviceConfigurations(target_dicts) | 1793 return _AddIOSDeviceConfigurations(target_dicts) |
1729 return target_dicts | 1794 return target_dicts |
OLD | NEW |