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

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

Issue 1518663003: Make GN public configs apply libs to targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « tools/gn/target.cc ('k') | tools/gn/variables.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/build_settings.h" 6 #include "tools/gn/build_settings.h"
7 #include "tools/gn/config.h" 7 #include "tools/gn/config.h"
8 #include "tools/gn/scheduler.h" 8 #include "tools/gn/scheduler.h"
9 #include "tools/gn/settings.h" 9 #include "tools/gn/settings.h"
10 #include "tools/gn/target.h" 10 #include "tools/gn/target.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 product.private_deps().push_back(LabelTargetPair(&testlib)); 379 product.private_deps().push_back(LabelTargetPair(&testlib));
380 ASSERT_FALSE(product.OnResolved(&err)); 380 ASSERT_FALSE(product.OnResolved(&err));
381 } 381 }
382 382
383 TEST(Target, PublicConfigs) { 383 TEST(Target, PublicConfigs) {
384 TestWithScope setup; 384 TestWithScope setup;
385 Err err; 385 Err err;
386 386
387 Label pub_config_label(SourceDir("//a/"), "pubconfig"); 387 Label pub_config_label(SourceDir("//a/"), "pubconfig");
388 Config pub_config(setup.settings(), pub_config_label); 388 Config pub_config(setup.settings(), pub_config_label);
389 std::string lib_name("testlib");
390 pub_config.own_values().libs().push_back(lib_name);
389 ASSERT_TRUE(pub_config.OnResolved(&err)); 391 ASSERT_TRUE(pub_config.OnResolved(&err));
390 392
391 // This is the destination target that has a public config. 393 // This is the destination target that has a public config.
392 TestTarget dest(setup, "//a:a", Target::SOURCE_SET); 394 TestTarget dest(setup, "//a:a", Target::SOURCE_SET);
393 dest.public_configs().push_back(LabelConfigPair(&pub_config)); 395 dest.public_configs().push_back(LabelConfigPair(&pub_config));
394 ASSERT_TRUE(dest.OnResolved(&err)); 396 ASSERT_TRUE(dest.OnResolved(&err));
395 397
396 // This target has a public dependency on dest. 398 // This target has a public dependency on dest.
397 TestTarget pub(setup, "//a:pub", Target::SOURCE_SET); 399 TestTarget pub(setup, "//a:pub", Target::SOURCE_SET);
398 pub.public_deps().push_back(LabelTargetPair(&dest)); 400 pub.public_deps().push_back(LabelTargetPair(&dest));
399 ASSERT_TRUE(pub.OnResolved(&err)); 401 ASSERT_TRUE(pub.OnResolved(&err));
400 402
401 // Depending on the target with the public dependency should forward dest's 403 // Depending on the target with the public dependency should forward dest's
402 // to the current target. 404 // to the current target.
403 TestTarget dep_on_pub(setup, "//a:dop", Target::SOURCE_SET); 405 TestTarget dep_on_pub(setup, "//a:dop", Target::SOURCE_SET);
404 dep_on_pub.private_deps().push_back(LabelTargetPair(&pub)); 406 dep_on_pub.private_deps().push_back(LabelTargetPair(&pub));
405 ASSERT_TRUE(dep_on_pub.OnResolved(&err)); 407 ASSERT_TRUE(dep_on_pub.OnResolved(&err));
406 ASSERT_EQ(1u, dep_on_pub.configs().size()); 408 ASSERT_EQ(1u, dep_on_pub.configs().size());
407 EXPECT_EQ(&pub_config, dep_on_pub.configs()[0].ptr); 409 EXPECT_EQ(&pub_config, dep_on_pub.configs()[0].ptr);
408 410
411 // Libs have special handling, check that they were forwarded from the
412 // public config to all_libs.
413 ASSERT_EQ(1u, dep_on_pub.all_libs().size());
414 ASSERT_EQ(lib_name, dep_on_pub.all_libs()[0]);
415
409 // This target has a private dependency on dest for forwards configs. 416 // This target has a private dependency on dest for forwards configs.
410 TestTarget forward(setup, "//a:f", Target::SOURCE_SET); 417 TestTarget forward(setup, "//a:f", Target::SOURCE_SET);
411 forward.private_deps().push_back(LabelTargetPair(&dest)); 418 forward.private_deps().push_back(LabelTargetPair(&dest));
412 ASSERT_TRUE(forward.OnResolved(&err)); 419 ASSERT_TRUE(forward.OnResolved(&err));
413 } 420 }
414 421
415 // Tests that different link/depend outputs work for solink tools. 422 // Tests that different link/depend outputs work for solink tools.
416 TEST(Target, LinkAndDepOutputs) { 423 TEST(Target, LinkAndDepOutputs) {
417 TestWithScope setup; 424 TestWithScope setup;
418 Err err; 425 Err err;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 "\n" 633 "\n"
627 "From //foo:bar\n" 634 "From //foo:bar\n"
628 " header: pch.h\n" 635 " header: pch.h\n"
629 " source: //pcs.cc\n" 636 " source: //pcs.cc\n"
630 "\n" 637 "\n"
631 "From //foo:c2\n" 638 "From //foo:c2\n"
632 " header: pch2.h\n" 639 " header: pch2.h\n"
633 " source: //pcs2.cc", 640 " source: //pcs2.cc",
634 err.help_text()); 641 err.help_text());
635 } 642 }
OLDNEW
« no previous file with comments | « tools/gn/target.cc ('k') | tools/gn/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698