Check whether variables is set before using GN not_needed

GN not_needed functions now checks whether the variable exists and
invoking not_needed on non-existent variable is considered an error.

Change-Id: I45bcb0c06228920d41db3482a0e50eae3b26eb0d
Reviewed-on: https://dart-review.googlesource.com/62022
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
This commit is contained in:
Petr Hosek 2018-06-23 23:59:59 +00:00 committed by commit-bot@chromium.org
parent f381778867
commit 212a817322

View file

@ -206,12 +206,6 @@ template("library_for_all_configs") {
if (defined(invoker.extra_deps)) {
extra_deps += invoker.extra_deps
}
not_needed(invoker,
[
"snapshot_sources",
"nosnapshot_sources",
"nosnapshot_deps",
])
foreach(conf, _all_configs) {
target(invoker.target_type, "${target_name}${conf.suffix}") {
forward_variables_from(invoker,
@ -231,11 +225,20 @@ template("library_for_all_configs") {
}
deps = configured_deps + extra_deps
if (conf.snapshot) {
if (defined(invoker.snapshot_sources)) {
if (defined(snapshot_sources)) {
sources += snapshot_sources
}
if (defined(nosnapshot_sources)) {
not_needed([ "nosnapshot_sources" ])
}
if (defined(nosnapshot_deps)) {
not_needed([ "nosnapshot_deps" ])
}
} else {
if (defined(invoker.nosnapshot_sources)) {
if (defined(snapshot_sources)) {
not_needed([ "snapshot_sources" ])
}
if (defined(nosnapshot_sources)) {
sources += nosnapshot_sources
}
if (defined(nosnapshot_deps)) {