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

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

Issue 561273003: Add public deps to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 3 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/command_refs.cc ('k') | tools/gn/copy_target_generator.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <sstream> 5 #include <sstream>
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "tools/gn/config.h" 8 #include "tools/gn/config.h"
9 #include "tools/gn/config_values_extractors.h" 9 #include "tools/gn/config_values_extractors.h"
10 #include "tools/gn/target.h" 10 #include "tools/gn/target.h"
(...skipping 28 matching lines...) Expand all
39 dep2_all.config_values().cflags().push_back("--dep2-all"); 39 dep2_all.config_values().cflags().push_back("--dep2-all");
40 dep2_all.config_values().include_dirs().push_back(SourceDir("//dep2/all/")); 40 dep2_all.config_values().include_dirs().push_back(SourceDir("//dep2/all/"));
41 41
42 Config dep2_direct(setup.settings(), Label(SourceDir("//dep2/"), "direct")); 42 Config dep2_direct(setup.settings(), Label(SourceDir("//dep2/"), "direct"));
43 dep2_direct.config_values().cflags().push_back("--dep2-direct"); 43 dep2_direct.config_values().cflags().push_back("--dep2-direct");
44 dep2_direct.config_values().include_dirs().push_back( 44 dep2_direct.config_values().include_dirs().push_back(
45 SourceDir("//dep2/direct/")); 45 SourceDir("//dep2/direct/"));
46 46
47 Target dep2(setup.settings(), Label(SourceDir("//dep2/"), "dep2")); 47 Target dep2(setup.settings(), Label(SourceDir("//dep2/"), "dep2"));
48 dep2.set_output_type(Target::SOURCE_SET); 48 dep2.set_output_type(Target::SOURCE_SET);
49 dep2.visibility().SetPublic();
49 dep2.SetToolchain(setup.toolchain()); 50 dep2.SetToolchain(setup.toolchain());
50 dep2.all_dependent_configs().push_back(LabelConfigPair(&dep2_all)); 51 dep2.all_dependent_configs().push_back(LabelConfigPair(&dep2_all));
51 dep2.direct_dependent_configs().push_back(LabelConfigPair(&dep2_direct)); 52 dep2.public_configs().push_back(LabelConfigPair(&dep2_direct));
52 53
53 // Set up dep1, direct and all dependent configs. 54 // Set up dep1, direct and all dependent configs.
54 Config dep1_all(setup.settings(), Label(SourceDir("//dep1/"), "all")); 55 Config dep1_all(setup.settings(), Label(SourceDir("//dep1/"), "all"));
55 dep1_all.config_values().cflags().push_back("--dep1-all"); 56 dep1_all.config_values().cflags().push_back("--dep1-all");
56 dep1_all.config_values().include_dirs().push_back(SourceDir("//dep1/all/")); 57 dep1_all.config_values().include_dirs().push_back(SourceDir("//dep1/all/"));
57 58
58 Config dep1_direct(setup.settings(), Label(SourceDir("//dep1/"), "direct")); 59 Config dep1_direct(setup.settings(), Label(SourceDir("//dep1/"), "direct"));
59 dep1_direct.config_values().cflags().push_back("--dep1-direct"); 60 dep1_direct.config_values().cflags().push_back("--dep1-direct");
60 dep1_direct.config_values().include_dirs().push_back( 61 dep1_direct.config_values().include_dirs().push_back(
61 SourceDir("//dep1/direct/")); 62 SourceDir("//dep1/direct/"));
62 63
63 Target dep1(setup.settings(), Label(SourceDir("//dep1/"), "dep1")); 64 Target dep1(setup.settings(), Label(SourceDir("//dep1/"), "dep1"));
64 dep1.set_output_type(Target::SOURCE_SET); 65 dep1.set_output_type(Target::SOURCE_SET);
66 dep1.visibility().SetPublic();
65 dep1.SetToolchain(setup.toolchain()); 67 dep1.SetToolchain(setup.toolchain());
66 dep1.all_dependent_configs().push_back(LabelConfigPair(&dep1_all)); 68 dep1.all_dependent_configs().push_back(LabelConfigPair(&dep1_all));
67 dep1.direct_dependent_configs().push_back(LabelConfigPair(&dep1_direct)); 69 dep1.public_configs().push_back(LabelConfigPair(&dep1_direct));
68 dep1.deps().push_back(LabelTargetPair(&dep2)); 70 dep1.private_deps().push_back(LabelTargetPair(&dep2));
69 71
70 // Set up target, direct and all dependent configs. 72 // Set up target, direct and all dependent configs.
71 Config target_all(setup.settings(), Label(SourceDir("//target/"), "all")); 73 Config target_all(setup.settings(), Label(SourceDir("//target/"), "all"));
72 target_all.config_values().cflags().push_back("--target-all"); 74 target_all.config_values().cflags().push_back("--target-all");
73 target_all.config_values().include_dirs().push_back( 75 target_all.config_values().include_dirs().push_back(
74 SourceDir("//target/all/")); 76 SourceDir("//target/all/"));
75 77
76 Config target_direct(setup.settings(), 78 Config target_direct(setup.settings(),
77 Label(SourceDir("//target/"), "direct")); 79 Label(SourceDir("//target/"), "direct"));
78 target_direct.config_values().cflags().push_back("--target-direct"); 80 target_direct.config_values().cflags().push_back("--target-direct");
79 target_direct.config_values().include_dirs().push_back( 81 target_direct.config_values().include_dirs().push_back(
80 SourceDir("//target/direct/")); 82 SourceDir("//target/direct/"));
81 83
82 // This config is applied directly to target. 84 // This config is applied directly to target.
83 Config target_config(setup.settings(), 85 Config target_config(setup.settings(),
84 Label(SourceDir("//target/"), "config")); 86 Label(SourceDir("//target/"), "config"));
85 target_config.config_values().cflags().push_back("--target-config"); 87 target_config.config_values().cflags().push_back("--target-config");
86 target_config.config_values().include_dirs().push_back( 88 target_config.config_values().include_dirs().push_back(
87 SourceDir("//target/config/")); 89 SourceDir("//target/config/"));
88 90
89 Target target(setup.settings(), Label(SourceDir("//target/"), "target")); 91 Target target(setup.settings(), Label(SourceDir("//target/"), "target"));
90 target.set_output_type(Target::SOURCE_SET); 92 target.set_output_type(Target::SOURCE_SET);
91 target.SetToolchain(setup.toolchain()); 93 target.SetToolchain(setup.toolchain());
92 target.all_dependent_configs().push_back(LabelConfigPair(&target_all)); 94 target.all_dependent_configs().push_back(LabelConfigPair(&target_all));
93 target.direct_dependent_configs().push_back(LabelConfigPair(&target_direct)); 95 target.public_configs().push_back(LabelConfigPair(&target_direct));
94 target.configs().push_back(LabelConfigPair(&target_config)); 96 target.configs().push_back(LabelConfigPair(&target_config));
95 target.deps().push_back(LabelTargetPair(&dep1)); 97 target.private_deps().push_back(LabelTargetPair(&dep1));
96 98
97 99
98 // Additionally add some values directly on "target". 100 // Additionally add some values directly on "target".
99 target.config_values().cflags().push_back("--target"); 101 target.config_values().cflags().push_back("--target");
100 target.config_values().include_dirs().push_back( 102 target.config_values().include_dirs().push_back(
101 SourceDir("//target/")); 103 SourceDir("//target/"));
102 104
103 // Mark targets resolved. This should push dependent configs. 105 // Mark targets resolved. This should push dependent configs.
104 ASSERT_TRUE(dep2.OnResolved(&err)); 106 ASSERT_TRUE(dep2.OnResolved(&err));
105 ASSERT_TRUE(dep1.OnResolved(&err)); 107 ASSERT_TRUE(dep1.OnResolved(&err));
(...skipping 10 matching lines...) Expand all
116 118
117 // Verify include dirs by serializing. 119 // Verify include dirs by serializing.
118 std::ostringstream include_out; 120 std::ostringstream include_out;
119 IncludeWriter include_writer; 121 IncludeWriter include_writer;
120 RecursiveTargetConfigToStream<SourceDir, IncludeWriter>( 122 RecursiveTargetConfigToStream<SourceDir, IncludeWriter>(
121 &target, &ConfigValues::include_dirs, include_writer, include_out); 123 &target, &ConfigValues::include_dirs, include_writer, include_out);
122 EXPECT_EQ(include_out.str(), 124 EXPECT_EQ(include_out.str(),
123 "//target/ //target/config/ //target/all/ //target/direct/ " 125 "//target/ //target/config/ //target/all/ //target/direct/ "
124 "//dep1/all/ //dep2/all/ //dep1/direct/ "); 126 "//dep1/all/ //dep2/all/ //dep1/direct/ ");
125 } 127 }
OLDNEW
« no previous file with comments | « tools/gn/command_refs.cc ('k') | tools/gn/copy_target_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698