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

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

Issue 93803004: Fix build output directories in GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « build/toolchain/goma.gni ('k') | no next file » | 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 <iostream> 5 #include <iostream>
6 #include <map> 6 #include <map>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/environment.h" 11 #include "base/environment.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "tools/gn/build_settings.h" 14 #include "tools/gn/build_settings.h"
15 #include "tools/gn/commands.h" 15 #include "tools/gn/commands.h"
16 #include "tools/gn/err.h" 16 #include "tools/gn/err.h"
17 #include "tools/gn/filesystem_utils.h"
17 #include "tools/gn/gyp_helper.h" 18 #include "tools/gn/gyp_helper.h"
18 #include "tools/gn/gyp_target_writer.h" 19 #include "tools/gn/gyp_target_writer.h"
19 #include "tools/gn/location.h" 20 #include "tools/gn/location.h"
20 #include "tools/gn/parser.h" 21 #include "tools/gn/parser.h"
21 #include "tools/gn/setup.h" 22 #include "tools/gn/setup.h"
22 #include "tools/gn/source_file.h" 23 #include "tools/gn/source_file.h"
23 #include "tools/gn/standard_out.h" 24 #include "tools/gn/standard_out.h"
24 #include "tools/gn/target.h" 25 #include "tools/gn/target.h"
25 #include "tools/gn/tokenizer.h" 26 #include "tools/gn/tokenizer.h"
26 27
27 namespace commands { 28 namespace commands {
28 29
29 namespace { 30 namespace {
30 31
31 typedef GypTargetWriter::TargetGroup TargetGroup; 32 typedef GypTargetWriter::TargetGroup TargetGroup;
32 typedef std::map<Label, TargetGroup> CorrelatedTargetsMap; 33 typedef std::map<Label, TargetGroup> CorrelatedTargetsMap;
33 typedef std::map<SourceFile, std::vector<TargetGroup> > GroupedTargetsMap; 34 typedef std::map<SourceFile, std::vector<TargetGroup> > GroupedTargetsMap;
34 typedef std::map<std::string, std::string> StringStringMap; 35 typedef std::map<std::string, std::string> StringStringMap;
35 typedef std::vector<const BuilderRecord*> RecordVector; 36 typedef std::vector<const BuilderRecord*> RecordVector;
36 37
38 // This function appends a suffix to the given source directory name. We append
39 // a suffix to the last directory component rather than adding a new level so
40 // that the relative location of the files don't change (i.e. a file
41 // relative to the build dir might be "../../foo/bar.cc") and we want these to
42 // be the same in all builds, and in particular the GYP build directories.
43 SourceDir AppendDirSuffix(const SourceDir& base, const std::string& suffix) {
44 return SourceDir(DirectoryWithNoLastSlash(base) + suffix + "/");
45 }
46
37 std::vector<const BuilderRecord*> GetAllResolvedTargetRecords( 47 std::vector<const BuilderRecord*> GetAllResolvedTargetRecords(
38 const Builder* builder) { 48 const Builder* builder) {
39 std::vector<const BuilderRecord*> all = builder->GetAllRecords(); 49 std::vector<const BuilderRecord*> all = builder->GetAllRecords();
40 std::vector<const BuilderRecord*> result; 50 std::vector<const BuilderRecord*> result;
41 result.reserve(all.size()); 51 result.reserve(all.size());
42 for (size_t i = 0; i < all.size(); i++) { 52 for (size_t i = 0; i < all.size(); i++) {
43 if (all[i]->type() == BuilderRecord::ITEM_TARGET && 53 if (all[i]->type() == BuilderRecord::ITEM_TARGET &&
44 all[i]->should_generate() && 54 all[i]->should_generate() &&
45 all[i]->item()) 55 all[i]->item())
46 result.push_back(all[i]); 56 result.push_back(all[i]);
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); 329 const CommandLine* cmdline = CommandLine::ForCurrentProcess();
320 330
321 base::TimeTicks begin_time = base::TimeTicks::Now(); 331 base::TimeTicks begin_time = base::TimeTicks::Now();
322 332
323 // Deliberately leaked to avoid expensive process teardown. 333 // Deliberately leaked to avoid expensive process teardown.
324 Setup* setup_debug = new Setup; 334 Setup* setup_debug = new Setup;
325 if (!setup_debug->DoSetup()) 335 if (!setup_debug->DoSetup())
326 return 1; 336 return 1;
327 const char kIsDebug[] = "is_debug"; 337 const char kIsDebug[] = "is_debug";
328 338
339 SourceDir base_build_dir = setup_debug->build_settings().build_dir();
340 setup_debug->build_settings().SetBuildDir(
341 AppendDirSuffix(base_build_dir, ".Debug"));
342
329 // Make a release build based on the debug one. We use a new directory for 343 // Make a release build based on the debug one. We use a new directory for
330 // the build output so that they don't stomp on each other. 344 // the build output so that they don't stomp on each other.
331 DependentSetup* setup_release = new DependentSetup(setup_debug); 345 DependentSetup* setup_release = new DependentSetup(setup_debug);
332 setup_release->build_settings().build_args().AddArgOverride( 346 setup_release->build_settings().build_args().AddArgOverride(
333 kIsDebug, Value(NULL, false)); 347 kIsDebug, Value(NULL, false));
334 setup_release->build_settings().SetBuildDir( 348 setup_release->build_settings().SetBuildDir(
335 SourceDir(setup_release->build_settings().build_dir().value() + 349 AppendDirSuffix(base_build_dir, ".Release"));
336 "gn_release.tmp/"));
337 350
338 // Host build. 351 // Host build.
339 DependentSetup* setup_host_debug = NULL; 352 DependentSetup* setup_host_debug = NULL;
340 DependentSetup* setup_host_release = NULL; 353 DependentSetup* setup_host_release = NULL;
341 // TODO(brettw) hook up host build. 354 // TODO(brettw) hook up host build.
342 355
343 // 64-bit build (Windows only). 356 // 64-bit build (Windows only).
344 DependentSetup* setup_debug64 = NULL; 357 DependentSetup* setup_debug64 = NULL;
345 DependentSetup* setup_release64 = NULL; 358 DependentSetup* setup_release64 = NULL;
346 #if defined(OS_WIN) 359 #if defined(OS_WIN)
347 static const char kForceWin64[] = "force_win64"; 360 static const char kForceWin64[] = "force_win64";
348 setup_debug64 = new DependentSetup(setup_debug); 361 setup_debug64 = new DependentSetup(setup_debug);
349 setup_debug64->build_settings().build_args().AddArgOverride( 362 setup_debug64->build_settings().build_args().AddArgOverride(
350 kForceWin64, Value(NULL, true)); 363 kForceWin64, Value(NULL, true));
351 setup_debug64->build_settings().SetBuildDir( 364 setup_debug64->build_settings().SetBuildDir(
352 SourceDir(setup_release->build_settings().build_dir().value() + 365 AppendDirSuffix(base_build_dir, ".Debug64"));
353 "gn_debug64.tmp/"));
354 366
355 setup_release64 = new DependentSetup(setup_release); 367 setup_release64 = new DependentSetup(setup_release);
356 setup_release64->build_settings().build_args().AddArgOverride( 368 setup_release64->build_settings().build_args().AddArgOverride(
357 kForceWin64, Value(NULL, true)); 369 kForceWin64, Value(NULL, true));
358 setup_release64->build_settings().SetBuildDir( 370 setup_release64->build_settings().SetBuildDir(
359 SourceDir(setup_release->build_settings().build_dir().value() + 371 AppendDirSuffix(base_build_dir, ".Release64"));
360 "gn_release64.tmp/"));
361 #endif 372 #endif
362 373
363 // Run all the builds in parellel. 374 // Run all the builds in parellel.
364 setup_release->RunPreMessageLoop(); 375 setup_release->RunPreMessageLoop();
365 if (setup_host_debug && setup_host_release) { 376 if (setup_host_debug && setup_host_release) {
366 setup_host_debug->RunPreMessageLoop(); 377 setup_host_debug->RunPreMessageLoop();
367 setup_host_release->RunPreMessageLoop(); 378 setup_host_release->RunPreMessageLoop();
368 } 379 }
369 if (setup_debug64 && setup_release64) { 380 if (setup_debug64 && setup_release64) {
370 setup_debug64->RunPreMessageLoop(); 381 setup_debug64->RunPreMessageLoop();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 + " GN files in " + 420 + " GN files in " +
410 base::IntToString((end_time - begin_time).InMilliseconds()) + "ms\n"; 421 base::IntToString((end_time - begin_time).InMilliseconds()) + "ms\n";
411 422
412 OutputString(stats); 423 OutputString(stats);
413 } 424 }
414 425
415 return 0; 426 return 0;
416 } 427 }
417 428
418 } // namespace commands 429 } // namespace commands
OLDNEW
« no previous file with comments | « build/toolchain/goma.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698