| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_BUNDLE_DATA_H_ | 5 #ifndef TOOLS_GN_BUNDLE_DATA_H_ |
| 6 #define TOOLS_GN_BUNDLE_DATA_H_ | 6 #define TOOLS_GN_BUNDLE_DATA_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "tools/gn/bundle_file_rule.h" | 11 #include "tools/gn/bundle_file_rule.h" |
| 12 #include "tools/gn/unique_vector.h" |
| 12 | 13 |
| 13 class OutputFile; | 14 class OutputFile; |
| 14 class SourceFile; | 15 class SourceFile; |
| 15 class Settings; | 16 class Settings; |
| 16 class Target; | 17 class Target; |
| 17 | 18 |
| 18 // Returns true if |source| correspond to the path of a file in an asset | 19 // Returns true if |source| correspond to the path of a file in an asset |
| 19 // catalog. If defined |asset_catalog| is set to its path. | 20 // catalog. If defined |asset_catalog| is set to its path. |
| 20 // | 21 // |
| 21 // An asset catalog is an OS X bundle with the ".xcassets" extension. It | 22 // An asset catalog is an OS X bundle with the ".xcassets" extension. It |
| 22 // contains one directory per assets each of them with the ".imageset" | 23 // contains one directory per assets each of them with the ".imageset" |
| 23 // extension. | 24 // extension. |
| 24 // | 25 // |
| 25 // All asset catalogs are compiled by Xcode into single Assets.car file as | 26 // All asset catalogs are compiled by Xcode into single Assets.car file as |
| 26 // part of the creation of an application or framework bundle. BundleData | 27 // part of the creation of an application or framework bundle. BundleData |
| 27 // emulates this with the "compile_xcassets" tool. | 28 // emulates this with the "compile_xcassets" tool. |
| 28 bool IsSourceFileFromAssetCatalog(const SourceFile& source, | 29 bool IsSourceFileFromAssetCatalog(const SourceFile& source, |
| 29 SourceFile* asset_catalog); | 30 SourceFile* asset_catalog); |
| 30 | 31 |
| 31 // BundleData holds the information required by "create_bundle" target. | 32 // BundleData holds the information required by "create_bundle" target. |
| 32 class BundleData { | 33 class BundleData { |
| 33 public: | 34 public: |
| 35 using UniqueTargets = UniqueVector<const Target*>; |
| 36 using SourceFiles = std::vector<SourceFile>; |
| 37 using OutputFiles = std::vector<OutputFile>; |
| 38 using BundleFileRules = std::vector<BundleFileRule>; |
| 39 |
| 34 BundleData(); | 40 BundleData(); |
| 35 ~BundleData(); | 41 ~BundleData(); |
| 36 | 42 |
| 37 // Extracts the information required from a "bundle_data" target. | 43 // Adds a bundle_data target to the recursive collection of all bundle_data |
| 38 void AddFileRuleFromTarget(const Target* target); | 44 // that the target depends on. |
| 45 void AddBundleData(const Target* target); |
| 46 |
| 47 // Called upon resolution of the target owning this instance of BundleData. |
| 48 // |owning_target| is the owning target. |
| 49 void OnTargetResolved(Target* owning_target); |
| 39 | 50 |
| 40 // Returns the list of inputs. | 51 // Returns the list of inputs. |
| 41 void GetSourceFiles(std::vector<SourceFile>* sources) const; | 52 void GetSourceFiles(SourceFiles* sources) const; |
| 42 | 53 |
| 43 // Returns the list of outputs. | 54 // Returns the list of outputs. |
| 44 void GetOutputFiles(const Settings* settings, | 55 void GetOutputFiles(const Settings* settings, |
| 45 std::vector<OutputFile>* outputs) const; | 56 OutputFiles* outputs) const; |
| 46 | 57 |
| 47 // Returns the list of outputs as SourceFile. | 58 // Returns the list of outputs as SourceFile. |
| 48 void GetOutputsAsSourceFiles( | 59 void GetOutputsAsSourceFiles( |
| 49 const Settings* settings, | 60 const Settings* settings, |
| 50 std::vector<SourceFile>* outputs_as_source) const; | 61 SourceFiles* outputs_as_source) const; |
| 51 | 62 |
| 52 // Returns the path to the compiled asset catalog. Only valid if | 63 // Returns the path to the compiled asset catalog. Only valid if |
| 53 // asset_catalog_sources() is not empty. | 64 // asset_catalog_sources() is not empty. |
| 54 SourceFile GetCompiledAssetCatalogPath() const; | 65 SourceFile GetCompiledAssetCatalogPath() const; |
| 55 | 66 |
| 56 // Returns the list of inputs for the compilation of the asset catalog. | 67 // Returns the list of inputs for the compilation of the asset catalog. |
| 57 std::vector<SourceFile>& asset_catalog_sources() { | 68 SourceFiles& asset_catalog_sources() { return asset_catalog_sources_; } |
| 58 return asset_catalog_sources_; | 69 const SourceFiles& asset_catalog_sources() const { |
| 59 } | |
| 60 const std::vector<SourceFile>& asset_catalog_sources() const { | |
| 61 return asset_catalog_sources_; | 70 return asset_catalog_sources_; |
| 62 } | 71 } |
| 63 | 72 |
| 64 std::vector<BundleFileRule>& file_rules() { return file_rules_; } | 73 BundleFileRules& file_rules() { return file_rules_; } |
| 65 const std::vector<BundleFileRule>& file_rules() const { return file_rules_; } | 74 const BundleFileRules& file_rules() const { return file_rules_; } |
| 66 | 75 |
| 67 std::string& root_dir() { return root_dir_; } | 76 std::string& root_dir() { return root_dir_; } |
| 68 const std::string& root_dir() const { return root_dir_; } | 77 const std::string& root_dir() const { return root_dir_; } |
| 69 | 78 |
| 70 std::string& resources_dir() { return resources_dir_; } | 79 std::string& resources_dir() { return resources_dir_; } |
| 71 const std::string& resources_dir() const { return resources_dir_; } | 80 const std::string& resources_dir() const { return resources_dir_; } |
| 72 | 81 |
| 73 std::string& executable_dir() { return executable_dir_; } | 82 std::string& executable_dir() { return executable_dir_; } |
| 74 const std::string& executable_dir() const { return executable_dir_; } | 83 const std::string& executable_dir() const { return executable_dir_; } |
| 75 | 84 |
| 76 std::string& plugins_dir() { return plugins_dir_; } | 85 std::string& plugins_dir() { return plugins_dir_; } |
| 77 const std::string& plugins_dir() const { return plugins_dir_; } | 86 const std::string& plugins_dir() const { return plugins_dir_; } |
| 78 | 87 |
| 88 // Recursive collection of all bundle_data that the target depends on. |
| 89 const UniqueTargets& bundle_deps() const { return bundle_deps_; } |
| 90 |
| 79 private: | 91 private: |
| 80 std::vector<SourceFile> asset_catalog_sources_; | 92 SourceFiles asset_catalog_sources_; |
| 81 std::vector<BundleFileRule> file_rules_; | 93 BundleFileRules file_rules_; |
| 94 UniqueTargets bundle_deps_; |
| 82 | 95 |
| 83 // All those values are subdirectories relative to root_build_dir, and apart | 96 // All those values are subdirectories relative to root_build_dir, and apart |
| 84 // from root_dir, they are either equal to root_dir_ or subdirectories of it. | 97 // from root_dir, they are either equal to root_dir_ or subdirectories of it. |
| 85 std::string root_dir_; | 98 std::string root_dir_; |
| 86 std::string resources_dir_; | 99 std::string resources_dir_; |
| 87 std::string executable_dir_; | 100 std::string executable_dir_; |
| 88 std::string plugins_dir_; | 101 std::string plugins_dir_; |
| 89 }; | 102 }; |
| 90 | 103 |
| 91 #endif // TOOLS_GN_BUNDLE_DATA_H_ | 104 #endif // TOOLS_GN_BUNDLE_DATA_H_ |
| OLD | NEW |