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" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 "I expected something more like \"gn gen out/foo\"\n" | 71 "I expected something more like \"gn gen out/foo\"\n" |
72 "You can also see \"gn help gen\".").PrintToStdout(); | 72 "You can also see \"gn help gen\".").PrintToStdout(); |
73 return 1; | 73 return 1; |
74 } | 74 } |
75 | 75 |
76 // Deliberately leaked to avoid expensive process teardown. | 76 // Deliberately leaked to avoid expensive process teardown. |
77 Setup* setup = new Setup(); | 77 Setup* setup = new Setup(); |
78 if (!setup->DoSetup(args[0], true)) | 78 if (!setup->DoSetup(args[0], true)) |
79 return 1; | 79 return 1; |
80 | 80 |
81 if (CommandLine::ForCurrentProcess()->HasSwitch(kSwitchCheck)) | 81 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchCheck)) |
82 setup->set_check_public_headers(true); | 82 setup->set_check_public_headers(true); |
83 | 83 |
84 // Cause the load to also generate the ninja files for each target. We wrap | 84 // Cause the load to also generate the ninja files for each target. We wrap |
85 // the writing to maintain a counter. | 85 // the writing to maintain a counter. |
86 base::subtle::Atomic32 write_counter = 0; | 86 base::subtle::Atomic32 write_counter = 0; |
87 setup->builder()->set_resolved_callback( | 87 setup->builder()->set_resolved_callback( |
88 base::Bind(&ItemResolvedCallback, &write_counter, | 88 base::Bind(&ItemResolvedCallback, &write_counter, |
89 scoped_refptr<Builder>(setup->builder()))); | 89 scoped_refptr<Builder>(setup->builder()))); |
90 | 90 |
91 // Do the actual load. This will also write out the target ninja files. | 91 // Do the actual load. This will also write out the target ninja files. |
92 if (!setup->Run()) | 92 if (!setup->Run()) |
93 return 1; | 93 return 1; |
94 | 94 |
95 Err err; | 95 Err err; |
96 // Write the root ninja files. | 96 // Write the root ninja files. |
97 if (!NinjaWriter::RunAndWriteFiles(&setup->build_settings(), | 97 if (!NinjaWriter::RunAndWriteFiles(&setup->build_settings(), |
98 setup->builder(), | 98 setup->builder(), |
99 &err)) { | 99 &err)) { |
100 err.PrintToStdout(); | 100 err.PrintToStdout(); |
101 return 1; | 101 return 1; |
102 } | 102 } |
103 | 103 |
104 base::TimeDelta elapsed_time = timer.Elapsed(); | 104 base::TimeDelta elapsed_time = timer.Elapsed(); |
105 | 105 |
106 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet)) { | 106 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet)) { |
107 OutputString("Done. ", DECORATION_GREEN); | 107 OutputString("Done. ", DECORATION_GREEN); |
108 | 108 |
109 std::string stats = "Wrote " + | 109 std::string stats = "Wrote " + |
110 base::IntToString(static_cast<int>(write_counter)) + | 110 base::IntToString(static_cast<int>(write_counter)) + |
111 " targets from " + | 111 " targets from " + |
112 base::IntToString( | 112 base::IntToString( |
113 setup->scheduler().input_file_manager()->GetInputFileCount()) + | 113 setup->scheduler().input_file_manager()->GetInputFileCount()) + |
114 " files in " + | 114 " files in " + |
115 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; | 115 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; |
116 OutputString(stats); | 116 OutputString(stats); |
117 } | 117 } |
118 | 118 |
119 return 0; | 119 return 0; |
120 } | 120 } |
121 | 121 |
122 } // namespace commands | 122 } // namespace commands |
OLD | NEW |