Exemple #1
0
def _CopyCDBToOutput(output_dir, target_arch):
    """Copies the Windows debugging executable cdb.exe to the output
  directory, which is created if it does not exist. The output
  directory, and target architecture that should be copied, are
  passed. Supported values for the target architecture are the GYP
  values "ia32" and "x64" and the GN values "x86" and "x64".
  """
    if not os.path.isdir(output_dir):
        os.makedirs(output_dir)
    vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
    win_sdk_dir = os.path.normpath(os.environ['WINDOWSSDKDIR'])
    if target_arch == 'ia32' or target_arch == 'x86':
        src_arch = 'x86'
    elif target_arch == 'x64':
        src_arch = 'x64'
    else:
        print 'copy_cdb_to_output.py: unknown target_arch %s' % target_arch
        sys.exit(1)
    # We need to copy multiple files, so cache the computed source directory.
    src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch)
    # Note that the outputs from the "copy_cdb_to_output" target need to
    # be kept in sync with this list.
    _CopyImpl('cdb.exe', output_dir, src_dir)
    _CopyImpl('dbgeng.dll', output_dir, src_dir)
    _CopyImpl('dbghelp.dll', output_dir, src_dir)
    _CopyImpl('dbgmodel.dll', output_dir, src_dir)
    return 0
Exemple #2
0
def prepare_path():
    if os.environ['GYP_GENERATORS'] == 'ninja':
        sys.path.insert(0, os.path.join(ENV_SOLUTION_DIRECTORY, 'build'))
        import vs_toolchain
        vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs(
        )

    sys.path.insert(0, os.environ.get('ENV_GYP_DIRECTORY'))
def set_environment():
    """Sets defaults for GYP_* variables."""

    if 'SKIP_V8_GYP_ENV' not in os.environ:
        # Update the environment based on v8.gyp_env
        gyp_env_path = os.path.join(os.path.dirname(V8_ROOT), 'v8.gyp_env')
        apply_gyp_environment(gyp_env_path)
        vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
Exemple #4
0
def _CopyCDBToOutput(output_dir, target_arch):
    """Copies the Windows debugging executable cdb.exe to the output
  directory, which is created if it does not exist. The output
  directory, and target architecture that should be copied, are
  passed. Supported values for the target architecture are the GYP
  values "ia32", "x64", "arm64" and the GN values "x86", "x64", "arm64".
  """
    _ConditionalMkdir(output_dir)
    vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
    # If WINDOWSSDKDIR is not set use the default SDK path. This will be the case
    # when DEPOT_TOOLS_WIN_TOOLCHAIN=0 and vcvarsall.bat has not been run.
    win_sdk_dir = os.path.normpath(
        os.environ.get(
            'WINDOWSSDKDIR',
            os.path.expandvars('%ProgramFiles(x86)%'
                               '\\Windows Kits\\10')))
    if target_arch == 'ia32' or target_arch == 'x86':
        src_arch = 'x86'
    elif target_arch in ['x64', 'arm64']:
        src_arch = target_arch
    else:
        print 'copy_cdb_to_output.py: unknown target_arch %s' % target_arch
        sys.exit(1)
    # We need to copy multiple files, so cache the computed source directory.
    src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch)
    # We need to copy some helper DLLs to get access to the !uniqstack
    # command to dump all threads' stacks.
    src_winext_dir = os.path.join(src_dir, 'winext')
    dst_winext_dir = os.path.join(output_dir, 'winext')
    src_winxp_dir = os.path.join(src_dir, 'winxp')
    dst_winxp_dir = os.path.join(output_dir, 'winxp')
    # Starting with the 10.0.17763 SDK the ucrt files are in a version-named
    # directory - this handles both cases.
    redist_dir = os.path.join(win_sdk_dir, 'Redist')
    version_dirs = glob.glob(os.path.join(redist_dir, '10.*'))
    if len(version_dirs) > 0:
        version_dirs.sort(reverse=True)
        redist_dir = version_dirs[0]
    src_crt_dir = os.path.join(redist_dir, 'ucrt', 'DLLs', src_arch)
    _ConditionalMkdir(dst_winext_dir)
    _ConditionalMkdir(dst_winxp_dir)
    # Note that the outputs from the "copy_cdb_to_output" target need to
    # be kept in sync with this list.
    _CopyImpl('cdb.exe', output_dir, src_dir)
    _CopyImpl('dbgeng.dll', output_dir, src_dir)
    _CopyImpl('dbghelp.dll', output_dir, src_dir)
    _CopyImpl('dbgmodel.dll', output_dir, src_dir)
    _CopyImpl('ext.dll', dst_winext_dir, src_winext_dir)
    _CopyImpl('uext.dll', dst_winext_dir, src_winext_dir)
    _CopyImpl('exts.dll', dst_winxp_dir, src_winxp_dir)
    _CopyImpl('ntsdexts.dll', dst_winxp_dir, src_winxp_dir)
    if src_arch in ['x64', 'x86']:
        _CopyImpl('api-ms-win-eventing-provider-l1-1-0.dll', output_dir,
                  src_dir)
        _CopyImpl('ucrtbase.dll', output_dir, src_crt_dir)
    for dll_path in glob.glob(os.path.join(src_crt_dir, 'api-ms-win-*.dll')):
        _CopyImpl(os.path.split(dll_path)[1], output_dir, src_crt_dir)
    return 0
Exemple #5
0
def set_environment():
    """Sets defaults for GYP_* variables."""

    if 'SKIP_V8_GYP_ENV' not in os.environ:
        # Update the environment based on v8.gyp_env
        gyp_env_path = os.path.join(os.path.dirname(V8_ROOT), 'v8.gyp_env')
        apply_gyp_environment(gyp_env_path)

        if not os.environ.get('GYP_GENERATORS'):
            # Default to ninja on all platforms.
            os.environ['GYP_GENERATORS'] = 'ninja'

        vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
def SetEnvironment():
    """Sets defaults for GYP_* variables."""
    # Default to ninja on linux and windows, but only if no generator has
    # explicitly been set.
    # Also default to ninja on mac, but only when not building chrome/ios.
    # . -f / --format has precedence over the env var, no need to check for it
    # . set the env var only if it hasn't been set yet
    # . chromium.gyp_env has been applied to os.environ at this point already
    if sys.platform.startswith(('linux', 'win', 'freebsd', 'darwin')) and \
        not os.environ.get('GYP_GENERATORS'):
        os.environ['GYP_GENERATORS'] = 'ninja'

    vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
Exemple #7
0
def main(target_dir):
  """Copy msdia140.dll into the requested directory.
  msdia140.dll is necessary for breakpad in dump_sym.exe

  Arguments:
    target_dir (string) target directory
  """

  vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
  vs_path = vs_toolchain.NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH'])

  msdia_path = os.path.join(vs_path, 'DIA SDK', 'bin', 'amd64', 'msdia140.dll')

  target_path = os.path.join(target_dir, 'msdia140.dll')
  shutil.copy2(msdia_path, target_path)
def GetVSVersion():
    global vs_version
    if vs_version:
        return vs_version

    # Try using the toolchain in depot_tools.
    # This sets environment variables used by SelectVisualStudioVersion below.
    sys.path.append(os.path.join(CHROMIUM_DIR, 'build'))
    import vs_toolchain
    vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()

    # Use gyp to find the MSVS installation, either in depot_tools as per above,
    # or a system-wide installation otherwise.
    sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib'))
    import gyp.MSVSVersion
    vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013')
    return vs_version
def _CopyCDBToOutput(output_dir, target_arch):
    """Copies the Windows debugging executable cdb.exe to the output
  directory, which is created if it does not exist. The output
  directory, and target architecture that should be copied, are
  passed. Supported values for the target architecture are the GYP
  values "ia32" and "x64" and the GN values "x86" and "x64".
  """
    _ConditionalMkdir(output_dir)
    vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
    # If WINDOWSSDKDIR is not set use the default SDK path. This will be the case
    # when DEPOT_TOOLS_WIN_TOOLCHAIN=0 and vcvarsall.bat has not been run.
    win_sdk_dir = os.path.normpath(
        os.environ.get('WINDOWSSDKDIR',
                       'C:\\Program Files (x86)\\Windows Kits\\10'))
    if target_arch == 'ia32' or target_arch == 'x86':
        src_arch = 'x86'
    elif target_arch == 'x64':
        src_arch = 'x64'
    else:
        print 'copy_cdb_to_output.py: unknown target_arch %s' % target_arch
        sys.exit(1)
    # We need to copy multiple files, so cache the computed source directory.
    src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch)
    # We need to copy some helper DLLs to get access to the !uniqstack
    # command to dump all threads' stacks.
    src_winext_dir = os.path.join(src_dir, 'winext')
    dst_winext_dir = os.path.join(output_dir, 'winext')
    src_winxp_dir = os.path.join(src_dir, 'winxp')
    dst_winxp_dir = os.path.join(output_dir, 'winxp')
    _ConditionalMkdir(dst_winext_dir)
    _ConditionalMkdir(dst_winxp_dir)
    # Note that the outputs from the "copy_cdb_to_output" target need to
    # be kept in sync with this list.
    _CopyImpl('cdb.exe', output_dir, src_dir)
    _CopyImpl('dbgeng.dll', output_dir, src_dir)
    _CopyImpl('dbghelp.dll', output_dir, src_dir)
    _CopyImpl('dbgmodel.dll', output_dir, src_dir)
    _CopyImpl('ext.dll', dst_winext_dir, src_winext_dir)
    _CopyImpl('uext.dll', dst_winext_dir, src_winext_dir)
    _CopyImpl('exts.dll', dst_winxp_dir, src_winxp_dir)
    _CopyImpl('ntsdexts.dll', dst_winxp_dir, src_winxp_dir)
    return 0
Exemple #10
0
def SetEnvironment():
    """Sets defaults for GYP_* variables."""
    gyp_helper.apply_chromium_gyp_env()

    # Default to ninja on linux and windows, but only if no generator has
    # explicitly been set.
    # Also default to ninja on mac, but only when not building chrome/ios.
    # . -f / --format has precedence over the env var, no need to check for it
    # . set the env var only if it hasn't been set yet
    # . chromium.gyp_env has been applied to os.environ at this point already
    if sys.platform.startswith(('linux', 'win', 'freebsd')) and \
        not os.environ.get('GYP_GENERATORS'):
        os.environ['GYP_GENERATORS'] = 'ninja'
    elif sys.platform == 'darwin' and not os.environ.get('GYP_GENERATORS') and \
        not 'OS=ios' in os.environ.get('GYP_DEFINES', []):
        os.environ['GYP_GENERATORS'] = 'ninja'

    vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
    mac_toolchain_dir = mac_toolchain.GetToolchainDirectory()
    if mac_toolchain_dir:
        os.environ['DEVELOPER_DIR'] = mac_toolchain_dir
Exemple #11
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)
def main():
    # Disabling garbage collection saves about 1 second out of 16 on a Linux
    # z620 workstation. Since this is a short-lived process it's not a problem to
    # leak a few cyclyc references in order to spare the CPU cycles for
    # scanning the heap.
    gc.disable()

    args = sys.argv[1:]

    use_analyzer = len(args) and args[0] == '--analyzer'
    if use_analyzer:
        args.pop(0)
        os.environ['GYP_GENERATORS'] = 'analyzer'
        args.append('-Gconfig_path=' + args.pop(0))
        args.append('-Ganalyzer_output_path=' + args.pop(0))

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

    # Use the Psyco JIT if available.
    if psyco:
        psyco.profile()
        print "Enabled Psyco JIT."

    # Fall back on hermetic python if we happen to get run under cygwin.
    # TODO(bradnelson): take this out once this issue is fixed:
    #    http://code.google.com/p/gyp/issues/detail?id=177
    if sys.platform == 'cygwin':
        import find_depot_tools
        depot_tools_path = find_depot_tools.add_depot_tools_to_path()
        python_dir = sorted(
            glob.glob(os.path.join(depot_tools_path, 'python2*_bin')))[-1]
        env = os.environ.copy()
        env['PATH'] = python_dir + os.pathsep + env.get('PATH', '')
        cmd = [os.path.join(python_dir, 'python.exe')] + sys.argv
        sys.exit(subprocess.call(cmd, env=env))

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

    gyp_environment.SetEnvironment()

    # If we didn't get a file, check an env var, and then fall back to
    # assuming 'all.gyp' from the same directory as the script.
    if not gyp_file_specified:
        gyp_file = os.environ.get('CHROMIUM_GYP_FILE')
        if gyp_file:
            # Note that CHROMIUM_GYP_FILE values can't have backslashes as
            # path separators even on Windows due to the use of shlex.split().
            args.extend(shlex.split(gyp_file))
        else:
            args.append(os.path.join(script_dir, 'all.gyp'))

    supplemental_includes = GetSupplementalFiles()
    gyp_vars_dict = GetGypVars(supplemental_includes)
    # There shouldn't be a circular dependency relationship between .gyp files,
    # but in Chromium's .gyp files, on non-Mac platforms, circular relationships
    # currently exist.  The check for circular dependencies is currently
    # bypassed on other platforms, but is left enabled on iOS, where a violation
    # of the rule causes Xcode to misbehave badly.
    # TODO(mark): Find and kill remaining circular dependencies, and remove this
    # option.  http://crbug.com/35878.
    # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the
    # list.
    if gyp_vars_dict.get('OS') != 'ios':
        args.append('--no-circular-check')

    # libtool on Mac warns about duplicate basenames in static libraries, so
    # they're disallowed in general by gyp. We are lax on this point, so disable
    # this check other than on Mac. GN does not use static libraries as heavily,
    # so over time this restriction will mostly go away anyway, even on Mac.
    # https://code.google.com/p/gyp/issues/detail?id=384
    if sys.platform != 'darwin':
        args.append('--no-duplicate-basename-check')

    # We explicitly don't support the make gyp generator (crbug.com/348686). Be
    # nice and fail here, rather than choking in gyp.
    if re.search(r'(^|,|\s)make($|,|\s)', os.environ.get('GYP_GENERATORS',
                                                         '')):
        print 'Error: make gyp generator not supported (check GYP_GENERATORS).'
        sys.exit(1)

    # We explicitly don't support the native msvs gyp generator. Be nice and
    # fail here, rather than generating broken projects.
    if re.search(r'(^|,|\s)msvs($|,|\s)', os.environ.get('GYP_GENERATORS',
                                                         '')):
        print 'Error: msvs gyp generator not supported (check GYP_GENERATORS).'
        print 'Did you mean to use the `msvs-ninja` generator?'
        sys.exit(1)

    # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check
    # to enfore syntax checking.
    syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK')
    if syntax_check and int(syntax_check):
        args.append('--check')

    # TODO(dmikurube): Remove these checks and messages after a while.
    if ('linux_use_tcmalloc' in gyp_vars_dict
            or 'android_use_tcmalloc' in gyp_vars_dict):
        print '*****************************************************************'
        print '"linux_use_tcmalloc" and "android_use_tcmalloc" are deprecated!'
        print '-----------------------------------------------------------------'
        print 'You specify "linux_use_tcmalloc" or "android_use_tcmalloc" in'
        print 'your GYP_DEFINES. Please switch them into "use_allocator" now.'
        print 'See http://crbug.com/345554 for the details.'
        print '*****************************************************************'

    # Automatically turn on crosscompile support for platforms that need it.
    # (The Chrome OS build sets CC_host / CC_target which implicitly enables
    # this mode.)
    if all(('ninja' in os.environ.get('GYP_GENERATORS',
                                      ''), gyp_vars_dict.get('OS')
            in ['android', 'ios'], 'GYP_CROSSCOMPILE' not in os.environ)):
        os.environ['GYP_CROSSCOMPILE'] = '1'
    if gyp_vars_dict.get('OS') == 'android':
        args.append('--check')

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

    args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()])

    if not use_analyzer:
        print 'Updating projects from gyp files...'
        sys.stdout.flush()

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

    if not use_analyzer:
        vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs(
        )
        if vs2013_runtime_dll_dirs:
            x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
            vs_toolchain.CopyVsRuntimeDlls(
                os.path.join(chrome_src, GetOutputDirectory()),
                (x86_runtime, x64_runtime))

    sys.exit(gyp_rc)
Exemple #13
0
#!/usr/bin/env python
# Copyright (c) 2015, the Dartino project authors.  Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

import os
import sys

script_dir = os.path.dirname(os.path.realpath(__file__))
dartino_src = os.path.abspath(os.path.join(script_dir, os.pardir))

assert os.path.exists(os.path.join(dartino_src, 'third_party', 'gyp', 'pylib'))
sys.path.append(os.path.join(dartino_src, 'third_party', 'gyp', 'pylib'))
import gyp

sys.path.append(os.path.join(dartino_src, 'tools', 'vs_dependency'))
import vs_toolchain

vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()

gyp_rc = gyp.script_main()

# TODO(herhut): Make the below work for dartino once compilation works.
if vs2013_runtime_dll_dirs:
    x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
    vs_toolchain.CopyVsRuntimeDlls(os.path.join(dartino_src, "out"),
                                   (x86_runtime, x64_runtime))

sys.exit(gyp_rc)
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

import subprocess
import sys

import vs_toolchain
# vs_toolchain adds gyp to sys.path.
import gyp.MSVSVersion

if len(sys.argv) < 2:
    print >> sys.stderr, "Usage: vs_env.py TARGET_ARCH CMD..."
    sys.exit(1)

target_arch = sys.argv[1]
cmd = sys.argv[2:]

vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
vs_version = gyp.MSVSVersion.SelectVisualStudioVersion()

# Using shell=True is somewhat ugly, but the alternative is to pull in a copy
# of the Chromium GN build's setup_toolchain.py which runs the setup script,
# then 'set', and then parses the environment variables out. (GYP internally
# does the same thing.)
sys.exit(
    subprocess.call(vs_version.SetupScript(target_arch) + ["&&"] + cmd,
                    shell=True))