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

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

Issue 2140363002: GN: Fix ordering of public and all dep configs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | 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 "tools/gn/target.h" 5 #include "tools/gn/target.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "tools/gn/build_settings.h" 10 #include "tools/gn/build_settings.h"
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // public config to all_libs. 455 // public config to all_libs.
456 ASSERT_EQ(1u, dep_on_pub.all_libs().size()); 456 ASSERT_EQ(1u, dep_on_pub.all_libs().size());
457 ASSERT_EQ(lib_name, dep_on_pub.all_libs()[0]); 457 ASSERT_EQ(lib_name, dep_on_pub.all_libs()[0]);
458 458
459 // This target has a private dependency on dest for forwards configs. 459 // This target has a private dependency on dest for forwards configs.
460 TestTarget forward(setup, "//a:f", Target::SOURCE_SET); 460 TestTarget forward(setup, "//a:f", Target::SOURCE_SET);
461 forward.private_deps().push_back(LabelTargetPair(&dest)); 461 forward.private_deps().push_back(LabelTargetPair(&dest));
462 ASSERT_TRUE(forward.OnResolved(&err)); 462 ASSERT_TRUE(forward.OnResolved(&err));
463 } 463 }
464 464
465 // Tests that configs are ordered properly between local and pulled ones.
466 TEST(Target, ConfigOrdering) {
467 TestWithScope setup;
468 Err err;
469
470 // Make Dep1. It has all_dependent_configs and public_configs.
471 TestTarget dep1(setup, "//:dep1", Target::SOURCE_SET);
472 Label dep1_all_config_label(SourceDir("//"), "dep1_all_config");
473 Config dep1_all_config(setup.settings(), dep1_all_config_label);
474 ASSERT_TRUE(dep1_all_config.OnResolved(&err));
475 dep1.all_dependent_configs().push_back(LabelConfigPair(&dep1_all_config));
476
477 Label dep1_public_config_label(SourceDir("//"), "dep1_public_config");
478 Config dep1_public_config(setup.settings(), dep1_public_config_label);
479 ASSERT_TRUE(dep1_public_config.OnResolved(&err));
480 dep1.public_configs().push_back(LabelConfigPair(&dep1_public_config));
481 ASSERT_TRUE(dep1.OnResolved(&err));
482
483 // Make Dep2 with the same structure.
484 TestTarget dep2(setup, "//:dep2", Target::SOURCE_SET);
485 Label dep2_all_config_label(SourceDir("//"), "dep2_all_config");
486 Config dep2_all_config(setup.settings(), dep2_all_config_label);
487 ASSERT_TRUE(dep2_all_config.OnResolved(&err));
488 dep2.all_dependent_configs().push_back(LabelConfigPair(&dep2_all_config));
489
490 Label dep2_public_config_label(SourceDir("//"), "dep2_public_config");
491 Config dep2_public_config(setup.settings(), dep2_public_config_label);
492 ASSERT_TRUE(dep2_public_config.OnResolved(&err));
493 dep2.public_configs().push_back(LabelConfigPair(&dep2_public_config));
494 ASSERT_TRUE(dep2.OnResolved(&err));
495
496 // This target depends on both previous targets.
497 TestTarget target(setup, "//:foo", Target::SOURCE_SET);
498 target.private_deps().push_back(LabelTargetPair(&dep1));
499 target.private_deps().push_back(LabelTargetPair(&dep2));
500
501 // It also has a private and public config.
502 Label public_config_label(SourceDir("//"), "public");
503 Config public_config(setup.settings(), public_config_label);
504 ASSERT_TRUE(public_config.OnResolved(&err));
505 target.public_configs().push_back(LabelConfigPair(&public_config));
506
507 Label private_config_label(SourceDir("//"), "private");
508 Config private_config(setup.settings(), private_config_label);
509 ASSERT_TRUE(private_config.OnResolved(&err));
510 target.configs().push_back(LabelConfigPair(&private_config));
511
512 // Resolve to get the computed list of configs applying.
513 ASSERT_TRUE(target.OnResolved(&err));
514 const auto& computed = target.configs();
515
516 // Order should be:
517 // 1. local private
518 // 2. local public
519 // 3. inherited all dependent
520 // 4. inherited public
521 ASSERT_EQ(6u, computed.size());
522 EXPECT_EQ(private_config_label, computed[0].label);
523 EXPECT_EQ(public_config_label, computed[1].label);
524 EXPECT_EQ(dep1_all_config_label, computed[2].label);
525 EXPECT_EQ(dep2_all_config_label, computed[3].label);
526 EXPECT_EQ(dep1_public_config_label, computed[4].label);
527 EXPECT_EQ(dep2_public_config_label, computed[5].label);
528 }
529
465 // Tests that different link/depend outputs work for solink tools. 530 // Tests that different link/depend outputs work for solink tools.
466 TEST(Target, LinkAndDepOutputs) { 531 TEST(Target, LinkAndDepOutputs) {
467 TestWithScope setup; 532 TestWithScope setup;
468 Err err; 533 Err err;
469 534
470 Toolchain toolchain(setup.settings(), Label(SourceDir("//tc/"), "tc")); 535 Toolchain toolchain(setup.settings(), Label(SourceDir("//tc/"), "tc"));
471 536
472 std::unique_ptr<Tool> solink_tool(new Tool()); 537 std::unique_ptr<Tool> solink_tool(new Tool());
473 solink_tool->set_output_prefix("lib"); 538 solink_tool->set_output_prefix("lib");
474 solink_tool->set_default_output_extension(".so"); 539 solink_tool->set_default_output_extension(".so");
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u); 979 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u);
915 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u); 980 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u);
916 ASSERT_EQ(c.bundle_data().bundle_deps().size(), 1u); 981 ASSERT_EQ(c.bundle_data().bundle_deps().size(), 1u);
917 982
918 // E does not have any bundle_data information but gets a list of 983 // E does not have any bundle_data information but gets a list of
919 // bundle_deps to propagate them during target resolution. 984 // bundle_deps to propagate them during target resolution.
920 ASSERT_TRUE(e.bundle_data().file_rules().empty()); 985 ASSERT_TRUE(e.bundle_data().file_rules().empty());
921 ASSERT_TRUE(e.bundle_data().assets_catalog_sources().empty()); 986 ASSERT_TRUE(e.bundle_data().assets_catalog_sources().empty());
922 ASSERT_EQ(e.bundle_data().bundle_deps().size(), 2u); 987 ASSERT_EQ(e.bundle_data().bundle_deps().size(), 2u);
923 } 988 }
OLDNEW
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698