Пример #1
0
    def install_xcode(self, xcode_build_version, mac_toolchain_cmd,
                      xcode_app_path):
        """Installs the requested Xcode build version.

    Args:
      xcode_build_version: (string) Xcode build version to install.
      mac_toolchain_cmd: (string) Path to mac_toolchain command to install Xcode
      See https://chromium.googlesource.com/infra/infra/+/master/go/src/infra/cmd/mac_toolchain/
      xcode_app_path: (string) Path to install the contents of Xcode.app.

    Returns:
      True if installation was successful. False otherwise.
    """
        try:
            if not mac_toolchain_cmd:
                raise test_runner.MacToolchainNotFoundError(mac_toolchain_cmd)
            # Guard against incorrect install paths. On swarming, this path
            # should be a requested named cache, and it must exist.
            if not os.path.exists(xcode_app_path):
                raise test_runner.XcodePathNotFoundError(xcode_app_path)

            xcode.install(mac_toolchain_cmd, xcode_build_version,
                          xcode_app_path)
            xcode.select(xcode_app_path)
        except subprocess.CalledProcessError as e:
            # Flush buffers to ensure correct output ordering.
            sys.stdout.flush()
            sys.stderr.write('Xcode build version %s failed to install: %s\n' %
                             (xcode_build_version, e))
            sys.stderr.flush()
            return False

        return True
Пример #2
0
    def install_xcode(self):
        """Installs the requested Xcode build version.

    Returns:
      (bool, bool)
        First bool: True if installation was successful. False otherwise.
        Second bool: True if Xcode is legacy package. False if it's new.
    """
        try:
            if not self.args.mac_toolchain_cmd:
                raise test_runner.MacToolchainNotFoundError(
                    self.args.mac_toolchain_cmd)
            # Guard against incorrect install paths. On swarming, this path
            # should be a requested named cache, and it must exist.
            if not os.path.exists(self.args.xcode_path):
                raise test_runner.XcodePathNotFoundError(self.args.xcode_path)

            runtime_cache_folder = None
            # Runner script only utilizes runtime cache when it's a simulator task.
            if self.args.version:
                runtime_cache_folder = xcode.construct_runtime_cache_folder(
                    self.args.runtime_cache_prefix, self.args.version)
                if not os.path.exists(runtime_cache_folder):
                    # Depending on infra project, runtime named cache might not be
                    # deployed. Create the dir if it doesn't exist since xcode_util
                    # assumes it exists.
                    # TODO(crbug.com/1191260): Raise error instead of creating dirs after
                    # runtime named cache is deployed everywhere.
                    os.makedirs(runtime_cache_folder)
            # xcode.install() installs the Xcode & iOS runtime, and returns a bool
            # indicating if the Xcode version in CIPD is a legacy Xcode package (which
            # includes iOS runtimes).
            is_legacy_xcode = xcode.install(
                self.args.mac_toolchain_cmd,
                self.args.xcode_build_version,
                self.args.xcode_path,
                runtime_cache_folder=runtime_cache_folder,
                ios_version=self.args.version)
            xcode.select(self.args.xcode_path)
        except subprocess.CalledProcessError as e:
            # Flush buffers to ensure correct output ordering.
            sys.stdout.flush()
            sys.stderr.write('Xcode build version %s failed to install: %s\n' %
                             (self.args.xcode_build_version, e))
            sys.stderr.flush()
            return (False, False)
        else:
            return (True, is_legacy_xcode)