Commit 96fdf7cb authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Commit Bot

[ninja] collect build configs

This is to know what build configs are popular among chromium developer.

Bug: 900161
Change-Id: Id07722e70fc407b3f8668080d49033da6e1a7f34
Reviewed-on: https://chromium-review.googlesource.com/c/1358034
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: 's avatarShinya Kawanaka <shinyak@chromium.org>
Reviewed-by: 's avatarFumitoshi Ukai <ukai@chromium.org>
parent 0b287c5b
......@@ -24,6 +24,7 @@ import multiprocessing
import os
import platform
import socket
import subprocess
import sys
from third_party import httplib2
......@@ -37,18 +38,55 @@ def IsGoogler(server):
except httplib2.HttpLib2Error:
return False
def ParseGNArgs(gn_args):
"""Parse gn_args as json and return config dictionary.
>>> ParseGNArgs("[]")
{}
>>> ParseGNArgs('[{\
"current": {"value": "true"}, \
"default": {"value": "false"}, \
"name": "is_component_build"}]')
{u'is_component_build': u'true'}
"""
configs = json.loads(gn_args)
build_configs = {}
for config in configs:
build_configs[config["name"]] = config["current"]["value"]
return build_configs
def GetMetadata(cmdline, ninjalog):
"""Get metadata for uploaded ninjalog."""
# TODO(tikuta): Support build_configs from args.gn.
build_dir = os.path.dirname(ninjalog)
build_configs = {}
try:
args = ['gn', 'args', build_dir, '--list', '--overrides-only',
'--short', '--json']
if sys.platform == 'win32':
# gn in PATH is bat file in windows environment (except cygwin).
args = ['cmd', '/c'] + args
gn_args = subprocess.check_output(args)
build_configs = ParseGNArgs(gn_args)
except subprocess.CalledProcessError as e:
logging.error("Failed to call gn %s", e)
build_configs = {}
# Stringify config.
for k in build_configs:
build_configs[k] = str(build_configs[k])
metadata = {
'platform': platform.system(),
'cwd': build_dir,
'hostname': socket.gethostname(),
'cpu_core': multiprocessing.cpu_count(),
'cmdline': cmdline,
'build_configs': build_configs,
}
return metadata
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment