| 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/filesystem_utils.h" | 5 #include "tools/gn/filesystem_utils.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 } | 713 } |
| 714 | 714 |
| 715 SourceDir GetOutputDirForSourceDir(const Settings* settings, | 715 SourceDir GetOutputDirForSourceDir(const Settings* settings, |
| 716 const SourceDir& source_dir) { | 716 const SourceDir& source_dir) { |
| 717 SourceDir toolchain = GetToolchainOutputDir(settings); | 717 SourceDir toolchain = GetToolchainOutputDir(settings); |
| 718 | 718 |
| 719 std::string ret; | 719 std::string ret; |
| 720 toolchain.SwapValue(&ret); | 720 toolchain.SwapValue(&ret); |
| 721 ret.append("obj/"); | 721 ret.append("obj/"); |
| 722 | 722 |
| 723 // The source dir should be source-absolute, so we trim off the two leading | 723 if (source_dir.is_source_absolute()) { |
| 724 // slashes to append to the toolchain object directory. | 724 // The source dir is source-absolute, so we trim off the two leading |
| 725 DCHECK(source_dir.is_source_absolute()); | 725 // slashes to append to the toolchain object directory. |
| 726 ret.append(&source_dir.value()[2], source_dir.value().size() - 2); | 726 ret.append(&source_dir.value()[2], source_dir.value().size() - 2); |
| 727 } |
| 728 // (Put system-absolute stuff in the root obj directory.) |
| 727 | 729 |
| 728 return SourceDir(SourceDir::SWAP_IN, &ret); | 730 return SourceDir(SourceDir::SWAP_IN, &ret); |
| 729 } | 731 } |
| 730 | 732 |
| 731 SourceDir GetGenDirForSourceDir(const Settings* settings, | 733 SourceDir GetGenDirForSourceDir(const Settings* settings, |
| 732 const SourceDir& source_dir) { | 734 const SourceDir& source_dir) { |
| 733 SourceDir toolchain = GetToolchainGenDir(settings); | 735 SourceDir toolchain = GetToolchainGenDir(settings); |
| 734 | 736 |
| 735 std::string ret; | 737 std::string ret; |
| 736 toolchain.SwapValue(&ret); | 738 toolchain.SwapValue(&ret); |
| 737 | 739 |
| 738 // The source dir should be source-absolute, so we trim off the two leading | 740 if (source_dir.is_source_absolute()) { |
| 739 // slashes to append to the toolchain object directory. | 741 // The source dir should be source-absolute, so we trim off the two leading |
| 740 DCHECK(source_dir.is_source_absolute()); | 742 // slashes to append to the toolchain object directory. |
| 741 ret.append(&source_dir.value()[2], source_dir.value().size() - 2); | 743 DCHECK(source_dir.is_source_absolute()); |
| 744 ret.append(&source_dir.value()[2], source_dir.value().size() - 2); |
| 745 } |
| 746 // (Put system-absolute stuff in the root gen directory.) |
| 742 | 747 |
| 743 return SourceDir(SourceDir::SWAP_IN, &ret); | 748 return SourceDir(SourceDir::SWAP_IN, &ret); |
| 744 } | 749 } |
| 745 | 750 |
| 746 SourceDir GetTargetOutputDir(const Target* target) { | 751 SourceDir GetTargetOutputDir(const Target* target) { |
| 747 return GetOutputDirForSourceDir(target->settings(), target->label().dir()); | 752 return GetOutputDirForSourceDir(target->settings(), target->label().dir()); |
| 748 } | 753 } |
| 749 | 754 |
| 750 SourceDir GetTargetGenDir(const Target* target) { | 755 SourceDir GetTargetGenDir(const Target* target) { |
| 751 return GetGenDirForSourceDir(target->settings(), target->label().dir()); | 756 return GetGenDirForSourceDir(target->settings(), target->label().dir()); |
| 752 } | 757 } |
| 753 | 758 |
| 754 SourceDir GetCurrentOutputDir(const Scope* scope) { | 759 SourceDir GetCurrentOutputDir(const Scope* scope) { |
| 755 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 760 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
| 756 } | 761 } |
| 757 | 762 |
| 758 SourceDir GetCurrentGenDir(const Scope* scope) { | 763 SourceDir GetCurrentGenDir(const Scope* scope) { |
| 759 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 764 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
| 760 } | 765 } |
| OLD | NEW |