Fix build when python=python3

Right now most of the dart SDK's python is compatible with python2
or python3. This change fixes a few of the build scripts to make
that completely true (at least when building the standard build on
Linux). There are only four types of changes:
  - Bare `print` statements now use the `print ()` function
  - `commands.getoutput` becomes `subprocess.check_output` with `shell=True`
  - `xrange` becomes `range`
  - `print >> sys.stderr` becomes `sys.stderr.write`

Starts work on addressing (but does not completely fix):
https://github.com/dart-lang/sdk/issues/28793

See related issue:
https://fuchsia-review.googlesource.com/c/fuchsia/+/272925

This change applys to both the `dev` and `master` branches.

Change-Id: Ibd3eb9b1f57520d2d745f05c2ac430b1d20943da

Closes #36662
https://github.com/dart-lang/sdk/pull/36662

GitOrigin-RevId: beab165294982a7e369daf6d61aea63efcab1b9b
Change-Id: I6d240749a9ba0889b5a45a08f3c4c2c20291f484
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99707
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
This commit is contained in:
Joseph Richey
2019-04-23 07:48:15 +00:00
committed by commit-bot@chromium.org
parent 475c918f0a
commit 86fe7ca75c
9 changed files with 86 additions and 87 deletions
+10 -10
View File
@@ -82,20 +82,20 @@ def ProcessOptions(options, args):
options.os = options.os.split(',')
for mode in options.mode:
if not mode in ['debug', 'release', 'product']:
print "Unknown mode %s" % mode
print ("Unknown mode %s" % mode)
return False
for arch in options.arch:
if not arch in AVAILABLE_ARCHS:
print "Unknown arch %s" % arch
print ("Unknown arch %s" % arch)
return False
options.os = [ProcessOsOption(os_name) for os_name in options.os]
for os_name in options.os:
if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']:
print "Unknown os %s" % os_name
print ("Unknown os %s" % os_name)
return False
if os_name != HOST_OS:
if os_name != 'android':
print "Unsupported target os %s" % os_name
print ("Unsupported target os %s" % os_name)
return False
if not HOST_OS in ['linux', 'macos']:
print ("Cross-compilation to %s is not supported on host os %s."
@@ -109,14 +109,14 @@ def ProcessOptions(options, args):
# We have not yet tweaked the v8 dart build to work with the Android
# NDK/SDK, so don't try to build it.
if not args:
print "For android builds you must specify a target, such as 'runtime'."
print ("For android builds you must specify a target, such as 'runtime'.")
return False
return True
def NotifyBuildDone(build_config, success, start):
if not success:
print "BUILD FAILED"
print ("BUILD FAILED")
sys.stdout.flush()
@@ -223,10 +223,10 @@ def EnsureGomaStarted(out_dir):
words = line.split()
goma_dir = words[2][1:-1] # goma_dir = "/path/to/goma"
if not goma_dir:
print 'Could not find goma for ' + out_dir
print ('Could not find goma for ' + out_dir)
return False
if not os.path.exists(goma_dir) or not os.path.isdir(goma_dir):
print 'Could not find goma at ' + goma_dir
print ('Could not find goma at ' + goma_dir)
return False
goma_ctl = os.path.join(goma_dir, 'goma_ctl.py')
goma_ctl_command = [
@@ -270,7 +270,7 @@ def BuildOneConfig(options, targets, target_os, mode, arch):
def RunOneBuildCommand(build_config, args):
start_time = time.time()
print ' '.join(args)
print (' '.join(args))
process = subprocess.Popen(args, stdin=None)
process.wait()
if process.returncode != 0:
@@ -284,7 +284,7 @@ def RunOneBuildCommand(build_config, args):
def RunOneGomaBuildCommand(args):
try:
print ' '.join(args)
print (' '.join(args))
process = subprocess.Popen(args, stdin=None)
process.wait()
print (' '.join(args) + " done.")