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 "tools/gn/setup.h" | 5 #include "tools/gn/setup.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <sstream> | 9 #include <sstream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 } | 514 } |
515 | 515 |
516 if (scheduler_.verbose_logging()) | 516 if (scheduler_.verbose_logging()) |
517 scheduler_.Log("Using source root", FilePathToUTF8(root_path)); | 517 scheduler_.Log("Using source root", FilePathToUTF8(root_path)); |
518 build_settings_.SetRootPath(root_path); | 518 build_settings_.SetRootPath(root_path); |
519 | 519 |
520 return true; | 520 return true; |
521 } | 521 } |
522 | 522 |
523 bool Setup::FillBuildDir(const std::string& build_dir, bool require_exists) { | 523 bool Setup::FillBuildDir(const std::string& build_dir, bool require_exists) { |
| 524 #if defined(OS_POSIX) |
| 525 // Expand all ./, ../, and symbolic links in build_dir. |
| 526 char realpath_buf[PATH_MAX]; |
| 527 if (!realpath(build_dir.c_str(), realpath_buf)) { |
| 528 Err(Location(), "Can't normalize the build directory path.", |
| 529 strerror(errno)) .PrintToStdout(); |
| 530 return false; |
| 531 } |
| 532 const std::string build_dir_realpath = realpath_buf; |
| 533 #else |
| 534 const std::string& build_dir_realpath = build_dir; |
| 535 #endif |
| 536 |
524 Err err; | 537 Err err; |
525 SourceDir resolved = | 538 SourceDir resolved = |
526 SourceDirForCurrentDirectory(build_settings_.root_path()). | 539 SourceDirForCurrentDirectory(build_settings_.root_path()). |
527 ResolveRelativeDir(Value(nullptr, build_dir), &err, | 540 ResolveRelativeDir(Value(nullptr, build_dir_realpath), &err, |
528 build_settings_.root_path_utf8()); | 541 build_settings_.root_path_utf8()); |
529 if (err.has_error()) { | 542 if (err.has_error()) { |
530 err.PrintToStdout(); | 543 err.PrintToStdout(); |
531 return false; | 544 return false; |
532 } | 545 } |
533 | 546 |
534 if (scheduler_.verbose_logging()) | 547 if (scheduler_.verbose_logging()) |
535 scheduler_.Log("Using build dir", resolved.value()); | 548 scheduler_.Log("Using build dir", resolved.value()); |
536 | 549 |
537 if (require_exists) { | 550 if (require_exists) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 if (err.has_error()) { | 697 if (err.has_error()) { |
685 err.PrintToStdout(); | 698 err.PrintToStdout(); |
686 return false; | 699 return false; |
687 } | 700 } |
688 } | 701 } |
689 build_settings_.set_exec_script_whitelist(std::move(whitelist)); | 702 build_settings_.set_exec_script_whitelist(std::move(whitelist)); |
690 } | 703 } |
691 | 704 |
692 return true; | 705 return true; |
693 } | 706 } |
OLD | NEW |