OLD | NEW |
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 "base/atomicops.h" | 5 #include "base/atomicops.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/timer/elapsed_timer.h" | 9 #include "base/timer/elapsed_timer.h" |
10 #include "tools/gn/build_settings.h" | 10 #include "tools/gn/build_settings.h" |
11 #include "tools/gn/commands.h" | 11 #include "tools/gn/commands.h" |
12 #include "tools/gn/ninja_target_writer.h" | 12 #include "tools/gn/ninja_target_writer.h" |
13 #include "tools/gn/ninja_writer.h" | 13 #include "tools/gn/ninja_writer.h" |
14 #include "tools/gn/scheduler.h" | 14 #include "tools/gn/scheduler.h" |
15 #include "tools/gn/setup.h" | 15 #include "tools/gn/setup.h" |
16 #include "tools/gn/standard_out.h" | 16 #include "tools/gn/standard_out.h" |
17 | 17 |
18 namespace commands { | 18 namespace commands { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Suppress output on success. | 22 // Suppress output on success. |
23 const char kSwitchQuiet[] = "q"; | 23 const char kSwitchQuiet[] = "q"; |
24 | 24 |
| 25 const char kSwitchCheck[] = "check"; |
| 26 |
25 void BackgroundDoWrite(const Target* target, | 27 void BackgroundDoWrite(const Target* target, |
26 const Toolchain* toolchain, | 28 const Toolchain* toolchain, |
27 const std::vector<const Item*>& deps_for_visibility) { | 29 const std::vector<const Item*>& deps_for_visibility) { |
28 // Validate visibility. | 30 // Validate visibility. |
29 Err err; | 31 Err err; |
30 for (size_t i = 0; i < deps_for_visibility.size(); i++) { | 32 for (size_t i = 0; i < deps_for_visibility.size(); i++) { |
31 if (!Visibility::CheckItemVisibility(target, deps_for_visibility[i], | 33 if (!Visibility::CheckItemVisibility(target, deps_for_visibility[i], |
32 &err)) { | 34 &err)) { |
33 g_scheduler->FailWithError(err); | 35 g_scheduler->FailWithError(err); |
34 break; // Don't return early since we need DecrementWorkCount below. | 36 break; // Don't return early since we need DecrementWorkCount below. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 "I expected something more like \"gn gen out/foo\"\n" | 98 "I expected something more like \"gn gen out/foo\"\n" |
97 "You can also see \"gn help gen\".").PrintToStdout(); | 99 "You can also see \"gn help gen\".").PrintToStdout(); |
98 return 1; | 100 return 1; |
99 } | 101 } |
100 | 102 |
101 // Deliberately leaked to avoid expensive process teardown. | 103 // Deliberately leaked to avoid expensive process teardown. |
102 Setup* setup = new Setup(); | 104 Setup* setup = new Setup(); |
103 if (!setup->DoSetup(args[0])) | 105 if (!setup->DoSetup(args[0])) |
104 return 1; | 106 return 1; |
105 | 107 |
| 108 if (CommandLine::ForCurrentProcess()->HasSwitch(kSwitchCheck)) |
| 109 setup->set_check_public_headers(true); |
| 110 |
106 // Cause the load to also generate the ninja files for each target. We wrap | 111 // Cause the load to also generate the ninja files for each target. We wrap |
107 // the writing to maintain a counter. | 112 // the writing to maintain a counter. |
108 base::subtle::Atomic32 write_counter = 0; | 113 base::subtle::Atomic32 write_counter = 0; |
109 setup->builder()->set_resolved_callback( | 114 setup->builder()->set_resolved_callback( |
110 base::Bind(&ItemResolvedCallback, &write_counter, | 115 base::Bind(&ItemResolvedCallback, &write_counter, |
111 scoped_refptr<Builder>(setup->builder()))); | 116 scoped_refptr<Builder>(setup->builder()))); |
112 | 117 |
113 // Do the actual load. This will also write out the target ninja files. | 118 // Do the actual load. This will also write out the target ninja files. |
114 if (!setup->Run()) | 119 if (!setup->Run()) |
115 return 1; | 120 return 1; |
(...skipping 15 matching lines...) Expand all Loading... |
131 setup->scheduler().input_file_manager()->GetInputFileCount()) + | 136 setup->scheduler().input_file_manager()->GetInputFileCount()) + |
132 " files in " + | 137 " files in " + |
133 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n"; | 138 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n"; |
134 OutputString(stats); | 139 OutputString(stats); |
135 } | 140 } |
136 | 141 |
137 return 0; | 142 return 0; |
138 } | 143 } |
139 | 144 |
140 } // namespace commands | 145 } // namespace commands |
OLD | NEW |