Ejemplo n.º 1
0
def DetectTargetArch():
    """Attempt for determine target architecture.

  This works by looking for target_arch in GYP_DEFINES.
  """
    # TODO(agrieve): Make this script not depend on GYP_DEFINES so that it works
    #     with GN as well.
    gyp_environment.SetEnvironment()
    supplemental_includes = gyp_chromium.GetSupplementalFiles()
    gyp_defines = gyp_chromium.GetGypVars(supplemental_includes)
    target_arch = gyp_defines.get('target_arch')
    if target_arch == 'x64':
        return 'amd64'
    elif target_arch == 'ia32':
        return 'i386'
    elif target_arch == 'arm':
        return 'arm'
    elif target_arch == 'arm64':
        return 'arm64'
    elif target_arch == 'mipsel':
        return 'mips'
    elif target_arch:
        raise Error('Unrecognized target_arch: %s' % target_arch)

    return None
Ejemplo n.º 2
0
def main():
    if options.running_as_hook and not sys.platform.startswith('linux'):
        return 0

    gyp_environment.SetEnvironment()
    supplemental_includes = gyp_chromium.GetSupplementalFiles()
    gyp_defines = gyp_chromium.GetGypVars(supplemental_includes)
    is_android = gyp_defines.get('OS') == 'android'

    if options.arch:
        target_arch = options.arch
    else:
        target_arch = DetectArch(gyp_defines, is_android)
        if not target_arch:
            print 'Unable to detect target architecture'
            return 1

    if (options.running_as_hook
            and not UsingSysroot(target_arch, is_android, gyp_defines)):
        return 0

    if is_android:
        # 32-bit Android builds require a 32-bit host sysroot for the v8 snapshot.
        if '64' not in target_arch:
            ret = _InstallSysroot('i386')
            if ret:
                return ret
        # Always need host sysroot (which we assume is x64).
        target_arch = 'amd64'

    return _InstallSysroot(target_arch)
Ejemplo n.º 3
0
def overwrite_arguments():
    gyp_environment.SetEnvironment()

    # GetGypVars reads command line, GYP_DEFINES and ~/.gyp/include.gypi.
    gyp_env_variables = gyp_chromium.GetGypVars([])

    # GetGypVars stringifies the values. Fix it up so we can use the relaxed
    # syntax in conditions.
    tmp = {}
    for k, v in gyp_env_variables.items():
        try:
            v_tmp = int(v)
        except ValueError:
            v_tmp = v
        tmp[k] = v_tmp

    gyp_env_variables = tmp

    variables = determine_variables(gyp_env_variables)

    forwarded_args = [sys.argv[0]]
    for v in variables:
        forwarded_args.append('-D' + str(v) + '=' + str(variables[v]))

    # Filter out definitions from command line not to duplicate them.
    next_is_var = False
    for arg in sys.argv[1:]:
        # gyp accepts both -Dvar=value and -D var=value.
        if next_is_var:
            next_is_var = False
            continue
        if arg.startswith('-D'):
            if arg == '-D':
                next_is_var = True
            continue
        forwarded_args.append(arg)

    sys.argv = forwarded_args

    # Check for non-supported configurations
    if ('-Denable_desktop_chrome=1' in sys.argv[1:]):
        if ('-Denable_s_android_browser=1' in sys.argv[1:]):
            print 'The enable_desktop_chrome and enable_s_android_browser ' \
                  'flags can not be set together!'
            sys.exit()

    print '---- gyp variables ----'
    gyp_file_specified = (os.path.splitext(sys.argv[-1])[1] == '.gyp')
    print ' '.join(sys.argv[1:-1] if gyp_file_specified else sys.argv[1:])
    print '----\n'
Ejemplo n.º 4
0
def InstallDefaultSysroots(host_arch):
  """Install the default set of sysroot images.

  This includes at least the sysroot for host architecture, and the 32-bit
  sysroot for building the v8 snapshot image.  It can also include the cross
  compile sysroot for ARM/MIPS if cross compiling environment can be detected.

  Another reason we're installing this by default is so that developers can
  compile and run on our supported platforms without having to worry about
  flipping things back and forth and whether the sysroots have been downloaded
  or not.
  """
  InstallDefaultSysrootForArch(host_arch)

  if host_arch == 'amd64':
    InstallDefaultSysrootForArch('i386')

  # Desktop Chromium OS builds require the precise sysroot.
  # TODO(thomasanderson): only download this when the GN arg target_os
  # == 'chromeos', when the functionality to perform the check becomes
  # available.
  InstallSysroot('Precise', 'amd64')

  # If we can detect a non-standard target_arch such as ARM or MIPS,
  # then install the sysroot too.  Don't attempt to install arm64
  # since this is currently and android-only architecture.
  target_arch = DetectTargetArch()
  if target_arch and target_arch not in (host_arch, 'i386'):
    InstallDefaultSysrootForArch(target_arch)

  # Desktop Linux ozone builds require libxkbcommon* which is not
  # available in Wheezy.
  # TODO(thomasanderson): Remove this once the Jessie sysroot is used
  # by default.
  gyp_defines = gyp_chromium.GetGypVars(gyp_chromium.GetSupplementalFiles())
  if gyp_defines.get('use_ozone') == '1':
    InstallSysroot('Jessie', 'amd64')
 def testDFlagMulti(self):
   self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': 'bar', 'baz': '1'})
 def testDFlagsNoValue(self):
   self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': '1'})
 def testDFlags(self):
   self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': 'bar'})
 def testDefault(self):
   self.assertEqual(gyp_chromium.GetGypVars([]), {})
Ejemplo n.º 9
0
def main():
  # Disabling garbage collection saves about 5% processing time. Since this is a
  # short-lived process it's not a problem.
  gc.disable()

  args = sys.argv[1:]

  if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)):
    print 'Skipping gyp_webrtc.py due to GYP_CHROMIUM_NO_ACTION env var.'
    sys.exit(0)

  if 'SKIP_WEBRTC_GYP_ENV' not in os.environ:
    # Update the environment based on webrtc.gyp_env.
    gyp_env_path = os.path.join(os.path.dirname(checkout_root),
                                'webrtc.gyp_env')
    gyp_helper.apply_gyp_environment_from_file(gyp_env_path)

  # This could give false positives since it doesn't actually do real option
  # parsing.  Oh well.
  gyp_file_specified = False
  for arg in args:
    if arg.endswith('.gyp'):
      gyp_file_specified = True
      break

  # If we didn't get a file, assume 'all.gyp' in the root of the checkout.
  if not gyp_file_specified:
    # Because of a bug in gyp, simply adding the abspath to all.gyp doesn't
    # work, but chdir'ing and adding the relative path does. Spooky :/
    os.chdir(checkout_root)
    args.append('all.gyp')

  # There shouldn't be a circular dependency relationship between .gyp files,
  args.append('--no-circular-check')

  # Default to ninja unless GYP_GENERATORS is set.
  if not os.environ.get('GYP_GENERATORS'):
    os.environ['GYP_GENERATORS'] = 'ninja'

  fixVS2015Ninja()

  # Enable check for missing sources in GYP files on Windows.
  if sys.platform.startswith('win'):
    gyp_generator_flags = os.getenv('GYP_GENERATOR_FLAGS', '')
    if not 'msvs_error_on_missing_sources' in gyp_generator_flags:
      os.environ['GYP_GENERATOR_FLAGS'] = (
          gyp_generator_flags + ' msvs_error_on_missing_sources=1')

  vs2013_runtime_dll_dirs = None
  if int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')):
    vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
  else:
    gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
    winSdkDir = os.environ.get('UniversalCRTSdkDir')
    if winSdkDir != None:
        gyp_defines_dict['windows_sdk_path'] = winSdkDir
        os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
            for k, v in gyp_defines_dict.iteritems())

  # Enforce gyp syntax checking. This adds about 20% execution time.
  args.append('--check')

  supplemental_includes = GetSupplementalFiles()
  gyp_vars = gyp_chromium.GetGypVars(supplemental_includes)

  # Automatically turn on crosscompile support for platforms that need it.
  if all(('ninja' in os.environ.get('GYP_GENERATORS', ''),
          gyp_vars.get('OS') in ['android', 'ios'],
          'GYP_CROSSCOMPILE' not in os.environ)):
    os.environ['GYP_CROSSCOMPILE'] = '1'

  args.extend(['-I' + i for i in
               gyp_chromium.additional_include_files(supplemental_includes,
                                                     args)])

  # Set the gyp depth variable to the root of the checkout.
  args.append('--depth=' + os.path.relpath(checkout_root))

  print 'Updating projects from gyp files...'
  sys.stdout.flush()

  # Off we go...
  gyp_rc = gyp.main(args)

  if vs2013_runtime_dll_dirs:
    # pylint: disable=unpacking-non-sequence
    x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
    vs_toolchain.CopyVsRuntimeDlls(
        os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()),
        (x86_runtime, x64_runtime))

  sys.exit(gyp_rc)
  elif detected_host_arch == 's390':
    return 's390'

  raise Error('Unrecognized host arch: %s' % detected_host_arch)


def DetectTargetArch():
  """Attempt for determine target architecture.

  This works by looking for target_arch in GYP_DEFINES.
  """
  # TODO(agrieve): Make this script not depend on GYP_DEFINES so that it works
  #     with GN as well.
  gyp_environment.SetEnvironment()
  supplemental_includes = gyp_chromium.GetSupplementalFiles()
  gyp_defines = gyp_chromium.GetGypVars(supplemental_includes)
  target_arch = gyp_defines.get('target_arch')
  if target_arch == 'x64':
    return 'amd64'
  elif target_arch == 'ia32':
    return 'i386'
  elif target_arch == 'arm':
    return 'arm'
  elif target_arch == 'arm64':
    return 'arm64'
  elif target_arch == 'mipsel':
    return 'mips'
  elif target_arch == 'mips64el':
    return 'mips64'

  return None