diff --git a/gn/checkdir.py b/gn/checkdir.py index 4de7e80203..3ad5819f5f 100755 --- a/gn/checkdir.py +++ b/gn/checkdir.py @@ -5,11 +5,13 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import print_function + import os import sys dirpath, = sys.argv[1:] -print os.path.isdir(dirpath) +print(os.path.isdir(dirpath)) diff --git a/gn/find_xcode_sysroot.py b/gn/find_xcode_sysroot.py index 789ae9f9a5..be5b687e03 100755 --- a/gn/find_xcode_sysroot.py +++ b/gn/find_xcode_sysroot.py @@ -5,9 +5,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import print_function + import subprocess import sys (sdk,) = sys.argv[1:] -print subprocess.check_output(['xcrun', '--sdk', sdk, '--show-sdk-path']) +print(subprocess.check_output(['xcrun', '--sdk', sdk, '--show-sdk-path'])) diff --git a/gn/gn_meta_sln.py b/gn/gn_meta_sln.py index 9f30cb02d2..e66757ad86 100644 --- a/gn/gn_meta_sln.py +++ b/gn/gn_meta_sln.py @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import print_function + import os import glob import re @@ -72,7 +74,7 @@ for config in configs: # We need something to work with. Typically, this will fail if no GN folders # have IDE files if len(allProjects) == 0: - print "ERROR: At least one GN directory must have been built with --ide=vs" + print("ERROR: At least one GN directory must have been built with --ide=vs") sys.exit() # Create a new solution. We arbitrarily use the first config as the GUID source diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py index 353f643ae5..acd1f4f762 100755 --- a/gn/gn_to_bp.py +++ b/gn/gn_to_bp.py @@ -7,6 +7,8 @@ # Generate Android.bp for Skia from GN configuration. +from __future__ import print_function + import os import pprint import string @@ -442,13 +444,13 @@ def disallow_platforms(config, desired): s += ' || ' if i % 2 == 1: s += '\\\n ' - print >>f, s - print >>f, ' #error "Only SK_BUILD_FOR_%s should be defined!"' % desired - print >>f, '#endif' + print(s, file=f) + print(' #error "Only SK_BUILD_FOR_%s should be defined!"' % desired, file=f) + print('#endif', file=f) def append_to_file(config, s): with open(config, 'a') as f: - print >>f, s + print(s, file=f) android_config = 'android/include/config/SkUserConfig.h' gn_to_bp_utils.WriteUserConfig(android_config, android_defines) @@ -483,7 +485,7 @@ def bpfmt(indent, lst, sort=True): # OK! We have everything to fill in Android.bp... with open('Android.bp', 'w') as Android_bp: - print >>Android_bp, bp.substitute({ + print(bp.substitute({ 'export_includes': bpfmt(8, export_includes), 'local_includes': bpfmt(8, local_includes), 'srcs': bpfmt(8, srcs), @@ -512,4 +514,4 @@ with open('Android.bp', 'w') as Android_bp: 'linux_srcs': bpfmt(10, linux_srcs), 'mac_srcs': bpfmt(10, mac_srcs), 'win_srcs': bpfmt(10, win_srcs), - }) + }), file=Android_bp) diff --git a/gn/gn_to_bp_utils.py b/gn/gn_to_bp_utils.py index 90acc61eed..088be3617c 100755 --- a/gn/gn_to_bp_utils.py +++ b/gn/gn_to_bp_utils.py @@ -7,6 +7,8 @@ # Generate Android.bp for Skia from GN configuration. +from __future__ import print_function + import argparse import json import os @@ -111,12 +113,12 @@ def WriteUserConfig(userConfigPath, defines): #... and all the #defines we want to put in SkUserConfig.h. with open(userConfigPath, 'w') as f: - print >>f, '// DO NOT MODIFY! This file is autogenerated by gn_to_bp.py.' - print >>f, '// If need to change a define, modify SkUserConfigManual.h' - print >>f, '#pragma once' - print >>f, '#include "SkUserConfigManual.h"' + print('// DO NOT MODIFY! This file is autogenerated by gn_to_bp.py.', file=f) + print('// If need to change a define, modify SkUserConfigManual.h', file=f) + print('#pragma once', file=f) + print('#include "SkUserConfigManual.h"', file=f) for define in sorted(defines): - print >>f, '' - print >>f, '#ifndef', define.split('=')[0] - print >>f, '#define', define.replace('=', ' ', 1) - print >>f, '#endif' + print('', file=f) + print('#ifndef', define.split('=')[0], file=f) + print('#define', define.replace('=', ' ', 1), file=f) + print('#endif', file=f) diff --git a/gn/highest_version_dir.py b/gn/highest_version_dir.py index 1b82697d9a..8c6b80facf 100755 --- a/gn/highest_version_dir.py +++ b/gn/highest_version_dir.py @@ -5,6 +5,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import print_function + import os import re import sys @@ -12,4 +14,4 @@ import sys dirpath = sys.argv[1] regex = re.compile(sys.argv[2]) -print sorted(filter(regex.match, os.listdir(dirpath)))[-1] +print(sorted(filter(regex.match, os.listdir(dirpath)))[-1]) diff --git a/gn/is_clang.py b/gn/is_clang.py index a63111c7a9..3b6bb45b09 100755 --- a/gn/is_clang.py +++ b/gn/is_clang.py @@ -5,13 +5,14 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import print_function + import subprocess import sys cc,cxx = sys.argv[1:3] if ('clang' in subprocess.check_output('%s --version' % cc, shell=True) and 'clang' in subprocess.check_output('%s --version' % cxx, shell=True)): - print 'true' + print('true') else: - print 'false' - + print('false')