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

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

Issue 165823003: GN: Change gen command syntax, support relative dirs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change in build file writing 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
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"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 " executable(\"my_app\") {\n" 417 " executable(\"my_app\") {\n"
418 " deps = [ \":gyp_target\" ]\n" 418 " deps = [ \":gyp_target\" ]\n"
419 " gyp_file = \"//foo/myapp.gyp\"\n" 419 " gyp_file = \"//foo/myapp.gyp\"\n"
420 " sources = ...\n" 420 " sources = ...\n"
421 " }\n"; 421 " }\n";
422 422
423 int RunGyp(const std::vector<std::string>& args) { 423 int RunGyp(const std::vector<std::string>& args) {
424 base::ElapsedTimer timer; 424 base::ElapsedTimer timer;
425 Setups setups; 425 Setups setups;
426 426
427 const CommandLine* cmdline = CommandLine::ForCurrentProcess();
428
429 // Compute output directory.
430 std::string build_dir;
431 if (args.size() == 1) {
432 build_dir = args[0];
433 } else {
434 // Backwards-compat code for the old invocation that uses
435 // "gn gyp --output=foo"
436 // TODO(brettw) This should be removed when gyp_chromium has been updated.
437
438 // Switch to set the build output directory.
439 const char kSwitchBuildOutput[] = "output";
440 build_dir = cmdline->GetSwitchValueASCII(kSwitchBuildOutput);
441 if (build_dir.empty())
442 build_dir = "//out/Default/";
443 }
444
427 // Deliberately leaked to avoid expensive process teardown. We also turn off 445 // Deliberately leaked to avoid expensive process teardown. We also turn off
428 // unused override checking since we want to merge all declared arguments and 446 // unused override checking since we want to merge all declared arguments and
429 // check those, rather than check each build individually. Otherwise, you 447 // check those, rather than check each build individually. Otherwise, you
430 // couldn't have an arg that was used in only one build type. This comes up 448 // couldn't have an arg that was used in only one build type. This comes up
431 // because some args are build-type specific. 449 // because some args are build-type specific.
432 setups.debug = new Setup; 450 setups.debug = new Setup;
433 setups.debug->set_check_for_unused_overrides(false); 451 setups.debug->set_check_for_unused_overrides(false);
434 if (!setups.debug->DoSetup()) 452 if (!setups.debug->DoSetup(build_dir))
435 return 1; 453 return 1;
436 const char kIsDebug[] = "is_debug"; 454 const char kIsDebug[] = "is_debug";
437 455
438 SourceDir base_build_dir = setups.debug->build_settings().build_dir(); 456 SourceDir base_build_dir = setups.debug->build_settings().build_dir();
439 setups.debug->build_settings().SetBuildDir( 457 setups.debug->build_settings().SetBuildDir(
440 AppendDirSuffix(base_build_dir, ".Debug")); 458 AppendDirSuffix(base_build_dir, ".Debug"));
441 459
442 // Make a release build based on the debug one. We use a new directory for 460 // Make a release build based on the debug one. We use a new directory for
443 // the build output so that they don't stomp on each other. 461 // the build output so that they don't stomp on each other.
444 setups.release = new DependentSetup(setups.debug); 462 setups.release = new DependentSetup(setups.debug);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 526
509 Err err; 527 Err err;
510 std::pair<int, int> counts = WriteGypFiles(setups, &err); 528 std::pair<int, int> counts = WriteGypFiles(setups, &err);
511 if (err.has_error()) { 529 if (err.has_error()) {
512 err.PrintToStdout(); 530 err.PrintToStdout();
513 return 1; 531 return 1;
514 } 532 }
515 533
516 base::TimeDelta elapsed_time = timer.Elapsed(); 534 base::TimeDelta elapsed_time = timer.Elapsed();
517 535
518 if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) { 536 if (!cmdline->HasSwitch(kSwitchQuiet)) {
519 OutputString("Done. ", DECORATION_GREEN); 537 OutputString("Done. ", DECORATION_GREEN);
520 538
521 std::string stats = "Wrote " + 539 std::string stats = "Wrote " +
522 base::IntToString(counts.first) + " targets to " + 540 base::IntToString(counts.first) + " targets to " +
523 base::IntToString(counts.second) + " GYP files read from " + 541 base::IntToString(counts.second) + " GYP files read from " +
524 base::IntToString( 542 base::IntToString(
525 setups.debug->scheduler().input_file_manager()->GetInputFileCount()) 543 setups.debug->scheduler().input_file_manager()->GetInputFileCount())
526 + " GN files in " + 544 + " GN files in " +
527 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n"; 545 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n";
528 546
529 OutputString(stats); 547 OutputString(stats);
530 } 548 }
531 549
532 return 0; 550 return 0;
533 } 551 }
534 552
535 } // namespace commands 553 } // namespace commands
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698