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

Side by Side Diff: tools/gn/config_values_extractors_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/command_gen.cc ('k') | tools/gn/escape.h » ('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 27 matching lines...) Expand all
38 dep2_all.config_values().cflags().push_back("--dep2-all"); 38 dep2_all.config_values().cflags().push_back("--dep2-all");
39 dep2_all.config_values().include_dirs().push_back(SourceDir("//dep2/all/")); 39 dep2_all.config_values().include_dirs().push_back(SourceDir("//dep2/all/"));
40 40
41 Config dep2_direct(setup.settings(), Label(SourceDir("//dep2/"), "direct")); 41 Config dep2_direct(setup.settings(), Label(SourceDir("//dep2/"), "direct"));
42 dep2_direct.config_values().cflags().push_back("--dep2-direct"); 42 dep2_direct.config_values().cflags().push_back("--dep2-direct");
43 dep2_direct.config_values().include_dirs().push_back( 43 dep2_direct.config_values().include_dirs().push_back(
44 SourceDir("//dep2/direct/")); 44 SourceDir("//dep2/direct/"));
45 45
46 Target dep2(setup.settings(), Label(SourceDir("//dep2/"), "dep2")); 46 Target dep2(setup.settings(), Label(SourceDir("//dep2/"), "dep2"));
47 dep2.set_output_type(Target::SOURCE_SET); 47 dep2.set_output_type(Target::SOURCE_SET);
48 dep2.SetToolchain(setup.toolchain());
48 dep2.all_dependent_configs().push_back(LabelConfigPair(&dep2_all)); 49 dep2.all_dependent_configs().push_back(LabelConfigPair(&dep2_all));
49 dep2.direct_dependent_configs().push_back(LabelConfigPair(&dep2_direct)); 50 dep2.direct_dependent_configs().push_back(LabelConfigPair(&dep2_direct));
50 51
51 // Set up dep1, direct and all dependent configs. 52 // Set up dep1, direct and all dependent configs.
52 Config dep1_all(setup.settings(), Label(SourceDir("//dep1/"), "all")); 53 Config dep1_all(setup.settings(), Label(SourceDir("//dep1/"), "all"));
53 dep1_all.config_values().cflags().push_back("--dep1-all"); 54 dep1_all.config_values().cflags().push_back("--dep1-all");
54 dep1_all.config_values().include_dirs().push_back(SourceDir("//dep1/all/")); 55 dep1_all.config_values().include_dirs().push_back(SourceDir("//dep1/all/"));
55 56
56 Config dep1_direct(setup.settings(), Label(SourceDir("//dep1/"), "direct")); 57 Config dep1_direct(setup.settings(), Label(SourceDir("//dep1/"), "direct"));
57 dep1_direct.config_values().cflags().push_back("--dep1-direct"); 58 dep1_direct.config_values().cflags().push_back("--dep1-direct");
58 dep1_direct.config_values().include_dirs().push_back( 59 dep1_direct.config_values().include_dirs().push_back(
59 SourceDir("//dep1/direct/")); 60 SourceDir("//dep1/direct/"));
60 61
61 Target dep1(setup.settings(), Label(SourceDir("//dep1/"), "dep1")); 62 Target dep1(setup.settings(), Label(SourceDir("//dep1/"), "dep1"));
62 dep1.set_output_type(Target::SOURCE_SET); 63 dep1.set_output_type(Target::SOURCE_SET);
64 dep1.SetToolchain(setup.toolchain());
63 dep1.all_dependent_configs().push_back(LabelConfigPair(&dep1_all)); 65 dep1.all_dependent_configs().push_back(LabelConfigPair(&dep1_all));
64 dep1.direct_dependent_configs().push_back(LabelConfigPair(&dep1_direct)); 66 dep1.direct_dependent_configs().push_back(LabelConfigPair(&dep1_direct));
65 dep1.deps().push_back(LabelTargetPair(&dep2)); 67 dep1.deps().push_back(LabelTargetPair(&dep2));
66 68
67 // Set up target, direct and all dependent configs. 69 // Set up target, direct and all dependent configs.
68 Config target_all(setup.settings(), Label(SourceDir("//target/"), "all")); 70 Config target_all(setup.settings(), Label(SourceDir("//target/"), "all"));
69 target_all.config_values().cflags().push_back("--target-all"); 71 target_all.config_values().cflags().push_back("--target-all");
70 target_all.config_values().include_dirs().push_back( 72 target_all.config_values().include_dirs().push_back(
71 SourceDir("//target/all/")); 73 SourceDir("//target/all/"));
72 74
73 Config target_direct(setup.settings(), 75 Config target_direct(setup.settings(),
74 Label(SourceDir("//target/"), "direct")); 76 Label(SourceDir("//target/"), "direct"));
75 target_direct.config_values().cflags().push_back("--target-direct"); 77 target_direct.config_values().cflags().push_back("--target-direct");
76 target_direct.config_values().include_dirs().push_back( 78 target_direct.config_values().include_dirs().push_back(
77 SourceDir("//target/direct/")); 79 SourceDir("//target/direct/"));
78 80
79 // This config is applied directly to target. 81 // This config is applied directly to target.
80 Config target_config(setup.settings(), 82 Config target_config(setup.settings(),
81 Label(SourceDir("//target/"), "config")); 83 Label(SourceDir("//target/"), "config"));
82 target_config.config_values().cflags().push_back("--target-config"); 84 target_config.config_values().cflags().push_back("--target-config");
83 target_config.config_values().include_dirs().push_back( 85 target_config.config_values().include_dirs().push_back(
84 SourceDir("//target/config/")); 86 SourceDir("//target/config/"));
85 87
86 Target target(setup.settings(), Label(SourceDir("//target/"), "target")); 88 Target target(setup.settings(), Label(SourceDir("//target/"), "target"));
87 target.set_output_type(Target::SOURCE_SET); 89 target.set_output_type(Target::SOURCE_SET);
90 target.SetToolchain(setup.toolchain());
88 target.all_dependent_configs().push_back(LabelConfigPair(&target_all)); 91 target.all_dependent_configs().push_back(LabelConfigPair(&target_all));
89 target.direct_dependent_configs().push_back(LabelConfigPair(&target_direct)); 92 target.direct_dependent_configs().push_back(LabelConfigPair(&target_direct));
90 target.configs().push_back(LabelConfigPair(&target_config)); 93 target.configs().push_back(LabelConfigPair(&target_config));
91 target.deps().push_back(LabelTargetPair(&dep1)); 94 target.deps().push_back(LabelTargetPair(&dep1));
92 95
93 96
94 // Additionally add some values directly on "target". 97 // Additionally add some values directly on "target".
95 target.config_values().cflags().push_back("--target"); 98 target.config_values().cflags().push_back("--target");
96 target.config_values().include_dirs().push_back( 99 target.config_values().include_dirs().push_back(
97 SourceDir("//target/")); 100 SourceDir("//target/"));
(...skipping 14 matching lines...) Expand all
112 115
113 // Verify include dirs by serializing. 116 // Verify include dirs by serializing.
114 std::ostringstream include_out; 117 std::ostringstream include_out;
115 IncludeWriter include_writer; 118 IncludeWriter include_writer;
116 RecursiveTargetConfigToStream<SourceDir, IncludeWriter>( 119 RecursiveTargetConfigToStream<SourceDir, IncludeWriter>(
117 &target, &ConfigValues::include_dirs, include_writer, include_out); 120 &target, &ConfigValues::include_dirs, include_writer, include_out);
118 EXPECT_EQ(include_out.str(), 121 EXPECT_EQ(include_out.str(),
119 "//target/ //target/config/ //target/all/ //target/direct/ " 122 "//target/ //target/config/ //target/all/ //target/direct/ "
120 "//dep1/all/ //dep2/all/ //dep1/direct/ "); 123 "//dep1/all/ //dep2/all/ //dep1/direct/ ");
121 } 124 }
OLDNEW
« no previous file with comments | « tools/gn/command_gen.cc ('k') | tools/gn/escape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698