gn_args: Add Python 3 support (see issue #2856)
This commit is contained in:
parent
11ee7e984c
commit
503ec7c2e6
|
@ -60,6 +60,8 @@
|
||||||
# - Perform validation in ValidateArgs().
|
# - Perform validation in ValidateArgs().
|
||||||
# - Result: An AssertionError will be thrown if validation fails.
|
# - Result: An AssertionError will be thrown if validation fails.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
|
@ -77,12 +79,12 @@ elif sys.platform == 'darwin':
|
||||||
elif sys.platform.startswith('linux'):
|
elif sys.platform.startswith('linux'):
|
||||||
platform = 'linux'
|
platform = 'linux'
|
||||||
else:
|
else:
|
||||||
print 'Unknown operating system platform'
|
print('Unknown operating system platform')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def msg(msg):
|
def msg(msg):
|
||||||
print 'NOTE: ' + msg
|
print('NOTE: ' + msg)
|
||||||
|
|
||||||
|
|
||||||
def NameValueListToDict(name_value_list):
|
def NameValueListToDict(name_value_list):
|
||||||
|
@ -139,13 +141,13 @@ def GetValueString(val):
|
||||||
"""
|
"""
|
||||||
Return the string representation of |val| expected by GN.
|
Return the string representation of |val| expected by GN.
|
||||||
"""
|
"""
|
||||||
if isinstance(val, basestring):
|
if isinstance(val, bool):
|
||||||
return '"%s"' % val
|
|
||||||
elif isinstance(val, bool):
|
|
||||||
if val:
|
if val:
|
||||||
return 'true'
|
return 'true'
|
||||||
else:
|
else:
|
||||||
return 'false'
|
return 'false'
|
||||||
|
else:
|
||||||
|
return '"%s"' % val
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
@ -565,13 +567,13 @@ if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
platform = sys.argv[1]
|
platform = sys.argv[1]
|
||||||
if not platform in ('linux', 'macosx', 'windows'):
|
if not platform in ('linux', 'macosx', 'windows'):
|
||||||
sys.stderr.write('Usage: %s <platform>' % sys.argv[0])
|
sys.stderr.write('Usage: %s <platform>\n' % sys.argv[0])
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
print 'Platform: %s' % platform
|
print('Platform: %s' % platform)
|
||||||
|
|
||||||
# Dump the configuration based on platform and environment.
|
# Dump the configuration based on platform and environment.
|
||||||
configs = GetAllPlatformConfigs({})
|
configs = GetAllPlatformConfigs({})
|
||||||
for dir, config in configs.items():
|
for dir, config in configs.items():
|
||||||
print '\n\nout/%s:\n' % dir
|
print('\n\nout/%s:\n' % dir)
|
||||||
print GetConfigFileContents(config)
|
print(GetConfigFileContents(config))
|
||||||
|
|
Loading…
Reference in New Issue