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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 const Value& originating, | 280 const Value& originating, |
281 Err* err) { | 281 Err* err) { |
282 // The last char of the dir will be a slash. We don't care if the input ends | 282 // The last char of the dir will be a slash. We don't care if the input ends |
283 // in a slash or not, so just compare up until there. | 283 // in a slash or not, so just compare up until there. |
284 // | 284 // |
285 // This check will be wrong for all proper prefixes "e.g. "/output" will | 285 // This check will be wrong for all proper prefixes "e.g. "/output" will |
286 // match "/out" but we don't really care since this is just a sanity check. | 286 // match "/out" but we don't really care since this is just a sanity check. |
287 const std::string& dir_str = dir.value(); | 287 const std::string& dir_str = dir.value(); |
288 if (str.compare(0, dir_str.length() - 1, dir_str, 0, dir_str.length() - 1) | 288 if (str.compare(0, dir_str.length() - 1, dir_str, 0, dir_str.length() - 1) |
289 != 0) { | 289 != 0) { |
290 *err = Err(originating, "File not inside output directory.", | 290 *err = Err(originating, "File is not inside output directory.", |
291 "The given file should be in the output directory. Normally you would " | 291 "The given file should be in the output directory. Normally you would " |
292 "specify\n\"$target_output_dir/foo\" or " | 292 "specify\n\"$target_out_dir/foo\" or " |
293 "\"$target_gen_dir/foo\". I interpreted this as\n\"" | 293 "\"$target_gen_dir/foo\". I interpreted this as\n\"" |
294 + str + "\"."); | 294 + str + "\"."); |
295 return false; | 295 return false; |
296 } | 296 } |
297 return true; | 297 return true; |
298 } | 298 } |
299 | 299 |
300 bool IsPathAbsolute(const base::StringPiece& path) { | 300 bool IsPathAbsolute(const base::StringPiece& path) { |
301 if (path.empty()) | 301 if (path.empty()) |
302 return false; | 302 return false; |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 return GetGenDirForSourceDir(target->settings(), target->label().dir()); | 624 return GetGenDirForSourceDir(target->settings(), target->label().dir()); |
625 } | 625 } |
626 | 626 |
627 SourceDir GetCurrentOutputDir(const Scope* scope) { | 627 SourceDir GetCurrentOutputDir(const Scope* scope) { |
628 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 628 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
629 } | 629 } |
630 | 630 |
631 SourceDir GetCurrentGenDir(const Scope* scope) { | 631 SourceDir GetCurrentGenDir(const Scope* scope) { |
632 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); | 632 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); |
633 } | 633 } |
OLD | NEW |