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/target.h

Issue 1752033002: Add "create_bundle" target in order to support bundle with gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-bundle-data
Patch Set: Add unit tests, address comments, update docs and format with clang-format Created 4 years, 9 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/substitution_type.cc ('k') | tools/gn/target.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 #ifndef TOOLS_GN_TARGET_H_ 5 #ifndef TOOLS_GN_TARGET_H_
6 #define TOOLS_GN_TARGET_H_ 6 #define TOOLS_GN_TARGET_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "tools/gn/action_values.h" 15 #include "tools/gn/action_values.h"
16 #include "tools/gn/bundle_data.h"
16 #include "tools/gn/config_values.h" 17 #include "tools/gn/config_values.h"
17 #include "tools/gn/inherited_libraries.h" 18 #include "tools/gn/inherited_libraries.h"
18 #include "tools/gn/item.h" 19 #include "tools/gn/item.h"
19 #include "tools/gn/label_pattern.h" 20 #include "tools/gn/label_pattern.h"
20 #include "tools/gn/label_ptr.h" 21 #include "tools/gn/label_ptr.h"
21 #include "tools/gn/lib_file.h" 22 #include "tools/gn/lib_file.h"
22 #include "tools/gn/ordered_set.h" 23 #include "tools/gn/ordered_set.h"
23 #include "tools/gn/output_file.h" 24 #include "tools/gn/output_file.h"
24 #include "tools/gn/source_file.h" 25 #include "tools/gn/source_file.h"
25 #include "tools/gn/toolchain.h" 26 #include "tools/gn/toolchain.h"
(...skipping 12 matching lines...) Expand all
38 GROUP, 39 GROUP,
39 EXECUTABLE, 40 EXECUTABLE,
40 SHARED_LIBRARY, 41 SHARED_LIBRARY,
41 LOADABLE_MODULE, 42 LOADABLE_MODULE,
42 STATIC_LIBRARY, 43 STATIC_LIBRARY,
43 SOURCE_SET, 44 SOURCE_SET,
44 COPY_FILES, 45 COPY_FILES,
45 ACTION, 46 ACTION,
46 ACTION_FOREACH, 47 ACTION_FOREACH,
47 BUNDLE_DATA, 48 BUNDLE_DATA,
49 CREATE_BUNDLE,
48 }; 50 };
49 51
50 enum DepsIterationType { 52 enum DepsIterationType {
51 DEPS_ALL, // Iterates through all public, private, and data deps. 53 DEPS_ALL, // Iterates through all public, private, and data deps.
52 DEPS_LINKED, // Iterates through all non-data dependencies. 54 DEPS_LINKED, // Iterates through all non-data dependencies.
53 }; 55 };
54 56
55 typedef std::vector<SourceFile> FileList; 57 typedef std::vector<SourceFile> FileList;
56 typedef std::vector<std::string> StringVector; 58 typedef std::vector<std::string> StringVector;
57 59
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Compile-time extra dependencies. 131 // Compile-time extra dependencies.
130 const FileList& inputs() const { return inputs_; } 132 const FileList& inputs() const { return inputs_; }
131 FileList& inputs() { return inputs_; } 133 FileList& inputs() { return inputs_; }
132 134
133 // Runtime dependencies. These are "file-like things" that can either be 135 // Runtime dependencies. These are "file-like things" that can either be
134 // directories or files. They do not need to exist, these are just passed as 136 // directories or files. They do not need to exist, these are just passed as
135 // runtime dependencies to external test systems as necessary. 137 // runtime dependencies to external test systems as necessary.
136 const std::vector<std::string>& data() const { return data_; } 138 const std::vector<std::string>& data() const { return data_; }
137 std::vector<std::string>& data() { return data_; } 139 std::vector<std::string>& data() { return data_; }
138 140
141 // Information about the bundle. Only valid for CREATE_BUNDLE target after
142 // they have been resolved.
143 const BundleData& bundle_data() const { return bundle_data_; }
144 BundleData& bundle_data() { return bundle_data_; }
145
139 // Returns true if targets depending on this one should have an order 146 // Returns true if targets depending on this one should have an order
140 // dependency. 147 // dependency.
141 bool hard_dep() const { 148 bool hard_dep() const {
142 return output_type_ == ACTION || 149 return output_type_ == ACTION ||
143 output_type_ == ACTION_FOREACH || 150 output_type_ == ACTION_FOREACH ||
144 output_type_ == COPY_FILES; 151 output_type_ == COPY_FILES ||
152 output_type_ == CREATE_BUNDLE;
145 } 153 }
146 154
147 // Returns the iterator range which can be used in range-based for loops 155 // Returns the iterator range which can be used in range-based for loops
148 // to iterate over multiple types of deps in one loop: 156 // to iterate over multiple types of deps in one loop:
149 // for (const auto& pair : target->GetDeps(Target::DEPS_ALL)) ... 157 // for (const auto& pair : target->GetDeps(Target::DEPS_ALL)) ...
150 DepsIteratorRange GetDeps(DepsIterationType type) const; 158 DepsIteratorRange GetDeps(DepsIterationType type) const;
151 159
152 // Linked private dependencies. 160 // Linked private dependencies.
153 const LabelTargetVector& private_deps() const { return private_deps_; } 161 const LabelTargetVector& private_deps() const { return private_deps_; }
154 LabelTargetVector& private_deps() { return private_deps_; } 162 LabelTargetVector& private_deps() { return private_deps_; }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 private: 285 private:
278 FRIEND_TEST_ALL_PREFIXES(Target, ResolvePrecompiledHeaders); 286 FRIEND_TEST_ALL_PREFIXES(Target, ResolvePrecompiledHeaders);
279 287
280 // Pulls necessary information from dependencies to this one when all 288 // Pulls necessary information from dependencies to this one when all
281 // dependencies have been resolved. 289 // dependencies have been resolved.
282 void PullDependentTargetConfigsFrom(const Target* dep); 290 void PullDependentTargetConfigsFrom(const Target* dep);
283 void PullDependentTargetConfigs(); 291 void PullDependentTargetConfigs();
284 void PullDependentTargetLibsFrom(const Target* dep, bool is_public); 292 void PullDependentTargetLibsFrom(const Target* dep, bool is_public);
285 void PullDependentTargetLibs(); 293 void PullDependentTargetLibs();
286 void PullRecursiveHardDeps(); 294 void PullRecursiveHardDeps();
295 void PullRecursiveBundleData();
287 296
288 // Fills the link and dependency output files when a target is resolved. 297 // Fills the link and dependency output files when a target is resolved.
289 void FillOutputFiles(); 298 void FillOutputFiles();
290 299
291 // Checks precompiled headers from configs and makes sure the resulting 300 // Checks precompiled headers from configs and makes sure the resulting
292 // values are in config_values_. 301 // values are in config_values_.
293 bool ResolvePrecompiledHeaders(Err* err); 302 bool ResolvePrecompiledHeaders(Err* err);
294 303
295 // Validates the given thing when a target is resolved. 304 // Validates the given thing when a target is resolved.
296 bool CheckVisibility(Err* err) const; 305 bool CheckVisibility(Err* err) const;
297 bool CheckTestonly(Err* err) const; 306 bool CheckTestonly(Err* err) const;
298 bool CheckNoNestedStaticLibs(Err* err) const; 307 bool CheckNoNestedStaticLibs(Err* err) const;
299 bool CheckAssertNoDeps(Err* err) const; 308 bool CheckAssertNoDeps(Err* err) const;
300 void CheckSourcesGenerated() const; 309 void CheckSourcesGenerated() const;
301 void CheckSourceGenerated(const SourceFile& source) const; 310 void CheckSourceGenerated(const SourceFile& source) const;
302 311
303 OutputType output_type_; 312 OutputType output_type_;
304 std::string output_name_; 313 std::string output_name_;
305 std::string output_extension_; 314 std::string output_extension_;
306 315
307 FileList sources_; 316 FileList sources_;
308 bool all_headers_public_; 317 bool all_headers_public_;
309 FileList public_headers_; 318 FileList public_headers_;
310 bool check_includes_; 319 bool check_includes_;
311 bool complete_static_lib_; 320 bool complete_static_lib_;
312 bool testonly_; 321 bool testonly_;
313 FileList inputs_; 322 FileList inputs_;
314 std::vector<std::string> data_; 323 std::vector<std::string> data_;
324 BundleData bundle_data_;
315 325
316 LabelTargetVector private_deps_; 326 LabelTargetVector private_deps_;
317 LabelTargetVector public_deps_; 327 LabelTargetVector public_deps_;
318 LabelTargetVector data_deps_; 328 LabelTargetVector data_deps_;
319 329
320 // See getters for more info. 330 // See getters for more info.
321 UniqueVector<LabelConfigPair> configs_; 331 UniqueVector<LabelConfigPair> configs_;
322 UniqueVector<LabelConfigPair> all_dependent_configs_; 332 UniqueVector<LabelConfigPair> all_dependent_configs_;
323 UniqueVector<LabelConfigPair> public_configs_; 333 UniqueVector<LabelConfigPair> public_configs_;
324 334
(...skipping 28 matching lines...) Expand all
353 // Output files. Empty until the target is resolved. 363 // Output files. Empty until the target is resolved.
354 std::vector<OutputFile> computed_outputs_; 364 std::vector<OutputFile> computed_outputs_;
355 OutputFile link_output_file_; 365 OutputFile link_output_file_;
356 OutputFile dependency_output_file_; 366 OutputFile dependency_output_file_;
357 OutputFile runtime_link_output_file_; 367 OutputFile runtime_link_output_file_;
358 368
359 DISALLOW_COPY_AND_ASSIGN(Target); 369 DISALLOW_COPY_AND_ASSIGN(Target);
360 }; 370 };
361 371
362 #endif // TOOLS_GN_TARGET_H_ 372 #endif // TOOLS_GN_TARGET_H_
OLDNEW
« no previous file with comments | « tools/gn/substitution_type.cc ('k') | tools/gn/target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698