| 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/action_values.h" | 11 #include "tools/gn/action_values.h" |
| 12 #include "tools/gn/bundle_file_rule.h" | 12 #include "tools/gn/bundle_file_rule.h" |
| 13 #include "tools/gn/source_dir.h" | 13 #include "tools/gn/source_dir.h" |
| 14 #include "tools/gn/source_file.h" | 14 #include "tools/gn/source_file.h" |
| 15 #include "tools/gn/substitution_list.h" | 15 #include "tools/gn/substitution_list.h" |
| 16 #include "tools/gn/unique_vector.h" | 16 #include "tools/gn/unique_vector.h" |
| 17 | 17 |
| 18 class OutputFile; | 18 class OutputFile; |
| 19 class Settings; | 19 class Settings; |
| 20 class Target; | 20 class Target; |
| 21 | 21 |
| 22 // Returns true if |source| correspond to the path of a file in an asset | |
| 23 // catalog. If defined |asset_catalog| is set to its path. | |
| 24 // | |
| 25 // An asset catalog is an OS X bundle with the ".xcassets" extension. It | |
| 26 // contains one directory per assets each of them with the ".imageset" | |
| 27 // extension. | |
| 28 // | |
| 29 // All asset catalogs are compiled by Xcode into single Assets.car file as | |
| 30 // part of the creation of an application or framework bundle. BundleData | |
| 31 // emulates this with the "compile_xcassets" tool. | |
| 32 bool IsSourceFileFromAssetCatalog(const SourceFile& source, | |
| 33 SourceFile* asset_catalog); | |
| 34 | |
| 35 // BundleData holds the information required by "create_bundle" target. | 22 // BundleData holds the information required by "create_bundle" target. |
| 36 class BundleData { | 23 class BundleData { |
| 37 public: | 24 public: |
| 38 using UniqueTargets = UniqueVector<const Target*>; | 25 using UniqueTargets = UniqueVector<const Target*>; |
| 39 using SourceFiles = std::vector<SourceFile>; | 26 using SourceFiles = std::vector<SourceFile>; |
| 40 using OutputFiles = std::vector<OutputFile>; | 27 using OutputFiles = std::vector<OutputFile>; |
| 41 using BundleFileRules = std::vector<BundleFileRule>; | 28 using BundleFileRules = std::vector<BundleFileRule>; |
| 42 | 29 |
| 43 BundleData(); | 30 BundleData(); |
| 44 ~BundleData(); | 31 ~BundleData(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 // Returns the list of outputs. | 44 // Returns the list of outputs. |
| 58 void GetOutputFiles(const Settings* settings, | 45 void GetOutputFiles(const Settings* settings, |
| 59 OutputFiles* outputs) const; | 46 OutputFiles* outputs) const; |
| 60 | 47 |
| 61 // Returns the list of outputs as SourceFile. | 48 // Returns the list of outputs as SourceFile. |
| 62 void GetOutputsAsSourceFiles( | 49 void GetOutputsAsSourceFiles( |
| 63 const Settings* settings, | 50 const Settings* settings, |
| 64 SourceFiles* outputs_as_source) const; | 51 SourceFiles* outputs_as_source) const; |
| 65 | 52 |
| 66 // Returns the path to the compiled asset catalog. Only valid if | 53 // Returns the path to the compiled asset catalog. Only valid if |
| 67 // asset_catalog_sources() is not empty. | 54 // assets_catalog_sources() is not empty. |
| 68 SourceFile GetCompiledAssetCatalogPath() const; | 55 SourceFile GetCompiledAssetCatalogPath() const; |
| 69 | 56 |
| 70 // Returns the path to the top-level directory of the bundle. This is | 57 // Returns the path to the top-level directory of the bundle. This is |
| 71 // based on root_dir(), but since that can be Bundle.app/Contents/ or | 58 // based on root_dir(), but since that can be Bundle.app/Contents/ or |
| 72 // any other subpath, this is just the most top-level directory (e.g., | 59 // any other subpath, this is just the most top-level directory (e.g., |
| 73 // just Bundle.app/). | 60 // just Bundle.app/). |
| 74 // | 61 // |
| 75 // Note that this is a SourceFile instead of a SourceDir. This is because | 62 // Note that this is a SourceFile instead of a SourceDir. This is because |
| 76 // the output of a create_bundle rule is a single logical unit, even though | 63 // the output of a create_bundle rule is a single logical unit, even though |
| 77 // it is really a directory containing many outputs. This allows other | 64 // it is really a directory containing many outputs. This allows other |
| 78 // targets to treat the bundle as a single unit, rather than a collection | 65 // targets to treat the bundle as a single unit, rather than a collection |
| 79 // of its contents. | 66 // of its contents. |
| 80 SourceFile GetBundleRootDirOutput(const Settings* settings) const; | 67 SourceFile GetBundleRootDirOutput(const Settings* settings) const; |
| 81 | 68 |
| 82 // Performs GetBundleRootDirOutput but returns the result as a directory. | 69 // Performs GetBundleRootDirOutput but returns the result as a directory. |
| 83 SourceDir GetBundleRootDirOutputAsDir(const Settings* settings) const; | 70 SourceDir GetBundleRootDirOutputAsDir(const Settings* settings) const; |
| 84 | 71 |
| 85 // Returns the list of inputs for the compilation of the asset catalog. | 72 // Returns the list of inputs for the compilation of the asset catalog. |
| 86 SourceFiles& asset_catalog_sources() { return asset_catalog_sources_; } | 73 SourceFiles& assets_catalog_sources() { return assets_catalog_sources_; } |
| 87 const SourceFiles& asset_catalog_sources() const { | 74 const SourceFiles& assets_catalog_sources() const { |
| 88 return asset_catalog_sources_; | 75 return assets_catalog_sources_; |
| 76 } |
| 77 |
| 78 // Returns the list of dependencies for the compilation of the asset catalog. |
| 79 std::vector<const Target*> assets_catalog_deps() const { |
| 80 return assets_catalog_deps_; |
| 89 } | 81 } |
| 90 | 82 |
| 91 BundleFileRules& file_rules() { return file_rules_; } | 83 BundleFileRules& file_rules() { return file_rules_; } |
| 92 const BundleFileRules& file_rules() const { return file_rules_; } | 84 const BundleFileRules& file_rules() const { return file_rules_; } |
| 93 | 85 |
| 94 SourceDir& root_dir() { return root_dir_; } | 86 SourceDir& root_dir() { return root_dir_; } |
| 95 const SourceDir& root_dir() const { return root_dir_; } | 87 const SourceDir& root_dir() const { return root_dir_; } |
| 96 | 88 |
| 97 SourceDir& resources_dir() { return resources_dir_; } | 89 SourceDir& resources_dir() { return resources_dir_; } |
| 98 const SourceDir& resources_dir() const { return resources_dir_; } | 90 const SourceDir& resources_dir() const { return resources_dir_; } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 125 | 117 |
| 126 SubstitutionList& code_signing_args() { return code_signing_args_; } | 118 SubstitutionList& code_signing_args() { return code_signing_args_; } |
| 127 const SubstitutionList& code_signing_args() const { | 119 const SubstitutionList& code_signing_args() const { |
| 128 return code_signing_args_; | 120 return code_signing_args_; |
| 129 } | 121 } |
| 130 | 122 |
| 131 // Recursive collection of all bundle_data that the target depends on. | 123 // Recursive collection of all bundle_data that the target depends on. |
| 132 const UniqueTargets& bundle_deps() const { return bundle_deps_; } | 124 const UniqueTargets& bundle_deps() const { return bundle_deps_; } |
| 133 | 125 |
| 134 private: | 126 private: |
| 135 SourceFiles asset_catalog_sources_; | 127 SourceFiles assets_catalog_sources_; |
| 128 std::vector<const Target*> assets_catalog_deps_; |
| 136 BundleFileRules file_rules_; | 129 BundleFileRules file_rules_; |
| 137 UniqueTargets bundle_deps_; | 130 UniqueTargets bundle_deps_; |
| 138 | 131 |
| 139 // All those values are subdirectories relative to root_build_dir, and apart | 132 // All those values are subdirectories relative to root_build_dir, and apart |
| 140 // from root_dir, they are either equal to root_dir_ or subdirectories of it. | 133 // from root_dir, they are either equal to root_dir_ or subdirectories of it. |
| 141 SourceDir root_dir_; | 134 SourceDir root_dir_; |
| 142 SourceDir resources_dir_; | 135 SourceDir resources_dir_; |
| 143 SourceDir executable_dir_; | 136 SourceDir executable_dir_; |
| 144 SourceDir plugins_dir_; | 137 SourceDir plugins_dir_; |
| 145 | 138 |
| 146 // This is the target type as known to Xcode. This is only used to generate | 139 // This is the target type as known to Xcode. This is only used to generate |
| 147 // the Xcode project file when using --ide=xcode. | 140 // the Xcode project file when using --ide=xcode. |
| 148 std::string product_type_; | 141 std::string product_type_; |
| 149 | 142 |
| 150 // Holds the values (script name, sources, outputs, script arguments) for the | 143 // Holds the values (script name, sources, outputs, script arguments) for the |
| 151 // code signing step if defined. | 144 // code signing step if defined. |
| 152 SourceFile code_signing_script_; | 145 SourceFile code_signing_script_; |
| 153 std::vector<SourceFile> code_signing_sources_; | 146 std::vector<SourceFile> code_signing_sources_; |
| 154 SubstitutionList code_signing_outputs_; | 147 SubstitutionList code_signing_outputs_; |
| 155 SubstitutionList code_signing_args_; | 148 SubstitutionList code_signing_args_; |
| 156 | 149 |
| 157 DISALLOW_COPY_AND_ASSIGN(BundleData); | 150 DISALLOW_COPY_AND_ASSIGN(BundleData); |
| 158 }; | 151 }; |
| 159 | 152 |
| 160 #endif // TOOLS_GN_BUNDLE_DATA_H_ | 153 #endif // TOOLS_GN_BUNDLE_DATA_H_ |
| OLD | NEW |