OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/test_with_scope.h" | 5 #include "tools/gn/test_with_scope.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "tools/gn/parser.h" | 8 #include "tools/gn/parser.h" |
9 #include "tools/gn/tokenizer.h" | 9 #include "tools/gn/tokenizer.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 settings_.set_toolchain_label(toolchain_.label()); | 33 settings_.set_toolchain_label(toolchain_.label()); |
34 settings_.set_default_toolchain_label(toolchain_.label()); | 34 settings_.set_default_toolchain_label(toolchain_.label()); |
35 | 35 |
36 SetupToolchain(&toolchain_); | 36 SetupToolchain(&toolchain_); |
37 } | 37 } |
38 | 38 |
39 TestWithScope::~TestWithScope() { | 39 TestWithScope::~TestWithScope() { |
40 } | 40 } |
41 | 41 |
| 42 Label TestWithScope::ParseLabel(const std::string& str) const { |
| 43 Err err; |
| 44 Label result = Label::Resolve(SourceDir("//"), toolchain_.label(), |
| 45 Value(nullptr, str), &err); |
| 46 CHECK(!err.has_error()); |
| 47 return result; |
| 48 } |
| 49 |
42 // static | 50 // static |
43 void TestWithScope::SetupToolchain(Toolchain* toolchain) { | 51 void TestWithScope::SetupToolchain(Toolchain* toolchain) { |
44 Err err; | 52 Err err; |
45 | 53 |
46 // CC | 54 // CC |
47 scoped_ptr<Tool> cc_tool(new Tool); | 55 scoped_ptr<Tool> cc_tool(new Tool); |
48 SetCommandForTool( | 56 SetCommandForTool( |
49 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " | 57 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " |
50 "-o {{output}}", | 58 "-o {{output}}", |
51 cc_tool.get()); | 59 cc_tool.get()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 : input_file_(SourceFile("//test")) { | 140 : input_file_(SourceFile("//test")) { |
133 input_file_.SetContents(input); | 141 input_file_.SetContents(input); |
134 | 142 |
135 tokens_ = Tokenizer::Tokenize(&input_file_, &parse_err_); | 143 tokens_ = Tokenizer::Tokenize(&input_file_, &parse_err_); |
136 if (!parse_err_.has_error()) | 144 if (!parse_err_.has_error()) |
137 parsed_ = Parser::Parse(tokens_, &parse_err_); | 145 parsed_ = Parser::Parse(tokens_, &parse_err_); |
138 } | 146 } |
139 | 147 |
140 TestParseInput::~TestParseInput() { | 148 TestParseInput::~TestParseInput() { |
141 } | 149 } |
| 150 |
| 151 TestTarget::TestTarget(TestWithScope& setup, |
| 152 const std::string& label_string, |
| 153 Target::OutputType type) |
| 154 : Target(setup.settings(), setup.ParseLabel(label_string)) { |
| 155 visibility().SetPublic(); |
| 156 set_output_type(type); |
| 157 SetToolchain(setup.toolchain()); |
| 158 } |
| 159 |
| 160 TestTarget::~TestTarget() { |
| 161 } |
OLD | NEW |