| 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 333 } |
| 334 | 334 |
| 335 bool EnsureStringIsInOutputDir(const SourceDir& dir, | 335 bool EnsureStringIsInOutputDir(const SourceDir& dir, |
| 336 const std::string& str, | 336 const std::string& str, |
| 337 const Value& originating, | 337 const Value& originating, |
| 338 bool allow_templates, | 338 bool allow_templates, |
| 339 Err* err) { | 339 Err* err) { |
| 340 // This check will be wrong for all proper prefixes "e.g. "/output" will | 340 // This check will be wrong for all proper prefixes "e.g. "/output" will |
| 341 // match "/out" but we don't really care since this is just a sanity check. | 341 // match "/out" but we don't really care since this is just a sanity check. |
| 342 const std::string& dir_str = dir.value(); | 342 const std::string& dir_str = dir.value(); |
| 343 if (str.compare(0, dir_str.length(), dir_str, 0, dir_str.length()) == 0) | 343 if (str.compare(0, dir_str.length(), dir_str) == 0) |
| 344 return true; // Output directory is hardcoded. | 344 return true; // Output directory is hardcoded. |
| 345 | 345 |
| 346 if (allow_templates) { | 346 if (allow_templates) { |
| 347 // Allow the string to begin with any source expansion inside the output | 347 // Allow the string to begin with any source expansion inside the output |
| 348 // directory. | 348 // directory. |
| 349 if (StartsWithASCII(str, FileTemplate::kSourceGenDir, true) || | 349 if (StartsWithASCII(str, FileTemplate::kSourceGenDir, true) || |
| 350 StartsWithASCII(str, FileTemplate::kSourceOutDir, true)) | 350 StartsWithASCII(str, FileTemplate::kSourceOutDir, true)) |
| 351 return true; | 351 return true; |
| 352 } | 352 } |
| 353 | 353 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 return GetGenDirForSourceDir(target->settings(), target->label().dir()); | 762 return GetGenDirForSourceDir(target->settings(), target->label().dir()); |
| 763 } | 763 } |
| 764 | 764 |
| 765 SourceDir GetCurrentOutputDir(const Scope* scope) { | 765 SourceDir GetCurrentOutputDir(const Scope* scope) { |
| 766 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 766 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
| 767 } | 767 } |
| 768 | 768 |
| 769 SourceDir GetCurrentGenDir(const Scope* scope) { | 769 SourceDir GetCurrentGenDir(const Scope* scope) { |
| 770 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 770 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
| 771 } | 771 } |
| OLD | NEW |