v8/tools/testrunner/utils/dump_build_config_gyp.py
Michael Achenbach 96c5e2df06 [test] Enable auto-detection of test flags in gyp
This ports the build_config json from GN to GYP to prepare deprecating
tedious flags passing to the test runner.

This also removes two unused GN flags that only hold temporary values.

Bug: v8:6917
Change-Id: I976185f1541277dc5c9bfbaa7578f35c19dd254c
Reviewed-on: https://chromium-review.googlesource.com/725706
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48715}
2017-10-19 07:02:38 +00:00

48 lines
1.0 KiB
Python

# Copyright 2017 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""The same as dump_build_config.py but for gyp legacy.
Expected to be called like:
dump_build_config.py path/to/file.json [key1=value1 ...]
Raw gyp values are supported - they will be tranformed into valid json.
"""
# TODO(machenbach): Remove this when gyp is deprecated.
import json
import os
import sys
assert len(sys.argv) > 2
GYP_GN_CONVERSION = {
'is_component_build': {
'"shared_library"': 'true',
'"static_library"': 'false',
},
'is_debug': {
'"Debug"': 'true',
'"Release"': 'false',
},
}
DEFAULT_CONVERSION ={
'0': 'false',
'1': 'true',
'"ia32"': '"x86"',
}
def gyp_to_gn(key, value):
return GYP_GN_CONVERSION.get(key, DEFAULT_CONVERSION).get(value, value)
def as_json(kv):
assert '=' in kv
k, v = kv.split('=', 1)
return k, json.loads(gyp_to_gn(k, v))
with open(sys.argv[1], 'w') as f:
json.dump(dict(map(as_json, sys.argv[2:])), f)