diff --git a/.gn b/.gn
index fc54abe46e9..a9e618fadae 100644
--- a/.gn
+++ b/.gn
@@ -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"
diff --git a/DEPS b/DEPS
index 5c44d05869b..1bebd4fc193 100644
--- a/DEPS
+++ b/DEPS
@@ -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",
- ],
- },
- ]
-}
diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py
index 70cc608cbea..a7334f79ff3 100644
--- a/build/config/linux/pkg-config.py
+++ b/build/config/linux/pkg-config.py
@@ -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]))
diff --git a/build/config/linux/sysroot_ld_path.py b/build/config/linux/sysroot_ld_path.py
index 53b094d6fa7..a62381f9697 100644
--- a/build/config/linux/sysroot_ld_path.py
+++ b/build/config/linux/sysroot_ld_path.py
@@ -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 + '"')
diff --git a/build/config/mac/mac_app.py b/build/config/mac/mac_app.py
index 82459678d36..3eec8c62ba8 100644
--- a/build/config/mac/mac_app.py
+++ b/build/config/mac/mac_app.py
@@ -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.
diff --git a/build/detect_host_arch.py b/build/detect_host_arch.py
index 1b179cbfac7..5d939b76be0 100755
--- a/build/detect_host_arch.py
+++ b/build/detect_host_arch.py
@@ -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([]))
diff --git a/build/gn_run_binary.py b/build/gn_run_binary.py
index 0c2287dc5e7..36161a17286 100755
--- a/build/gn_run_binary.py
+++ b/build/gn_run_binary.py
@@ -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 [args ...]
+ python3 gn_run_binary.py [args ...]
Where 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: " +
diff --git a/build/linux/sysroot_scripts/install-sysroot.py b/build/linux/sysroot_scripts/install-sysroot.py
index cbe8fffe0ff..5e2fffec584 100755
--- a/build/linux/sysroot_scripts/install-sysroot.py
+++ b/build/linux/sysroot_scripts/install-sysroot.py
@@ -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
diff --git a/build/mac/change_mach_o_flags.py b/build/mac/change_mach_o_flags.py
index 427117ce72e..4155dc6aa53 100755
--- a/build/mac/change_mach_o_flags.py
+++ b/build/mac/change_mach_o_flags.py
@@ -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.
diff --git a/build/mac/find_sdk.py b/build/mac/find_sdk.py
index 01d06736b3b..d2bf4247a55 100755
--- a/build/mac/find_sdk.py
+++ b/build/mac/find_sdk.py
@@ -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())
diff --git a/build/mac/strip_save_dsym b/build/mac/strip_save_dsym
index c9cf2266375..0b0bc7b1d76 100755
--- a/build/mac/strip_save_dsym
+++ b/build/mac/strip_save_dsym
@@ -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
diff --git a/build/mac/tweak_info_plist.py b/build/mac/tweak_info_plist.py
index b2a0f0c8225..988a1b3715e 100755
--- a/build/mac/tweak_info_plist.py
+++ b/build/mac/tweak_info_plist.py
@@ -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:
diff --git a/build/rust/run.py b/build/rust/run.py
index 6bdbea1273f..3041cf92b7a 100755
--- a/build/rust/run.py
+++ b/build/rust/run.py
@@ -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
diff --git a/build/toolchain/get_concurrent_links.py b/build/toolchain/get_concurrent_links.py
index 45e3ff52f87..a322526b344 100644
--- a/build/toolchain/get_concurrent_links.py
+++ b/build/toolchain/get_concurrent_links.py
@@ -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())
diff --git a/build/toolchain/win/BUILD.gn b/build/toolchain/win/BUILD.gn
index 16518a614f3..478e39cb140 100644
--- a/build/toolchain/win/BUILD.gn
+++ b/build/toolchain/win/BUILD.gn
@@ -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")
diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py
index fde043b210a..ee3d8eeae2f 100644
--- a/build/toolchain/win/setup_toolchain.py
+++ b/build/toolchain/win/setup_toolchain.py
@@ -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 '
' '
- ' ')
+ ' '
+ '')
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__':
diff --git a/build/toolchain/win/tool_wrapper.py b/build/toolchain/win/tool_wrapper.py
index fbe924801bb..b094b2bfd78 100644
--- a/build/toolchain/win/tool_wrapper.py
+++ b/build/toolchain/win/tool_wrapper.py
@@ -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):
diff --git a/build/vs_toolchain.py b/build/vs_toolchain.py
index 11376198979..6c9f2d3470f 100644
--- a/build/vs_toolchain.py
+++ b/build/vs_toolchain.py
@@ -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',
diff --git a/build/win/importlibs/create_importlib_win.py b/build/win/importlibs/create_importlib_win.py
index 401b6e8aae4..b23a7c07bfa 100755
--- a/build/win/importlibs/create_importlib_win.py
+++ b/build/win/importlibs/create_importlib_win.py
@@ -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.
diff --git a/build/win/importlibs/filter_export_list.py b/build/win/importlibs/filter_export_list.py
index 23fe3627d29..b1fc1228f07 100755
--- a/build/win/importlibs/filter_export_list.py
+++ b/build/win/importlibs/filter_export_list.py
@@ -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
diff --git a/build/win/reorder-imports.py b/build/win/reorder-imports.py
index f96a9ec85e5..45c4c9a2c46 100755
--- a/build/win/reorder-imports.py
+++ b/build/win/reorder-imports.py
@@ -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.
diff --git a/build/win/use_ansi_codes.py b/build/win/use_ansi_codes.py
index b24ae24bcb8..c453c7b2e06 100755
--- a/build/win/use_ansi_codes.py
+++ b/build/win/use_ansi_codes.py
@@ -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)
diff --git a/pkg/analyzer/tool/fasta_migration_progress.sh b/pkg/analyzer/tool/fasta_migration_progress.sh
index 042e0db281b..ec3d9eb1bbc 100644
--- a/pkg/analyzer/tool/fasta_migration_progress.sh
+++ b/pkg/analyzer/tool/fasta_migration_progress.sh
@@ -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
diff --git a/pkg/front_end/test/language_versioning/language_versioning_up_to_date_git_test.dart b/pkg/front_end/test/language_versioning/language_versioning_up_to_date_git_test.dart
index 16a442b502e..d79b1fd88b4 100644
--- a/pkg/front_end/test/language_versioning/language_versioning_up_to_date_git_test.dart
+++ b/pkg/front_end/test/language_versioning/language_versioning_up_to_date_git_test.dart
@@ -18,7 +18,7 @@ String get dartVm => Platform.executable;
main(List 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();
diff --git a/pkg/test_runner/lib/bot_results.dart b/pkg/test_runner/lib/bot_results.dart
index b5032f6b42a..8f68b04178a 100644
--- a/pkg/test_runner/lib/bot_results.dart
+++ b/pkg/test_runner/lib/bot_results.dart
@@ -71,7 +71,7 @@ final gsutilPool = Pool(math.max(1, Platform.numberOfProcessors ~/ 2));
Future runGsutil(List 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 runGsutil(List 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);
}
diff --git a/pkg/test_runner/lib/src/build_configurations.dart b/pkg/test_runner/lib/src/build_configurations.dart
index 61799975bc9..b6c8aa8b040 100644
--- a/pkg/test_runner/lib/src/build_configurations.dart
+++ b/pkg/test_runner/lib/src/build_configurations.dart
@@ -49,8 +49,8 @@ Future buildConfigurations(List 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;
diff --git a/pkg/test_runner/lib/src/status_reporter.dart b/pkg/test_runner/lib/src/status_reporter.dart
index 36e0414bf0e..e795d96ef3b 100644
--- a/pkg/test_runner/lib/src/status_reporter.dart
+++ b/pkg/test_runner/lib/src/status_reporter.dart
@@ -77,9 +77,9 @@ void ensureBuild(Iterable modes, Iterable 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 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);
diff --git a/pkg/test_runner/lib/src/test_progress.dart b/pkg/test_runner/lib/src/test_progress.dart
index 850c4925ba4..a089688a371 100644
--- a/pkg/test_runner/lib/src/test_progress.dart
+++ b/pkg/test_runner/lib/src/test_progress.dart
@@ -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);
diff --git a/pkg/test_runner/lib/test_runner.dart b/pkg/test_runner/lib/test_runner.dart
index 33f93ba9b77..59fcb9f9f8c 100644
--- a/pkg/test_runner/lib/test_runner.dart
+++ b/pkg/test_runner/lib/test_runner.dart
@@ -482,7 +482,7 @@ Future runTests(List args) async {
print("Running tests");
print("".padLeft(80, "="));
await runProcessInheritStdio(
- "python",
+ "python3",
[
"tools/test.py",
"--named-configuration=${configurationsToRun.join(",")}",
@@ -607,7 +607,7 @@ Future deflake(Directory outDirectory, List configurations,
];
await runProcessInheritStdio(
- "python", ["tools/test.py", ...deflakeArguments],
+ "python3", ["tools/test.py", ...deflakeArguments],
runInShell: Platform.isWindows);
deflakingResultsPaths.add("${deflakeDirectory.path}/results.json");
}
diff --git a/runtime/docs/dwarf_stack_traces.md b/runtime/docs/dwarf_stack_traces.md
index afddbc7adf3..e1f6c5e64a4 100644
--- a/runtime/docs/dwarf_stack_traces.md
+++ b/runtime/docs/dwarf_stack_traces.md
@@ -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
diff --git a/runtime/observatory/update_sources.py b/runtime/observatory/update_sources.py
index 39f6ad3db54..a9eaef73131 100755
--- a/runtime/observatory/update_sources.py
+++ b/runtime/observatory/update_sources.py
@@ -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
diff --git a/runtime/observatory_2/update_sources.py b/runtime/observatory_2/update_sources.py
index 39f6ad3db54..a9eaef73131 100755
--- a/runtime/observatory_2/update_sources.py
+++ b/runtime/observatory_2/update_sources.py
@@ -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
diff --git a/runtime/third_party/binary_size/src/explain_binary_size_delta.py b/runtime/third_party/binary_size/src/explain_binary_size_delta.py
index b6a02704558..ed9c6893232 100755
--- a/runtime/third_party/binary_size/src/explain_binary_size_delta.py
+++ b/runtime/third_party/binary_size/src/explain_binary_size_delta.py
@@ -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,
diff --git a/runtime/third_party/binary_size/src/run_binary_size_analysis.py b/runtime/third_party/binary_size/src/run_binary_size_analysis.py
index d78e02d7dbf..ac41f4a4bf2 100755
--- a/runtime/third_party/binary_size/src/run_binary_size_analysis.py
+++ b/runtime/third_party/binary_size/src/run_binary_size_analysis.py
@@ -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__':
diff --git a/runtime/tools/android_finder.py b/runtime/tools/android_finder.py
index c3d82494f54..6c8078c9e97 100755
--- a/runtime/tools/android_finder.py
+++ b/runtime/tools/android_finder.py
@@ -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
diff --git a/runtime/tools/benchmark.py b/runtime/tools/benchmark.py
index ec0b5e65282..0f6cd7267a2 100755
--- a/runtime/tools/benchmark.py
+++ b/runtime/tools/benchmark.py
@@ -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
diff --git a/runtime/tools/bin_to_assembly.py b/runtime/tools/bin_to_assembly.py
index 9ec13e723bb..b66c285a06a 100755
--- a/runtime/tools/bin_to_assembly.py
+++ b/runtime/tools/bin_to_assembly.py
@@ -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
diff --git a/runtime/tools/bin_to_coff.py b/runtime/tools/bin_to_coff.py
index 1925bcdb9b2..f98f051f884 100644
--- a/runtime/tools/bin_to_coff.py
+++ b/runtime/tools/bin_to_coff.py
@@ -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:
diff --git a/runtime/tools/compiler_layering_check.py b/runtime/tools/compiler_layering_check.py
index e686ce9304b..06d73d98fd3 100755
--- a/runtime/tools/compiler_layering_check.py
+++ b/runtime/tools/compiler_layering_check.py
@@ -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)
diff --git a/runtime/tools/create_archive.py b/runtime/tools/create_archive.py
index 7bc93d5c5f7..40d6813cb89 100755
--- a/runtime/tools/create_archive.py
+++ b/runtime/tools/create_archive.py
@@ -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.
diff --git a/runtime/tools/create_snapshot_bin.py b/runtime/tools/create_snapshot_bin.py
index 93c5b69ae87..65c35a85846 100755
--- a/runtime/tools/create_snapshot_bin.py
+++ b/runtime/tools/create_snapshot_bin.py
@@ -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
diff --git a/runtime/tools/create_snapshot_file.py b/runtime/tools/create_snapshot_file.py
index 42163662e1c..2354acb26ab 100755
--- a/runtime/tools/create_snapshot_file.py
+++ b/runtime/tools/create_snapshot_file.py
@@ -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
diff --git a/runtime/tools/create_string_literal.py b/runtime/tools/create_string_literal.py
index 68a969b1059..3065e7d82df 100755
--- a/runtime/tools/create_string_literal.py
+++ b/runtime/tools/create_string_literal.py
@@ -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
diff --git a/runtime/tools/embedder_layering_check.py b/runtime/tools/embedder_layering_check.py
index 8e33bf09a15..775040e5987 100644
--- a/runtime/tools/embedder_layering_check.py
+++ b/runtime/tools/embedder_layering_check.py
@@ -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)
diff --git a/runtime/tools/gen_library_src_paths.py b/runtime/tools/gen_library_src_paths.py
index 97f4ae17cf1..79ef9d8c731 100755
--- a/runtime/tools/gen_library_src_paths.py
+++ b/runtime/tools/gen_library_src_paths.py
@@ -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.
diff --git a/runtime/tools/utils.py b/runtime/tools/utils.py
index 8cec062976a..a70681da9d1 100644
--- a/runtime/tools/utils.py
+++ b/runtime/tools/utils.py
@@ -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):
diff --git a/runtime/tools/valgrind.py b/runtime/tools/valgrind.py
index f82d6d378c8..ec0c886ed48 100755
--- a/runtime/tools/valgrind.py
+++ b/runtime/tools/valgrind.py
@@ -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
diff --git a/samples-dev/swarm/appengine/dev.html b/samples-dev/swarm/appengine/dev.html
index 2204ec9f5f4..672ec9c8980 100644
--- a/samples-dev/swarm/appengine/dev.html
+++ b/samples-dev/swarm/appengine/dev.html
@@ -18,7 +18,7 @@
for UI development using something like: file:///Users/jimhug/dart-all/dart/samples/swarm/swarm.html
.
When you are ready to test your new UI on this live server, first you
- need to run
python update.py
from your
+ need to run python3 update.py
from your
dart/samples/swarm
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
diff --git a/samples-dev/swarm/appengine/main.py b/samples-dev/swarm/appengine/main.py
index f047c471a31..4216fe829c0 100644
--- a/samples-dev/swarm/appengine/main.py
+++ b/samples-dev/swarm/appengine/main.py
@@ -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
diff --git a/samples-dev/swarm/buildapp.py b/samples-dev/swarm/buildapp.py
index 12d2a6afb01..b8198e1e03c 100755
--- a/samples-dev/swarm/buildapp.py
+++ b/samples-dev/swarm/buildapp.py
@@ -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
diff --git a/samples-dev/swarm/cacheimages.py b/samples-dev/swarm/cacheimages.py
index 0a8d1d31327..23241258c54 100755
--- a/samples-dev/swarm/cacheimages.py
+++ b/samples-dev/swarm/cacheimages.py
@@ -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):
diff --git a/samples-dev/swarm/gen_manifest.py b/samples-dev/swarm/gen_manifest.py
index 4cc1280b013..d75356db95b 100755
--- a/samples-dev/swarm/gen_manifest.py
+++ b/samples-dev/swarm/gen_manifest.py
@@ -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('', '' % 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")
diff --git a/samples-dev/swarm/update.py b/samples-dev/swarm/update.py
index 33526b0d0b1..5ff7000f93a 100755
--- a/samples-dev/swarm/update.py
+++ b/samples-dev/swarm/update.py
@@ -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,
diff --git a/sdk/lib/libraries.yaml b/sdk/lib/libraries.yaml
index 87beca8d264..626222175fb 100644
--- a/sdk/lib/libraries.yaml
+++ b/sdk/lib/libraries.yaml
@@ -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
diff --git a/sdk/lib/vmservice_libraries.yaml b/sdk/lib/vmservice_libraries.yaml
index 169d6afcef7..c30ac8ff275 100644
--- a/sdk/lib/vmservice_libraries.yaml
+++ b/sdk/lib/vmservice_libraries.yaml
@@ -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
diff --git a/tools/bots/bot_utils.py b/tools/bots/bot_utils.py
index 29f840b6c1a..07f66c3969b 100755
--- a/tools/bots/bot_utils.py
+++ b/tools/bots/bot_utils.py
@@ -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(
diff --git a/tools/bots/dart_sdk.py b/tools/bots/dart_sdk.py
index 8e7f6f9c981..019396922e4 100755
--- a/tools/bots/dart_sdk.py
+++ b/tools/bots/dart_sdk.py
@@ -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:
diff --git a/tools/bots/linux_distribution_support.py b/tools/bots/linux_distribution_support.py
index 789fce8c6e3..04fb693f4a2 100644
--- a/tools/bots/linux_distribution_support.py
+++ b/tools/bots/linux_distribution_support.py
@@ -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)
diff --git a/tools/bots/pub_integration_test.py b/tools/bots/pub_integration_test.py
index 6d6ef43c378..726427901bc 100755
--- a/tools/bots/pub_integration_test.py
+++ b/tools/bots/pub_integration_test.py
@@ -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.
diff --git a/tools/bots/upload_debian_packages.py b/tools/bots/upload_debian_packages.py
index 4ee76422ac3..b3cb55a1cab 100755
--- a/tools/bots/upload_debian_packages.py
+++ b/tools/bots/upload_debian_packages.py
@@ -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')
diff --git a/tools/build.py b/tools/build.py
index 513bef86094..fb17356aba4 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -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',
]
diff --git a/tools/buildtools/update.py b/tools/buildtools/update.py
index a39822507e7..bafeab11592 100755
--- a/tools/buildtools/update.py
+++ b/tools/buildtools/update.py
@@ -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',
diff --git a/tools/copy_dart.py b/tools/copy_dart.py
index dbb7ecf33e7..fedc29b0daf 100755
--- a/tools/copy_dart.py
+++ b/tools/copy_dart.py
@@ -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 = []
diff --git a/tools/copy_tree.py b/tools/copy_tree.py
index f5c5c569eee..8c63308bf6c 100755
--- a/tools/copy_tree.py
+++ b/tools/copy_tree.py
@@ -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.
diff --git a/tools/create_debian_chroot.sh b/tools/create_debian_chroot.sh
index 4376f3b40c4..4e98093bc56 100755
--- a/tools/create_debian_chroot.sh
+++ b/tools/create_debian_chroot.sh
@@ -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
diff --git a/tools/create_debian_packages.py b/tools/create_debian_packages.py
index e0e81bb1e46..74b8a777577 100755
--- a/tools/create_debian_packages.py
+++ b/tools/create_debian_packages.py
@@ -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()
diff --git a/tools/create_pkg_manifest.py b/tools/create_pkg_manifest.py
index 0448ca9a85e..0233b44c7b6 100755
--- a/tools/create_pkg_manifest.py
+++ b/tools/create_pkg_manifest.py
@@ -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.
diff --git a/tools/create_tarball.py b/tools/create_tarball.py
index ee5630a88df..6844cadf639 100755
--- a/tools/create_tarball.py
+++ b/tools/create_tarball.py
@@ -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.
diff --git a/tools/create_timestamp_file.py b/tools/create_timestamp_file.py
index 8f449a6f918..bb48e7ff8ee 100755
--- a/tools/create_timestamp_file.py
+++ b/tools/create_timestamp_file.py
@@ -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.
diff --git a/tools/dom/dom.py b/tools/dom/dom.py
index 8fa8254a760..f986d3f1d3d 100755
--- a/tools/dom/dom.py
+++ b/tools/dom/dom.py
@@ -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
diff --git a/tools/dom/new_scripts/code_generator_dart.py b/tools/dom/new_scripts/code_generator_dart.py
index 6fdd2a95f67..2a929233da0 100644
--- a/tools/dom/new_scripts/code_generator_dart.py
+++ b/tools/dom/new_scripts/code_generator_dart.py
@@ -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
diff --git a/tools/dom/new_scripts/compiler.py b/tools/dom/new_scripts/compiler.py
index 9a27581b386..7eb727087f8 100755
--- a/tools/dom/new_scripts/compiler.py
+++ b/tools/dom/new_scripts/compiler.py
@@ -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
diff --git a/tools/dom/new_scripts/dart_compiler.py b/tools/dom/new_scripts/dart_compiler.py
index 5dd2b348c60..5a1762939dc 100755
--- a/tools/dom/new_scripts/dart_compiler.py
+++ b/tools/dom/new_scripts/dart_compiler.py
@@ -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
diff --git a/tools/dom/scripts/all_tests.py b/tools/dom/scripts/all_tests.py
index 40a5a49f896..f0e30ced4f1 100755
--- a/tools/dom/scripts/all_tests.py
+++ b/tools/dom/scripts/all_tests.py
@@ -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.
diff --git a/tools/dom/scripts/css_code_generator.py b/tools/dom/scripts/css_code_generator.py
index 9b5ccc5620c..717630b4547 100644
--- a/tools/dom/scripts/css_code_generator.py
+++ b/tools/dom/scripts/css_code_generator.py
@@ -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
diff --git a/tools/dom/scripts/dartdomgenerator.py b/tools/dom/scripts/dartdomgenerator.py
index bf2662dad75..6e529a40666 100755
--- a/tools/dom/scripts/dartdomgenerator.py
+++ b/tools/dom/scripts/dartdomgenerator.py
@@ -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__':
diff --git a/tools/dom/scripts/dartgenerator.py b/tools/dom/scripts/dartgenerator.py
index eb5674e7ec7..ceb213e5a0b 100755
--- a/tools/dom/scripts/dartgenerator.py
+++ b/tools/dom/scripts/dartgenerator.py
@@ -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.
diff --git a/tools/dom/scripts/dartgenerator_test.py b/tools/dom/scripts/dartgenerator_test.py
index cfd7b2e1781..818d66ee260 100755
--- a/tools/dom/scripts/dartgenerator_test.py
+++ b/tools/dom/scripts/dartgenerator_test.py
@@ -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.
diff --git a/tools/dom/scripts/dartmetadata.py b/tools/dom/scripts/dartmetadata.py
index 71f76022222..4909c413073 100644
--- a/tools/dom/scripts/dartmetadata.py
+++ b/tools/dom/scripts/dartmetadata.py
@@ -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.
diff --git a/tools/dom/scripts/database.py b/tools/dom/scripts/database.py
index 2ec758918e5..75d8d2ed061 100755
--- a/tools/dom/scripts/database.py
+++ b/tools/dom/scripts/database.py
@@ -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.
diff --git a/tools/dom/scripts/database_test.py b/tools/dom/scripts/database_test.py
index 85c6e3e73b6..a82ed24d9ef 100755
--- a/tools/dom/scripts/database_test.py
+++ b/tools/dom/scripts/database_test.py
@@ -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.
diff --git a/tools/dom/scripts/databasebuilder.py b/tools/dom/scripts/databasebuilder.py
index e768ee47b38..c5327a78afe 100755
--- a/tools/dom/scripts/databasebuilder.py
+++ b/tools/dom/scripts/databasebuilder.py
@@ -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.
diff --git a/tools/dom/scripts/databasebuilder_test.py b/tools/dom/scripts/databasebuilder_test.py
index c1132a1fe53..7467b3edee7 100755
--- a/tools/dom/scripts/databasebuilder_test.py
+++ b/tools/dom/scripts/databasebuilder_test.py
@@ -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.
diff --git a/tools/dom/scripts/emitter.py b/tools/dom/scripts/emitter.py
index 7d45fbe5a42..21f4a17c3b7 100755
--- a/tools/dom/scripts/emitter.py
+++ b/tools/dom/scripts/emitter.py
@@ -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.
diff --git a/tools/dom/scripts/emitter_test.py b/tools/dom/scripts/emitter_test.py
index f1d168eed94..eb50c2a42cf 100755
--- a/tools/dom/scripts/emitter_test.py
+++ b/tools/dom/scripts/emitter_test.py
@@ -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.
diff --git a/tools/dom/scripts/fremontcutbuilder.py b/tools/dom/scripts/fremontcutbuilder.py
index a9ce07c5dfc..bd5fcad6ec2 100755
--- a/tools/dom/scripts/fremontcutbuilder.py
+++ b/tools/dom/scripts/fremontcutbuilder.py
@@ -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
diff --git a/tools/dom/scripts/generate_blink_file.py b/tools/dom/scripts/generate_blink_file.py
index 6414f7a659a..4e9c2a4629f 100644
--- a/tools/dom/scripts/generate_blink_file.py
+++ b/tools/dom/scripts/generate_blink_file.py
@@ -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
diff --git a/tools/dom/scripts/generator.py b/tools/dom/scripts/generator.py
index 9f64192b3a7..0a07e202191 100644
--- a/tools/dom/scripts/generator.py
+++ b/tools/dom/scripts/generator.py
@@ -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(
diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py
index 08c65a85681..7891aa389d5 100644
--- a/tools/dom/scripts/htmldartgenerator.py
+++ b/tools/dom/scripts/htmldartgenerator.py
@@ -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:
diff --git a/tools/dom/scripts/htmleventgenerator.py b/tools/dom/scripts/htmleventgenerator.py
index fcad117aac3..d614e88e78d 100644
--- a/tools/dom/scripts/htmleventgenerator.py
+++ b/tools/dom/scripts/htmleventgenerator.py
@@ -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.
diff --git a/tools/dom/scripts/htmlrenamer.py b/tools/dom/scripts/htmlrenamer.py
index 014e8116258..96cdf8a8eef 100644
--- a/tools/dom/scripts/htmlrenamer.py
+++ b/tools/dom/scripts/htmlrenamer.py
@@ -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.
diff --git a/tools/dom/scripts/idlnode.py b/tools/dom/scripts/idlnode.py
index 45189820399..40e86e5ab12 100644
--- a/tools/dom/scripts/idlnode.py
+++ b/tools/dom/scripts/idlnode.py
@@ -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):
diff --git a/tools/dom/scripts/idlnode_test.py b/tools/dom/scripts/idlnode_test.py
index 8c21546548e..61de65a46ec 100755
--- a/tools/dom/scripts/idlnode_test.py
+++ b/tools/dom/scripts/idlnode_test.py
@@ -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.
diff --git a/tools/dom/scripts/idlrenderer.py b/tools/dom/scripts/idlrenderer.py
index 40edc3da4db..ba095dd2871 100755
--- a/tools/dom/scripts/idlrenderer.py
+++ b/tools/dom/scripts/idlrenderer.py
@@ -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.
diff --git a/tools/dom/scripts/idlrenderer_test.py b/tools/dom/scripts/idlrenderer_test.py
index dd057c2fb07..000ef2ac10f 100755
--- a/tools/dom/scripts/idlrenderer_test.py
+++ b/tools/dom/scripts/idlrenderer_test.py
@@ -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.
diff --git a/tools/dom/scripts/idlsync.py b/tools/dom/scripts/idlsync.py
index 440284927b7..f95c0b9c0bd 100755
--- a/tools/dom/scripts/idlsync.py
+++ b/tools/dom/scripts/idlsync.py
@@ -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__':
diff --git a/tools/dom/scripts/mdnreader.py b/tools/dom/scripts/mdnreader.py
index 9fe43a3e977..b142b7af735 100644
--- a/tools/dom/scripts/mdnreader.py
+++ b/tools/dom/scripts/mdnreader.py
@@ -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.
diff --git a/tools/dom/scripts/monitored.py b/tools/dom/scripts/monitored.py
index 55d4e11b524..1b3babe552d 100644
--- a/tools/dom/scripts/monitored.py
+++ b/tools/dom/scripts/monitored.py
@@ -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.
diff --git a/tools/dom/scripts/multiemitter.py b/tools/dom/scripts/multiemitter.py
index 64a8b2db119..a897a16d111 100644
--- a/tools/dom/scripts/multiemitter.py
+++ b/tools/dom/scripts/multiemitter.py
@@ -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.
diff --git a/tools/dom/scripts/multiemitter_test.py b/tools/dom/scripts/multiemitter_test.py
index 0b114a56f11..17c360d5001 100644
--- a/tools/dom/scripts/multiemitter_test.py
+++ b/tools/dom/scripts/multiemitter_test.py
@@ -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.
diff --git a/tools/dom/scripts/systemhtml.py b/tools/dom/scripts/systemhtml.py
index 3b3575017c6..5749cd9c984 100644
--- a/tools/dom/scripts/systemhtml.py
+++ b/tools/dom/scripts/systemhtml.py
@@ -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.
@@ -2024,7 +2024,9 @@ class Dart2JSBackend(HtmlDartGenerator):
-
1]
else:
- print "ERROR: Arguments exceede 20 - please fix Python code to handle more."
+ print(
+ "ERROR: Arguments exceede 20 - please fix Python code to handle more."
+ )
self._members_emitter.Emit(
' $RENAME$METADATA$MODIFIERS$TYPE$TARGET($PARAMS) =>\n'
' promiseToFuture(JS("", "#.$JSNAME($HASH_STR)", this$CALLING_PARAMS));\n',
diff --git a/tools/dom/scripts/systemnative.py b/tools/dom/scripts/systemnative.py
index 296bd67b2cf..2c2ab7c37b8 100644
--- a/tools/dom/scripts/systemnative.py
+++ b/tools/dom/scripts/systemnative.py
@@ -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.
diff --git a/tools/dom/scripts/templateloader.py b/tools/dom/scripts/templateloader.py
index fcbebe860ac..7e69a8e4fcd 100644
--- a/tools/dom/scripts/templateloader.py
+++ b/tools/dom/scripts/templateloader.py
@@ -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.
diff --git a/tools/dom/scripts/templateloader_test.py b/tools/dom/scripts/templateloader_test.py
index edcd75975c7..4b16df7febb 100755
--- a/tools/dom/scripts/templateloader_test.py
+++ b/tools/dom/scripts/templateloader_test.py
@@ -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.
diff --git a/tools/find_depot_tools.py b/tools/find_depot_tools.py
index ed06c941315..413a12f482a 100644
--- a/tools/find_depot_tools.py
+++ b/tools/find_depot_tools.py
@@ -6,10 +6,11 @@ Will throw an ImportError exception if depot_tools can't be found since it
imports breakpad.
"""
+from __future__ import print_function
+
import os
import sys
-
def IsRealDepotTools(path):
return os.path.isfile(os.path.join(path, 'gclient.py'))
@@ -35,7 +36,7 @@ def add_depot_tools_to_path():
return i
previous_dir = root_dir
root_dir = os.path.dirname(root_dir)
- print >> sys.stderr, 'Failed to find depot_tools'
+ print('Failed to find depot_tools', file=sys.stderr)
return None
diff --git a/tools/fuchsia/find_resources.py b/tools/fuchsia/find_resources.py
index 9d38053eabe..f8b051895b3 100755
--- a/tools/fuchsia/find_resources.py
+++ b/tools/fuchsia/find_resources.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env 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
@@ -24,34 +24,37 @@ DART_DIR = abspath(join(__file__, '..', '..', '..'))
def listFiles(path):
- allFiles = []
- for dirpath, dirs, files in os.walk(join(DART_DIR, path)):
- allFiles += [relpath(abspath(join(dirpath, p)), DART_DIR) for p in files]
- return allFiles
+ allFiles = []
+ for dirpath, dirs, files in os.walk(join(DART_DIR, path)):
+ allFiles += [
+ relpath(abspath(join(dirpath, p)), DART_DIR) for p in files
+ ]
+ return allFiles
def printOutput(files):
- print('[')
- print(',\n'.join([
- ' {\n "path": "%s",\n "dest": "data/%s"\n }' % (f, f) for f in files
- ]))
- print(']')
+ print('[')
+ print(',\n'.join([
+ ' {\n "path": "%s",\n "dest": "data/%s"\n }' % (f, f)
+ for f in files
+ ]))
+ print(']')
def main():
- if len(sys.argv) < 2:
- print('Expected at least 1 arg, the paths to search.')
- return 1
- allFiles = []
- for directory in sys.argv[1:]:
- files = listFiles(directory)
- if len(files) == 0:
- print('Did not find any files in the directory: ' + directory)
- return 2
- allFiles += files
- printOutput(sorted(allFiles))
- return 0
+ if len(sys.argv) < 2:
+ print('Expected at least 1 arg, the paths to search.')
+ return 1
+ allFiles = []
+ for directory in sys.argv[1:]:
+ files = listFiles(directory)
+ if len(files) == 0:
+ print('Did not find any files in the directory: ' + directory)
+ return 2
+ allFiles += files
+ printOutput(sorted(allFiles))
+ return 0
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main())
diff --git a/tools/gen_fuchsia_test_manifest.py b/tools/gen_fuchsia_test_manifest.py
index fa754b57b00..d521e36eee1 100755
--- a/tools/gen_fuchsia_test_manifest.py
+++ b/tools/gen_fuchsia_test_manifest.py
@@ -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.
diff --git a/tools/generate_buildfiles.py b/tools/generate_buildfiles.py
index 1de693632a9..693de547322 100755
--- a/tools/generate_buildfiles.py
+++ b/tools/generate_buildfiles.py
@@ -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.
@@ -29,7 +29,7 @@ def RunAndroidGn(options):
if not HOST_OS in ['linux', 'macos']:
return 0
gn_command = [
- 'python',
+ 'python3',
os.path.join(DART_ROOT, 'tools', 'gn.py'),
'-m',
'all',
@@ -48,7 +48,7 @@ def RunCrossGn(options):
if HOST_OS != 'linux':
return 0
gn_command = [
- 'python',
+ 'python3',
os.path.join(DART_ROOT, 'tools', 'gn.py'),
'-m',
'all',
@@ -63,7 +63,7 @@ def RunCrossGn(options):
def RunHostGn(options):
gn_command = [
- 'python',
+ 'python3',
os.path.join(DART_ROOT, 'tools', 'gn.py'),
'-m',
'all',
diff --git a/tools/generate_idefiles.py b/tools/generate_idefiles.py
index d84bcb2aeb2..7809c64854a 100755
--- a/tools/generate_idefiles.py
+++ b/tools/generate_idefiles.py
@@ -1,4 +1,4 @@
-#!/usr/bin/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
@@ -42,7 +42,7 @@ def GenerateCompileCommands(options):
fname = os.path.join(options.dir, "compile_commands.json")
if os.path.isfile(fname) and not options.force:
- print fname + " already exists, use --force to override"
+ print(fname + " already exists, use --force to override")
return
gn_result = generate_buildfiles.RunGn(options)
@@ -132,7 +132,7 @@ def GenerateAnalysisOptions(options):
fname = os.path.join(options.dir, "analysis_options.yaml")
if os.path.isfile(fname) and not options.force:
- print fname + " already exists, use --force to override"
+ print(fname + " already exists, use --force to override")
return
with open(fname, "w") as f:
diff --git a/tools/get_dot_git_folder.py b/tools/get_dot_git_folder.py
index 443addbfdd8..482616cfd18 100755
--- a/tools/get_dot_git_folder.py
+++ b/tools/get_dot_git_folder.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (c) 2021, 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.
@@ -8,7 +8,6 @@
import sys
import subprocess
-import os
import utils
@@ -24,13 +23,15 @@ def main():
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
- shell=True)
+ shell=True,
+ universal_newlines=True)
else:
process = subprocess.Popen(args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
- shell=False)
+ shell=False,
+ universal_newlines=True)
outs, _ = process.communicate()
diff --git a/tools/gn.py b/tools/gn.py
index 6f2b0c15057..dc355cf9af0 100755
--- a/tools/gn.py
+++ b/tools/gn.py
@@ -1,11 +1,10 @@
-#!/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.
import argparse
import os
-import shutil
import subprocess
import sys
import time
@@ -64,7 +63,7 @@ def ToCommandLine(gn_args):
return '%s=%d' % (key, value)
return '%s="%s"' % (key, value)
- return [merge(x, y) for x, y in gn_args.iteritems()]
+ return [merge(x, y) for x, y in gn_args.items()]
def HostCpuForArch(arch):
diff --git a/tools/linux_dist_support/debian/rules b/tools/linux_dist_support/debian/rules
index da3ff23f99b..1ccacf5d1fb 100755
--- a/tools/linux_dist_support/debian/rules
+++ b/tools/linux_dist_support/debian/rules
@@ -53,11 +53,11 @@ override_dh_auto_clean:
find . -name *.Makefile -execdir rm -f {} \;
override_dh_auto_configure:
- python dart/tools/generate_buildfiles.py
+ python3 dart/tools/generate_buildfiles.py
override_dh_auto_build:
cd dart; \
- python tools/build.py -v -m release -a $(ARCH) $(TOOLCHAIN) create_sdk; \
+ python3 tools/build.py -v -m release -a $(ARCH) $(TOOLCHAIN) create_sdk; \
cd ..
# Building the Dart SDK will already strip all binaries.
diff --git a/tools/list_dart_files.py b/tools/list_dart_files.py
index cc131de1eeb..ec9da09bafd 100755
--- a/tools/list_dart_files.py
+++ b/tools/list_dart_files.py
@@ -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
# BSD-style license that can be found in the LICENSE file.
@@ -9,7 +9,7 @@ current working directory. If the first argument is 'absolute', the script
produces absolute paths.
Usage:
- python tools/list_dart_files.py {absolute, relative}
+ python3 tools/list_dart_files.py {absolute, relative}
"""
import os
@@ -48,7 +48,7 @@ def main(argv):
else:
fullname = os.path.relpath(os.path.join(root, filename))
fullname = fullname.replace(os.sep, '/')
- print (fullname)
+ print(fullname)
if __name__ == '__main__':
diff --git a/tools/make_version.py b/tools/make_version.py
index 0e6e8be30ee..c99511bc5c0 100755
--- a/tools/make_version.py
+++ b/tools/make_version.py
@@ -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.
@@ -11,7 +11,6 @@ import argparse
import hashlib
import os
import sys
-import time
import utils
# When these files change, snapshots created by the VM are potentially no longer
@@ -85,7 +84,7 @@ def FormatVersionString(version,
version_time = utils.GetGitTimestamp()
if version_time == None:
version_time = 'Unknown timestamp'
- version = version.replace('{{COMMIT_TIME}}', version_time.decode('utf-8'))
+ version = version.replace('{{COMMIT_TIME}}', version_time)
snapshot_hash = MakeSnapshotHashString()
version = version.replace('{{SNAPSHOT_HASH}}', snapshot_hash)
diff --git a/tools/patches/flutter-engine/apply.sh b/tools/patches/flutter-engine/apply.sh
index 91918a13435..b5b7e0c5d3b 100755
--- a/tools/patches/flutter-engine/apply.sh
+++ b/tools/patches/flutter-engine/apply.sh
@@ -57,7 +57,7 @@ if [ $need_runhooks = true ]; then
# referencing.
# Normally gclient sync would update the cache - but we are bypassing
# it here.
- git_cache=$(python -c 'import imp; config = imp.load_source("config", ".gclient"); print getattr(config, "cache_dir", "")')
+ git_cache=$(python3 -c 'import imp; config = imp.load_source("config", ".gclient"); print(getattr(config, "cache_dir", ""))')
# DEPS file might have been patched with new version of packages that
# Dart SDK depends on. Get information about dependencies from the
diff --git a/tools/promote.py b/tools/promote.py
old mode 100644
new mode 100755
index 7b57fb39cb3..966b735e8a0
--- a/tools/promote.py
+++ b/tools/promote.py
@@ -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
@@ -6,10 +6,8 @@
# Dart SDK promote tools.
-import imp
import optparse
import os
-import subprocess
import sys
import time
import urllib
@@ -28,7 +26,7 @@ def BuildOptions():
locations.
Example: Promote version 2.5.0 on the stable channel:
- python editor/build/promote.py promote --channel=stable --version=2.5.0
+ python3 tools/promote.py promote --channel=stable --version=2.5.0
"""
result = optparse.OptionParser(usage=usage)
@@ -64,7 +62,7 @@ def main():
(options, args) = parser.parse_args()
def die(msg):
- print msg
+ print(msg)
parser.print_help()
sys.exit(1)
@@ -97,14 +95,14 @@ def main():
def UpdateDocs():
try:
- print 'Updating docs'
+ print('Updating docs')
url = 'http://api.dartlang.org/docs/releases/latest/?force_reload=true'
f = urllib.urlopen(url)
f.read()
- print 'Successfully updated api docs'
+ print('Successfully updated api docs')
except Exception as e:
- print 'Could not update api docs, please manually update them'
- print 'Failed with: %s' % e
+ print('Could not update api docs, please manually update them')
+ print('Failed with: %s' % e)
def _PromoteDartArchiveBuild(channel, source_channel, revision):
@@ -187,7 +185,7 @@ def Gsutil(cmd, throw_on_error=True):
gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil')
command = [sys.executable, gsutilTool] + cmd
if DRY_RUN:
- print 'DRY runnning: %s' % command
+ print('DRY runnning: %s' % command)
return (None, None, 0)
return bot_utils.run(command, throw_on_error=throw_on_error)
diff --git a/tools/publish_pkg.py b/tools/publish_pkg.py
index 2ecf2baa80a..6cd50f00f57 100755
--- a/tools/publish_pkg.py
+++ b/tools/publish_pkg.py
@@ -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
@@ -25,7 +25,7 @@ def Main(argv):
pubspec = os.path.join(HOME, argv[1], 'pubspec.yaml')
if not os.path.exists(pubspec):
- print 'Error: did not find pubspec.yaml at ' + pubspec
+ print('Error: did not find pubspec.yaml at ' + pubspec)
return -1
with open(pubspec) as pubspecFile:
@@ -45,16 +45,17 @@ def Main(argv):
version = line[len('version:'):].strip()
if inDependencies:
if line.endswith(': any'):
- print 'Error in %s: should not use "any" version constraint: %s' % (
- pubspec, line)
+ print(
+ 'Error in %s: should not use "any" version constraint: %s' %
+ (pubspec, line))
return -1
if not version:
- print 'Error in %s: did not find package version.' % pubspec
+ print('Error in %s: did not find package version.' % pubspec)
return -1
if not foundSdkConstraint:
- print 'Error in %s: did not find SDK version constraint.' % pubspec
+ print('Error in %s: did not find SDK version constraint.' % pubspec)
return -1
tmpDir = tempfile.mkdtemp()
@@ -95,7 +96,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
''')
- print 'publishing version ' + version + ' of ' + argv[1] + ' to pub.\n'
+ print('publishing version ' + version + ' of ' + argv[1] + ' to pub.\n')
# TODO(jmesserly): this code puts things in the pub cache. Useful for testing
# without actually uploading.
diff --git a/tools/run_debian_build.sh b/tools/run_debian_build.sh
index e0d54a1a780..5399a690a3e 100755
--- a/tools/run_debian_build.sh
+++ b/tools/run_debian_build.sh
@@ -9,7 +9,7 @@ depot_tools=$(dirname $ninja)
cmd="sed -i /jessie-updates/d /etc/apt/sources.list\
&& apt-get update && apt-get -y install build-essential debhelper git python\
&& PATH=\"$depot_tools:\$PATH\"\
- python tools/bots/linux_distribution_support.py"
+ python3 tools/bots/linux_distribution_support.py"
image="launcher.gcr.io/google/debian8:latest"
docker run -e BUILDBOT_BUILDERNAME -v $depot_tools:$depot_tools\
-v `pwd`:`pwd` -w `pwd` -i --rm $image bash -c "$cmd"
diff --git a/tools/spec_parse.py b/tools/spec_parse.py
index 90a97e827bb..d9238f58d61 100755
--- a/tools/spec_parse.py
+++ b/tools/spec_parse.py
@@ -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
diff --git a/tools/task_kill.py b/tools/task_kill.py
index 3c36acc5620..8281475b3ec 100755
--- a/tools/task_kill.py
+++ b/tools/task_kill.py
@@ -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
@@ -105,8 +105,11 @@ def GetPidsPosix(process_name):
# Sample output:
# 1 /sbin/launchd
# 80943 /Applications/Safari.app/Contents/MacOS/Safari
- p = subprocess.Popen(
- cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ p = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True,
+ universal_newlines=True)
output, stderr = p.communicate()
results = []
lines = output.splitlines()
@@ -123,8 +126,11 @@ def GetPidsWindows(process_name):
cmd = 'tasklist /FI "IMAGENAME eq %s" /NH' % process_name
# Sample output:
# dart.exe 4356 Console 1 6,800 K
- p = subprocess.Popen(
- cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ p = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True,
+ universal_newlines=True)
output, stderr = p.communicate()
results = []
lines = output.splitlines()
@@ -146,44 +152,44 @@ def GetPids(process_name):
def PrintPidStackInfo(pid):
command_pattern = STACK_INFO_COMMAND.get(os_name, False)
if command_pattern:
- p = subprocess.Popen(
- command_pattern % pid,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- shell=True)
+ p = subprocess.Popen(command_pattern % pid,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True,
+ universal_newlines=True)
stdout, stderr = p.communicate()
stdout = stdout.splitlines()
stderr = stderr.splitlines()
- print " Stack:"
+ print(" Stack:")
for line in stdout:
- print " %s" % line
+ print(" %s" % line)
if stderr:
- print " Stack (stderr):"
+ print(" Stack (stderr):")
for line in stderr:
- print " %s" % line
+ print(" %s" % line)
def PrintPidInfo(pid, dump_stacks):
# We assume that the list command will return lines in the format:
# EXECUTABLE_PATH ARGS
# There may be blank strings in the output
- p = subprocess.Popen(
- INFO_COMMAND[os_name] % pid,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- shell=True)
+ p = subprocess.Popen(INFO_COMMAND[os_name] % pid,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True,
+ universal_newlines=True)
output, stderr = p.communicate()
lines = output.splitlines()
# Pop the header
lines.pop(0)
- print "Hanging process info:"
- print " PID: %s" % pid
+ print("Hanging process info:")
+ print(" PID: %s" % pid)
for line in lines:
# wmic will output a bunch of empty strings, we ignore these
- if line: print " Command line: %s" % line
+ if line: print(" Command line: %s" % line)
if dump_stacks:
PrintPidStackInfo(pid)
@@ -200,8 +206,11 @@ def KillPosix(pid):
def KillWindows(pid):
# os.kill is not available until python 2.7
cmd = "taskkill /F /PID %s" % pid
- p = subprocess.Popen(
- cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ p = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True,
+ universal_newlines=True)
p.communicate()
diff --git a/tools/test.py b/tools/test.py
index b1065002dd4..3e676fcda5e 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -1,8 +1,9 @@
-#!/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.
+from contextlib import ExitStack
import os
import string
import subprocess
@@ -35,7 +36,9 @@ def Main():
android_platform_tools)
with utils.FileDescriptorLimitIncreaser():
- with utils.CoreDumpArchiver(args):
+ with ExitStack() as stack:
+ for ctx in utils.CoreDumpArchiver(args):
+ stack.enter_context(ctx)
exit_code = subprocess.call(command)
if cleanup_dart:
diff --git a/tools/utils.py b/tools/utils.py
index dcb68a5d384..9a0c7207983 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -192,82 +192,6 @@ def GuessCpus():
return 2
-def GetWindowsRegistryKeyName(name):
- import win32process
- # Check if python process is 64-bit or if it's 32-bit running in 64-bit OS.
- # We need to know whether host is 64-bit so that we are looking in right
- # registry for Visual Studio path.
- if sys.maxsize > 2**32 or win32process.IsWow64Process():
- wow6432Node = 'Wow6432Node\\'
- else:
- wow6432Node = ''
- return r'SOFTWARE\{}{}'.format(wow6432Node, name)
-
-
-# Try to guess Visual Studio location when buiding on Windows.
-def GuessVisualStudioPath():
- defaultPath = r'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7' \
- r'\IDE'
- defaultExecutable = 'devenv.com'
-
- if not IsWindows():
- return (defaultPath, defaultExecutable)
-
- keyNamesAndExecutables = [
- # Pair for non-Express editions.
- (GetWindowsRegistryKeyName(r'Microsoft\VisualStudio'), 'devenv.com'),
- # Pair for 2012 Express edition.
- (GetWindowsRegistryKeyName(r'Microsoft\VSWinExpress'),
- 'VSWinExpress.exe'),
- # Pair for pre-2012 Express editions.
- (GetWindowsRegistryKeyName(r'Microsoft\VCExpress'), 'VCExpress.exe')
- ]
-
- bestGuess = (0.0, (defaultPath, defaultExecutable))
-
- import _winreg
- for (keyName, executable) in keyNamesAndExecutables:
- try:
- key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, keyName)
- except WindowsError:
- # Can't find this key - moving on the next one.
- continue
-
- try:
- subkeyCounter = 0
- while True:
- try:
- subkeyName = _winreg.EnumKey(key, subkeyCounter)
- subkeyCounter += 1
- except WindowsError:
- # Reached end of enumeration. Moving on the next key.
- break
-
- match = re.match(r'^\d+\.\d+$', subkeyName)
- if match:
- with _winreg.OpenKey(key, subkeyName) as subkey:
- try:
- (installDir, registrytype) = _winreg.QueryValueEx(
- subkey, 'InstallDir')
- except WindowsError:
- # Can't find value under the key - continue to the next key.
- continue
- isExpress = executable != 'devenv.com'
- if not isExpress and subkeyName == '14.0':
- # Stop search since if we found non-Express VS2015 version
- # installed, which is preferred version.
- return installDir, executable
-
- version = float(subkeyName)
- # We prefer higher version of Visual Studio and given equal
- # version numbers we prefer non-Express edition.
- if version > bestGuess[0]:
- bestGuess = (version, (installDir, executable))
- finally:
- _winreg.CloseKey(key)
- return bestGuess[1]
-
-
# Returns true if we're running under Windows.
def IsWindows():
return GuessOS() == 'win32'
@@ -612,22 +536,6 @@ def ParseTestOptionsMultiple(pattern, source, workspace):
return None
-def Daemonize():
- """
- Create a detached background process (daemon). Returns True for
- the daemon, False for the parent process.
- See: http://www.faqs.org/faqs/unix-faq/programmer/faq/
- "1.7 How do I get my program to act like a daemon?"
- """
- if os.fork() > 0:
- return False
- os.setsid()
- if os.fork() > 0:
- exit(0)
- # TODO: What is this supposed to do? Didn't we already exit?
- raise
- return True
-
def CheckedUnlink(name):
"""Unlink a file without throwing an exception."""
@@ -666,11 +574,6 @@ def DiagnoseExitCode(exit_code, command):
' '.join(command), exit_code, exit_code & 0xffffffff))
-def Touch(name):
- with file(name, 'a'):
- os.utime(name, None)
-
-
def ExecuteCommand(cmd):
"""Execute a command in a subprocess."""
print('Executing: ' + ' '.join(cmd))
@@ -1206,21 +1109,19 @@ def CoreDumpArchiver(args):
(arg[len(prefix):] for arg in args if arg.startswith(prefix)), None)
if not enabled:
- return NooptContextManager()
+ return (NooptContextManager(),)
osname = GuessOS()
if osname == 'linux':
- return contextlib.nested(LinuxCoreDumpEnabler(),
- LinuxCoreDumpArchiver(output_directory))
+ return (LinuxCoreDumpEnabler(), LinuxCoreDumpArchiver(output_directory))
elif osname == 'macos':
- return contextlib.nested(PosixCoreDumpEnabler(),
- MacOSCoreDumpArchiver(output_directory))
+ return (PosixCoreDumpEnabler(), MacOSCoreDumpArchiver(output_directory))
elif osname == 'win32':
- return contextlib.nested(WindowsCoreDumpEnabler(),
- WindowsCoreDumpArchiver(output_directory))
+ return (WindowsCoreDumpEnabler(),
+ WindowsCoreDumpArchiver(output_directory))
# We don't have support for MacOS yet.
- return NooptContextManager()
+ return (NooptContextManager(),)
def FileDescriptorLimitIncreaser():
@@ -1238,7 +1139,6 @@ def Main():
print('GuessArchitecture() -> ', GuessArchitecture())
print('GuessCpus() -> ', GuessCpus())
print('IsWindows() -> ', IsWindows())
- print('GuessVisualStudioPath() -> ', GuessVisualStudioPath())
print('GetGitRevision() -> ', GetGitRevision())
print('GetGitTimestamp() -> ', GetGitTimestamp())
print('GetVersionFileContent() -> ', GetVersionFileContent())
diff --git a/tools/write_dartdoc_options_file.py b/tools/write_dartdoc_options_file.py
index b1d23f3acdf..7e6567aa558 100755
--- a/tools/write_dartdoc_options_file.py
+++ b/tools/write_dartdoc_options_file.py
@@ -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
# BSD-style license that can be found in the LICENSE file.
diff --git a/tools/write_revision_file.py b/tools/write_revision_file.py
index db85841439b..3b9dd7d5a6b 100755
--- a/tools/write_revision_file.py
+++ b/tools/write_revision_file.py
@@ -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.
diff --git a/tools/write_version_file.py b/tools/write_version_file.py
index 75cbc09a3ce..aea586c32dd 100755
--- a/tools/write_version_file.py
+++ b/tools/write_version_file.py
@@ -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.
diff --git a/tools/yaml2json.py b/tools/yaml2json.py
index f9f3519d629..251f65708a4 100755
--- a/tools/yaml2json.py
+++ b/tools/yaml2json.py
@@ -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.
diff --git a/utils/compiler/create_snapshot_entry.dart b/utils/compiler/create_snapshot_entry.dart
index 5cf11a84d0a..360debef6c4 100644
--- a/utils/compiler/create_snapshot_entry.dart
+++ b/utils/compiler/create_snapshot_entry.dart
@@ -11,7 +11,7 @@ import 'dart:async';
Future getVersion(var rootPath) {
var printVersionScript = rootPath.resolve("tools/make_version.py");
- return Process.run("python", [printVersionScript.toFilePath(), "--quiet"],
+ return Process.run("python3", [printVersionScript.toFilePath(), "--quiet"],
runInShell: true)
.then((result) {
if (result.exitCode != 0) {