コード例 #1
0
ファイル: isolate_driver.py プロジェクト: zanxi/bitpop
def create_wrapper(args, isolate_index, isolated_index):
    """Creates a wrapper .isolate that add dynamic libs.

  The original .isolate is not modified.
  """
    cwd = os.getcwd()
    isolate = args[isolate_index]
    # The code assumes the .isolate file is always specified path-less in cwd. Fix
    # if this assumption doesn't hold true.
    assert os.path.basename(isolate) == isolate, isolate

    # This will look like ../out/Debug. This is based against cwd. Note that this
    # must equal the value provided as PRODUCT_DIR.
    build_dir = os.path.dirname(args[isolated_index])

    # This will look like chrome/unit_tests.isolate. It is based against SRC_DIR.
    # It's used to calculate temp_isolate.
    src_isolate = os.path.relpath(os.path.join(cwd, isolate), SRC_DIR)

    # The wrapping .isolate. This will look like
    # ../out/Debug/gen/chrome/unit_tests.isolate.
    temp_isolate = os.path.join(build_dir, "gen", src_isolate)
    temp_isolate_dir = os.path.dirname(temp_isolate)

    # Relative path between the new and old .isolate file.
    isolate_relpath = os.path.relpath(".", temp_isolate_dir).replace(os.path.sep, "/")

    # It's a big assumption here that the name of the isolate file matches the
    # primary target '_run'. Fix accordingly if this doesn't hold true, e.g.
    # complain to maruel@.
    target = isolate[: -len(".isolate")] + "_run"
    build_steps = load_ninja(build_dir)
    binary_deps = post_process_deps(build_dir, recurse(target, build_steps, None))
    logging.debug("Binary dependencies:%s", "".join("\n  " + i for i in binary_deps))

    # Now do actual wrapping .isolate.
    isolate_dict = {
        "includes": [posixpath.join(isolate_relpath, isolate)],
        "variables": {
            # Will look like ['<(PRODUCT_DIR)/lib/flibuser_prefs.so'].
            isolate_format.KEY_TRACKED: sorted("<(PRODUCT_DIR)/%s" % i.replace(os.path.sep, "/") for i in binary_deps)
        },
    }
    if not os.path.isdir(temp_isolate_dir):
        os.makedirs(temp_isolate_dir)
    comment = "# Warning: this file was AUTOGENERATED.\n" "# DO NO EDIT.\n"
    out = StringIO.StringIO()
    isolate_format.print_all(comment, isolate_dict, out)
    isolate_content = out.getvalue()
    with open(temp_isolate, "wb") as f:
        f.write(isolate_content)
    logging.info("Added %d dynamic libs", len(binary_deps))
    logging.debug("%s", isolate_content)
    args[isolate_index] = temp_isolate
コード例 #2
0
ファイル: isolate_driver.py プロジェクト: Tomeno/chromium
def create_wrapper(args, isolate_index, isolated_index):
  """Creates a wrapper .isolate that add dynamic libs.

  The original .isolate is not modified.
  """
  cwd = os.getcwd()
  isolate = args[isolate_index]
  # The code assumes the .isolate file is always specified path-less in cwd. Fix
  # if this assumption doesn't hold true.
  assert os.path.basename(isolate) == isolate, isolate

  # This will look like ../out/Debug. This is based against cwd. Note that this
  # must equal the value provided as PRODUCT_DIR.
  build_dir = os.path.dirname(args[isolated_index])

  # This will look like chrome/unit_tests.isolate. It is based against SRC_DIR.
  # It's used to calculate temp_isolate.
  src_isolate = os.path.relpath(os.path.join(cwd, isolate), SRC_DIR)

  # The wrapping .isolate. This will look like
  # ../out/Debug/gen/chrome/unit_tests.isolate.
  temp_isolate = os.path.join(build_dir, 'gen', src_isolate)
  temp_isolate_dir = os.path.dirname(temp_isolate)

  # Relative path between the new and old .isolate file.
  isolate_relpath = os.path.relpath(
      '.', temp_isolate_dir).replace(os.path.sep, '/')

  # Will look like ['<(PRODUCT_DIR)/lib/flibuser_prefs.so'].
  rebased_libs = [
    '<(PRODUCT_DIR)/%s' % i[len(build_dir)+1:]
    for i in get_dynamic_libs(build_dir)
  ]

  # Now do actual wrapping .isolate.
  out = {
    'includes': [
      posixpath.join(isolate_relpath, isolate),
    ],
    'variables': {
      isolate_format.KEY_TRACKED: rebased_libs,
    },
  }
  if not os.path.isdir(temp_isolate_dir):
    os.makedirs(temp_isolate_dir)
  comment = (
      '# Warning: this file was AUTOGENERATED.\n'
      '# DO NO EDIT.\n')
  with open(temp_isolate, 'wb') as f:
    isolate_format.print_all(comment, out, f)
  if '--verbose' in args:
    print('Added %d dynamic libs' % len(dynamic_libs))
  args[isolate_index] = temp_isolate
コード例 #3
0
def create_wrapper(args, isolate_index, isolated_index):
    """Creates a wrapper .isolate that add dynamic libs.

  The original .isolate is not modified.
  """
    cwd = os.getcwd()
    isolate = args[isolate_index]
    # The code assumes the .isolate file is always specified path-less in cwd. Fix
    # if this assumption doesn't hold true.
    assert os.path.basename(isolate) == isolate, isolate

    # This will look like ../out/Debug. This is based against cwd. Note that this
    # must equal the value provided as PRODUCT_DIR.
    build_dir = os.path.dirname(args[isolated_index])

    # This will look like chrome/unit_tests.isolate. It is based against SRC_DIR.
    # It's used to calculate temp_isolate.
    src_isolate = os.path.relpath(os.path.join(cwd, isolate), SRC_DIR)

    # The wrapping .isolate. This will look like
    # ../out/Debug/gen/chrome/unit_tests.isolate.
    temp_isolate = os.path.join(build_dir, 'gen', src_isolate)
    temp_isolate_dir = os.path.dirname(temp_isolate)

    # Relative path between the new and old .isolate file.
    isolate_relpath = os.path.relpath('.', temp_isolate_dir).replace(
        os.path.sep, '/')

    # Will look like ['<(PRODUCT_DIR)/lib/flibuser_prefs.so'].
    rebased_libs = [
        '<(PRODUCT_DIR)/%s' % i[len(build_dir) + 1:]
        for i in get_dynamic_libs(build_dir)
    ]

    # Now do actual wrapping .isolate.
    out = {
        'includes': [
            posixpath.join(isolate_relpath, isolate),
        ],
        'variables': {
            isolate_format.KEY_TRACKED: rebased_libs,
        },
    }
    if not os.path.isdir(temp_isolate_dir):
        os.makedirs(temp_isolate_dir)
    comment = ('# Warning: this file was AUTOGENERATED.\n' '# DO NO EDIT.\n')
    with open(temp_isolate, 'wb') as f:
        isolate_format.print_all(comment, out, f)
    if '--verbose' in args:
        print('Added %d dynamic libs' % len(dynamic_libs))
    args[isolate_index] = temp_isolate
コード例 #4
0
def main(args=None):
    tools.disable_buffering()
    parser = tools.OptionParserWithLogging(usage="%prog <options> [file1] [file2] ...")
    parser.add_option("-o", "--output", help="Output to file instead of stdout")

    options, args = parser.parse_args(args)

    configs = load_isolates(args)
    data = configs.make_isolate_file()
    if options.output:
        with open(options.output, "wb") as f:
            print_all(configs.file_comment, data, f)
    else:
        print_all(configs.file_comment, data, sys.stdout)
    return 0
コード例 #5
0
ファイル: isolate_merge.py プロジェクト: WHS-TechOps/Aviator
def main(args=None):
  tools.disable_buffering()
  parser = tools.OptionParserWithLogging(
      usage='%prog <options> [file1] [file2] ...')
  parser.add_option(
      '-o', '--output', help='Output to file instead of stdout')

  options, args = parser.parse_args(args)

  configs = load_isolates(args)
  data = configs.make_isolate_file()
  if options.output:
    with open(options.output, 'wb') as f:
      isolate_format.print_all(configs.file_comment, data, f)
  else:
    isolate_format.print_all(configs.file_comment, data, sys.stdout)
  return 0
コード例 #6
0
def main(args=None):
    tools.disable_buffering()
    parser = tools.OptionParserWithLogging(
        usage='%prog <options> [file1] [file2] ...')
    parser.add_option('-o',
                      '--output',
                      help='Output to file instead of stdout')

    options, args = parser.parse_args(args)

    configs = load_isolates(args)
    data = configs.make_isolate_file()
    if options.output:
        with open(options.output, 'wb') as f:
            isolate_format.print_all(configs.file_comment, data, f)
    else:
        isolate_format.print_all(configs.file_comment, data, sys.stdout)
    return 0
コード例 #7
0
def create_wrapper(args, isolate_index, isolated_index):
    """Creates a wrapper .isolate that add dynamic libs.

  The original .isolate is not modified.
  """
    cwd = os.getcwd()
    isolate = args[isolate_index]
    # The code assumes the .isolate file is always specified path-less in cwd. Fix
    # if this assumption doesn't hold true.
    assert os.path.basename(isolate) == isolate, isolate

    # This will look like ../out/Debug. This is based against cwd. Note that this
    # must equal the value provided as PRODUCT_DIR.
    build_dir = os.path.dirname(args[isolated_index])

    # This will look like chrome/unit_tests.isolate. It is based against SRC_DIR.
    # It's used to calculate temp_isolate.
    src_isolate = os.path.relpath(os.path.join(cwd, isolate), SRC_DIR)

    # The wrapping .isolate. This will look like
    # ../out/Debug/gen/chrome/unit_tests.isolate.
    temp_isolate = os.path.join(build_dir, 'gen', src_isolate)
    temp_isolate_dir = os.path.dirname(temp_isolate)

    # Relative path between the new and old .isolate file.
    isolate_relpath = os.path.relpath('.', temp_isolate_dir).replace(
        os.path.sep, '/')

    # It's a big assumption here that the name of the isolate file matches the
    # primary target '_run'. Fix accordingly if this doesn't hold true, e.g.
    # complain to maruel@.
    target = isolate[:-len('.isolate')] + '_run'
    build_steps = load_ninja(build_dir)
    binary_deps = set()
    collect_deps(target, build_steps, binary_deps, None)
    binary_deps = post_process_deps(build_dir, binary_deps)
    logging.debug('Binary dependencies:%s',
                  ''.join('\n  ' + i for i in binary_deps))

    # Now do actual wrapping .isolate.
    isolate_dict = {
        'includes': [
            posixpath.join(isolate_relpath, isolate),
        ],
        'variables': {
            # Will look like ['<(PRODUCT_DIR)/lib/flibuser_prefs.so'].
            'files':
            sorted('<(PRODUCT_DIR)/%s' % i.replace(os.path.sep, '/')
                   for i in binary_deps),
        },
    }
    # Some .isolate files have the same temp directory and the build system may
    # run this script in parallel so make directories safely here.
    try:
        os.makedirs(temp_isolate_dir)
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise
    comment = ('# Warning: this file was AUTOGENERATED.\n' '# DO NO EDIT.\n')
    out = StringIO.StringIO()
    isolate_format.print_all(comment, isolate_dict, out)
    isolate_content = out.getvalue()
    with open(temp_isolate, 'wb') as f:
        f.write(isolate_content)
    logging.info('Added %d dynamic libs', len(binary_deps))
    logging.debug('%s', isolate_content)
    args[isolate_index] = temp_isolate
コード例 #8
0
def create_wrapper(args, isolate_index, isolated_index):
  """Creates a wrapper .isolate that add dynamic libs.

  The original .isolate is not modified.
  """
  cwd = os.getcwd()
  isolate = args[isolate_index]
  # The code assumes the .isolate file is always specified path-less in cwd. Fix
  # if this assumption doesn't hold true.
  assert os.path.basename(isolate) == isolate, isolate

  # This will look like ../out/Debug. This is based against cwd. Note that this
  # must equal the value provided as PRODUCT_DIR.
  build_dir = os.path.dirname(args[isolated_index])

  # This will look like chrome/unit_tests.isolate. It is based against SRC_DIR.
  # It's used to calculate temp_isolate.
  src_isolate = os.path.relpath(os.path.join(cwd, isolate), SRC_DIR)

  # The wrapping .isolate. This will look like
  # ../out/Debug/gen/chrome/unit_tests.isolate.
  temp_isolate = os.path.join(build_dir, 'gen', src_isolate)
  temp_isolate_dir = os.path.dirname(temp_isolate)

  # Relative path between the new and old .isolate file.
  isolate_relpath = os.path.relpath(
      '.', temp_isolate_dir).replace(os.path.sep, '/')

  # It's a big assumption here that the name of the isolate file matches the
  # primary target '_run'. Fix accordingly if this doesn't hold true, e.g.
  # complain to maruel@.
  target = isolate[:-len('.isolate')] + '_run'
  build_steps = load_ninja(build_dir)
  binary_deps = set()
  collect_deps(target, build_steps, binary_deps, None)
  binary_deps = post_process_deps(build_dir, binary_deps)
  logging.debug(
      'Binary dependencies:%s', ''.join('\n  ' + i for i in binary_deps))

  # Now do actual wrapping .isolate.
  isolate_dict = {
    'includes': [
      posixpath.join(isolate_relpath, isolate),
    ],
    'variables': {
      # Will look like ['<(PRODUCT_DIR)/lib/flibuser_prefs.so'].
      'files': sorted(
          '<(PRODUCT_DIR)/%s' % i.replace(os.path.sep, '/')
          for i in binary_deps),
    },
  }
  # Some .isolate files have the same temp directory and the build system may
  # run this script in parallel so make directories safely here.
  try:
    os.makedirs(temp_isolate_dir)
  except OSError as e:
    if e.errno != errno.EEXIST:
      raise
  comment = (
      '# Warning: this file was AUTOGENERATED.\n'
      '# DO NO EDIT.\n')
  out = StringIO.StringIO()
  isolate_format.print_all(comment, isolate_dict, out)
  isolate_content = out.getvalue()
  with open(temp_isolate, 'wb') as f:
    f.write(isolate_content)
  logging.info('Added %d dynamic libs', len(binary_deps))
  logging.debug('%s', isolate_content)
  args[isolate_index] = temp_isolate