[gyp] Fix string escaping for GYP on Windows
Fixes .gyp scaffolding for building on Windows.
Patch from Refael Ackermann <refack@gmail.com>.
5528afd073
Bug=v8:7061
Change-Id: I4faaf3f488b6725942746d74838ef7ce73b1e8d0
Reviewed-on: https://chromium-review.googlesource.com/761477
Reviewed-by: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49280}
This commit is contained in:
parent
f3a2e34dba
commit
02c84d4192
@ -2540,18 +2540,18 @@
|
||||
'dcheck_always_on=<(dcheck_always_on)',
|
||||
'is_asan=<(asan)',
|
||||
'is_cfi=<(cfi_vptr)',
|
||||
'is_component_build="<(component)"',
|
||||
'is_debug="<(CONFIGURATION_NAME)"',
|
||||
'is_component_build=<(component)',
|
||||
'is_debug=<(CONFIGURATION_NAME)',
|
||||
# Not available in gyp.
|
||||
'is_gcov_coverage=0',
|
||||
'is_msan=<(msan)',
|
||||
'is_tsan=<(tsan)',
|
||||
# Not available in gyp.
|
||||
'is_ubsan_vptr=0',
|
||||
'target_cpu="<(target_arch)"',
|
||||
'target_cpu=<(target_arch)',
|
||||
'v8_enable_i18n_support=<(v8_enable_i18n_support)',
|
||||
'v8_enable_verify_predictable=<(v8_enable_verify_predictable)',
|
||||
'v8_target_cpu="<(v8_target_arch)"',
|
||||
'v8_target_cpu=<(v8_target_arch)',
|
||||
'v8_use_snapshot=<(v8_use_snapshot)',
|
||||
],
|
||||
},
|
||||
|
@ -20,28 +20,35 @@ assert len(sys.argv) > 2
|
||||
|
||||
GYP_GN_CONVERSION = {
|
||||
'is_component_build': {
|
||||
'"shared_library"': 'true',
|
||||
'"static_library"': 'false',
|
||||
'shared_library': 'true',
|
||||
'static_library': 'false',
|
||||
},
|
||||
'is_debug': {
|
||||
'"Debug"': 'true',
|
||||
'"Release"': 'false',
|
||||
'Debug': 'true',
|
||||
'Release': 'false',
|
||||
},
|
||||
}
|
||||
|
||||
DEFAULT_CONVERSION ={
|
||||
'0': 'false',
|
||||
'1': 'true',
|
||||
'"ia32"': '"x86"',
|
||||
'ia32': 'x86',
|
||||
}
|
||||
|
||||
def gyp_to_gn(key, value):
|
||||
return GYP_GN_CONVERSION.get(key, DEFAULT_CONVERSION).get(value, value)
|
||||
value = GYP_GN_CONVERSION.get(key, DEFAULT_CONVERSION).get(value, value)
|
||||
value = value if value in ['true', 'false'] else '"{0}"'.format(value)
|
||||
return value
|
||||
|
||||
def as_json(kv):
|
||||
assert '=' in kv
|
||||
k, v = kv.split('=', 1)
|
||||
return k, json.loads(gyp_to_gn(k, v))
|
||||
v2 = gyp_to_gn(k, v)
|
||||
try:
|
||||
return k, json.loads(v2)
|
||||
except ValueError as e:
|
||||
print(k, v, v2)
|
||||
raise e
|
||||
|
||||
with open(sys.argv[1], 'w') as f:
|
||||
json.dump(dict(map(as_json, sys.argv[2:])), f)
|
||||
|
Loading…
Reference in New Issue
Block a user