Fail write_build_config.py if current_toolchain != default_toolchain

There are a few spots in the Android templates that assume appending
__build_config to a given target label will result in the label for a
write_build_config action. When toolchains exist in a label, appending
like this doesn't work. E.g.: :some_label(//toolchain)__build_config

Previously, we added a GN assert to enforce default toolchain, but that
was too strict, as it made it so no other targets that are defined in
the same BUILD.gn file could use a non-default toolchain.

This change make the error a build-time error rather than a gn gen
error.

BUG=629371

Review-Url: https://codereview.chromium.org/2161063003
Cr-Original-Commit-Position: refs/heads/master@{#408576}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 83bcd862038586061feea4b390ac524ab0a9a358
This commit is contained in:
agrieve 2016-07-28 21:26:20 -07:00 коммит произвёл Commit bot
Родитель 5240573aa6
Коммит 8adc3cd78c
2 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -279,11 +279,15 @@ def main(argv):
help='Path to the proguard .info output for this apk.')
parser.add_option('--has-alternative-locale-resource', action='store_true',
help='Whether there is alternative-locale-resource in direct deps')
parser.add_option('--fail',
help='GYP-list of error message lines to fail with.')
options, args = parser.parse_args(argv)
if args:
parser.error('No positional arguments should be given.')
if options.fail:
parser.error('\n'.join(build_utils.ParseGypList(options.fail)))
required_options_map = {
'java_binary': ['build_config', 'jar_path'],

Просмотреть файл

@ -336,6 +336,25 @@ template("write_build_config") {
rebase_path(invoker.bundled_srcjars, root_build_dir)
args += [ "--bundled-srcjars=$_rebased_bundled_srcjars" ]
}
if (current_toolchain != default_toolchain) {
# This has to be a built-time error rather than a GN assert because many
# packages have a mix of java and non-java targets. For example, the
# following would fail even though nothing depends on :bar(//baz):
#
# shared_library("foo") {
# }
#
# android_library("bar") {
# deps = [ ":foo(//baz)" ]
# assert(current_toolchain == default_toolchain)
# }
_msg = [
"Tried to build an Android target in a non-default toolchain.",
"target: " + get_label_info(":$target_name", "label_with_toolchain"),
"default_toolchain: $default_toolchain",
]
args += [ "--fail=$_msg" ]
}
}
}