Example #1
0
def _set_up_git_hooks():
  # These git hooks do not make sense for the open source repo because they:
  # 1) lint the source, but that was already done when committed internally,
  #    and we will run 'ninja all' as a test step before committing to open
  #    source.
  # 2) add fields to the commit message for the internal dev workflow.
  if open_source.is_open_source_repo():
    return
  script_dir = os.path.dirname(__file__)
  hooks = {
      'pre-push': os.path.join(script_dir, 'git_pre_push.py'),
      'prepare-commit-msg': os.path.join(script_dir, 'git_prepare_commit.py'),
      'commit-msg': 'third_party/gerrit/commit-msg',
  }
  obsolete_hooks = ['pre-commit']  # Replaced by pre-push hook.

  git_hooks_dir = os.path.join(build_common.get_arc_root(), '.git', 'hooks')
  for git_hook, source_path in hooks.iteritems():
    symlink_path = os.path.join(git_hooks_dir, git_hook)
    file_util.create_link(symlink_path, source_path, overwrite=True)

  for git_hook in obsolete_hooks:
    symlink_path = os.path.join(git_hooks_dir, git_hook)
    if os.path.lexists(symlink_path):
      os.unlink(symlink_path)
Example #2
0
def _set_up_git_hooks():
    # These git hooks do not make sense for the open source repo because they:
    # 1) lint the source, but that was already done when committed internally,
    #    and we will run 'ninja all' as a test step before committing to open
    #    source.
    # 2) add fields to the commit message for the internal dev workflow.
    if open_source.is_open_source_repo():
        return
    script_dir = os.path.dirname(__file__)
    hooks = {
        'pre-push': os.path.join(script_dir, 'git_pre_push.py'),
        'prepare-commit-msg': os.path.join(script_dir,
                                           'git_prepare_commit.py'),
        'commit-msg': 'third_party/gerrit/commit-msg',
    }
    obsolete_hooks = ['pre-commit']  # Replaced by pre-push hook.

    git_hooks_dir = os.path.join(build_common.get_arc_root(), '.git', 'hooks')
    for git_hook, source_path in hooks.iteritems():
        symlink_path = os.path.join(git_hooks_dir, git_hook)
        file_util.create_link(symlink_path, source_path, overwrite=True)

    for git_hook in obsolete_hooks:
        symlink_path = os.path.join(git_hooks_dir, git_hook)
        if os.path.lexists(symlink_path):
            os.unlink(symlink_path)
Example #3
0
def _set_up_internal_repo():
  if OPTIONS.internal_apks_source_is_internal():
    # Checkout internal/ repository if needed, and sync internal/third_party/*
    # to internal/build/DEPS.*.  The files needs to be re-staged and is done
    # in staging.create_staging.
    subprocess.check_call('src/build/sync_arc_int.py')

  # Create a symlink to the integration_test definition directory, either in the
  # internal repository checkout or in the downloaded archive.
  # It is used to determine the definitions loaded in run_integration_tests.py
  # without relying on OPTIONS. Otherwise, run_integration_tests_test may fail
  # due to the mismatch between the expectations and the actual test apk since
  # it always runs under the default OPTIONS.
  if OPTIONS.internal_apks_source_is_internal():
    test_dir = 'internal/integration_tests'
  else:
    test_dir = 'out/internal-apks/integration_tests'

  symlink_location = 'out/internal-apks-integration-tests'
  if not os.path.islink(symlink_location) and os.path.isdir(symlink_location):
    # TODO(crbug.com/517306): This is a short-term fix for making bots green.
    # Remove once we implement a more proper solution (like, isolating the
    # test bundle extraction directory from the checkout, or stop running
    # ./configure on test-only builders.)
    #
    # 'Test only' bots extracts a directory structure from test-bundle zip, so
    # in that case we don't need to create a symlink.
    print 'WARNING: A directory exists at %s.' % symlink_location
    print 'WARNING: If not on test-only bot, gms test expectation may be stale.'
  else:
    # Otherwise, (re)create the link.
    file_util.create_link(symlink_location, test_dir, overwrite=True)
Example #4
0
def _set_up_internal_repo():
    if OPTIONS.internal_apks_source_is_internal():
        # Checkout internal/ repository if needed, and sync internal/third_party/*
        # to internal/build/DEPS.*.  The files needs to be re-staged and is done
        # in staging.create_staging.
        subprocess.check_call('src/build/sync_arc_int.py')

    # Create a symlink to the integration_test definition directory, either in the
    # internal repository checkout or in the downloaded archive.
    # It is used to determine the definitions loaded in run_integration_tests.py
    # without relying on OPTIONS. Otherwise, run_integration_tests_test may fail
    # due to the mismatch between the expectations and the actual test apk since
    # it always runs under the default OPTIONS.
    if OPTIONS.internal_apks_source_is_internal():
        test_dir = 'internal/integration_tests'
    else:
        test_dir = 'out/internal-apks/integration_tests'

    symlink_location = 'out/internal-apks-integration-tests'
    if not os.path.islink(symlink_location) and os.path.isdir(
            symlink_location):
        # TODO(crbug.com/517306): This is a short-term fix for making bots green.
        # Remove once we implement a more proper solution (like, isolating the
        # test bundle extraction directory from the checkout, or stop running
        # ./configure on test-only builders.)
        #
        # 'Test only' bots extracts a directory structure from test-bundle zip, so
        # in that case we don't need to create a symlink.
        print 'WARNING: A directory exists at %s.' % symlink_location
        print 'WARNING: If not on test-only bot, gms test expectation may be stale.'
    else:
        # Otherwise, (re)create the link.
        file_util.create_link(symlink_location, test_dir, overwrite=True)
Example #5
0
  def populate_final_directory(self):
    """Sets up the final location for the download from the cache."""
    logging.info('%s: Setting up %s from cache %s', self._name,
                 self._unpacked_final_path, self.unpacked_linked_cache_path)

    file_util.makedirs_safely(self._unpacked_final_path)

    # We create a directory, and make symbolic links for the first level
    # of contents for backwards compatibility with an older version of
    # this code, which could only handle FINAL_DIR being a directory.
    for child in os.listdir(self.unpacked_linked_cache_path):
      file_util.create_link(
          os.path.join(self._unpacked_final_path, child),
          os.path.join(self.unpacked_linked_cache_path, child),
          overwrite=True)
Example #6
0
    def populate_final_directory(self):
        """Sets up the final location for the download from the cache."""
        logging.info('%s: Setting up %s from cache %s', self._name,
                     self._unpacked_final_path,
                     self.unpacked_linked_cache_path)

        file_util.makedirs_safely(self._unpacked_final_path)

        # We create a directory, and make symbolic links for the first level
        # of contents for backwards compatibility with an older version of
        # this code, which could only handle FINAL_DIR being a directory.
        for child in os.listdir(self.unpacked_linked_cache_path):
            file_util.create_link(os.path.join(self._unpacked_final_path,
                                               child),
                                  os.path.join(self.unpacked_linked_cache_path,
                                               child),
                                  overwrite=True)
Example #7
0
def _set_up_chromium_org_submodules():
  CHROMIUM_ORG_ROOT = 'third_party/android/external/chromium_org'
  # android/external/chromium_org contains these required submodules.  It is not
  # posible to have submodules within a submodule path (i.e., chromium_org)
  # using git submodules.  This is the list of subdirectories relative to
  # chromium_org that we need to symlink to the appropriate submodules.
  submodules = [
      'sdch/open-vcdiff',
      'testing/gtest',
      'third_party/WebKit',
      'third_party/angle',
      'third_party/brotli/src',
      ('third_party/eyesfree/src/android/java/'
       'src/com/googlecode/eyesfree/braille'),
      'third_party/freetype',
      'third_party/icu',
      'third_party/leveldatabase/src',
      'third_party/libjingle/source/talk',
      'third_party/libphonenumber/src/phonenumbers',
      'third_party/libphonenumber/src/resources',
      'third_party/libsrtp',
      'third_party/libvpx',
      'third_party/libyuv',
      'third_party/mesa/src',
      'third_party/openmax_dl',
      'third_party/openssl',
      'third_party/opus/src',
      'third_party/ots',
      'third_party/sfntly/cpp/src',
      'third_party/skia',
      'third_party/smhasher/src',
      'third_party/usrsctp/usrsctplib',
      'third_party/webrtc',
      'third_party/yasm/source/patched-yasm',
      'v8']

  # First remove all existing symlinks to make sure no stale links exist.
  for dirpath, dirs, fnames in os.walk(CHROMIUM_ORG_ROOT):
    # We only create symlinks for directories.
    for name in dirs:
      directory = os.path.join(dirpath, name)
      if os.path.islink(directory):
        os.unlink(directory)

  for s in submodules:
    target = os.path.join(CHROMIUM_ORG_ROOT, s)
    # As an example, this maps 'sdch/open-vcdiff' to
    # 'android/external/chromium_org__sdch_open-vcdiff', which is the true
    # location of the submodule checkout.
    source = 'third_party/android/external/chromium_org__' + s.replace('/', '_')
    if not os.path.exists(source):
      print 'ERROR: path "%s" does not exist.' % source
      print 'ERROR: Did you forget to run git submodules update --init?'
      sys.exit(1)

    # Remove existing symlink for transition from previous version.
    # The previous configuration script creates symlinks to the top of
    # chromium.org submodules, and now it tries to symlink them one-level
    # deeper.
    #
    # TODO(tzik): Remove this clean up code after the transition is no longer
    # needed.
    if os.path.islink(target):
      os.remove(target)

    target_contents = set()
    try:
      target_contents = set(os.listdir(target))
    except OSError as e:
      if e.errno != errno.ENOENT:
        raise

    source_contents = set(os.listdir(source))
    for content in source_contents:
      link_source = os.path.join(source, content)
      link_target = os.path.join(target, content)
      # If a real directory exists, remove it explicitly. |overwrite|
      # flag does not care for real directories and files, but old symlinks.
      if os.path.exists(link_target) and not os.path.islink(link_target):
        file_util.rmtree(link_target)

      file_util.create_link(link_target, link_source, overwrite=True)

    for removed_item in target_contents.difference(source_contents):
      os.unlink(os.path.join(target, removed_item))
Example #8
0
def _set_up_chromium_org_submodules():
    CHROMIUM_ORG_ROOT = 'third_party/android/external/chromium_org'
    # android/external/chromium_org contains these required submodules.  It is not
    # posible to have submodules within a submodule path (i.e., chromium_org)
    # using git submodules.  This is the list of subdirectories relative to
    # chromium_org that we need to symlink to the appropriate submodules.
    submodules = [
        'sdch/open-vcdiff', 'testing/gtest', 'third_party/WebKit',
        'third_party/angle', 'third_party/brotli/src',
        ('third_party/eyesfree/src/android/java/'
         'src/com/googlecode/eyesfree/braille'), 'third_party/freetype',
        'third_party/icu', 'third_party/leveldatabase/src',
        'third_party/libjingle/source/talk',
        'third_party/libphonenumber/src/phonenumbers',
        'third_party/libphonenumber/src/resources', 'third_party/libsrtp',
        'third_party/libvpx', 'third_party/libyuv', 'third_party/mesa/src',
        'third_party/openmax_dl', 'third_party/openssl',
        'third_party/opus/src', 'third_party/ots',
        'third_party/sfntly/cpp/src', 'third_party/skia',
        'third_party/smhasher/src', 'third_party/usrsctp/usrsctplib',
        'third_party/webrtc', 'third_party/yasm/source/patched-yasm', 'v8'
    ]

    # First remove all existing symlinks to make sure no stale links exist.
    for dirpath, dirs, fnames in os.walk(CHROMIUM_ORG_ROOT):
        # We only create symlinks for directories.
        for name in dirs:
            directory = os.path.join(dirpath, name)
            if os.path.islink(directory):
                os.unlink(directory)

    for s in submodules:
        target = os.path.join(CHROMIUM_ORG_ROOT, s)
        # As an example, this maps 'sdch/open-vcdiff' to
        # 'android/external/chromium_org__sdch_open-vcdiff', which is the true
        # location of the submodule checkout.
        source = 'third_party/android/external/chromium_org__' + s.replace(
            '/', '_')
        if not os.path.exists(source):
            print 'ERROR: path "%s" does not exist.' % source
            print 'ERROR: Did you forget to run git submodules update --init?'
            sys.exit(1)

        # Remove existing symlink for transition from previous version.
        # The previous configuration script creates symlinks to the top of
        # chromium.org submodules, and now it tries to symlink them one-level
        # deeper.
        #
        # TODO(tzik): Remove this clean up code after the transition is no longer
        # needed.
        if os.path.islink(target):
            os.remove(target)

        target_contents = set()
        try:
            target_contents = set(os.listdir(target))
        except OSError as e:
            if e.errno != errno.ENOENT:
                raise

        source_contents = set(os.listdir(source))
        for content in source_contents:
            link_source = os.path.join(source, content)
            link_target = os.path.join(target, content)
            # If a real directory exists, remove it explicitly. |overwrite|
            # flag does not care for real directories and files, but old symlinks.
            if os.path.exists(link_target) and not os.path.islink(link_target):
                file_util.rmtree(link_target)

            file_util.create_link(link_target, link_source, overwrite=True)

        for removed_item in target_contents.difference(source_contents):
            os.unlink(os.path.join(target, removed_item))