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

Side by Side Diff: tools/gn/builder_unittest.cc

Issue 440333002: Support more configurability in GN toolchains (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unsigned check Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/builder.cc ('k') | tools/gn/command_gen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/builder.h" 6 #include "tools/gn/builder.h"
7 #include "tools/gn/loader.h" 7 #include "tools/gn/loader.h"
8 #include "tools/gn/target.h" 8 #include "tools/gn/target.h"
9 #include "tools/gn/test_with_scope.h" 9 #include "tools/gn/test_with_scope.h"
10 #include "tools/gn/toolchain.h" 10 #include "tools/gn/toolchain.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 builder_(new Builder(loader_.get())), 64 builder_(new Builder(loader_.get())),
65 settings_(&build_settings_, std::string()), 65 settings_(&build_settings_, std::string()),
66 scope_(&settings_) { 66 scope_(&settings_) {
67 build_settings_.SetBuildDir(SourceDir("//out/")); 67 build_settings_.SetBuildDir(SourceDir("//out/"));
68 settings_.set_toolchain_label(Label(SourceDir("//tc/"), "default")); 68 settings_.set_toolchain_label(Label(SourceDir("//tc/"), "default"));
69 settings_.set_default_toolchain_label(settings_.toolchain_label()); 69 settings_.set_default_toolchain_label(settings_.toolchain_label());
70 } 70 }
71 71
72 Toolchain* DefineToolchain() { 72 Toolchain* DefineToolchain() {
73 Toolchain* tc = new Toolchain(&settings_, settings_.toolchain_label()); 73 Toolchain* tc = new Toolchain(&settings_, settings_.toolchain_label());
74 TestWithScope::SetupToolchain(tc);
74 builder_->ItemDefined(scoped_ptr<Item>(tc)); 75 builder_->ItemDefined(scoped_ptr<Item>(tc));
75 return tc; 76 return tc;
76 } 77 }
77 78
78 protected: 79 protected:
79 scoped_refptr<MockLoader> loader_; 80 scoped_refptr<MockLoader> loader_;
80 scoped_refptr<Builder> builder_; 81 scoped_refptr<Builder> builder_;
81 BuildSettings build_settings_; 82 BuildSettings build_settings_;
82 Settings settings_; 83 Settings settings_;
83 Scope scope_; 84 Scope scope_;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 178
178 // Tests that the should generate bit is set and propogated properly. 179 // Tests that the should generate bit is set and propogated properly.
179 TEST_F(BuilderTest, ShouldGenerate) { 180 TEST_F(BuilderTest, ShouldGenerate) {
180 DefineToolchain(); 181 DefineToolchain();
181 182
182 // Define a secondary toolchain. 183 // Define a secondary toolchain.
183 Settings settings2(&build_settings_, "secondary/"); 184 Settings settings2(&build_settings_, "secondary/");
184 Label toolchain_label2(SourceDir("//tc/"), "secondary"); 185 Label toolchain_label2(SourceDir("//tc/"), "secondary");
185 settings2.set_toolchain_label(toolchain_label2); 186 settings2.set_toolchain_label(toolchain_label2);
186 Toolchain* tc2 = new Toolchain(&settings2, toolchain_label2); 187 Toolchain* tc2 = new Toolchain(&settings2, toolchain_label2);
188 TestWithScope::SetupToolchain(tc2);
187 builder_->ItemDefined(scoped_ptr<Item>(tc2)); 189 builder_->ItemDefined(scoped_ptr<Item>(tc2));
188 190
189 // Construct a dependency chain: A -> B. A is in the default toolchain, B 191 // Construct a dependency chain: A -> B. A is in the default toolchain, B
190 // is not. 192 // is not.
191 Label a_label(SourceDir("//foo/"), "a", 193 Label a_label(SourceDir("//foo/"), "a",
192 settings_.toolchain_label().dir(), "a"); 194 settings_.toolchain_label().dir(), "a");
193 Label b_label(SourceDir("//foo/"), "b", 195 Label b_label(SourceDir("//foo/"), "b",
194 toolchain_label2.dir(), toolchain_label2.name()); 196 toolchain_label2.dir(), toolchain_label2.name());
195 197
196 // First define B. 198 // First define B.
(...skipping 11 matching lines...) Expand all
208 a->set_output_type(Target::EXECUTABLE); 210 a->set_output_type(Target::EXECUTABLE);
209 builder_->ItemDefined(scoped_ptr<Item>(a)); 211 builder_->ItemDefined(scoped_ptr<Item>(a));
210 212
211 // A should have the generate bit set since it's in the default toolchain. 213 // A should have the generate bit set since it's in the default toolchain.
212 BuilderRecord* a_record = builder_->GetRecord(a_label); 214 BuilderRecord* a_record = builder_->GetRecord(a_label);
213 EXPECT_TRUE(a_record->should_generate()); 215 EXPECT_TRUE(a_record->should_generate());
214 216
215 // It should have gotten pushed to B. 217 // It should have gotten pushed to B.
216 EXPECT_TRUE(b_record->should_generate()); 218 EXPECT_TRUE(b_record->should_generate());
217 } 219 }
OLDNEW
« no previous file with comments | « tools/gn/builder.cc ('k') | tools/gn/command_gen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698