Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: tools/gn/visibility.cc

Issue 2160533004: Revert of [GN] Add JSON project writer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/visibility.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ptr_util.h"
8 #include "base/strings/string_piece.h" 7 #include "base/strings/string_piece.h"
9 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
10 #include "base/values.h"
11 #include "tools/gn/err.h" 9 #include "tools/gn/err.h"
12 #include "tools/gn/filesystem_utils.h" 10 #include "tools/gn/filesystem_utils.h"
13 #include "tools/gn/item.h" 11 #include "tools/gn/item.h"
14 #include "tools/gn/label.h" 12 #include "tools/gn/label.h"
15 #include "tools/gn/scope.h" 13 #include "tools/gn/scope.h"
16 #include "tools/gn/value.h" 14 #include "tools/gn/value.h"
17 #include "tools/gn/variables.h" 15 #include "tools/gn/variables.h"
18 16
19 Visibility::Visibility() { 17 Visibility::Visibility() {
20 } 18 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 76 }
79 77
80 for (const auto& pattern : patterns_) 78 for (const auto& pattern : patterns_)
81 result += inner_indent_string + pattern.Describe() + "\n"; 79 result += inner_indent_string + pattern.Describe() + "\n";
82 80
83 if (include_brackets) 81 if (include_brackets)
84 result += outer_indent_string + "]\n"; 82 result += outer_indent_string + "]\n";
85 return result; 83 return result;
86 } 84 }
87 85
88 std::unique_ptr<base::Value> Visibility::AsValue() const {
89 auto* res = new base::ListValue();
90 for (const auto& pattern : patterns_)
91 res->AppendString(pattern.Describe());
92
93 return WrapUnique(res);
94 }
95
96 // static 86 // static
97 bool Visibility::CheckItemVisibility(const Item* from, 87 bool Visibility::CheckItemVisibility(const Item* from,
98 const Item* to, 88 const Item* to,
99 Err* err) { 89 Err* err) {
100 if (!to->visibility().CanSeeMe(from->label())) { 90 if (!to->visibility().CanSeeMe(from->label())) {
101 std::string to_label = to->label().GetUserVisibleName(false); 91 std::string to_label = to->label().GetUserVisibleName(false);
102 *err = Err(from->defined_from(), "Dependency not allowed.", 92 *err = Err(from->defined_from(), "Dependency not allowed.",
103 "The item " + from->label().GetUserVisibleName(false) + "\n" 93 "The item " + from->label().GetUserVisibleName(false) + "\n"
104 "can not depend on " + to_label + "\n" 94 "can not depend on " + to_label + "\n"
105 "because it is not in " + to_label + "'s visibility list: " + 95 "because it is not in " + to_label + "'s visibility list: " +
106 to->visibility().Describe(0, true)); 96 to->visibility().Describe(0, true));
107 return false; 97 return false;
108 } 98 }
109 return true; 99 return true;
110 } 100 }
111 101
112 // static 102 // static
113 bool Visibility::FillItemVisibility(Item* item, Scope* scope, Err* err) { 103 bool Visibility::FillItemVisibility(Item* item, Scope* scope, Err* err) {
114 const Value* vis_value = scope->GetValue(variables::kVisibility, true); 104 const Value* vis_value = scope->GetValue(variables::kVisibility, true);
115 if (vis_value) 105 if (vis_value)
116 item->visibility().Set(scope->GetSourceDir(), *vis_value, err); 106 item->visibility().Set(scope->GetSourceDir(), *vis_value, err);
117 else // Default to public. 107 else // Default to public.
118 item->visibility().SetPublic(); 108 item->visibility().SetPublic();
119 return !err->has_error(); 109 return !err->has_error();
120 } 110 }
OLDNEW
« no previous file with comments | « tools/gn/visibility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698