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

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

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 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_desc.cc ('k') | tools/gn/commands.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/command_line.h"
7 #include "base/strings/string_number_conversions.h"
8 #include "base/time/time.h"
9 #include "tools/gn/build_settings.h"
10 #include "tools/gn/commands.h"
11 #include "tools/gn/ninja_target_writer.h"
12 #include "tools/gn/ninja_writer.h"
13 #include "tools/gn/scheduler.h"
14 #include "tools/gn/setup.h"
15 #include "tools/gn/standard_out.h"
16
17 namespace {
18
19 // Suppress output on success.
20 const char kSwitchQuiet[] = "q";
21
22 } // namespace
23
24 int RunGenCommand(const std::vector<std::string>& args) {
25 base::TimeTicks begin_time = base::TimeTicks::Now();
26
27 // Deliberately leaked to avoid expensive process teardown.
28 Setup* setup = new Setup;
29 if (!setup->DoSetup())
30 return 1;
31
32 // Cause the load to also generate the ninja files for each target.
33 setup->build_settings().set_target_resolved_callback(
34 base::Bind(&NinjaTargetWriter::RunAndWriteFile));
35
36 // Do the actual load. This will also write out the target ninja files.
37 if (!setup->Run())
38 return 1;
39
40 // Write the root ninja files.
41 if (!NinjaWriter::RunAndWriteFiles(&setup->build_settings())) {
42 Err(Location(),
43 "Couldn't open root buildfile(s) for writing").PrintToStdout();
44 return 1;
45 }
46
47 base::TimeTicks end_time = base::TimeTicks::Now();
48
49 if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) {
50 OutputString("Done. ", DECORATION_GREEN);
51
52 // TODO(brettw) get the number of targets without getting the entire list.
53 std::vector<const Target*> all_targets;
54 setup->build_settings().target_manager().GetAllTargets(&all_targets);
55 std::string stats = "Generated " +
56 base::IntToString(static_cast<int>(all_targets.size())) +
57 " targets from " +
58 base::IntToString(
59 setup->scheduler().input_file_manager()->GetInputFileCount()) +
60 " files in " +
61 base::IntToString((end_time - begin_time).InMilliseconds()) + "ms\n";
62 OutputString(stats);
63 }
64
65 return 0;
66 }
OLDNEW
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698