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

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

Issue 165823003: GN: Change gen command syntax, support relative dirs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments fixes Created 6 years, 10 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_args.cc ('k') | tools/gn/command_gyp.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 (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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 base::Bind(&BackgroundDoWrite, target, toolchain)); 43 base::Bind(&BackgroundDoWrite, target, toolchain));
44 } 44 }
45 } 45 }
46 46
47 } // namespace 47 } // namespace
48 48
49 const char kGen[] = "gen"; 49 const char kGen[] = "gen";
50 const char kGen_HelpShort[] = 50 const char kGen_HelpShort[] =
51 "gen: Generate ninja files."; 51 "gen: Generate ninja files.";
52 const char kGen_Help[] = 52 const char kGen_Help[] =
53 "gn gen\n" 53 "gn gen: Generate ninja files.\n"
54 " Generates ninja files from the current tree.\n" 54 "\n"
55 " gn gen <output_directory>\n"
56 "\n"
57 " Generates ninja files from the current tree and puts them in the given\n"
58 " output directory.\n"
59 "\n"
60 " The output directory can be a source-repo-absolute path name such as:\n"
61 " //out/foo\n"
62 " Or it can be a directory relative to the current directory such as:\n"
63 " out/foo\n"
55 "\n" 64 "\n"
56 " See \"gn help\" for the common command-line switches.\n"; 65 " See \"gn help\" for the common command-line switches.\n";
57 66
58 // Note: partially duplicated in command_gyp.cc. 67 // Note: partially duplicated in command_gyp.cc.
59 int RunGen(const std::vector<std::string>& args) { 68 int RunGen(const std::vector<std::string>& args) {
60 base::ElapsedTimer timer; 69 base::ElapsedTimer timer;
61 70
71 if (args.size() != 1) {
72 Err(Location(), "Need exactly one build directory to generate.",
73 "I expected something more like \"gn gen out/foo\"\n"
74 "You can also see \"gn help gen\".").PrintToStdout();
75 return 1;
76 }
77
62 // Deliberately leaked to avoid expensive process teardown. 78 // Deliberately leaked to avoid expensive process teardown.
63 Setup* setup = new Setup; 79 Setup* setup = new Setup();
64 if (!setup->DoSetup()) 80 if (!setup->DoSetup(args[0]))
65 return 1; 81 return 1;
66 82
67 // Cause the load to also generate the ninja files for each target. We wrap 83 // Cause the load to also generate the ninja files for each target. We wrap
68 // the writing to maintain a counter. 84 // the writing to maintain a counter.
69 base::subtle::Atomic32 write_counter = 0; 85 base::subtle::Atomic32 write_counter = 0;
70 setup->builder()->set_resolved_callback( 86 setup->builder()->set_resolved_callback(
71 base::Bind(&ItemResolvedCallback, &write_counter, 87 base::Bind(&ItemResolvedCallback, &write_counter,
72 scoped_refptr<Builder>(setup->builder()))); 88 scoped_refptr<Builder>(setup->builder())));
73 89
74 // Do the actual load. This will also write out the target ninja files. 90 // Do the actual load. This will also write out the target ninja files.
(...skipping 17 matching lines...) Expand all
92 setup->scheduler().input_file_manager()->GetInputFileCount()) + 108 setup->scheduler().input_file_manager()->GetInputFileCount()) +
93 " files in " + 109 " files in " +
94 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n"; 110 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n";
95 OutputString(stats); 111 OutputString(stats);
96 } 112 }
97 113
98 return 0; 114 return 0;
99 } 115 }
100 116
101 } // namespace commands 117 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_args.cc ('k') | tools/gn/command_gyp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698