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

Issue 2187523003: Allow creation and modification of scopes in GN. (Closed)

Created:
4 years, 4 months ago by brettw
Modified:
4 years, 4 months ago
Reviewers:
Dirk Pranke
CC:
chromium-reviews, Dirk Pranke, tfarina
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Allow creation and modification of scopes in GN. Previously scope variables could only be created by exec_script() and read_file() functions. This patch adds the following syntax: foo = { a = 1 b = 2 } foo.a += 1 foo.c = 3 This will be used in a followup for toolchain args for non-default toolchains, which will allow us to generalize the templates as the number of configurations grows over time (currently every variable has be to be forwarded in the root toolchain templates). It also allows mutations of list elements which isn't actually necessary for this but the implementation is the same as for scope mutations: list[0] = "foo" This does a significant rework of the operator implementation. This was required for the more general "destination" for assignments and mutations. It also updates the operator functions to use move semantics more. Previously: list3 = list1 + list2 Would be implemented as: 1. Copy list1 into new new variable. 2. Copy list2 into a new variable. 3. Copy list1's copy to a new variable. 4. Append elements of list2 to list1's copy by copying. 5. Copy that list to list3. That's a lot of copies! The new implementation does: 1. Copy list1 into a new variable. 2. Copy list2 into a new variable. 3. Append elements of list2's copy to list1's copy by moving. 4. Move list2 to list3. Assuming the lists contain strings, each string should now be copied exactly once rather than three times. Added a lot of documentation to the grammar help on how the language works (not strictly grammar but it seems like the best place to put it. BUG= Committed: https://crrev.com/01cdea1ed9ad32a7a595ef1a5adfa384006e3097 Cr-Commit-Position: refs/heads/master@{#409672}

Patch Set 1 #

Patch Set 2 : operator work #

Patch Set 3 : Compiles but doesn't pass tests #

Patch Set 4 : Merge remote-tracking branch 'origin/master' into scope #

Patch Set 5 : . #

Patch Set 6 : . #

Patch Set 7 : Cleanup #

Patch Set 8 : . #

Patch Set 9 : Cleanup #

Total comments: 8

Patch Set 10 : Review comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+802 lines, -331 lines) Patch
M tools/gn/command_help.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M tools/gn/function_foreach.cc View 1 2 3 4 5 6 7 1 chunk +2 lines, -1 line 0 comments Download
M tools/gn/function_forward_variables_from.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M tools/gn/functions.cc View 1 1 chunk +6 lines, -4 lines 0 comments Download
M tools/gn/loader_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M tools/gn/operators.cc View 1 2 3 4 5 6 7 8 9 8 chunks +405 lines, -228 lines 0 comments Download
M tools/gn/operators_unittest.cc View 1 2 3 4 5 6 7 2 chunks +74 lines, -0 lines 0 comments Download
M tools/gn/parse_tree.h View 1 2 3 4 5 6 7 8 4 chunks +25 lines, -1 line 0 comments Download
M tools/gn/parse_tree.cc View 1 2 3 4 5 6 7 8 6 chunks +67 lines, -33 lines 0 comments Download
M tools/gn/parse_tree_unittest.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M tools/gn/parser.h View 2 chunks +5 lines, -1 line 0 comments Download
M tools/gn/parser.cc View 1 2 3 4 5 6 7 8 9 11 chunks +124 lines, -17 lines 0 comments Download
M tools/gn/parser_unittest.cc View 1 2 3 4 2 chunks +35 lines, -2 lines 0 comments Download
M tools/gn/scope.h View 1 2 3 4 5 6 7 5 chunks +25 lines, -12 lines 0 comments Download
M tools/gn/scope.cc View 1 2 3 4 5 6 7 4 chunks +12 lines, -21 lines 0 comments Download
M tools/gn/scope_unittest.cc View 1 2 3 4 5 6 2 chunks +8 lines, -4 lines 0 comments Download
M tools/gn/template.cc View 1 2 2 chunks +4 lines, -3 lines 0 comments Download
M tools/gn/value.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M tools/gn/value.cc View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M tools/gn/visibility_unittest.cc View 1 2 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 28 (16 generated)
brettw
.
4 years, 4 months ago (2016-08-01 23:40:41 UTC) #1
brettw
.
4 years, 4 months ago (2016-08-02 00:02:26 UTC) #2
brettw
Cleanup
4 years, 4 months ago (2016-08-02 16:58:41 UTC) #9
brettw
4 years, 4 months ago (2016-08-02 18:03:57 UTC) #12
Dirk Pranke
Can you point to a CL or something that shows how the toolchain_args() code will ...
4 years, 4 months ago (2016-08-03 16:51:31 UTC) #17
brettw
I don't have a CL yet, but it's easy. The toolchain args will look like ...
4 years, 4 months ago (2016-08-03 16:58:11 UTC) #18
Dirk Pranke
lgtm w/ nits. https://codereview.chromium.org/2187523003/diff/160001/tools/gn/operators.cc File tools/gn/operators.cc (right): https://codereview.chromium.org/2187523003/diff/160001/tools/gn/operators.cc#newcode45 tools/gn/operators.cc:45: Value* GetExistingMutableValue(const ParseNode* origin); Nit: would ...
4 years, 4 months ago (2016-08-03 23:06:20 UTC) #19
brettw
https://codereview.chromium.org/2187523003/diff/160001/tools/gn/operators.cc File tools/gn/operators.cc (right): https://codereview.chromium.org/2187523003/diff/160001/tools/gn/operators.cc#newcode45 tools/gn/operators.cc:45: Value* GetExistingMutableValue(const ParseNode* origin); On 2016/08/03 23:06:19, Dirk Pranke ...
4 years, 4 months ago (2016-08-03 23:23:00 UTC) #20
brettw
Review comments
4 years, 4 months ago (2016-08-03 23:23:52 UTC) #21
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/2187523003/180001
4 years, 4 months ago (2016-08-03 23:24:21 UTC) #24
commit-bot: I haz the power
Committed patchset #10 (id:180001)
4 years, 4 months ago (2016-08-04 00:00:51 UTC) #26
commit-bot: I haz the power
4 years, 4 months ago (2016-08-04 00:04:04 UTC) #28
Message was sent while issue was closed.
Patchset 10 (id:??) landed as
https://crrev.com/01cdea1ed9ad32a7a595ef1a5adfa384006e3097
Cr-Commit-Position: refs/heads/master@{#409672}

Powered by Google App Engine
This is Rietveld 408576698