| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/visibility.h" | 5 #include "tools/gn/visibility.h" |
| 6 | 6 |
| 7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "tools/gn/err.h" | 9 #include "tools/gn/err.h" |
| 10 #include "tools/gn/filesystem_utils.h" | 10 #include "tools/gn/filesystem_utils.h" |
| 11 #include "tools/gn/item.h" | 11 #include "tools/gn/item.h" |
| 12 #include "tools/gn/label.h" | 12 #include "tools/gn/label.h" |
| 13 #include "tools/gn/scope.h" | 13 #include "tools/gn/scope.h" |
| 14 #include "tools/gn/value.h" | 14 #include "tools/gn/value.h" |
| 15 #include "tools/gn/variables.h" | 15 #include "tools/gn/variables.h" |
| 16 | 16 |
| 17 Visibility::Visibility() { | 17 Visibility::Visibility() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 Visibility::~Visibility() { | 20 Visibility::~Visibility() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool Visibility::Set(const SourceDir& current_dir, | 23 bool Visibility::Set(const base::FilePath& source_root, |
| 24 const SourceDir& current_dir, |
| 24 const Value& value, | 25 const Value& value, |
| 25 Err* err) { | 26 Err* err) { |
| 26 patterns_.clear(); | 27 patterns_.clear(); |
| 27 | 28 |
| 28 if (!value.VerifyTypeIs(Value::LIST, err)) { | 29 if (!value.VerifyTypeIs(Value::LIST, err)) { |
| 29 CHECK(err->has_error()); | 30 CHECK(err->has_error()); |
| 30 return false; | 31 return false; |
| 31 } | 32 } |
| 32 | 33 |
| 33 for (const auto& item : value.list_value()) { | 34 for (const auto& item : value.list_value()) { |
| 34 patterns_.push_back(LabelPattern::GetPattern(current_dir, item, err)); | 35 patterns_.push_back(LabelPattern::GetPattern(source_root, current_dir, |
| 36 item, err)); |
| 35 if (err->has_error()) | 37 if (err->has_error()) |
| 36 return false; | 38 return false; |
| 37 } | 39 } |
| 38 return true; | 40 return true; |
| 39 } | 41 } |
| 40 | 42 |
| 41 void Visibility::SetPublic() { | 43 void Visibility::SetPublic() { |
| 42 patterns_.clear(); | 44 patterns_.clear(); |
| 43 patterns_.push_back( | 45 patterns_.push_back( |
| 44 LabelPattern(LabelPattern::RECURSIVE_DIRECTORY, SourceDir(), | 46 LabelPattern(LabelPattern::RECURSIVE_DIRECTORY, SourceDir(), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 to->visibility().Describe(0, true)); | 98 to->visibility().Describe(0, true)); |
| 97 return false; | 99 return false; |
| 98 } | 100 } |
| 99 return true; | 101 return true; |
| 100 } | 102 } |
| 101 | 103 |
| 102 // static | 104 // static |
| 103 bool Visibility::FillItemVisibility(Item* item, Scope* scope, Err* err) { | 105 bool Visibility::FillItemVisibility(Item* item, Scope* scope, Err* err) { |
| 104 const Value* vis_value = scope->GetValue(variables::kVisibility, true); | 106 const Value* vis_value = scope->GetValue(variables::kVisibility, true); |
| 105 if (vis_value) | 107 if (vis_value) |
| 106 item->visibility().Set(scope->GetSourceDir(), *vis_value, err); | 108 item->visibility().Set(scope->settings()->build_settings()->root_path(), |
| 109 scope->GetSourceDir(), *vis_value, err); |
| 107 else // Default to public. | 110 else // Default to public. |
| 108 item->visibility().SetPublic(); | 111 item->visibility().SetPublic(); |
| 109 return !err->has_error(); | 112 return !err->has_error(); |
| 110 } | 113 } |
| OLD | NEW |