コード例 #1
0
  def gn_gen(self):
    """Finalize args.gn and run `gn gen`."""
    args_gn_path = os.path.join(self.get_build_dir_path(), ARGS_GN_FILENAME)

    common.ensure_dir(self.get_build_dir_path())
    common.delete_if_exists(args_gn_path)

    # Let users edit the current args.
    content = serialize_gn_args(self.get_gn_args())
    content = common.edit_if_needed(
        content, prefix='edit-args-gn-',
        comment='Edit %s before building.' % ARGS_GN_FILENAME,
        should_edit=self.options.edit_mode)

    # Write args to file and store.
    with open(args_gn_path, 'w') as f:
      f.write(content)

    logger.info(
        common.colorize('\nGenerating %s:\n%s\n', common.BASH_GREEN_MARKER),
        args_gn_path, content)

    common.execute(
        'gn', 'gen %s' % (self.get_build_dir_path()),
        self.get_source_dir_path())
コード例 #2
0
def download_build(dest, url, binary_name):
  """Download and extract a build (if it's not already there)."""
  if os.path.exists(dest):
    return dest

  logger.info('Downloading build data...')
  common.ensure_dir(common.CLUSTERFUZZ_BUILDS_DIR)

  gsutil_path = url.replace(
      'https://storage.cloud.google.com/', 'gs://')
  common.gsutil('cp %s .' % gsutil_path, common.CLUSTERFUZZ_CACHE_DIR)

  filename = os.path.basename(gsutil_path)
  saved_file = os.path.join(common.CLUSTERFUZZ_CACHE_DIR, filename)

  common.execute(
      'unzip', '-q %s -d %s' % (saved_file, common.CLUSTERFUZZ_BUILDS_DIR),
      cwd=common.CLUSTERFUZZ_DIR)

  logger.info('Cleaning up...')
  os.remove(saved_file)
  os.rename(os.path.join(
      common.CLUSTERFUZZ_BUILDS_DIR, os.path.splitext(filename)[0]), dest)

  binary_location = os.path.join(dest, binary_name)
  stats = os.stat(binary_location)
  os.chmod(binary_location, stats.st_mode | stat.S_IEXEC)
コード例 #3
0
 def test_exist(self):
     """Test ensuring dir when the dir exists."""
     os.makedirs('/test')
     self.assertTrue(os.path.exists('/test'))
     common.ensure_dir('/test')
     self.assertTrue(os.path.exists('/test'))
コード例 #4
0
 def test_not_exist(self):
     """Test ensuring dir when the dir doesn't exist."""
     self.assertFalse(os.path.exists('/test'))
     common.ensure_dir('/test')
     self.assertTrue(os.path.exists('/test'))