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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 return os.path.join(self.GetWrapperName(), 'Contents') | 295 return os.path.join(self.GetWrapperName(), 'Contents') |
296 | 296 |
297 def GetBundleResourceFolder(self): | 297 def GetBundleResourceFolder(self): |
298 """Returns the qualified path to the bundle's resource folder. E.g. | 298 """Returns the qualified path to the bundle's resource folder. E.g. |
299 Chromium.app/Contents/Resources. Only valid for bundles.""" | 299 Chromium.app/Contents/Resources. Only valid for bundles.""" |
300 assert self._IsBundle() | 300 assert self._IsBundle() |
301 if self.isIOS: | 301 if self.isIOS: |
302 return self.GetBundleContentsFolderPath() | 302 return self.GetBundleContentsFolderPath() |
303 return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') | 303 return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') |
304 | 304 |
| 305 def GetBundleExecutableFolderPath(self): |
| 306 """Returns the qualified path to the bundle's executables folder. E.g. |
| 307 Chromium.app/Contents/MacOS. Only valid for bundles.""" |
| 308 assert self._IsBundle() |
| 309 if self.spec['type'] in ('shared_library') or self.isIOS: |
| 310 return self.GetBundleContentsFolderPath() |
| 311 elif self.spec['type'] in ('executable', 'loadable_module'): |
| 312 return os.path.join(self.GetBundleContentsFolderPath(), 'MacOS') |
| 313 |
| 314 def GetBundleJavaFolderPath(self): |
| 315 """Returns the qualified path to the bundle's Java resource folder. |
| 316 E.g. Chromium.app/Contents/Resources/Java. Only valid for bundles.""" |
| 317 assert self._IsBundle() |
| 318 return os.path.join(self.GetBundleResourceFolder(), 'Java') |
| 319 |
| 320 def GetBundleFrameworksFolderPath(self): |
| 321 """Returns the qualified path to the bundle's frameworks folder. E.g, |
| 322 Chromium.app/Contents/Frameworks. Only valid for bundles.""" |
| 323 assert self._IsBundle() |
| 324 return os.path.join(self.GetBundleContentsFolderPath(), 'Frameworks') |
| 325 |
| 326 def GetBundleSharedFrameworksFolderPath(self): |
| 327 """Returns the qualified path to the bundle's frameworks folder. E.g, |
| 328 Chromium.app/Contents/SharedFrameworks. Only valid for bundles.""" |
| 329 assert self._IsBundle() |
| 330 return os.path.join(self.GetBundleContentsFolderPath(), |
| 331 'SharedFrameworks') |
| 332 |
| 333 def GetBundleSharedSupportFolderPath(self): |
| 334 """Returns the qualified path to the bundle's shared support folder. E.g, |
| 335 Chromium.app/Contents/SharedSupport. Only valid for bundles.""" |
| 336 assert self._IsBundle() |
| 337 if self.spec['type'] == 'shared_library': |
| 338 return self.GetBundleResourceFolder() |
| 339 else: |
| 340 return os.path.join(self.GetBundleContentsFolderPath(), |
| 341 'SharedSupport') |
| 342 |
| 343 def GetBundlePlugInsFolderPath(self): |
| 344 """Returns the qualified path to the bundle's plugins folder. E.g, |
| 345 Chromium.app/Contents/PlugIns. Only valid for bundles.""" |
| 346 assert self._IsBundle() |
| 347 return os.path.join(self.GetBundleContentsFolderPath(), 'PlugIns') |
| 348 |
| 349 def GetBundleXPCServicesFolderPath(self): |
| 350 """Returns the qualified path to the bundle's XPC services folder. E.g, |
| 351 Chromium.app/Contents/XPCServices. Only valid for bundles.""" |
| 352 assert self._IsBundle() |
| 353 return os.path.join(self.GetBundleContentsFolderPath(), 'XPCServices') |
| 354 |
305 def GetBundlePlistPath(self): | 355 def GetBundlePlistPath(self): |
306 """Returns the qualified path to the bundle's plist file. E.g. | 356 """Returns the qualified path to the bundle's plist file. E.g. |
307 Chromium.app/Contents/Info.plist. Only valid for bundles.""" | 357 Chromium.app/Contents/Info.plist. Only valid for bundles.""" |
308 assert self._IsBundle() | 358 assert self._IsBundle() |
309 if self.spec['type'] in ('executable', 'loadable_module'): | 359 if self.spec['type'] in ('executable', 'loadable_module'): |
310 return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist') | 360 return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist') |
311 else: | 361 else: |
312 return os.path.join(self.GetBundleContentsFolderPath(), | 362 return os.path.join(self.GetBundleContentsFolderPath(), |
313 'Resources', 'Info.plist') | 363 'Resources', 'Info.plist') |
314 | 364 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 'executable': 'mh_execute', | 399 'executable': 'mh_execute', |
350 'static_library': 'staticlib', | 400 'static_library': 'staticlib', |
351 'shared_library': 'mh_dylib', | 401 'shared_library': 'mh_dylib', |
352 'loadable_module': 'mh_bundle', | 402 'loadable_module': 'mh_bundle', |
353 }[self.spec['type']] | 403 }[self.spec['type']] |
354 | 404 |
355 def _GetBundleBinaryPath(self): | 405 def _GetBundleBinaryPath(self): |
356 """Returns the name of the bundle binary of by this target. | 406 """Returns the name of the bundle binary of by this target. |
357 E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles.""" | 407 E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles.""" |
358 assert self._IsBundle() | 408 assert self._IsBundle() |
359 if self.spec['type'] in ('shared_library') or self.isIOS: | 409 return os.path.join(self.GetBundleExecutableFolderPath(), \ |
360 path = self.GetBundleContentsFolderPath() | 410 self.GetExecutableName()) |
361 elif self.spec['type'] in ('executable', 'loadable_module'): | |
362 path = os.path.join(self.GetBundleContentsFolderPath(), 'MacOS') | |
363 return os.path.join(path, self.GetExecutableName()) | |
364 | 411 |
365 def _GetStandaloneExecutableSuffix(self): | 412 def _GetStandaloneExecutableSuffix(self): |
366 if 'product_extension' in self.spec: | 413 if 'product_extension' in self.spec: |
367 return '.' + self.spec['product_extension'] | 414 return '.' + self.spec['product_extension'] |
368 return { | 415 return { |
369 'executable': '', | 416 'executable': '', |
370 'static_library': '.a', | 417 'static_library': '.a', |
371 'shared_library': '.dylib', | 418 'shared_library': '.dylib', |
372 'loadable_module': '.so', | 419 'loadable_module': '.so', |
373 }[self.spec['type']] | 420 }[self.spec['type']] |
(...skipping 30 matching lines...) Expand all Loading... |
404 | 451 |
405 def GetExecutableName(self): | 452 def GetExecutableName(self): |
406 """Returns the executable name of the bundle represented by this target. | 453 """Returns the executable name of the bundle represented by this target. |
407 E.g. Chromium.""" | 454 E.g. Chromium.""" |
408 if self._IsBundle(): | 455 if self._IsBundle(): |
409 return self.spec.get('product_name', self.spec['target_name']) | 456 return self.spec.get('product_name', self.spec['target_name']) |
410 else: | 457 else: |
411 return self._GetStandaloneBinaryPath() | 458 return self._GetStandaloneBinaryPath() |
412 | 459 |
413 def GetExecutablePath(self): | 460 def GetExecutablePath(self): |
414 """Returns the directory name of the bundle represented by this target. E.g. | 461 """Returns the qualified path to the primary executable of the bundle |
415 Chromium.app/Contents/MacOS/Chromium.""" | 462 represented by this target. E.g. Chromium.app/Contents/MacOS/Chromium.""" |
416 if self._IsBundle(): | 463 if self._IsBundle(): |
417 return self._GetBundleBinaryPath() | 464 return self._GetBundleBinaryPath() |
418 else: | 465 else: |
419 return self._GetStandaloneBinaryPath() | 466 return self._GetStandaloneBinaryPath() |
420 | 467 |
421 def GetActiveArchs(self, configname): | 468 def GetActiveArchs(self, configname): |
422 """Returns the architectures this target should be built for.""" | 469 """Returns the architectures this target should be built for.""" |
423 config_settings = self.xcode_settings[configname] | 470 config_settings = self.xcode_settings[configname] |
424 xcode_archs_default = GetXcodeArchsDefault() | 471 xcode_archs_default = GetXcodeArchsDefault() |
425 return xcode_archs_default.ActiveArchs( | 472 return xcode_archs_default.ActiveArchs( |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 | 1520 |
1474 Args: | 1521 Args: |
1475 xcode_settings: An XcodeSettings object. If this is None, this function | 1522 xcode_settings: An XcodeSettings object. If this is None, this function |
1476 returns an empty dict. | 1523 returns an empty dict. |
1477 built_products_dir: Absolute path to the built products dir. | 1524 built_products_dir: Absolute path to the built products dir. |
1478 srcroot: Absolute path to the source root. | 1525 srcroot: Absolute path to the source root. |
1479 configuration: The build configuration name. | 1526 configuration: The build configuration name. |
1480 additional_settings: An optional dict with more values to add to the | 1527 additional_settings: An optional dict with more values to add to the |
1481 result. | 1528 result. |
1482 """ | 1529 """ |
| 1530 |
1483 if not xcode_settings: return {} | 1531 if not xcode_settings: return {} |
1484 | 1532 |
1485 # This function is considered a friend of XcodeSettings, so let it reach into | 1533 # This function is considered a friend of XcodeSettings, so let it reach into |
1486 # its implementation details. | 1534 # its implementation details. |
1487 spec = xcode_settings.spec | 1535 spec = xcode_settings.spec |
1488 | 1536 |
1489 # These are filled in on a as-needed basis. | 1537 # These are filled in on an as-needed basis. |
1490 env = { | 1538 env = { |
1491 'BUILT_FRAMEWORKS_DIR' : built_products_dir, | 1539 'BUILT_FRAMEWORKS_DIR' : built_products_dir, |
1492 'BUILT_PRODUCTS_DIR' : built_products_dir, | 1540 'BUILT_PRODUCTS_DIR' : built_products_dir, |
1493 'CONFIGURATION' : configuration, | 1541 'CONFIGURATION' : configuration, |
1494 'PRODUCT_NAME' : xcode_settings.GetProductName(), | 1542 'PRODUCT_NAME' : xcode_settings.GetProductName(), |
1495 # See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifica
tions/MacOSX\ Product\ Types.xcspec for FULL_PRODUCT_NAME | 1543 # See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifica
tions/MacOSX\ Product\ Types.xcspec for FULL_PRODUCT_NAME |
1496 'SRCROOT' : srcroot, | 1544 'SRCROOT' : srcroot, |
1497 'SOURCE_ROOT': '${SRCROOT}', | 1545 'SOURCE_ROOT': '${SRCROOT}', |
1498 # This is not true for static libraries, but currently the env is only | 1546 # This is not true for static libraries, but currently the env is only |
1499 # written for bundles: | 1547 # written for bundles: |
1500 'TARGET_BUILD_DIR' : built_products_dir, | 1548 'TARGET_BUILD_DIR' : built_products_dir, |
1501 'TEMP_DIR' : '${TMPDIR}', | 1549 'TEMP_DIR' : '${TMPDIR}', |
1502 'XCODE_VERSION_ACTUAL' : XcodeVersion()[0], | 1550 'XCODE_VERSION_ACTUAL' : XcodeVersion()[0], |
1503 } | 1551 } |
1504 if xcode_settings.GetPerConfigSetting('SDKROOT', configuration): | 1552 if xcode_settings.GetPerConfigSetting('SDKROOT', configuration): |
1505 env['SDKROOT'] = xcode_settings._SdkPath(configuration) | 1553 env['SDKROOT'] = xcode_settings._SdkPath(configuration) |
1506 else: | 1554 else: |
1507 env['SDKROOT'] = '' | 1555 env['SDKROOT'] = '' |
1508 | 1556 |
1509 if spec['type'] in ( | 1557 if spec['type'] in ( |
1510 'executable', 'static_library', 'shared_library', 'loadable_module'): | 1558 'executable', 'static_library', 'shared_library', 'loadable_module'): |
1511 env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName() | 1559 env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName() |
1512 env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath() | 1560 env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath() |
1513 env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName() | 1561 env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName() |
1514 mach_o_type = xcode_settings.GetMachOType() | 1562 mach_o_type = xcode_settings.GetMachOType() |
1515 if mach_o_type: | 1563 if mach_o_type: |
1516 env['MACH_O_TYPE'] = mach_o_type | 1564 env['MACH_O_TYPE'] = mach_o_type |
1517 env['PRODUCT_TYPE'] = xcode_settings.GetProductType() | 1565 env['PRODUCT_TYPE'] = xcode_settings.GetProductType() |
1518 if xcode_settings._IsBundle(): | 1566 if xcode_settings._IsBundle(): |
| 1567 # xcodeproj_file.py sets the same Xcode subfolder value for this as for |
| 1568 # FRAMEWORKS_FOLDER_PATH so Xcode builds will actually use FFP's value. |
| 1569 env['BUILT_FRAMEWORKS_DIR'] = \ |
| 1570 os.path.join(built_products_dir + os.sep \ |
| 1571 + xcode_settings.GetBundleFrameworksFolderPath()) |
1519 env['CONTENTS_FOLDER_PATH'] = \ | 1572 env['CONTENTS_FOLDER_PATH'] = \ |
1520 xcode_settings.GetBundleContentsFolderPath() | 1573 xcode_settings.GetBundleContentsFolderPath() |
| 1574 env['EXECUTABLE_FOLDER_PATH'] = \ |
| 1575 xcode_settings.GetBundleExecutableFolderPath() |
1521 env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \ | 1576 env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \ |
1522 xcode_settings.GetBundleResourceFolder() | 1577 xcode_settings.GetBundleResourceFolder() |
| 1578 env['JAVA_FOLDER_PATH'] = xcode_settings.GetBundleJavaFolderPath() |
| 1579 env['FRAMEWORKS_FOLDER_PATH'] = \ |
| 1580 xcode_settings.GetBundleFrameworksFolderPath() |
| 1581 env['SHARED_FRAMEWORKS_FOLDER_PATH'] = \ |
| 1582 xcode_settings.GetBundleSharedFrameworksFolderPath() |
| 1583 env['SHARED_SUPPORT_FOLDER_PATH'] = \ |
| 1584 xcode_settings.GetBundleSharedSupportFolderPath() |
| 1585 env['PLUGINS_FOLDER_PATH'] = xcode_settings.GetBundlePlugInsFolderPath() |
| 1586 env['XPCSERVICES_FOLDER_PATH'] = \ |
| 1587 xcode_settings.GetBundleXPCServicesFolderPath() |
1523 env['INFOPLIST_PATH'] = xcode_settings.GetBundlePlistPath() | 1588 env['INFOPLIST_PATH'] = xcode_settings.GetBundlePlistPath() |
1524 env['WRAPPER_NAME'] = xcode_settings.GetWrapperName() | 1589 env['WRAPPER_NAME'] = xcode_settings.GetWrapperName() |
1525 | 1590 |
1526 install_name = xcode_settings.GetInstallName() | 1591 install_name = xcode_settings.GetInstallName() |
1527 if install_name: | 1592 if install_name: |
1528 env['LD_DYLIB_INSTALL_NAME'] = install_name | 1593 env['LD_DYLIB_INSTALL_NAME'] = install_name |
1529 install_name_base = xcode_settings.GetInstallNameBase() | 1594 install_name_base = xcode_settings.GetInstallNameBase() |
1530 if install_name_base: | 1595 if install_name_base: |
1531 env['DYLIB_INSTALL_NAME_BASE'] = install_name_base | 1596 env['DYLIB_INSTALL_NAME_BASE'] = install_name_base |
1532 if XcodeVersion() >= '0500' and not env.get('SDKROOT'): | 1597 if XcodeVersion() >= '0500' and not env.get('SDKROOT'): |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 if toolset == 'target': | 1720 if toolset == 'target': |
1656 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' | 1721 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' |
1657 return targets | 1722 return targets |
1658 | 1723 |
1659 def CloneConfigurationForDeviceAndEmulator(target_dicts): | 1724 def CloneConfigurationForDeviceAndEmulator(target_dicts): |
1660 """If |target_dicts| contains any iOS targets, automatically create -iphoneos | 1725 """If |target_dicts| contains any iOS targets, automatically create -iphoneos |
1661 targets for iOS device builds.""" | 1726 targets for iOS device builds.""" |
1662 if _HasIOSTarget(target_dicts): | 1727 if _HasIOSTarget(target_dicts): |
1663 return _AddIOSDeviceConfigurations(target_dicts) | 1728 return _AddIOSDeviceConfigurations(target_dicts) |
1664 return target_dicts | 1729 return target_dicts |
OLD | NEW |