forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is in preparation for using {{patterns}} in toolchain definitions. It makes them more generic and usable for this, without actually implementing any new features or changing behavior. The only external change should be that the $in variable is used for actions instead of making a redundant new variable (used to be called $source). It removes the FileTemplate class and explodes it into several files: the type list and helpers (substitution_type), a single pattern (substitution_pattern), a list of patterns (substitution_list), and a class of helper functions for processing templates in various ways (substitution_writer). Previously, the things needing substitutions (args, outputs, depfile) were stored as strings and parsed in to FileTemplates as needed. This new method stores the SubstitutionList/Pattern directly on the target. This allows it to issue parse errors (previously such errors were ignored since errors weren't reportable when writing Ninja files) and cleans up a lot of the code that uses it. R=scottmg@chromium.org Review URL: https://codereview.chromium.org/429423002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287847 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
brettw@chromium.org
committed
Aug 6, 2014
1 parent
9866947
commit 012db59
Showing
40 changed files
with
1,484 additions
and
1,117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "tools/gn/scheduler.h" | ||
#include "tools/gn/test_with_scope.h" | ||
|
||
// Tests that actions can't have output substitutions. | ||
TEST(ActionTargetGenerator, ActionOutputSubstitutions) { | ||
Scheduler scheduler; | ||
TestWithScope setup; | ||
Scope::ItemVector items_; | ||
setup.scope()->set_item_collector(&items_); | ||
|
||
// First test one with no substitutions, this should be valid. | ||
TestParseInput input_good( | ||
"action(\"foo\") {\n" | ||
" script = \"//foo.py\"\n" | ||
" sources = [ \"//bar.txt\" ]\n" | ||
" outputs = [ \"//out/Debug/one.txt\" ]\n" | ||
"}"); | ||
ASSERT_FALSE(input_good.has_error()); | ||
|
||
// This should run fine. | ||
Err err; | ||
input_good.parsed()->Execute(setup.scope(), &err); | ||
ASSERT_FALSE(err.has_error()) << err.message(); | ||
|
||
// Same thing with a pattern in the output should fail. | ||
TestParseInput input_bad( | ||
"action(\"foo\") {\n" | ||
" script = \"//foo.py\"\n" | ||
" sources = [ \"//bar.txt\" ]\n" | ||
" outputs = [ \"//out/Debug/{{source_name_part}}.txt\" ]\n" | ||
"}"); | ||
ASSERT_FALSE(input_bad.has_error()); | ||
|
||
// This should run fine. | ||
input_bad.parsed()->Execute(setup.scope(), &err); | ||
ASSERT_TRUE(err.has_error()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.