Change GN to disallow reading args defined in the same declare_args() call.

If you have a declare_args() block like:

    declare_args() {
      use_foo = true
      use_bar = use_foo
    }

currently this will probably produce behavior different than you might
expect. In the normal case (where you don't use use_foo=false in args.gn),
both use_foo and use_bar will bet set to true, but if you do set
use_foo=false in args.gn, use_foo will be set to false, but use_bar
will still be set to true. This happens because GN evaluates the value
of foo inside the block *before* it looks for arg overrides.

We've decided that this is bad enough to flat-out disallow. Now if you
try to do this GN will just return an error. If you want to have one
declared arg depend on the value of another, you need to put them in
separate declare_arg() calls.

This is changing the behavior of GN in a way that may break existing
builds, but hopefully that will happen only rarely and if it does will
expose the surprises that might otherwise be lurking undetected.

In the Chromium build, it turned out we only did this a few times and
they were all unintentional, so this correctly found bugs.

R=brettw@chromium.org, kjellander@chromium.org
BUG=542846

Review-Url: https://codereview.chromium.org/2509333003
Cr-Original-Commit-Position: refs/heads/master@{#433944}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: f6fd4d747c77e1c7968eb5af8b195a94a7ed2fac
7 files changed
tree: 6d061e0ed3eab0a61ca6ce0b1cd559f2a6efb95a
  1. tools/