Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Issue 2509333003: Change GN to disallow reading args defined in the same declare_args() call. (Closed)

Created:
4 years, 1 month ago by Dirk Pranke
Modified:
4 years ago
CC:
chromium-reviews, Dirk Pranke, tfarina, agrieve+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

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 Committed: https://crrev.com/f6fd4d747c77e1c7968eb5af8b195a94a7ed2fac Cr-Commit-Position: refs/heads/master@{#433944}

Patch Set 1 : initial patch for review #

Total comments: 6

Patch Set 2 : update w/ review feedback #

Patch Set 3 : add tests #

Total comments: 4

Patch Set 4 : update w/ review feedback #

Patch Set 5 : update w/ review feedback #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+154 lines, -32 lines) Patch
M build/config/BUILDCONFIG.gn View 1 2 chunks +5 lines, -3 lines 0 comments Download
M build/config/ui.gni View 1 2 3 2 chunks +6 lines, -4 lines 0 comments Download
M tools/gn/docs/reference.md View 2 chunks +7 lines, -8 lines 0 comments Download
M tools/gn/functions.h View 1 2 chunks +11 lines, -1 line 0 comments Download
M tools/gn/functions.cc View 1 2 3 4 chunks +38 lines, -8 lines 1 comment Download
M tools/gn/functions_unittest.cc View 1 2 1 chunk +45 lines, -0 lines 0 comments Download
M tools/gn/parse_tree.cc View 1 1 chunk +6 lines, -1 line 0 comments Download
M tools/gn/scope.h View 1 2 3 2 chunks +10 lines, -1 line 0 comments Download
M tools/gn/scope.cc View 1 2 chunks +26 lines, -6 lines 0 comments Download

Messages

Total messages: 21 (8 generated)
Dirk Pranke
What do you think?
4 years, 1 month ago (2016-11-18 03:33:24 UTC) #4
kjellander_chromium
lgtm. I don't think it'll break WebRTC rolling and if it does that's fine since ...
4 years, 1 month ago (2016-11-18 13:25:50 UTC) #5
kjellander_chromium
On 2016/11/18 13:25:50, kjellander_chromium wrote: > lgtm. I don't think it'll break WebRTC rolling and ...
4 years, 1 month ago (2016-11-18 13:27:32 UTC) #6
brettw
https://codereview.chromium.org/2509333003/diff/40001/tools/gn/functions.cc File tools/gn/functions.cc (right): https://codereview.chromium.org/2509333003/diff/40001/tools/gn/functions.cc#newcode421 tools/gn/functions.cc:421: block_scope.SetProperty(&kInDeclareArgsKey, (void *)&kInDeclareArgsKey); Are you sure you need the ...
4 years, 1 month ago (2016-11-18 22:07:43 UTC) #7
Dirk Pranke
https://codereview.chromium.org/2509333003/diff/40001/tools/gn/functions.cc File tools/gn/functions.cc (right): https://codereview.chromium.org/2509333003/diff/40001/tools/gn/functions.cc#newcode421 tools/gn/functions.cc:421: block_scope.SetProperty(&kInDeclareArgsKey, (void *)&kInDeclareArgsKey); On 2016/11/18 22:07:43, brettw (ping on ...
4 years, 1 month ago (2016-11-18 22:35:40 UTC) #8
Dirk Pranke
Updated. Please take another look?
4 years, 1 month ago (2016-11-19 03:34:14 UTC) #9
brettw
lgtm https://codereview.chromium.org/2509333003/diff/80001/tools/gn/functions.cc File tools/gn/functions.cc (right): https://codereview.chromium.org/2509333003/diff/80001/tools/gn/functions.cc#newcode73 tools/gn/functions.cc:73: "Reading a variable defined in the same declare_args() ...
4 years ago (2016-11-21 17:23:39 UTC) #10
Dirk Pranke
https://codereview.chromium.org/2509333003/diff/80001/tools/gn/functions.cc File tools/gn/functions.cc (right): https://codereview.chromium.org/2509333003/diff/80001/tools/gn/functions.cc#newcode73 tools/gn/functions.cc:73: "Reading a variable defined in the same declare_args() call."); ...
4 years ago (2016-11-21 17:39:48 UTC) #11
Dirk Pranke
Updated, please take another look? https://codereview.chromium.org/2509333003/diff/120001/tools/gn/functions.cc File tools/gn/functions.cc (right): https://codereview.chromium.org/2509333003/diff/120001/tools/gn/functions.cc#newcode76 tools/gn/functions.cc:76: "them in two separate ...
4 years ago (2016-11-22 02:48:53 UTC) #12
brettw
Seems good enough to me (still lgtm)
4 years ago (2016-11-22 04:55:57 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2509333003/120001
4 years ago (2016-11-22 17:06:46 UTC) #16
commit-bot: I haz the power
Committed patchset #5 (id:120001)
4 years ago (2016-11-22 19:43:46 UTC) #19
commit-bot: I haz the power
4 years ago (2016-11-22 19:45:20 UTC) #21
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/f6fd4d747c77e1c7968eb5af8b195a94a7ed2fac
Cr-Commit-Position: refs/heads/master@{#433944}

Powered by Google App Engine
This is Rietveld 408576698