Skip to content

Commit

Permalink
Make tools/gn compatible with Python 3
Browse files Browse the repository at this point in the history
Python 2.7 was end-of-lifed on 2020-01-01. This makes tools/gn
compatible with both Python 2.7 and Python 3.

Issue: flutter/flutter#83043
  • Loading branch information
cbracken committed May 21, 2021
1 parent cb3ee34 commit d58931c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ def get_out_dir(args):
return os.path.join(args.out_dir, 'out', '_'.join(target_dir))

def to_command_line(gn_args):
"""Converts the arguments dictionary to a list of command-line arguments.
Args:
gn_args: GN arguments dictionary generated by to_gn_args().
"""
def merge(key, value):
if type(value) is bool:
return '%s=%s' % (key, 'true' if value else 'false')
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 cpu_for_target_arch(arch):
if arch in ['ia32', 'arm', 'armv6', 'armv5te', 'mips',
Expand Down Expand Up @@ -327,7 +332,7 @@ def to_gn_args(args):
gn_args['is_ubsan'] = True

if args.enable_vulkan_validation_layers:
if args.target_os is not 'fuchsia':
if args.target_os != 'fuchsia':
print('Vulkan validation layers are currently only supported on Fuchsia targets.')
sys.exit(1)
gn_args['enable_vulkan_validation_layers'] = True
Expand Down

0 comments on commit d58931c

Please sign in to comment.