[infra] Migrate scripts to python3

* Migrate to python3; drop python support.
* Update Windows toolchain support.
* Remove some unused methods.
* Python 2.7 is still needed on Windows.
* Update gsutil to a version that supports python3.

Fixes: https://github.com/dart-lang/sdk/issues/28793

TEST=Manually tested common user journeys.

Change-Id: I663a22b237a548bb82dc2e601e399e3bc3649211
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192182
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
Alexander Thomas 2021-04-15 10:10:20 +00:00
parent d84f359786
commit b5c63ce757
127 changed files with 821 additions and 768 deletions

3
.gn
View file

@ -12,3 +12,6 @@ buildconfig = "//build/config/BUILDCONFIG.gn"
# GN build files are placed when they can not be placed directly
# in the source tree, e.g. for third party source trees.
secondary_source = "//build/secondary/"
# Override the default script executable to always be python3.
script_executable = "python3"

53
DEPS
View file

@ -268,8 +268,8 @@ deps = {
Var("dart_root") + "/third_party/gsutil": {
"packages": [{
"package": "infra/gsutil",
"version": "version:4.34",
"package": "infra/3pp/tools/gsutil",
"version": "version:4.58",
}],
"dep_type": "cipd",
},
@ -672,59 +672,56 @@ hooks = [
# Pull Debian sysroot for i386 Linux
'name': 'sysroot_i386',
'pattern': '.',
'action': ['python', 'sdk/build/linux/sysroot_scripts/install-sysroot.py',
'action': ['python3', 'sdk/build/linux/sysroot_scripts/install-sysroot.py',
'--arch', 'i386'],
},
{
# Pull Debian sysroot for amd64 Linux
'name': 'sysroot_amd64',
'pattern': '.',
'action': ['python', 'sdk/build/linux/sysroot_scripts/install-sysroot.py',
'action': ['python3', 'sdk/build/linux/sysroot_scripts/install-sysroot.py',
'--arch', 'amd64'],
},
{
# Pull Debian sysroot for arm Linux
'name': 'sysroot_amd64',
'pattern': '.',
'action': ['python', 'sdk/build/linux/sysroot_scripts/install-sysroot.py',
'action': ['python3', 'sdk/build/linux/sysroot_scripts/install-sysroot.py',
'--arch', 'arm'],
},
{
# Pull Debian jessie sysroot for arm64 Linux
'name': 'sysroot_amd64',
'pattern': '.',
'action': ['python', 'sdk/build/linux/sysroot_scripts/install-sysroot.py',
'action': ['python3', 'sdk/build/linux/sysroot_scripts/install-sysroot.py',
'--arch', 'arm64'],
},
{
'name': 'buildtools',
'pattern': '.',
'action': ['python', 'sdk/tools/buildtools/update.py'],
'action': ['python3', 'sdk/tools/buildtools/update.py'],
},
{
# Update the Windows toolchain if necessary.
'name': 'win_toolchain',
'pattern': '.',
'action': ['python', 'sdk/build/vs_toolchain.py', 'update'],
'action': ['python3', 'sdk/build/vs_toolchain.py', 'update'],
'condition': 'checkout_win'
},
{
"name": "7zip",
"pattern": ".",
"action": [
"download_from_google_storage",
"--no_auth",
"--no_resume",
"--bucket",
"dart-dependencies",
"--platform=win32",
"--extract",
"-s",
Var('dart_root') + "/third_party/7zip.tar.gz.sha1",
],
'condition': 'checkout_win'
},
]
hooks_os = {
"win": [
{
"name": "7zip",
"pattern": ".",
"action": [
"download_from_google_storage",
"--no_auth",
"--no_resume",
"--bucket",
"dart-dependencies",
"--platform=win32",
"--extract",
"-s",
Var('dart_root') + "/third_party/7zip.tar.gz.sha1",
],
},
]
}

View file

@ -34,7 +34,7 @@ from optparse import OptionParser
# success. This allows us to "kind of emulate" a Linux build from other
# platforms.
if sys.platform.find("linux") == -1:
print "[[],[],[],[],[]]"
print("[[],[],[],[],[]]")
sys.exit(0)
@ -50,7 +50,7 @@ def SetConfigPath(options):
# Compute the library path name based on the architecture.
arch = options.arch
if sysroot and not arch:
print "You must specify an architecture via -a if using a sysroot."
print("You must specify an architecture via -a if using a sysroot.")
sys.exit(1)
if arch == 'x64':
libpath = 'lib64'
@ -138,9 +138,9 @@ if options.atleast_version:
[options.pkg_config, "--atleast-version=" + options.atleast_version] +
args,
env=os.environ):
print "true"
print("true")
else:
print "false"
print("false")
sys.exit(0)
if options.libdir:
@ -148,7 +148,7 @@ if options.libdir:
libdir = subprocess.check_output(
[options.pkg_config, "--variable=libdir"] + args, env=os.environ)
except:
print "Error from pkg-config."
print("Error from pkg-config.")
sys.exit(1)
sys.stdout.write(libdir.strip())
sys.exit(0)
@ -163,7 +163,7 @@ try:
# to happen in practice.
all_flags = flag_string.strip().split(' ')
except:
print "Could not run pkg-config."
print("Could not run pkg-config.")
sys.exit(1)
sysroot = options.sysroot
@ -199,4 +199,4 @@ for flag in all_flags[:]:
# Output a GN array, the first one is the cflags, the second are the libs. The
# JSON formatter prints GN compatible lists when everything is a list of
# strings.
print json.dumps([includes, cflags, libs, lib_dirs, ldflags])
print(json.dumps([includes, cflags, libs, lib_dirs, ldflags]))

View file

@ -12,9 +12,10 @@ import subprocess
import sys
if len(sys.argv) != 3:
print "Need two arguments"
print("Need two arguments")
sys.exit(1)
result = subprocess.check_output([sys.argv[1], sys.argv[2]]).strip()
result = subprocess.check_output([sys.argv[1], sys.argv[2]],
universal_newlines=True).strip()
print '"' + result + '"'
print('"' + result + '"')

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -48,4 +48,4 @@ def DoMain(_):
if __name__ == '__main__':
print DoMain([])
print(DoMain([]))

View file

@ -1,11 +1,11 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Helper script for GN to run an arbitrary binary. See compiled_action.gni.
Run with:
python gn_run_binary.py <invoker> <binary_name> [args ...]
python3 gn_run_binary.py <invoker> <binary_name> [args ...]
Where <invoker> is either "compiled_action" or "exec_script". If it is
"compiled_action" the script has a non-zero exit code on a failure. If it is
@ -21,7 +21,9 @@ import subprocess
# Run a command, swallowing the output unless there is an error.
def run_command(command):
try:
subprocess.check_output(command, stderr=subprocess.STDOUT)
subprocess.check_output(command,
stderr=subprocess.STDOUT,
universal_newlines=True)
return 0
except subprocess.CalledProcessError as e:
return ("Command failed: " + ' '.join(command) + "\n" + "output: " +

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -17,14 +17,12 @@
import hashlib
import json
import platform
import optparse
import os
import re
import shutil
import subprocess
import sys
import urllib2
from urllib.request import urlopen
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.dirname(os.path.dirname(SCRIPT_DIR)))
@ -87,7 +85,7 @@ def main(args):
return 0
if not options.arch:
print 'You much specify either --arch or --running-as-hook'
print('You much specify either --arch or --running-as-hook')
return 1
InstallDefaultSysrootForArch(options.arch)
@ -134,18 +132,18 @@ def InstallSysroot(target_platform, target_arch):
if s.read() == url:
return
print 'Installing Debian %s %s root image: %s' % \
(target_platform, target_arch, sysroot)
print('Installing Debian %s %s root image: %s' % \
(target_platform, target_arch, sysroot))
if os.path.isdir(sysroot):
shutil.rmtree(sysroot)
os.mkdir(sysroot)
tarball = os.path.join(sysroot, tarball_filename)
print 'Downloading %s' % url
print('Downloading %s' % url)
sys.stdout.flush()
sys.stderr.flush()
for _ in range(3):
try:
response = urllib2.urlopen(url)
response = urlopen(url)
with open(tarball, "wb") as f:
f.write(response.read())
break

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -6,7 +6,7 @@
given minimum sdk version to standard output.
Usage:
python find_sdk.py 10.6 # Ignores SDKs < 10.6
python3 find_sdk.py 10.6 # Ignores SDKs < 10.6
"""
import os
@ -54,7 +54,7 @@ def CreateSymlinkForSDKAt(src, dst):
def parse_version(version_str):
"""'10.6' => [10, 6]"""
return map(int, re.findall(r'(\d+)', version_str))
return list(map(int, re.findall(r'(\d+)', version_str)))
def main():
@ -90,11 +90,12 @@ def main():
job = subprocess.Popen(['xcode-select', '-print-path'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stderr=subprocess.STDOUT,
universal_newlines=True)
out, err = job.communicate()
if job.returncode != 0:
print >> sys.stderr, out
print >> sys.stderr, err
print(out, file=sys.stderr)
print(err, file=sys.stderr)
raise Exception((
'Error %d running xcode-select, you might have to run '
'|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
@ -119,27 +120,26 @@ def main():
best_sdk = sorted(sdks, key=parse_version)[0]
if options.verify and best_sdk != min_sdk_version and not options.sdk_path:
print >> sys.stderr, ''
print >> sys.stderr, ' vvvvvvv'
print >> sys.stderr, ''
print >> sys.stderr, \
'This build requires the %s SDK, but it was not found on your system.' \
% min_sdk_version
print >> sys.stderr, \
'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.'
print >> sys.stderr, ''
print >> sys.stderr, ' ^^^^^^^'
print >> sys.stderr, ''
print('''
vvvvvvv
This build requires the %s SDK, but it was not found on your system.
Either install it, or explicitly set mac_sdk in your GYP_DEFINES.
^^^^^^^'
''' % min_sdk_version,
file=sys.stderr)
return min_sdk_version
if options.print_sdk_path:
sdk_path = subprocess.check_output(
['xcodebuild', '-version', '-sdk', 'macosx' + best_sdk,
'Path']).strip()
['xcodebuild', '-version', '-sdk', 'macosx' + best_sdk, 'Path'],
universal_newlines=True).strip()
if options.create_symlink_at:
print CreateSymlinkForSDKAt(sdk_path, options.create_symlink_at)
print(CreateSymlinkForSDKAt(sdk_path, options.create_symlink_at))
else:
print sdk_path
print(sdk_path)
return best_sdk
@ -147,4 +147,4 @@ def main():
if __name__ == '__main__':
if sys.platform != 'darwin':
raise Exception("This script only runs on Mac")
print main()
print(main())

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
@ -68,7 +68,8 @@ def _AddVersionKeys(plist, version=None):
if version:
match = re.match('\d+\.\d+\.(\d+\.\d+)$', version)
if not match:
print >> sys.stderr, 'Invalid version string specified: "%s"' % version
print('Invalid version string specified: "%s"' % version,
file=sys.stderr)
return False
full_version = match.group(0)
@ -129,7 +130,8 @@ def _DoSCMKeys(plist, add_keys):
if scm_revision != None:
plist['SCMRevision'] = scm_revision
elif add_keys:
print >> sys.stderr, 'Could not determine SCM revision. This may be OK.'
print('Could not determine SCM revision. This may be OK.',
file=sys.stderr)
return True
@ -162,9 +164,9 @@ def _TagSuffixes():
components_len = len(components)
combinations = 1 << components_len
tag_suffixes = []
for combination in xrange(0, combinations):
for combination in range(0, combinations):
tag_suffix = ''
for component_index in xrange(0, components_len):
for component_index in range(0, components_len):
if combination & (1 << component_index):
tag_suffix += '-' + components[component_index]
tag_suffixes.append(tag_suffix)
@ -248,7 +250,7 @@ def Main(argv):
(options, args) = parser.parse_args(argv)
if len(args) > 0:
print >> sys.stderr, parser.get_usage()
print(parser.get_usage(), file=sys.stderr)
return 1
# Read the plist into its parsed format.
@ -263,7 +265,7 @@ def Main(argv):
# Add Breakpad if configured to do so.
if options.use_breakpad:
if options.branding is None:
print >> sys.stderr, 'Use of Breakpad requires branding.'
print('Use of Breakpad requires branding.', file=sys.stderr)
return 1
_AddBreakpadKeys(plist, options.branding)
if options.breakpad_uploads:
@ -282,7 +284,7 @@ def Main(argv):
# Only add Keystone in Release builds.
if options.use_keystone and env['CONFIGURATION'] == 'Release':
if options.bundle_identifier is None:
print >> sys.stderr, 'Use of Keystone requires the bundle id.'
print('Use of Keystone requires the bundle id.', file=sys.stderr)
return 1
_AddKeystoneKeys(plist, options.bundle_identifier)
else:

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -15,9 +15,9 @@ def run(cmd):
bindir = os.path.dirname(cmd[0]);
env = os.environ
if 'PATH' in env:
env['PATH'] += os.pathsep + bindir
env['PATH'] += os.pathsep + bindir
else:
env['PATH'] = bindir
env['PATH'] = bindir
out = ''
err = ''
proc = subprocess.Popen(
@ -29,7 +29,7 @@ def run(cmd):
err += stderr
proc.poll()
if proc.returncode == 0:
return 0
return 0
print(out)
print(err)
return proc.returncode

View file

@ -36,7 +36,7 @@ def GetDefaultConcurrentLinks():
stat = MEMORYSTATUSEX(dwLength=ctypes.sizeof(MEMORYSTATUSEX))
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
mem_limit = max(1, stat.ullTotalPhys / (4 * (2**30))) # total / 4GB
mem_limit = max(1, stat.ullTotalPhys // (4 * (2**30))) # total / 4GB
hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32)))
return min(mem_limit, hard_cap)
elif sys.platform.startswith('linux'):
@ -48,7 +48,7 @@ def GetDefaultConcurrentLinks():
if not match:
continue
# Allow 8Gb per link on Linux because Gold is quite memory hungry
return max(1, int(match.group(1)) / (8 * (2**20)))
return max(1, int(match.group(1)) // (8 * (2**20)))
return 1
elif sys.platform == 'darwin':
try:
@ -56,7 +56,7 @@ def GetDefaultConcurrentLinks():
subprocess.check_output(['sysctl', '-n', 'hw.memsize']))
# A static library debug build of Chromium's unit_tests takes ~2.7GB, so
# 4GB per ld process allows for some more bloat.
return max(1, avail_bytes / (4 * (2**30))) # total / 4GB
return max(1, avail_bytes // (4 * (2**30))) # total / 4GB
except Exception:
return 1
else:
@ -64,4 +64,4 @@ def GetDefaultConcurrentLinks():
return 1
print GetDefaultConcurrentLinks()
print(GetDefaultConcurrentLinks())

View file

@ -26,7 +26,9 @@ toolchain_data = exec_script("setup_toolchain.py",
visual_studio_path,
windows_sdk_path,
visual_studio_runtime_dirs,
"win",
current_cpu,
"environment." + current_cpu,
],
"scope")

View file

@ -10,7 +10,8 @@
# win tool. The script assumes that the root build directory is the current dir
# and the files will be written to the current directory.
import errno
from __future__ import print_function
import json
import os
import re
@ -22,20 +23,25 @@ import gn_helpers
SCRIPT_DIR = os.path.dirname(__file__)
def _ExtractImportantEnvironment(output_of_set):
"""Extracts environment variables required for the toolchain to run from
a textual dump output by the cmd.exe 'set' command."""
envvars_to_save = (
'cipd_cache_dir', # needed by vpython
'homedrive', # needed by vpython
'homepath', # needed by vpython
'goma_.*', # TODO(scottmg): This is ugly, but needed for goma.
'include',
'lib',
'libpath',
'luci_context', # needed by vpython
'path',
'pathext',
'systemroot',
'temp',
'tmp',
'userprofile', # needed by vpython
'vpython_virtualenv_root' # needed by vpython
)
env = {}
# This occasionally happens and leads to misleading SYSTEMROOT error messages
@ -52,7 +58,7 @@ def _ExtractImportantEnvironment(output_of_set):
# path when ninja is run later, python will still be found.
setting = os.path.dirname(
sys.executable) + os.pathsep + setting
env[var.upper()] = setting.lower()
env[var.upper()] = setting
break
if sys.platform in ('win32', 'cygwin'):
for required in ('SYSTEMROOT', 'TEMP', 'TMP'):
@ -63,7 +69,7 @@ def _ExtractImportantEnvironment(output_of_set):
def _DetectVisualStudioPath():
"""Return path to the GYP_MSVS_VERSION of Visual Studio.
"""Return path to the installed Visual Studio.
"""
# Use the code in build/vs_toolchain.py to avoid duplicating code.
@ -77,31 +83,36 @@ def _LoadEnvFromBat(args):
"""Given a bat command, runs it and returns env vars set by it."""
args = args[:]
args.extend(('&&', 'set'))
popen = subprocess.Popen(
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
popen = subprocess.Popen(args,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
variables, _ = popen.communicate()
if popen.returncode != 0:
raise Exception('"%s" failed with error %d' % (args, popen.returncode))
return variables
return variables.decode(errors='ignore')
def _LoadToolchainEnv(cpu, sdk_dir):
def _LoadToolchainEnv(cpu, toolchain_root, sdk_dir, target_store):
"""Returns a dictionary with environment variables that must be set while
running binaries from the toolchain (e.g. INCLUDE and PATH for cl.exe)."""
# Check if we are running in the SDK command line environment and use
# the setup script from the SDK if so. |cpu| should be either
# 'x86' or 'x64'.
assert cpu in ('x86', 'x64')
# 'x86' or 'x64' or 'arm' or 'arm64'.
assert cpu in ('x86', 'x64', 'arm', 'arm64')
if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir:
# Load environment from json file.
env = os.path.normpath(
os.path.join(sdk_dir, 'bin/SetEnv.%s.json' % cpu))
env = os.path.normpath(os.path.join(sdk_dir,
'bin/SetEnv.%s.json' % cpu))
env = json.load(open(env))['env']
if env['VSINSTALLDIR'] == [["..", "..\\"]]:
# Old-style paths were relative to the win_sdk\bin directory.
json_relative_dir = os.path.join(sdk_dir, 'bin')
else:
# New-style paths are relative to the toolchain directory.
json_relative_dir = toolchain_root
for k in env:
entries = [
os.path.join(*([os.path.join(sdk_dir, 'bin')] + e))
for e in env[k]
]
entries = [os.path.join(*([json_relative_dir] + e)) for e in env[k]]
# clang-cl wants INCLUDE to be ;-separated even on non-Windows,
# lld-link wants LIB to be ;-separated even on non-Windows. Path gets :.
# The separator for INCLUDE here must match the one used in main() below.
@ -122,8 +133,11 @@ def _LoadToolchainEnv(cpu, sdk_dir):
# Check that the json file contained the same environment as the .cmd file.
if sys.platform in ('win32', 'cygwin'):
script = os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.cmd'))
assert _ExtractImportantEnvironment(variables) == \
_ExtractImportantEnvironment(_LoadEnvFromBat([script, '/' + cpu]))
arg = '/' + cpu
json_env = _ExtractImportantEnvironment(variables)
cmd_env = _ExtractImportantEnvironment(
_LoadEnvFromBat([script, arg]))
assert _LowercaseDict(json_env) == _LowercaseDict(cmd_env)
else:
if 'GYP_MSVS_OVERRIDE_PATH' not in os.environ:
os.environ['GYP_MSVS_OVERRIDE_PATH'] = _DetectVisualStudioPath()
@ -134,9 +148,16 @@ def _LoadToolchainEnv(cpu, sdk_dir):
if not os.path.exists(script_path):
# vcvarsall.bat for VS 2017 fails if run after running vcvarsall.bat from
# VS 2013 or VS 2015. Fix this by clearing the vsinstalldir environment
# variable.
# variable. Since vcvarsall.bat appends to the INCLUDE, LIB, and LIBPATH
# environment variables we need to clear those to avoid getting double
# entries when vcvarsall.bat has been run before gn gen. vcvarsall.bat
# also adds to PATH, but there is no clean way of clearing that and it
# doesn't seem to cause problems.
if 'VSINSTALLDIR' in os.environ:
del os.environ['VSINSTALLDIR']
del os.environ['INCLUDE']
del os.environ['LIB']
del os.environ['LIBPATH']
other_path = os.path.normpath(
os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'],
'VC/Auxiliary/Build/vcvarsall.bat'))
@ -145,9 +166,21 @@ def _LoadToolchainEnv(cpu, sdk_dir):
'%s is missing - make sure VC++ tools are installed.' %
script_path)
script_path = other_path
# Chromium requires the 10.0.14393.0 SDK or higher - previous versions don't
# have all of the required declarations.
args = [script_path, 'amd64_x86' if cpu == 'x86' else 'amd64']
cpu_arg = "amd64"
if (cpu != 'x64'):
# x64 is default target CPU thus any other CPU requires a target set
cpu_arg += '_' + cpu
args = [
script_path,
cpu_arg,
]
# Store target must come before any SDK version declaration
if (target_store):
args.append('store')
# Explicitly specifying the SDK version to build with to avoid accidentally
# building with a new and untested SDK. This should stay in sync with the
# packaged toolchain in build/vs_toolchain.py.
args.append('10.0.19041.0')
variables = _LoadEnvFromBat(args)
return _ExtractImportantEnvironment(variables)
@ -158,68 +191,137 @@ def _FormatAsEnvironmentBlock(envvar_dict):
CreateProcess documentation for more details."""
block = ''
nul = '\0'
for key, value in envvar_dict.iteritems():
for key, value in envvar_dict.items():
block += key + '=' + value + nul
block += nul
return block
def _LowercaseDict(d):
"""Returns a copy of `d` with both key and values lowercased.
Args:
d: dict to lowercase (e.g. {'A': 'BcD'}).
Returns:
A dict with both keys and values lowercased (e.g.: {'a': 'bcd'}).
"""
return {k.lower(): d[k].lower() for k in d}
def FindFileInEnvList(env, env_name, separator, file_name, optional=False):
parts = env[env_name].split(separator)
for path in parts:
if os.path.exists(os.path.join(path, file_name)):
return os.path.realpath(path)
assert optional, "%s is not found in %s:\n%s\nCheck if it is installed." % (
file_name, env_name, '\n'.join(parts))
return ''
def main():
if len(sys.argv) != 5:
if len(sys.argv) != 7:
print('Usage setup_toolchain.py '
'<visual studio path> <win sdk path> '
'<runtime dirs> <target_cpu> <include prefix>')
'<runtime dirs> <target_os> <target_cpu> '
'<environment block name|none>')
sys.exit(2)
# toolchain_root and win_sdk_path are only read if the hermetic Windows
# toolchain is set, that is if DEPOT_TOOLS_WIN_TOOLCHAIN is not set to 0.
# With the hermetic Windows toolchain, the visual studio path in argv[1]
# is the root of the Windows toolchain directory.
toolchain_root = sys.argv[1]
win_sdk_path = sys.argv[2]
runtime_dirs = sys.argv[3]
target_cpu = sys.argv[4]
cpus = ('x86', 'x64')
runtime_dirs = sys.argv[3]
target_os = sys.argv[4]
target_cpu = sys.argv[5]
environment_block_name = sys.argv[6]
if (environment_block_name == 'none'):
environment_block_name = ''
if (target_os == 'winuwp'):
target_store = True
else:
target_store = False
cpus = ('x86', 'x64', 'arm', 'arm64')
assert target_cpu in cpus
vc_bin_dir = ''
vc_lib_path = ''
vc_lib_atlmfc_path = ''
vc_lib_um_path = ''
include = ''
lib = ''
# TODO(scottmg|goma): Do we need an equivalent of
# ninja_use_custom_environment_files?
for cpu in cpus:
# Extract environment variables for subprocesses.
env = _LoadToolchainEnv(cpu, win_sdk_path)
env['PATH'] = runtime_dirs + os.pathsep + env['PATH']
def relflag(
s): # Make s relative to builddir when cwd and sdk on same drive.
try:
return os.path.relpath(s)
except ValueError:
return s
def q(s): # Quote s if it contains spaces or other weird characters.
return s if re.match(r'^[a-zA-Z0-9._/\\:-]*$', s) else '"' + s + '"'
for cpu in cpus:
if cpu == target_cpu:
for path in env['PATH'].split(os.pathsep):
if os.path.exists(os.path.join(path, 'cl.exe')):
vc_bin_dir = os.path.realpath(path)
break
# Extract environment variables for subprocesses.
env = _LoadToolchainEnv(cpu, toolchain_root, win_sdk_path,
target_store)
env['PATH'] = runtime_dirs + os.pathsep + env['PATH']
vc_bin_dir = FindFileInEnvList(env, 'PATH', os.pathsep, 'cl.exe')
vc_lib_path = FindFileInEnvList(env, 'LIB', ';', 'msvcrt.lib')
vc_lib_atlmfc_path = FindFileInEnvList(env,
'LIB',
';',
'atls.lib',
optional=True)
vc_lib_um_path = FindFileInEnvList(env, 'LIB', ';', 'user32.lib')
# The separator for INCLUDE here must match the one used in
# _LoadToolchainEnv() above.
include = [
p.replace('"', r'\"') for p in env['INCLUDE'].split(';') if p
]
include_I = ' '.join(['"/I' + i + '"' for i in include])
include_imsvc = ' '.join(['"-imsvc' + i + '"' for i in include])
include = list(map(relflag, include))
env_block = _FormatAsEnvironmentBlock(env)
with open('environment.' + cpu, 'wb') as f:
f.write(env_block)
lib = [p.replace('"', r'\"') for p in env['LIB'].split(';') if p]
lib = list(map(relflag, lib))
# Create a store app version of the environment.
if 'LIB' in env:
env['LIB'] = env['LIB'].replace(r'\VC\LIB', r'\VC\LIB\STORE')
if 'LIBPATH' in env:
env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB',
r'\VC\LIB\STORE')
env_block = _FormatAsEnvironmentBlock(env)
with open('environment.winrt_' + cpu, 'wb') as f:
f.write(env_block)
include_I = ' '.join([q('/I' + i) for i in include])
include_imsvc = ' '.join([q('-imsvc' + i) for i in include])
libpath_flags = ' '.join([q('-libpath:' + i) for i in lib])
assert vc_bin_dir
print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir)
if (environment_block_name != ''):
env_block = _FormatAsEnvironmentBlock(env)
with open(environment_block_name, 'w') as f:
f.write(env_block)
print('vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir))
assert include_I
print 'include_flags_I = ' + gn_helpers.ToGNString(include_I)
print('include_flags_I = ' + gn_helpers.ToGNString(include_I))
assert include_imsvc
print 'include_flags_imsvc = ' + gn_helpers.ToGNString(include_imsvc)
if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN',
1))) and win_sdk_path:
print('include_flags_imsvc = ' +
gn_helpers.ToGNString(q('/winsysroot' + relflag(toolchain_root))))
else:
print('include_flags_imsvc = ' + gn_helpers.ToGNString(include_imsvc))
print('vc_lib_path = ' + gn_helpers.ToGNString(vc_lib_path))
# Possible atlmfc library path gets introduced in the future for store thus
# output result if a result exists.
if (vc_lib_atlmfc_path != ''):
print('vc_lib_atlmfc_path = ' +
gn_helpers.ToGNString(vc_lib_atlmfc_path))
print('vc_lib_um_path = ' + gn_helpers.ToGNString(vc_lib_um_path))
print('paths = ' + gn_helpers.ToGNString(env['PATH']))
assert libpath_flags
print('libpath_flags = ' + gn_helpers.ToGNString(libpath_flags))
if __name__ == '__main__':

View file

@ -12,7 +12,6 @@ import re
import shutil
import subprocess
import stat
import string
import sys
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
@ -137,19 +136,19 @@ class WinTool(object):
# Popen(['/bin/sh', '-c', args[0], args[1], ...])"
# For that reason, since going through the shell doesn't seem necessary on
# non-Windows don't do that there.
link = subprocess.Popen(
args,
shell=sys.platform == 'win32',
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
link = subprocess.Popen(args,
shell=sys.platform == 'win32',
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
# Read output one line at a time as it shows up to avoid OOM failures when
# GBs of output is produced.
for line in link.stdout:
if (not line.startswith(' Creating library ') and
not line.startswith('Generating code') and
not line.startswith('Finished generating code')):
print line,
print(line)
return link.wait()
def ExecMidlWrapper(self, arch, outdir, tlb, h, dlldata, iid, proxy, idl,
@ -162,12 +161,12 @@ class WinTool(object):
iid, '/proxy', proxy, idl
]
env = self._GetEnv(arch)
popen = subprocess.Popen(
args,
shell=True,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
popen = subprocess.Popen(args,
shell=True,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
out, _ = popen.communicate()
# Filter junk out of stdout, and write filtered versions. Output we want
# to filter is pairs of lines that look like this:
@ -179,18 +178,18 @@ class WinTool(object):
os.path.basename(x) for x in lines if x.startswith(prefixes))
for line in lines:
if not line.startswith(prefixes) and line not in processing:
print line
print(line)
return popen.returncode
def ExecAsmWrapper(self, arch, *args):
"""Filter logo banner from invocations of asm.exe."""
env = self._GetEnv(arch)
popen = subprocess.Popen(
args,
shell=True,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
popen = subprocess.Popen(args,
shell=True,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
out, _ = popen.communicate()
for line in out.splitlines():
# Split to avoid triggering license checks:
@ -198,26 +197,26 @@ class WinTool(object):
') Microsoft Corporation') and
not line.startswith('Microsoft (R) Macro Assembler') and
not line.startswith(' Assembling: ') and line):
print line
print(line)
return popen.returncode
def ExecRcWrapper(self, arch, *args):
"""Filter logo banner from invocations of rc.exe. Older versions of RC
don't support the /nologo flag."""
env = self._GetEnv(arch)
popen = subprocess.Popen(
args,
shell=True,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
popen = subprocess.Popen(args,
shell=True,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
out, _ = popen.communicate()
for line in out.splitlines():
if (not line.startswith(
'Microsoft (R) Windows (R) Resource Compiler') and
not line.startswith('Copy' + 'right (C' +
') Microsoft Corporation') and line):
print line
print(line)
return popen.returncode
def ExecActionWrapper(self, arch, rspfile, *dirname):

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -27,18 +27,44 @@ import sys
from gn_helpers import ToGNString
# VS 2019 16.61 with 10.0.19041 SDK, and 10.0.17134 version of
# d3dcompiler_47.dll, with ARM64 libraries and UWP support.
# See go/chromium-msvc-toolchain for instructions about how to update the
# toolchain.
#
# When updating the toolchain, consider the following areas impacted by the
# toolchain version:
#
# * //base/win/windows_version.cc NTDDI preprocessor check
# Triggers a compiler error if the available SDK is older than the minimum.
# * //build/config/win/BUILD.gn NTDDI_VERSION value
# Affects the availability of APIs in the toolchain headers.
# * //docs/windows_build_instructions.md mentions of VS or Windows SDK.
# Keeps the document consistent with the toolchain version.
TOOLCHAIN_HASH = '20d5f2553f'
script_dir = os.path.dirname(os.path.realpath(__file__))
chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(chrome_src, 'tools'))
dart_src = os.path.abspath(os.path.join(script_dir, os.pardir))
sys.path.insert(0, os.path.join(dart_src, 'tools'))
json_data_file = os.path.join(script_dir, 'win_toolchain.json')
# VS versions are listed in descending order of priority (highest first).
MSVS_VERSIONS = collections.OrderedDict([
('2017', '15.0'),
('2019', '16.0'),
('2017', '15.0'),
])
# List of preferred VC toolset version based on MSVS
MSVC_TOOLSET_VERSION = {
'2019': 'VC142',
'2017': 'VC141',
}
def _HostIsWindows():
"""Returns True if running on a Windows host (including under cygwin)."""
return sys.platform in ('win32', 'cygwin')
def SetEnvironmentAndGetRuntimeDllDirs():
"""Sets up os.environ to use the depot_tools VS toolchain with gyp, and
@ -54,24 +80,22 @@ def SetEnvironmentAndGetRuntimeDllDirs():
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
# When running on a non-Windows host, only do this if the SDK has explicitly
# been downloaded before (in which case json_data_file will exist).
if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file))
and depot_tools_win_toolchain):
if ((_HostIsWindows() or os.path.exists(json_data_file)) and
depot_tools_win_toolchain):
if ShouldUpdateToolchain():
if len(sys.argv) > 1 and sys.argv[1] == 'update':
update_result = Update()
else:
update_result = Update(no_download=True)
if update_result != 0:
raise Exception(
'Failed to update, error code %d.' % update_result)
raise Exception('Failed to update, error code %d.' %
update_result)
with open(json_data_file, 'r') as tempf:
toolchain_data = json.load(tempf)
toolchain = toolchain_data['path']
version = toolchain_data['version']
win_sdk = toolchain_data.get('win_sdk')
if not win_sdk:
win_sdk = toolchain_data['win8sdk']
wdk = toolchain_data['wdk']
# TODO(scottmg): The order unfortunately matters in these. They should be
# split into separate keys for x64/x86/arm64. (See CopyDlls call below).
@ -84,7 +108,6 @@ def SetEnvironmentAndGetRuntimeDllDirs():
vs_runtime_dll_dirs.append('Arm64Unused')
os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
os.environ['GYP_MSVS_VERSION'] = version
os.environ['WINDOWSSDKDIR'] = win_sdk
os.environ['WDK_DIR'] = wdk
@ -94,8 +117,6 @@ def SetEnvironmentAndGetRuntimeDllDirs():
elif sys.platform == 'win32' and not depot_tools_win_toolchain:
if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath()
if not 'GYP_MSVS_VERSION' in os.environ:
os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
# When using an installed toolchain these files aren't needed in the output
# directory in order to run binaries locally, but they are needed in order
@ -146,12 +167,7 @@ def _RegistryGetValue(key, value):
def GetVisualStudioVersion():
"""Return best available version of Visual Studio.
"""
env_version = os.environ.get('GYP_MSVS_VERSION')
if env_version:
return env_version
supported_versions = MSVS_VERSIONS.keys()
supported_versions = list(MSVS_VERSIONS.keys())
# VS installed in depot_tools for Googlers
if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))):
@ -162,13 +178,23 @@ def GetVisualStudioVersion():
'{} ({})'.format(v, k) for k, v in MSVS_VERSIONS.items())
available_versions = []
for version in supported_versions:
for path in (
os.environ.get('vs%s_install' % version),
os.path.expandvars('%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s' % version)):
if path and os.path.exists(path):
available_versions.append(version)
break
# Checking vs%s_install environment variables.
# For example, vs2019_install could have the value
# "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community".
# Only vs2017_install and vs2019_install are supported.
path = os.environ.get('vs%s_install' % version)
if path and os.path.exists(path):
available_versions.append(version)
break
# Detecting VS under possible paths.
path = os.path.expandvars('%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s' % version)
if path and any(
os.path.exists(os.path.join(path, edition))
for edition in ('Enterprise', 'Professional', 'Community',
'Preview', 'BuildTools')):
available_versions.append(version)
break
if not available_versions:
raise Exception('No supported Visual Studio can be found.'
@ -177,7 +203,7 @@ def GetVisualStudioVersion():
def DetectVisualStudioPath():
"""Return path to the GYP_MSVS_VERSION of Visual Studio.
"""Return path to the installed Visual Studio.
"""
# Note that this code is used from
@ -188,25 +214,26 @@ def DetectVisualStudioPath():
# the registry. For details see:
# https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
# For now we use a hardcoded default with an environment variable override.
for path in (
os.environ.get('vs%s_install' % version_as_year),
os.path.expandvars(
'%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/Enterprise' % version_as_year),
os.path.expandvars(
'%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/Professional' % version_as_year),
os.path.expandvars(
'%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/Community' % version_as_year),
os.path.expandvars(
'%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/Preview' % version_as_year)):
for path in (os.environ.get('vs%s_install' % version_as_year),
os.path.expandvars('%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/Enterprise' %
version_as_year),
os.path.expandvars('%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/Professional' %
version_as_year),
os.path.expandvars('%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/Community' %
version_as_year),
os.path.expandvars('%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/Preview' %
version_as_year),
os.path.expandvars('%ProgramFiles(x86)%' +
'/Microsoft Visual Studio/%s/BuildTools' %
version_as_year)):
if path and os.path.exists(path):
return path
raise Exception('Visual Studio Version %s (from GYP_MSVS_VERSION)'
' not found.' % version_as_year)
raise Exception('Visual Studio Version %s not found.' % version_as_year)
def _CopyRuntimeImpl(target, source, verbose=True):
@ -251,21 +278,28 @@ def _SortByHighestVersionNumberFirst(list_of_str_versions):
list_of_str_versions.sort(key=to_number_sequence, reverse=True)
def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix):
def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, suffix):
"""Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
exist, but the target directory does exist."""
if target_cpu == 'arm64':
# Windows ARM64 VCRuntime is located at {toolchain_root}/VC/Redist/MSVC/
# {x.y.z}/[debug_nonredist/]arm64/Microsoft.VC141.CRT/.
# {x.y.z}/[debug_nonredist/]arm64/Microsoft.VC14x.CRT/.
# Select VC toolset directory based on Visual Studio version
vc_redist_root = FindVCRedistRoot()
if suffix.startswith('.'):
source_dir = os.path.join(vc_redist_root, 'arm64',
'Microsoft.VC141.CRT')
vc_toolset_dir = 'Microsoft.{}.CRT' \
.format(MSVC_TOOLSET_VERSION[GetVisualStudioVersion()])
source_dir = os.path.join(vc_redist_root, 'arm64', vc_toolset_dir)
else:
vc_toolset_dir = 'Microsoft.{}.DebugCRT' \
.format(MSVC_TOOLSET_VERSION[GetVisualStudioVersion()])
source_dir = os.path.join(vc_redist_root, 'debug_nonredist',
'arm64', 'Microsoft.VC141.DebugCRT')
for file_part in ('msvcp', 'vccorlib', 'vcruntime'):
dll = dll_pattern % file_part
'arm64', vc_toolset_dir)
file_parts = ('msvcp140', 'vccorlib140', 'vcruntime140')
if target_cpu == 'x64' and GetVisualStudioVersion() != '2017':
file_parts = file_parts + ('vcruntime140_1',)
for file_part in file_parts:
dll = file_part + suffix
target = os.path.join(target_dir, dll)
source = os.path.join(source_dir, dll)
_CopyRuntimeImpl(target, source)
@ -301,22 +335,19 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix):
if not suffix.startswith('.'):
# ucrtbased.dll is located at {win_sdk_dir}/bin/{a.b.c.d}/{target_cpu}/
# ucrt/.
sdk_redist_root = os.path.join(win_sdk_dir, 'bin')
sdk_bin_sub_dirs = os.listdir(sdk_redist_root)
sdk_bin_root = os.path.join(win_sdk_dir, 'bin')
sdk_bin_sub_dirs = glob.glob(os.path.join(sdk_bin_root, '10.*'))
# Select the most recent SDK if there are multiple versions installed.
_SortByHighestVersionNumberFirst(sdk_bin_sub_dirs)
for directory in sdk_bin_sub_dirs:
sdk_redist_root_version = os.path.join(sdk_redist_root,
directory)
sdk_redist_root_version = os.path.join(sdk_bin_root, directory)
if not os.path.isdir(sdk_redist_root_version):
continue
if re.match(r'10\.\d+\.\d+\.\d+', directory):
source_dir = os.path.join(sdk_redist_root_version,
target_cpu, 'ucrt')
break
_CopyRuntimeImpl(
os.path.join(target_dir, 'ucrtbase' + suffix),
os.path.join(source_dir, 'ucrtbase' + suffix))
source_dir = os.path.join(sdk_redist_root_version, target_cpu,
'ucrt')
break
_CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
os.path.join(source_dir, 'ucrtbase' + suffix))
def FindVCComponentRoot(component):
@ -330,14 +361,13 @@ def FindVCComponentRoot(component):
assert ('GYP_MSVS_OVERRIDE_PATH' in os.environ)
vc_component_msvc_root = os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'],
'VC', component, 'MSVC')
vc_component_msvc_contents = os.listdir(vc_component_msvc_root)
vc_component_msvc_contents = glob.glob(
os.path.join(vc_component_msvc_root, '14.*'))
# Select the most recent toolchain if there are several.
_SortByHighestVersionNumberFirst(vc_component_msvc_contents)
for directory in vc_component_msvc_contents:
if not os.path.isdir(os.path.join(vc_component_msvc_root, directory)):
continue
if re.match(r'14\.\d+\.\d+', directory):
return os.path.join(vc_component_msvc_root, directory)
if os.path.isdir(directory):
return directory
raise Exception('Unable to find the VC %s directory.' % component)
@ -355,8 +385,7 @@ def _CopyRuntime(target_dir, source_dir, target_cpu, debug):
directory does exist. Handles VS 2015, 2017 and 2019."""
suffix = 'd.dll' if debug else '.dll'
# VS 2015, 2017 and 2019 use the same CRT DLLs.
_CopyUCRTRuntime(target_dir, source_dir, target_cpu, '%s140' + suffix,
suffix)
_CopyUCRTRuntime(target_dir, source_dir, target_cpu, suffix)
def CopyDlls(target_dir, configuration, target_cpu):
@ -407,6 +436,10 @@ def _CopyDebugger(target_dir, target_cpu):
# List of debug files that should be copied, the first element of the tuple is
# the name of the file and the second indicates if it's optional.
debug_files = [('dbghelp.dll', False), ('dbgcore.dll', True)]
# The UCRT is not a redistributable component on arm64.
if target_cpu != 'arm64':
debug_files.extend([('api-ms-win-downlevel-kernel32-l2-1-0.dll', False),
('api-ms-win-eventing-provider-l1-1-0.dll', False)])
for debug_file, is_optional in debug_files:
full_path = os.path.join(win_sdk_dir, 'Debuggers', target_cpu,
debug_file)
@ -414,11 +447,11 @@ def _CopyDebugger(target_dir, target_cpu):
if is_optional:
continue
else:
# TODO(crbug.com/773476): remove version requirement.
raise Exception(
'%s not found in "%s"\r\nYou must install the '
'"Debugging Tools for Windows" feature from the Windows'
' 10 SDK.' % (debug_file, full_path))
'%s not found in "%s"\r\nYou must install'
'Windows 10 SDK version 10.0.19041.0 including the '
'"Debugging Tools for Windows" feature.' %
(debug_file, full_path))
target_path = os.path.join(target_dir, debug_file)
_CopyRuntimeImpl(target_path, full_path)
@ -426,17 +459,10 @@ def _CopyDebugger(target_dir, target_cpu):
def _GetDesiredVsToolchainHashes():
"""Load a list of SHA1s corresponding to the toolchains that we want installed
to build with."""
env_version = GetVisualStudioVersion()
if env_version == '2017':
# VS 2017 Update 9 (15.9.12) with 10.0.18362 SDK, 10.0.17763 version of
# Debuggers, and 10.0.17134 version of d3dcompiler_47.dll, with ARM64
# libraries.
toolchain_hash = '418b3076791776573a815eb298c8aa590307af63'
# Third parties that do not have access to the canonical toolchain can map
# canonical toolchain version to their own toolchain versions.
toolchain_hash_mapping_key = 'GYP_MSVS_HASH_%s' % toolchain_hash
return [os.environ.get(toolchain_hash_mapping_key, toolchain_hash)]
raise Exception('Unsupported VS version %s' % env_version)
# Third parties that do not have access to the canonical toolchain can map
# canonical toolchain version to their own toolchain versions.
toolchain_hash_mapping_key = 'GYP_MSVS_HASH_%s' % TOOLCHAIN_HASH
return [os.environ.get(toolchain_hash_mapping_key, TOOLCHAIN_HASH)]
def ShouldUpdateToolchain():
@ -467,8 +493,7 @@ def Update(force=False, no_download=False):
depot_tools_win_toolchain = \
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
if ((sys.platform in ('win32', 'cygwin') or force) and
depot_tools_win_toolchain):
if (_HostIsWindows() or force) and depot_tools_win_toolchain:
import find_depot_tools
depot_tools_path = find_depot_tools.add_depot_tools_to_path()
@ -500,11 +525,9 @@ def Update(force=False, no_download=False):
toolchain_dir
])
# Necessary so that get_toolchain_if_necessary.py will put the VS toolkit
# in the correct directory.
os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
get_toolchain_args = [
sys.executable,
# TODO(athom): use sys.executable (python3).
'python',
os.path.join(depot_tools_path, 'win_toolchain',
'get_toolchain_if_necessary.py'),
'--output-json',

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -79,7 +79,7 @@ def main():
found_exports = set(master_mapping.values()) - set(found_exports)
# Sort the found exports for tidy output.
print '\n'.join(sorted(found_exports))
print('\n'.join(sorted(found_exports)))
return 0

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -7,4 +7,4 @@
import os
# Add more terminals here as needed.
print 'ANSICON' in os.environ
print('ANSICON' in os.environ)

View file

@ -44,7 +44,7 @@ if [[ $logfile == '' ]]; then
echo " Log file: $logfile"
# TODO: delete by default and stop logging the location of the file.
# delete=1
python tools/test.py -m release --checked --use-sdk \
python3 tools/test.py -m release --checked --use-sdk \
--vm-options="-DuseFastaParser=true" \
--print_passing_stdout \
pkg/analy > $logfile

View file

@ -18,7 +18,7 @@ String get dartVm => Platform.executable;
main(List<String> args) async {
ProcessResult result = await Process.run(
"python", ["tools/make_version.py", "--no_git", "-q"],
"python3", ["tools/make_version.py", "--no_git", "-q"],
workingDirectory: repoDir);
String stdout = result.stdout.toString();

View file

@ -71,7 +71,7 @@ final gsutilPool = Pool(math.max(1, Platform.numberOfProcessors ~/ 2));
Future<String> runGsutil(List<String> arguments) async {
return gsutilPool.withResource(() async {
var processResult = await Process.run(
"python", [gsutilPy]..addAll(arguments),
"python3", [gsutilPy]..addAll(arguments),
runInShell: Platform.isWindows);
var stderr = processResult.stderr as String;
if (processResult.exitCode != 0) {
@ -79,14 +79,14 @@ Future<String> runGsutil(List<String> arguments) async {
stderr.contains("One or more URLs matched no objects")) {
return null;
}
var error = "Failed to run: python $gsutilPy $arguments\n"
var error = "Failed to run: python3 $gsutilPy $arguments\n"
"exitCode: ${processResult.exitCode}\n"
"stdout:\n${processResult.stdout}\n"
"stderr:\n${processResult.stderr}";
if (processResult.exitCode == 1 &&
stderr.contains("401 Anonymous caller")) {
error =
"\n\nYou need to authenticate by running:\npython $gsutilPy config\n";
"\n\nYou need to authenticate by running:\npython3 $gsutilPy config\n";
}
throw Exception(error);
}

View file

@ -49,8 +49,8 @@ Future buildConfigurations(List<TestConfiguration> configurations) async {
...osFlags,
...buildTargets
];
print('Running command: python ${command.join(' ')}');
final process = await Process.start('python', command);
print('Running command: python3 ${command.join(' ')}');
final process = await Process.start('python3', command);
stdout.nonBlocking.addStream(process.stdout);
stderr.nonBlocking.addStream(process.stderr);
final exitCode = await process.exitCode;

View file

@ -77,9 +77,9 @@ void ensureBuild(Iterable<String> modes, Iterable<String> archs) {
'runtime'
];
print('Running: python ${args.join(" ")}');
print('Running: python3 ${args.join(" ")}');
var result = Process.runSync('python', args);
var result = Process.runSync('python3', args);
if (result.exitCode != 0) {
print('ERROR');
@ -149,7 +149,7 @@ void main(List<String> args) {
'--report-in-json',
'--use-sdk'
];
var result = Process.runSync('python', args);
var result = Process.runSync('python3', args);
if (result.exitCode != 0) {
print(result.stdout);
print(result.stderr);

View file

@ -622,7 +622,7 @@ void _writeFailureReproductionCommands(
if (Platform.isFuchsia) {
arguments = [Platform.executable, Platform.script.path];
} else {
arguments = ['python', 'tools/test.py'];
arguments = ['python3', 'tools/test.py'];
}
arguments.addAll(test.configuration.reproducingArguments);
arguments.add(test.displayName);

View file

@ -482,7 +482,7 @@ Future<void> runTests(List<String> args) async {
print("Running tests");
print("".padLeft(80, "="));
await runProcessInheritStdio(
"python",
"python3",
[
"tools/test.py",
"--named-configuration=${configurationsToRun.join(",")}",
@ -607,7 +607,7 @@ Future<void> deflake(Directory outDirectory, List<String> configurations,
];
await runProcessInheritStdio(
"python", ["tools/test.py", ...deflakeArguments],
"python3", ["tools/test.py", ...deflakeArguments],
runInShell: Platform.isWindows);
deflakingResultsPaths.add("${deflakeDirectory.path}/results.json");
}

View file

@ -46,7 +46,7 @@ Below is the result of running the file both without and with
`--dwarf-stack-traces` in a 64-bit Linux development environment:
```bash
$ python tools/build.py -a x64 -m release runtime_kernel runtime_precompiled
$ python3 tools/build.py -a x64 -m release runtime_kernel runtime_precompiled
$ pkg/vm/tool/gen_kernel --platform out/ReleaseX64/vm_platform_strong.dill -o throws.dill throws.dart

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -362,7 +362,7 @@ def CrunchStats(added, removed, changed, unchanged, showsources, showsymbols):
for section in sections:
allFiles = allFiles | section.sources
allFiles = allFiles | maybe_unchanged_sources
print 'Source stats:'
print('Source stats:')
print(' %d sources encountered.' % len(allFiles))
print(' %d completely new.' % len(new_sources))
print(' %d removed completely.' % len(removed_sources))
@ -374,7 +374,7 @@ def CrunchStats(added, removed, changed, unchanged, showsources, showsymbols):
if not showsources:
return # Per-source analysis, only if requested
print 'Per-source Analysis:'
print('Per-source Analysis:')
delta_by_path = {}
for section in sections:
for path in section.symbols_by_path:
@ -409,10 +409,10 @@ def CrunchStats(added, removed, changed, unchanged, showsources, showsymbols):
header = ' %s - Source: %s - (gained %d, lost %d)' % (DeltaStr(delta),
path, gain, loss)
divider = '-' * len(header)
print ''
print divider
print header
print divider
print('')
print(divider)
print(header)
print(divider)
if showsymbols:
def ExtractNewSize(tup):
@ -424,7 +424,7 @@ def CrunchStats(added, removed, changed, unchanged, showsources, showsymbols):
return symbol_delta.old_size
if path in new_symbols.symbols_by_path:
print ' New symbols:'
print(' New symbols:')
for symbol_name, symbol_type, symbol_delta in \
sorted(new_symbols.symbols_by_path[path],
key=ExtractNewSize,
@ -434,7 +434,7 @@ def CrunchStats(added, removed, changed, unchanged, showsources, showsymbols):
symbol_type, symbol_delta.new_size,
SharedInfoStr(symbol_delta)))
if path in removed_symbols.symbols_by_path:
print ' Removed symbols:'
print(' Removed symbols:')
for symbol_name, symbol_type, symbol_delta in \
sorted(removed_symbols.symbols_by_path[path],
key=ExtractOldSize):
@ -446,7 +446,7 @@ def CrunchStats(added, removed, changed, unchanged, showsources, showsymbols):
type_str) in [(grown_symbols.symbols_by_path, "Grown"),
(shrunk_symbols.symbols_by_path, "Shrunk")]:
if path in changed_symbols_by_path:
print ' %s symbols:' % type_str
print(' %s symbols:' % type_str)
def changed_symbol_sortkey(item):
symbol_name, _symbol_type, symbol_delta = item
@ -505,9 +505,9 @@ def main():
parser.error('--nm2 is required')
symbols = []
for path in [opts.nm1, opts.nm2]:
with file(path, 'r') as nm_input:
with open(path, 'r') as nm_input:
if opts.verbose:
print 'parsing ' + path + '...'
print('parsing ' + path + '...')
symbols.append(list(binary_size_utils.ParseNm(nm_input)))
(added, removed, changed, unchanged) = Compare(symbols[0], symbols[1])
CrunchStats(added, removed, changed, unchanged,

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -9,7 +9,6 @@ in the location of the library to be analyzed along with any other options
you desire.
"""
import collections
import json
import logging
import multiprocessing
@ -336,7 +335,7 @@ def RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs,
user_interrupted = True
print('Patience you must have my young padawan.')
print ''
print('')
if user_interrupted:
print('Skipping the rest of the file mapping. '
@ -379,9 +378,9 @@ def RunNm(binary, nm_binary):
if nm_process.returncode != 0:
if err_output:
raise Exception, err_output
raise Exception(err_output)
else:
raise Exception, process_output
raise Exception(process_output)
return process_output
@ -393,15 +392,15 @@ def GetNmSymbols(nm_infile, outfile, library, jobs, verbose, addr2line_binary,
outfile = tempfile.NamedTemporaryFile(delete=False).name
if verbose:
print 'Running parallel addr2line, dumping symbols to ' + outfile
print('Running parallel addr2line, dumping symbols to ' + outfile)
RunElfSymbolizer(outfile, library, addr2line_binary, nm_binary, jobs,
disambiguate, src_path)
nm_infile = outfile
elif verbose:
print 'Using nm input from ' + nm_infile
with file(nm_infile, 'r') as infile:
print('Using nm input from ' + nm_infile)
with open(nm_infile, 'r') as infile:
return list(binary_size_utils.ParseNm(infile))
@ -624,12 +623,12 @@ def main():
(not opts.nm_in)) or (opts.library and opts.nm_in):
parser.error('exactly one of --library or --nm-in is required')
if opts.nm_out:
print >> sys.stderr, (
'WARNING: --nm-out is deprecated and has no effect.')
print('WARNING: --nm-out is deprecated and has no effect.',
file=sys.stderr)
if (opts.nm_in):
if opts.jobs:
print >> sys.stderr, ('WARNING: --jobs has no effect '
'when used with --nm-in')
print('WARNING: --jobs has no effect when used with --nm-in',
file=sys.stderr)
if not opts.destdir:
parser.error('--destdir is a required argument')
if not opts.jobs:
@ -666,7 +665,7 @@ def main():
# Prepare output directory and report guts
if not os.path.exists(opts.destdir):
os.makedirs(opts.destdir, 0755)
os.makedirs(opts.destdir, 0o755)
nm_out = os.path.join(opts.destdir, 'nm.out')
if opts.no_nm_out:
nm_out = None
@ -677,7 +676,7 @@ def main():
data_js_file_name = os.path.join(opts.destdir, 'data.js')
d3_out = os.path.join(opts.destdir, 'd3')
if not os.path.exists(d3_out):
os.makedirs(d3_out, 0755)
os.makedirs(d3_out, 0o755)
d3_src = os.path.join(os.path.dirname(__file__), '..', '..', 'd3', 'src')
template_src = os.path.join(os.path.dirname(__file__), 'template')
shutil.copy(os.path.join(d3_src, 'LICENSE'), d3_out)
@ -701,7 +700,7 @@ def main():
symbol_path_origin_dir = os.path.abspath(os.getcwd())
# Dump JSON for the HTML report.
DumpCompactTree(symbols, symbol_path_origin_dir, data_js_file_name)
print 'Report saved to ' + opts.destdir + '/index.html'
print('Report saved to ' + opts.destdir + '/index.html')
if __name__ == '__main__':

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -36,7 +36,8 @@ def GetBenchmarkFile(path):
def ReadBenchmarkList(mode, path, core):
filename = GetBenchmarkFile([path])
benchmarks = dict()
execfile(filename, benchmarks)
with open(filename) as infile:
exec(infile.read(), benchmarks)
if (mode == "release") and not core:
return benchmarks['SUPPORTED_BENCHMARKS']
else:
@ -91,11 +92,11 @@ def ProcessOptions(options):
options.arch = options.arch.split(',')
for mode in options.mode:
if not mode in ['debug', 'release']:
print "Unknown mode %s" % mode
print("Unknown mode %s" % mode)
return False
for arch in options.arch:
if not arch in ['ia32', 'x64', 'simarm', 'arm', 'dartc']:
print "Unknown arch %s" % arch
print("Unknown arch %s" % arch)
return False
return True
@ -138,7 +139,7 @@ def Main():
GetBenchmarkFile([benchmark, 'dart', benchmark + '.dart']),
]
if options.verbose:
print ' '.join(command)
print(' '.join(command))
subprocess.call(command)
return 0

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -54,8 +54,8 @@ FILE_HEADER_FLAGS = FILE_HEADER_LNNO
# } SCNHDR;
SECTION_HEADER_FORMAT = '8sIIIIIIHHI'
SECTION_HEADER_SIZE = calcsize(SECTION_HEADER_FORMAT)
SECTION_NAME_RODATA = '.rodata'
SECTION_NAME_TEXT = '.text'
SECTION_NAME_RODATA = b'.rodata'
SECTION_NAME_TEXT = b'.text'
SECTION_PADDR = 0x0
SECTION_VADDR = 0x0
SECTION_RAW_DATA_PTR = (
@ -130,13 +130,13 @@ def main():
includes_size_name = (args.size_name != None)
# Symbols on x86 are prefixed with '_'
symbol_prefix = '' if args.use_64_bit else '_'
symbol_prefix = b'' if args.use_64_bit else b'_'
num_symbols = 2 if includes_size_name else 1
symbol_name = symbol_prefix + args.symbol_name
symbol_name = symbol_prefix + args.symbol_name.encode()
size_symbol_name = None
if (includes_size_name):
size_symbol = args.size_name if args.size_name else args.symbol_name + "Size"
size_symbol_name = symbol_prefix + size_symbol
size_symbol_name = symbol_prefix + size_symbol.encode()
size_symbol_format = SIZE_SYMBOL_FORMAT_X64 if args.use_64_bit else SIZE_FORMAT
size_symbol_size = SIZE_SYMBOL_LENGTH_X64 if args.use_64_bit else SIZE_LENGTH
@ -237,14 +237,14 @@ def main():
symbol_len = len(symbol_name)
buff[offset:offset + symbol_len] = symbol_name
offset += symbol_len
buff[offset] = '\0'
buff[offset] = b'\0'
offset += 1
if includes_size_name and long_size_symbol_name:
symbol_len = len(size_symbol_name)
buff[offset:offset + symbol_len] = size_symbol_name
offset += symbol_len
buff[offset] = '\0'
buff[offset] = b'\0'
offset += 1
with open(args.output, 'wb') as f:

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -127,6 +127,6 @@ def DoCheck(sdk_root):
if __name__ == '__main__':
errors = DoCheck('.')
print '\n'.join(errors)
print('\n'.join(errors))
if errors:
sys.exit(-1)

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2015, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -75,6 +75,6 @@ def DoCheck(sdk_root):
if __name__ == '__main__':
errors = DoCheck('.')
print '\n'.join(errors)
print('\n'.join(errors))
if errors:
sys.exit(-1)

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2013, the Dart 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.

View file

@ -5,17 +5,17 @@
# This file contains a set of utilities functions used by other Python-based
# scripts.
import commands
import os
import platform
import Queue
import queue
import re
import StringIO
import subprocess
import sys
import threading
import time
from io import StringIO
from subprocess import getoutput
# Try to guess the host operating system.
def GuessOS():
@ -55,11 +55,11 @@ def GuessArchitecture():
def GuessCpus():
if os.path.exists("/proc/cpuinfo"):
return int(
commands.getoutput(
getoutput(
"GREP_OPTIONS= grep -E '^processor' /proc/cpuinfo | wc -l"))
if os.path.exists("/usr/bin/hostinfo"):
return int(
commands.getoutput(
getoutput(
'/usr/bin/hostinfo | GREP_OPTIONS= grep "processors are logically available." | awk "{ print \$1 }"'
))
win_cpu_count = os.getenv("NUMBER_OF_PROCESSORS")
@ -197,14 +197,14 @@ def RunCommand(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError as e:
if not isinstance(command, basestring):
if not isinstance(command, str):
command = ' '.join(command)
if printErrorInfo:
sys.stderr.write("Command failed: '%s'\n" % command)
raise Error(e)
def StartThread(out):
queue = Queue.Queue()
queue = queue.Queue()
def EnqueueOutput(out, queue):
for line in iter(out.readline, b''):
@ -226,7 +226,7 @@ def RunCommand(command,
out.write(line)
if out2 != None:
out2.write(line)
except Queue.Empty:
except queue.Empty:
pass
outBuf = StringIO.StringIO()
@ -252,7 +252,7 @@ def RunCommand(command,
out = outBuf.getvalue()
error = errorBuf.getvalue()
if returncode:
if not isinstance(command, basestring):
if not isinstance(command, str):
command = ' '.join(command)
if printErrorInfo:
sys.stderr.write("Command failed: '%s'\n" % command)
@ -266,10 +266,10 @@ def RunCommand(command,
def Main(argv):
print "GuessOS() -> ", GuessOS()
print "GuessArchitecture() -> ", GuessArchitecture()
print "GuessCpus() -> ", GuessCpus()
print "IsWindows() -> ", IsWindows()
print("GuessOS() -> ", GuessOS())
print("GuessArchitecture() -> ", GuessArchitecture())
print("GuessCpus() -> ", GuessCpus())
print("IsWindows() -> ", IsWindows())
class Error(Exception):

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
#
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -18,7 +18,7 @@
for UI development using something like: <pre>file:///Users/jimhug/dart-all/dart/samples/swarm/swarm.html</pre>.</p>
<p>When you are ready to test your new UI on this live server, first you
need to run <pre>python update.py</pre> from your
need to run <pre>python3 update.py</pre> from your
<pre>dart/samples/swarm</pre> directory. This will build
both a self-contained html file for both js and dart code. Then,
use the link below to upload your files to this server. If you are

View file

@ -2,7 +2,7 @@
# 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.
#!/usr/bin/env python
#!/usr/bin/env python3
#
import re, base64, logging, pickle, httplib2, time, urlparse, urllib2, urllib, StringIO, gzip, zipfile

View file

@ -2,7 +2,7 @@
# 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.
#!/usr/bin/env python
#!/usr/bin/env python3
#
# This script builds a Chrome App file (.crx) for Swarm
@ -65,14 +65,14 @@ def main():
dartiumResult = createChromeApp(buildRoot, 'build_dart_app', 'swarm.crx')
dartCResult = createChromeApp(buildRoot, 'build_js_app', 'swarm-js.crx')
print '''
print('''
Successfully created Chrome apps!
Dartium: file://%s
DartC/JS: file://%s
To install, open this URL in Chrome and select Continue at the bottom.
''' % (dartiumResult, dartCResult)
''' % (dartiumResult, dartCResult))
return 0

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.
@ -28,9 +28,9 @@ def convertImgs(infile):
infile,
verbose=options.verbose,
encode_images=options.inline_images)
print 'Converted ' + infile
except BaseException, e:
print 'Caught error: %s' % e
print('Converted ' + infile)
except BaseException as e:
print('Caught error: %s' % e)
def Flags():
@ -53,13 +53,13 @@ def main():
global options
parser = Flags()
options, args = parser.parse_args()
print "args: %s" % args
print("args: %s" % args)
if len(args) < 1 or 'help' in args[0]:
print 'Usage: %s DIRECTORY' % basename(sys.argv[0])
print('Usage: %s DIRECTORY' % basename(sys.argv[0]))
return 1
dirname = args[0]
print 'Searching directory ' + dirname
print('Searching directory ' + dirname)
files = []
for root, dirs, fnames in os.walk(dirname):

View file

@ -2,7 +2,7 @@
# 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.
#!/usr/bin/python2.6
#!/usr/bin/env python3
#
"""
Usage: gen_manifest.py DIRECTORY EXTENSIONS CACHE-FILE HTML-FILES...
@ -30,7 +30,7 @@ manifestName = sys.argv[3]
htmlFiles = sys.argv[4:]
os.chdir(cacheDir)
print "Generating manifest from root path: " + cacheDir
print("Generating manifest from root path: " + cacheDir)
patterns = extensions + htmlFiles
@ -68,7 +68,7 @@ manifest.append("*")
with open(manifestName, 'w') as f:
f.writelines(m + '\n' for m in manifest)
print "Created manifest file: " + manifestName
print("Created manifest file: " + manifestName)
for htmlFile in htmlFiles:
cachedHtmlFile = htmlFile.replace('.html', '-cache.html')
@ -76,6 +76,6 @@ for htmlFile in htmlFiles:
text = text.replace('<html>', '<html manifest="%s">' % manifestName, 1)
with open(cachedHtmlFile, 'w') as output:
output.write(text)
print "Processed html file: %s -> %s" % (htmlFile, cachedHtmlFile)
print("Processed html file: %s -> %s" % (htmlFile, cachedHtmlFile))
print "Successfully generated manifest and html files"
print("Successfully generated manifest and html files")

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.
@ -24,7 +24,7 @@ import htmlconverter
def convertOne(infile, options):
outDirBase = 'outcode'
outfile = join(outDirBase, infile)
print 'converting %s to %s' % (infile, outfile)
print('converting %s to %s' % (infile, outfile))
if 'dart' in options.target:
htmlconverter.convertForDartium(infile, outDirBase,

View file

@ -5,7 +5,7 @@
# Note: if you edit this file, you must also generate libraries.json in this
# directory:
#
# python ./tools/yaml2json.py sdk/lib/libraries.yaml sdk/lib/libraries.json
# python3 ./tools/yaml2json.py sdk/lib/libraries.yaml sdk/lib/libraries.json
#
# We currently have several different files that needs to be updated when
# changing libraries, sources, and patch files. See

View file

@ -5,7 +5,7 @@
# Note: if you edit this file, you must also edit libraries.json in this
# directory:
#
# python ./tools/yaml2json.py sdk/lib/vmservice_libraries.yaml sdk/lib/vmservice_libraries.json
# python3 ./tools/yaml2json.py sdk/lib/vmservice_libraries.yaml sdk/lib/vmservice_libraries.json
#
# We currently have several different files that needs to be updated when
# changing libraries, sources, and patch files. See

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -7,8 +7,6 @@
import hashlib
import imp
import os
import platform
import string
import subprocess
import sys
@ -176,7 +174,7 @@ class GCSNamerApiDocs(object):
def run(command, env=None, shell=False, throw_on_error=True):
print "Running command: ", command
print("Running command: ", command)
p = subprocess.Popen(
command,
@ -186,10 +184,11 @@ def run(command, env=None, shell=False, throw_on_error=True):
shell=shell)
(stdout, stderr) = p.communicate()
if throw_on_error and p.returncode != 0:
print >> sys.stderr, "Failed to execute '%s'. Exit code: %s." % (
command, p.returncode)
print >> sys.stderr, "stdout: ", stdout
print >> sys.stderr, "stderr: ", stderr
print("Failed to execute '%s'. Exit code: %s." %
(command, p.returncode),
file=sys.stderr)
print("stdout: ", stdout, file=sys.stderr)
print("stderr: ", stderr, file=sys.stderr)
raise Exception("Failed to execute %s." % command)
return (stdout, stderr, p.returncode)
@ -307,7 +306,7 @@ def CreateMD5ChecksumFile(filename, mangled_filename=None):
with open(checksum_filename, 'w') as f:
f.write('%s *%s' % (checksum, mangled_filename))
print "MD5 checksum of %s is %s" % (filename, checksum)
print("MD5 checksum of %s is %s" % (filename, checksum))
return checksum_filename
@ -322,14 +321,14 @@ def CreateSha256ChecksumFile(filename, mangled_filename=None):
with open(checksum_filename, 'w') as f:
f.write('%s *%s' % (checksum, mangled_filename))
print "SHA256 checksum of %s is %s" % (filename, checksum)
print("SHA256 checksum of %s is %s" % (filename, checksum))
return checksum_filename
def GetChannelFromName(name):
"""Get the channel from the name. Bleeding edge builders don't
have a suffix."""
channel_name = string.split(name, '-').pop()
channel_name = name.split('-').pop()
if channel_name in Channel.ALL_CHANNELS:
return channel_name
return Channel.BLEEDING_EDGE
@ -337,7 +336,7 @@ def GetChannelFromName(name):
def GetSystemFromName(name):
"""Get the system from the name."""
for part in string.split(name, '-'):
for part in name.split('-'):
if part in SYSTEM_RENAMES: return SYSTEM_RENAMES[part]
raise ValueError(

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -233,8 +233,8 @@ def DartArchiveFile(local_path, remote_path, checksum_files=False):
def Run(command, env=None):
print "Running %s" % ' '.join(command)
print "Environment %s" % env
print("Running %s" % ' '.join(command))
print("Environment %s" % env)
sys.stdout.flush()
exit_code = subprocess.call(command)
if exit_code != 0:

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -43,7 +43,7 @@ def CreateDartTestFile(tempdir):
def Run(command):
print "Running: %s" % ' '.join(command)
print("Running: %s" % ' '.join(command))
sys.stdout.flush()
no_color_env = dict(os.environ)
no_color_env['TERM'] = 'nocolor'
@ -59,11 +59,11 @@ def TestInstallation(assume_installed=True):
for path in paths:
if os.path.exists(path):
if not assume_installed:
print 'Assumed not installed, found %s' % path
print('Assumed not installed, found %s' % path)
sys.exit(1)
else:
if assume_installed:
print 'Assumed installed, but could not find %s' % path
print('Assumed installed, but could not find %s' % path)
sys.exit(1)
@ -77,23 +77,23 @@ def SrcSteps():
tarfilename = 'dart-%s.tar.gz' % version
tarfile = os.path.join(builddir, tarfilename)
print 'Validating that we are on debian jessie'
print('Validating that we are on debian jessie')
args = ['cat', '/etc/os-release']
(stdout, stderr, exitcode) = bot_utils.run(args)
if exitcode != 0:
print "Could not find linux system, exiting"
print("Could not find linux system, exiting")
sys.exit(1)
if not "jessie" in stdout:
print "Trying to build debian bits but not on debian Jessie"
print "You can't fix this, please contact dart-engprod@"
print("Trying to build debian bits but not on debian Jessie")
print("You can't fix this, please contact dart-engprod@")
sys.exit(1)
print 'Building src tarball'
print('Building src tarball')
Run([
sys.executable, './tools/create_tarball.py', '--tar_filename', tarfile
])
print 'Building Debian packages'
print('Building Debian packages')
Run([
sys.executable, './tools/create_debian_packages.py', '--tar_filename',
tarfile, '--out_dir', builddir
@ -101,7 +101,7 @@ def SrcSteps():
if os.path.exists('/usr/bin/dart') or os.path.exists(
'/usr/lib/dart/bin/dart2js'):
print "Dart already installed, removing"
print("Dart already installed, removing")
UninstallDart()
TestInstallation(assume_installed=False)

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2018, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -44,4 +44,4 @@ if __name__ == '__main__':
tarfile = os.path.join(builddir, tarfilename)
ArchiveArtifacts(tarfile, builddir, channel)
else:
print 'Not uploading artifacts on bleeding edge'
print('Not uploading artifacts on bleeding edge')

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -143,7 +143,7 @@ def EnsureGomaStarted(out_dir):
return False
goma_ctl = os.path.join(goma_dir, 'goma_ctl.py')
goma_ctl_command = [
'python',
'python3',
goma_ctl,
'ensure_start',
]

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2017 The Dart project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -27,9 +27,9 @@ def UpdateClangFormatOnWindows():
downloader_script = os.path.join(DEPOT_PATH,
'download_from_google_storage.py')
download_cmd = [
'python', downloader_script, '--no_auth', '--no_resume', '--quiet',
'--platform=win', '--bucket', 'chromium-clang-format', '-s', sha1_file,
'-o', output_dir
sys.executable, downloader_script, '--no_auth', '--no_resume',
'--quiet', '--platform=win', '--bucket', 'chromium-clang-format', '-s',
sha1_file, '-o', output_dir
]
return subprocess.call(download_cmd)
@ -37,7 +37,7 @@ def UpdateClangFormatOnWindows():
def CreateSymlink(symlink, link_name):
try:
os.symlink(symlink, link_name)
except OSError, e:
except OSError as e:
if e.errno == errno.EEXIST:
os.remove(link_name)
os.symlink(symlink, link_name)
@ -57,7 +57,7 @@ def LinksForGitCLFormat():
tools = 'linux64'
toolchain = 'linux-x64'
else:
print 'Unknown platform: ' + sys.platform
print('Unknown platform: ' + sys.platform)
return 1
clang_format = os.path.join(BUILDTOOLS, toolchain, 'clang', 'bin',

View file

@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.
@ -80,14 +80,14 @@ def mergefiles(srcs, dstfile):
def main(outdir=None, *inputs):
if not outdir or not inputs:
print "Usage: %s OUTDIR INPUTS" % sys.argv[0]
print " OUTDIR is the war directory to copy to"
print " INPUTS is a list of files or patterns used to specify the input"
print " .dart files"
print "This script should be run from the client root directory."
print "Files will be merged and copied to: OUTDIR/relative-path-of-file,"
print "except for dart files with absolute paths, which will be copied to"
print " OUTDIR/absolute-path-as-directories"
print("""Usage: %s OUTDIR INPUTS
OUTDIR is the war directory to copy to
INPUTS is a list of files or patterns used to specify the input
.dart files
This script should be run from the client root directory.
Files will be merged and copied to: OUTDIR/relative-path-of-file,
except for dart files with absolute paths, which will be copied to
OUTDIR/absolute-path-as-directories""" % sys.argv[0])
return 1
entry_libraries = []

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2017, the Dart 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.

View file

@ -72,7 +72,7 @@ debootstrap --arch=$ARCH --components=main,restricted,universe,multiverse \
jessie $CHROOT http://http.us.debian.org/debian/
chroot $CHROOT apt-get update
chroot $CHROOT apt-get -y install \
debhelper python git gcc sudo make
debhelper python3 git gcc sudo make
# Add chrome-bot user.
chroot $CHROOT groupadd --gid 1001 chrome-bot

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -59,7 +59,7 @@ def BuildDebianPackage(tarball, out_dir, arch, toolchain):
origtarname = 'dart_%s.orig.tar.gz' % version
if not exists(tarball):
print 'Source tarball not found'
print('Source tarball not found')
return -1
with utils.TempDir() as temp_dir:
@ -70,30 +70,30 @@ def BuildDebianPackage(tarball, out_dir, arch, toolchain):
tar.extractall(path=temp_dir)
# Build source package.
print "Building source package"
print("Building source package")
RunBuildPackage(['-S', '-us', '-uc'], join(temp_dir, tarroot))
# Build 32-bit binary package.
if 'ia32' in arch:
print "Building i386 package"
print("Building i386 package")
RunBuildPackage(['-B', '-ai386', '-us', '-uc'],
join(temp_dir, tarroot))
# Build 64-bit binary package.
if 'x64' in arch:
print "Building amd64 package"
print("Building amd64 package")
RunBuildPackage(['-B', '-aamd64', '-us', '-uc'],
join(temp_dir, tarroot))
# Build armhf binary package.
if 'armhf' in arch:
print "Building armhf package"
print("Building armhf package")
RunBuildPackage(['-B', '-aarmhf', '-us', '-uc'],
join(temp_dir, tarroot), toolchain)
# Build armel binary package.
if 'armel' in arch:
print "Building armel package"
print("Building armel package")
RunBuildPackage(['-B', '-aarmel', '-us', '-uc'],
join(temp_dir, tarroot), toolchain)
@ -127,7 +127,7 @@ def BuildDebianPackage(tarball, out_dir, arch, toolchain):
def Main():
if HOST_OS != 'linux':
print 'Debian build only supported on linux'
print('Debian build only supported on linux')
return -1
options, args = BuildOptions().parse_args()

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2016 The Dart project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -80,7 +80,7 @@ def Filter(tar_info):
# out-of-the-box.
tar_info.name = join(versiondir, 'dart', original_name)
if verbose:
print 'Adding %s as %s' % (original_name, tar_info.name)
print('Adding %s as %s' % (original_name, tar_info.name))
return tar_info
@ -129,7 +129,7 @@ def CreateTarball(tarfilename):
builddir = utils.GetBuildDir(HOST_OS)
ignoredPaths.append(builddir)
print 'Creating tarball: %s' % tarfilename
print('Creating tarball: %s' % tarfilename)
with tarfile.open(tarfilename, mode='w:gz') as tar:
for f in listdir(DART_DIR):
tar.add(join(DART_DIR, f), filter=Filter)
@ -165,7 +165,7 @@ def CreateTarball(tarfilename):
def Main():
if HOST_OS != 'linux':
print 'Tarball can only be created on linux'
print('Tarball can only be created on linux')
return -1
# Parse the options.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2013, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -172,14 +172,14 @@ def start_test_server(port, build_directory):
def call(args):
print ' '.join(args)
print(' '.join(args))
pipe = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = pipe.communicate()
if output:
print output
print(output)
if error:
print error
print(error)
return pipe.returncode

View file

@ -238,10 +238,9 @@ class CodeGeneratorDart(object):
world['callbacks'].append(idl_world['callback'])
idl_pickle_file.close()
world['interfaces'] = sorted(
world['interfaces'], key=lambda (x): x['name'])
world['callbacks'] = sorted(
world['callbacks'], key=lambda (x): x['name'])
world['interfaces'] = sorted(world['interfaces'],
key=lambda x: x['name'])
world['callbacks'] = sorted(world['callbacks'], key=lambda x: x['name'])
template_contents = world
template_contents['code_generator'] = module_pyname
@ -299,7 +298,7 @@ def main(argv):
cache_dir = argv[1]
dummy_filename = argv[2]
except IndexError as err:
print 'Usage: %s OUTPUT_DIR DUMMY_FILENAME' % argv[0]
print('Usage: %s OUTPUT_DIR DUMMY_FILENAME' % argv[0])
return 1
# Cache templates

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (C) 2014 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (C) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
#
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.
@ -96,8 +96,8 @@ def GenerateFromDatabase(common_database,
update_dom_metadata=False,
logging_level=logging.WARNING,
dart_js_interop=False):
print '\n ----- Accessing DOM using %s -----\n' % (
'dart:js' if dart_js_interop else 'C++')
print('\n ----- Accessing DOM using %s -----\n' %
('dart:js' if dart_js_interop else 'C++'))
start_time = time.time()
@ -130,8 +130,8 @@ def GenerateFromDatabase(common_database,
renamer = HtmlRenamer(webkit_database, metadata)
type_registry = TypeRegistry(webkit_database, renamer)
print 'GenerateFromDatabase %s seconds' % round(
(time.time() - start_time), 2)
print('GenerateFromDatabase %s seconds' % round(
(time.time() - start_time), 2))
def RunGenerator(dart_libraries, dart_output_dir, template_loader,
backend_factory, dart_js_interop):
@ -178,14 +178,14 @@ def GenerateFromDatabase(common_database,
if file.endswith('darttemplate'):
dart_libraries._libraries['html'].AddFile(file)
print '\nGenerating dart2js:\n'
print('\nGenerating dart2js:\n')
start_time = time.time()
RunGenerator(dart_libraries, dart_output_dir, template_loader,
backend_factory, dart_js_interop)
print 'Generated dart2js in %s seconds' % round(
time.time() - start_time, 2)
print('Generated dart2js in %s seconds' %
round(time.time() - start_time, 2))
emitters.Flush()
@ -351,13 +351,13 @@ def main():
source, os.path.join('..', '..', '..', 'sdk', 'lib',
library_name, 'dart2js'))
print '\nGenerating single file %s seconds' % round(
time.time() - file_generation_start_time, 2)
print('\nGenerating single file %s seconds' %
round(time.time() - file_generation_start_time, 2))
end_time = time.time()
print '\nDone (dartdomgenerator) %s seconds' % round(
end_time - start_time, 2)
print('\nDone (dartdomgenerator) %s seconds' %
round(end_time - start_time, 2))
if __name__ == '__main__':

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2012, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2012, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2012, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.
@ -306,7 +306,7 @@ class Database(object):
if type_def_name in self._all_type_defs:
raise RuntimeError('Typedef %s already exists' % type_def_name)
self._all_type_defs[type_def_name] = type_def
print ' Added typedef %s' % type_def_name
print(' Added typedef %s' % type_def_name)
def TransitiveSecondaryParents(self, interface, propagate_event_target):
"""Returns a list of all non-primary parents.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.
@ -92,11 +92,11 @@ def _compile_idl_file(build, file_name, import_options):
idl_definition = build.idl_compiler.compile_file(idl_file_fullpath)
return idl_definition
except Exception as err:
print 'ERROR: idl_compiler.py: ' + os.path.basename(file_name)
print err
print
print 'Stack Dump:'
print format_exception(err)
print('ERROR: idl_compiler.py: ' + os.path.basename(file_name))
print(err)
print()
print('Stack Dump:')
print(format_exception(err))
return 1
@ -110,11 +110,11 @@ def _load_idl_file(build, file_name, import_options):
idl_definition = new_asts[name]
return IDLFile(idl_definition, file_name)
except Exception as err:
print 'ERROR: loading AST from cache: ' + os.path.basename(file_name)
print err
print
print 'Stack Dump:'
print format_exception(err)
print('ERROR: loading AST from cache: ' + os.path.basename(file_name))
print(err)
print()
print('Stack Dump:')
print(format_exception(err))
return 1
@ -159,11 +159,11 @@ class Build():
idl_file_fullpath = os.path.realpath(idl_file)
self.idl_compiler.compile_file(idl_file_fullpath)
except Exception as err:
print 'ERROR: idl_compiler.py: ' + os.path.basename(idl_file)
print err
print
print 'Stack Dump:'
print self.format_exception(err)
print('ERROR: idl_compiler.py: ' + os.path.basename(idl_file))
print(err)
print()
print('Stack Dump:')
print(self.format_exception(err))
return 1
@ -593,8 +593,8 @@ class DatabaseBuilder(object):
self._info_collector.collect_info(file_path)
end_time = time.time()
print 'Compute dependencies %s seconds' % round(
(end_time - start_time), 2)
print('Compute dependencies %s seconds' % round(
(end_time - start_time), 2))
else:
# Compute the interface_info for dart.idl for implements defined. This
# file is special in that more than one interface can exist in this file.
@ -614,14 +614,14 @@ class DatabaseBuilder(object):
os.path.splitext(os.path.basename(file_path))[0], ast)
end_time = time.time()
print 'Compiled %s IDL files in %s seconds' % (
len(file_paths), round((end_time - start_time), 2))
print('Compiled %s IDL files in %s seconds' %
(len(file_paths), round((end_time - start_time), 2)))
def _process_ast(self, filename, ast):
if len(ast) == 1:
ast = ast.values()[0]
else:
print 'ERROR: Processing AST: ' + os.path.basename(file_name)
print('ERROR: Processing AST: ' + os.path.basename(file_name))
new_asts[filename] = ast
def import_idl_files(self, file_paths, import_options, is_dart_idl):
@ -642,8 +642,8 @@ class DatabaseBuilder(object):
for warning in report_unions_to_any():
_logger.warning(warning)
print 'Total %s files %sprocessed in databasebuilder in %s seconds' % \
(len(file_paths), '', round((end_time - start_time), 2))
print('Total %s files %sprocessed in databasebuilder in %s seconds' % \
(len(file_paths), '', round((end_time - start_time), 2)))
def _process_idl_file(self, idl_file, import_options, dart_idl=False):
# TODO(terry): strip_ext_attributes on an idl_file does nothing.
@ -862,27 +862,30 @@ class DatabaseBuilder(object):
# Report all interface marked with NoInterfaceObject and their usage.
self._output_examination(check_dictionaries=False)
print '\nKey:'
print ' (READ-ONLY) - read-only attribute has relationship'
print ' (GET/SET) - attribute has relationship'
print ' RETURN - operation\'s returned value has relationship'
print ' (ARGUMENT) - operation\'s argument(s) has relationship'
print ''
print ' (New) - After dictionary name if constructor(s) exist'
print ' (Ops,Props,New) after a NoInterfaceObject name is defined as:'
print ' Ops - number of operations for a NoInterfaceObject'
print ' Props - number of properties for a NoInterfaceObject'
print ' New - T(#) number constructors for a NoInterfaceObject'
print ' F no constructors for a NoInterfaceObject'
print ' e.g., an interface 5 operations, 3 properties and 2'
print ' constructors would display (5,3,T(2))'
print('''
Key:
(READ-ONLY) - read-only attribute has relationship
(GET/SET) - attribute has relationship
RETURN - operation\'s returned value has relationship
(ARGUMENT) - operation\'s argument(s) has relationship
print '\n\nExamination Complete\n'
(New) - After dictionary name if constructor(s) exist
(Ops,Props,New) after a NoInterfaceObject name is defined as:
Ops - number of operations for a NoInterfaceObject
Props - number of properties for a NoInterfaceObject
New - T(#) number constructors for a NoInterfaceObject
F no constructors for a NoInterfaceObject
e.g., an interface 5 operations, 3 properties and 2
constructors would display (5,3,T(2))
Examination Complete
''')
def _output_examination(self, check_dictionaries=True):
# Output diagnostics. First columns is Dictionary or NoInterfaceObject e.g.,
# | Dictionary | Used In Interface | Usage Operation/Attribute |
print '\n\n'
print('\n\n')
title_bar = ['Dictionary', 'Used In Interface', 'Usage Operation/Attribute'] if check_dictionaries \
else ['NoInterfaceObject (Ops,Props,New)', 'Used In Interface', 'Usage Operation/Attribute']
self._tabulate_title(title_bar)
@ -993,7 +996,8 @@ class DatabaseBuilder(object):
return
# If we get to this point, the IDL dictionary was never defined ... oops.
print 'DIAGNOSE_ERROR: IDL Dictionary %s doesn\'t exist.' % dictionary_id
print('DIAGNOSE_ERROR: IDL Dictionary %s doesn\'t exist.' %
dictionary_id)
# Iterator function to look for any IDLType that is an interface marked with
# NoInterfaceObject then remember that interface.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.
@ -155,7 +155,7 @@ def build_database(idl_files,
sorted(unknown_conditionals))
_logger.warning('Please update fremontcutbuilder.py')
print 'Merging interfaces %s seconds' % round(time.time() - start_time, 2)
print('Merging interfaces %s seconds' % round(time.time() - start_time, 2))
return db

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
#
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
@ -199,7 +199,7 @@ class Stats {
bool TRACK_STATS = true;
dumpStats() {
print("------------ STATS ----------------");
print(Blink_JsNative_DomException.getPropertyStats.toString());
print(Blink_JsNative_DomException.getPropertyStats.toString());
print(Blink_JsNative_DomException.setPropertyStats.toString());
print(Blink_JsNative_DomException.callMethodStats.toString());
print(Blink_JsNative_DomException.constructorStats.toString());
@ -209,8 +209,8 @@ dumpStats() {
clearStats() {
Blink_JsNative_DomException.getPropertyStats.clear();
Blink_JsNative_DomException.setPropertyStats.clear();
Blink_JsNative_DomException.callMethodStats.clear();
Blink_JsNative_DomException.constructorStats.clear();
Blink_JsNative_DomException.callMethodStats.clear();
Blink_JsNative_DomException.constructorStats.clear();
}
class Blink_JsNative_DomException {
@ -388,7 +388,7 @@ CLASS_DEFINITION_END = """}
def ConstantOutputOrder(a, b):
"""Canonical output ordering for constants."""
return cmp(a.id, b.id)
return (a.id > b.id) - (a.id < b.id)
def generate_parameter_entries(param_infos):
@ -617,8 +617,8 @@ def _Emit_Blink_Operation(blink_file, interface, analyzeOperations,
Select_Stub(OPERATION_2, is_native) % (name, interface.id,
name))
else:
print "FATAL ERROR: _blink emitter operator %s.%s" % (
interface.id, name)
print("FATAL ERROR: _blink emitter operator %s.%s" %
(interface.id, name))
exit
return

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2012, the Dart 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.
@ -937,7 +937,7 @@ class OperationInfo(object):
def ConstantOutputOrder(a, b):
"""Canonical output ordering for constants."""
return cmp(a.id, b.id)
return (a.id > b.id) - (a.id < b.id)
def _FormatNameList(names):
@ -2098,7 +2098,8 @@ class TypeRegistry(object):
# It's a typedef (implied union)
return self.TypeInfo('any')
else:
print "ERROR: Unexpected interface, or type not found. %s" % type_name
print("ERROR: Unexpected interface, or type not found. %s" %
type_name)
if 'Callback' in interface.ext_attrs:
return CallbackIDLTypeInfo(

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2012, the Dart 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.
@ -760,8 +760,9 @@ class HtmlDartGenerator(object):
if not (param_list.endswith(', mapArg') or
param_list.endswith(', options') or
param_list == mapArg):
print "ERROR: %s.%s - Last parameter or only parameter %s is not of type Map" % (
self._interface.id, html_name, mapArg)
print(
"ERROR: %s.%s - Last parameter or only parameter %s is not of type Map"
% (self._interface.id, html_name, mapArg))
param_list = '%s_dict' % param_list
if mapArgOptional:

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2012, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2012, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.
@ -81,7 +81,7 @@ class IDLNode(object):
('%s %s' % (self.id, extras)).strip(),
hash(self))
return '<%s %s 0x%x>' % (type(self).__name__, extras, hash(self))
except Exception, e:
except Exception as e:
return "can't convert to string: %s" % e
def _extra_repr(self):
@ -264,7 +264,7 @@ class IDLNode(object):
}
result = label_field.get(label)
if result != '' and not (result):
print 'FATAL ERROR: AST mapping name not found %s.' % label
print('FATAL ERROR: AST mapping name not found %s.' % label)
return result if result else ''
def _convert_all(self, ast, label, idlnode_ctor):
@ -708,7 +708,7 @@ class IDLType(IDLNode):
# should consider synthesizing a new interface (e.g., UnionType) that's
# both Type1 and Type2.
if not self.id:
print '>>>> __module__ %s' % ast.__module__
print('>>>> __module__ %s' % ast.__module__)
raise SyntaxError('Could not parse type %s' % (ast))
def _label_to_type(self, label, ast):

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -10,14 +10,14 @@
#
# To update all *.idl, *.py, LICENSE files, and IDLExtendedAttributes.txt:
# > cd sdk
# > python tools/dom/scripts/idlsync.py
# > python3 tools/dom/scripts/idlsync.py
#
# Display blink files to delete, copy, update, and collisions to review:
# > python tools/dom/scripts/idlsync.py --check
# > python3 tools/dom/scripts/idlsync.py --check
#
# Bring over all blink files to dart/third_party/WebCore (*.py, *.idl, and
# IDLExtendedAttributes.txt):
# > python tools/dom/scripts/idlsync.py
# > python3 tools/dom/scripts/idlsync.py
#
# Update the DEPS file SHA for "WebCore_rev" with the committed changes of files
# in WebCore e.g., "WebCore_rev": "@NNNNNNNNNNNNNNNNNNNNNNNNN"
@ -117,14 +117,14 @@ def chromiumDirectory():
def RunCommand(cmd, valid_exits=[0]):
"""Executes a shell command and return its stdout."""
if isVerbose():
print ' '.join(cmd)
print(' '.join(cmd))
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = pipe.communicate()
if pipe.returncode in valid_exits:
return output[0]
else:
print output[1]
print 'FAILED. RET_CODE=%d' % pipe.returncode
print(output[1])
print('FAILED. RET_CODE=%d' % pipe.returncode)
sys.exit(pipe.returncode)
@ -298,7 +298,8 @@ def ValidateGitRemotes():
remotes_list[1] == GIT_REMOTES_CHROMIUM):
return True
print 'ERROR: Unable to find dart/dartium/src repository %s' % GIT_REMOTES_CHROMIUM
print('ERROR: Unable to find dart/dartium/src repository %s' %
GIT_REMOTES_CHROMIUM)
return False
@ -348,25 +349,25 @@ def GetDEPSWebCoreGitRevision(deps, component):
# Get the SHA for the Chromium/WebKit changes for Dartium.
#revision = url[len(url_base):]
revision = foundIt.group(1)[1:]
print '%s' % revision
print('%s' % revision)
return revision
def copy_subdir(src, src_prefix, dest, subdir):
idls_deleted = remove_obsolete_webcore_files(dest, src, subdir)
print "%s files removed in WebCore %s" % (idls_deleted.__len__(), subdir)
print("%s files removed in WebCore %s" % (idls_deleted.__len__(), subdir))
if isVerbose():
for delete_file in idls_deleted:
print " %s" % delete_file
print(" %s" % delete_file)
idls_copied, py_copied, other_copied = copy_files(
os.path.join(src, subdir), src_prefix, dest)
if idls_copied > 0:
print "Copied %s IDLs to %s" % (idls_copied, subdir)
print("Copied %s IDLs to %s" % (idls_copied, subdir))
if py_copied > 0:
print "Copied %s PYs to %s" % (py_copied, subdir)
print("Copied %s PYs to %s" % (py_copied, subdir))
if other_copied > 0:
print "Copied %s other to %s\n" % (other_copied, subdir)
print("Copied %s other to %s\n" % (other_copied, subdir))
def main():
@ -375,7 +376,8 @@ def main():
current_dir = os.path.dirname(os.path.abspath(__file__))
if not current_dir.endswith(SOURCE_FILE_DIR):
print 'ERROR: idlsync.py not run in proper directory (%s)\n', current_dir
print('ERROR: idlsync.py not run in proper directory (%s)\n',
current_dir)
base_directory = current_dir[:current_dir.rfind(SOURCE_FILE_DIR)]
@ -384,8 +386,8 @@ def main():
webcore_revision = GetDEPSWebCoreGitRevision(deps, 'webkit')
chromium_sha = getChromiumSHA()
if webcore_revision == chromium_sha:
print "ERROR: Nothing to update in WebCore, WebCore_rev SHA in DEPS " \
"matches Chromium GIT master SHA in %s" % options['webkit_dir']
print("ERROR: Nothing to update in WebCore, WebCore_rev SHA in DEPS "
"matches Chromium GIT master SHA in %s" % options['webkit_dir'])
return
start_time = time.time()
@ -417,12 +419,14 @@ def main():
end_time = time.time()
print 'WARNING: File(s) contain FIXMEDART and are NOT "git add " please review:'
print(
'WARNING: File(s) contain FIXMEDART and are NOT "git add " please review:'
)
for warning in warning_messages:
print ' %s' % warning
print(' %s' % warning)
print '\nDone idlsync completed in %s seconds' % round(
end_time - start_time, 2)
print('\nDone idlsync completed in %s seconds' %
round(end_time - start_time, 2))
if __name__ == '__main__':

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2020, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2013, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (c) 2011, the Dart 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.

Some files were not shown because too many files have changed in this diff Show more