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/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 if (IsPathAbsolute(input) && !IsSlash(input[0]) && IsSlash(dest[0])) { | 522 if (IsPathAbsolute(input) && !IsSlash(input[0]) && IsSlash(dest[0])) { |
523 std::string corrected_input(1, dest[0]); | 523 std::string corrected_input(1, dest[0]); |
524 corrected_input.append(input); | 524 corrected_input.append(input); |
525 return MakeRelativePath(corrected_input, dest); | 525 return MakeRelativePath(corrected_input, dest); |
526 } | 526 } |
527 if (IsPathAbsolute(dest) && !IsSlash(dest[0]) && IsSlash(input[0])) { | 527 if (IsPathAbsolute(dest) && !IsSlash(dest[0]) && IsSlash(input[0])) { |
528 std::string corrected_dest(1, input[0]); | 528 std::string corrected_dest(1, input[0]); |
529 corrected_dest.append(dest); | 529 corrected_dest.append(dest); |
530 return MakeRelativePath(input, corrected_dest); | 530 return MakeRelativePath(input, corrected_dest); |
531 } | 531 } |
| 532 |
| 533 // Make sure that both absolute paths use the same drive letter case. |
| 534 if (IsPathAbsolute(input) && IsPathAbsolute(dest) && input.size() > 1 && |
| 535 dest.size() > 1) { |
| 536 int letter_pos = base::IsAsciiAlpha(input[0]) ? 0 : 1; |
| 537 if (input[letter_pos] != dest[letter_pos] && |
| 538 base::ToUpperASCII(input[letter_pos]) == |
| 539 base::ToUpperASCII(dest[letter_pos])) { |
| 540 std::string corrected_input = input; |
| 541 corrected_input[letter_pos] = dest[letter_pos]; |
| 542 return MakeRelativePath(corrected_input, dest); |
| 543 } |
| 544 } |
532 #endif | 545 #endif |
533 | 546 |
534 std::string ret; | 547 std::string ret; |
535 | 548 |
536 // Skip the common prefixes of the source and dest as long as they end in | 549 // Skip the common prefixes of the source and dest as long as they end in |
537 // a [back]slash. | 550 // a [back]slash. |
538 size_t common_prefix_len = 0; | 551 size_t common_prefix_len = 0; |
539 size_t max_common_length = std::min(input.size(), dest.size()); | 552 size_t max_common_length = std::min(input.size(), dest.size()); |
540 for (size_t i = common_prefix_len; i < max_common_length; i++) { | 553 for (size_t i = common_prefix_len; i < max_common_length; i++) { |
541 if (IsSlash(input[i]) && IsSlash(dest[i])) | 554 if (IsSlash(input[i]) && IsSlash(dest[i])) |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 | 928 |
916 SourceDir GetCurrentOutputDir(const Scope* scope) { | 929 SourceDir GetCurrentOutputDir(const Scope* scope) { |
917 return GetOutputDirForSourceDirAsOutputFile( | 930 return GetOutputDirForSourceDirAsOutputFile( |
918 scope->settings(), scope->GetSourceDir()).AsSourceDir( | 931 scope->settings(), scope->GetSourceDir()).AsSourceDir( |
919 scope->settings()->build_settings()); | 932 scope->settings()->build_settings()); |
920 } | 933 } |
921 | 934 |
922 SourceDir GetCurrentGenDir(const Scope* scope) { | 935 SourceDir GetCurrentGenDir(const Scope* scope) { |
923 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 936 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
924 } | 937 } |
OLD | NEW |