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

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

Issue 223783005: Add support for reading .gypi files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/input_file_manager.h ('k') | tools/gn/parse_tree_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/input_file_manager.h" 5 #include "tools/gn/input_file_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "tools/gn/filesystem_utils.h" 9 #include "tools/gn/filesystem_utils.h"
10 #include "tools/gn/parser.h" 10 #include "tools/gn/parser.h"
(...skipping 20 matching lines...) Expand all
31 InputFileManager::InputFileData::~InputFileData() { 31 InputFileManager::InputFileData::~InputFileData() {
32 } 32 }
33 33
34 InputFileManager::InputFileManager() { 34 InputFileManager::InputFileManager() {
35 } 35 }
36 36
37 InputFileManager::~InputFileManager() { 37 InputFileManager::~InputFileManager() {
38 // Should be single-threaded by now. 38 // Should be single-threaded by now.
39 STLDeleteContainerPairSecondPointers(input_files_.begin(), 39 STLDeleteContainerPairSecondPointers(input_files_.begin(),
40 input_files_.end()); 40 input_files_.end());
41 STLDeleteContainerPointers(dynamic_inputs_.begin(), dynamic_inputs_.end());
41 } 42 }
42 43
43 bool InputFileManager::AsyncLoadFile(const LocationRange& origin, 44 bool InputFileManager::AsyncLoadFile(const LocationRange& origin,
44 const BuildSettings* build_settings, 45 const BuildSettings* build_settings,
45 const SourceFile& file_name, 46 const SourceFile& file_name,
46 const FileLoadCallback& callback, 47 const FileLoadCallback& callback,
47 Err* err) { 48 Err* err) {
48 // Try not to schedule callbacks while holding the lock. All cases that don't 49 // Try not to schedule callbacks while holding the lock. All cases that don't
49 // want to schedule should return early. Otherwise, this will be scheduled 50 // want to schedule should return early. Otherwise, this will be scheduled
50 // after we leave the lock. 51 // after we leave the lock.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 160 }
160 161
161 // The other load could have failed. In this case that error will be printed 162 // The other load could have failed. In this case that error will be printed
162 // to the console, but we need to return something here, so make up a 163 // to the console, but we need to return something here, so make up a
163 // dummy error. 164 // dummy error.
164 if (!data->parsed_root) 165 if (!data->parsed_root)
165 *err = Err(origin, "File parse failed"); 166 *err = Err(origin, "File parse failed");
166 return data->parsed_root.get(); 167 return data->parsed_root.get();
167 } 168 }
168 169
170 void InputFileManager::AddDynamicInput(InputFile** file,
171 std::vector<Token>** tokens,
172 scoped_ptr<ParseNode>** parse_root) {
173 InputFileData* data = new InputFileData(SourceFile());
174 {
175 base::AutoLock lock(lock_);
176 dynamic_inputs_.push_back(data);
177 }
178 *file = &data->file;
179 *tokens = &data->tokens;
180 *parse_root = &data->parsed_root;
181 }
182
169 int InputFileManager::GetInputFileCount() const { 183 int InputFileManager::GetInputFileCount() const {
170 base::AutoLock lock(lock_); 184 base::AutoLock lock(lock_);
171 return static_cast<int>(input_files_.size()); 185 return static_cast<int>(input_files_.size());
172 } 186 }
173 187
174 void InputFileManager::GetAllPhysicalInputFileNames( 188 void InputFileManager::GetAllPhysicalInputFileNames(
175 std::vector<base::FilePath>* result) const { 189 std::vector<base::FilePath>* result) const {
176 base::AutoLock lock(lock_); 190 base::AutoLock lock(lock_);
177 result->reserve(input_files_.size()); 191 result->reserve(input_files_.size());
178 for (InputFileMap::const_iterator i = input_files_.begin(); 192 for (InputFileMap::const_iterator i = input_files_.begin();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 callbacks.swap(data->scheduled_callbacks); 284 callbacks.swap(data->scheduled_callbacks);
271 } 285 }
272 286
273 // Run pending invocations. Theoretically we could schedule each of these 287 // Run pending invocations. Theoretically we could schedule each of these
274 // separately to get some parallelism. But normally there will only be one 288 // separately to get some parallelism. But normally there will only be one
275 // item in the list, so that's extra overhead and complexity for no gain. 289 // item in the list, so that's extra overhead and complexity for no gain.
276 for (size_t i = 0; i < callbacks.size(); i++) 290 for (size_t i = 0; i < callbacks.size(); i++)
277 callbacks[i].Run(unowned_root); 291 callbacks[i].Run(unowned_root);
278 return true; 292 return true;
279 } 293 }
OLDNEW
« no previous file with comments | « tools/gn/input_file_manager.h ('k') | tools/gn/parse_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698