Commit 067d014b authored by dpranke's avatar dpranke Committed by Commit bot

Modify the gn version of 'mb analyze' to handle GN group targets as well.

Previously, if a group target like 'mandoline:all' was specified as
an additional_compile_target that we wanted to build, the gn implementation
of 'analyze' would not handle it correctly (it could only handle dependencies
on files that existed in the build directory, like executables).

This patch modifies the MB implementation to also handle label-like targets
(the ninja mandoline:all target is the equivalent of the GN //mandonline:all
target); we do this by calling 'gn refs' twice, once looking for a list
of output paths to match against the compile targets and once looking for
a list of phony labels to match against the compile targets.

We also will match against just the target_name, so 'chrome_shell_apk' will
also match "//chrome/android:chrome_shell_apk'. This may result in
too many targets being rebuilt, but we can adjust that if need be.

This is somewhat inefficient, but the alternatives would be to either
1) force the user to specify the stamp files for a group, which would be
   ugly, or
2) force the user to specify all the compile targets in terms of GN labels,
   which would be different from how the recipes work w/ GYP and possibly
   require us to map binary names to targets outside of GN, which would
   be a maintenance headache.

R=scottmg@chromium.org,brettw@chromium.org
BUG=487035
CQ_EXTRA_TRYBOTS=tryserver.chromium.mac:mac_chromium_gn_rel;tryserver.chromium.win:win8_chromium_gn_rel

Review URL: https://codereview.chromium.org/1135743005

Cr-Commit-Position: refs/heads/master@{#329964}
parent ac496302
...@@ -429,9 +429,7 @@ class MetaBuildWrapper(object): ...@@ -429,9 +429,7 @@ class MetaBuildWrapper(object):
matching_targets = [] matching_targets = []
try: try:
cmd = self.GNCmd('refs', self.args.path[0]) + [ cmd = self.GNCmd('refs', self.args.path[0]) + [
'@%s' % response_file.name, '@%s' % response_file.name, '--all', '--as=output']
'--type=executable', '--all', '--as=output'
]
ret, out, _ = self.Run(cmd) ret, out, _ = self.Run(cmd)
if ret and not 'The input matches no targets' in out: if ret and not 'The input matches no targets' in out:
self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out),
...@@ -441,6 +439,22 @@ class MetaBuildWrapper(object): ...@@ -441,6 +439,22 @@ class MetaBuildWrapper(object):
build_output = output.replace(build_dir, '') build_output = output.replace(build_dir, '')
if build_output in inp['targets']: if build_output in inp['targets']:
matching_targets.append(build_output) matching_targets.append(build_output)
cmd = self.GNCmd('refs', self.args.path[0]) + [
'@%s' % response_file.name, '--all']
ret, out, _ = self.Run(cmd)
if ret and not 'The input matches no targets' in out:
self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out),
output_path)
for label in out.splitlines():
build_target = label[2:]
# We want to accept 'chrome/android:chrome_shell_apk' and
# just 'chrome_shell_apk'. This may result in too many targets
# getting built, but we can adjust that later if need be.
for input_target in inp['targets']:
if (input_target == build_target or
build_target.endswith(':' + input_target)):
matching_targets.append(input_target)
finally: finally:
self.RemoveFile(response_file.name) self.RemoveFile(response_file.name)
......
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