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

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

Issue 1842563006: DO NOT SUBMIT. Experimental Mac GN Framework support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Binary bundle data Created 4 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
« no previous file with comments | « tools/gn/bundle_data.h ('k') | tools/gn/bundle_data_target_generator.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 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 #include "tools/gn/bundle_data.h" 5 #include "tools/gn/bundle_data.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "tools/gn/output_file.h" 8 #include "tools/gn/output_file.h"
9 #include "tools/gn/settings.h" 9 #include "tools/gn/settings.h"
10 #include "tools/gn/target.h" 10 #include "tools/gn/target.h"
(...skipping 21 matching lines...) Expand all
32 dir = FindDirNoTrailingSeparator(dir); 32 dir = FindDirNoTrailingSeparator(dir);
33 if (!dir.ends_with(".xcassets")) 33 if (!dir.ends_with(".xcassets"))
34 return false; 34 return false;
35 if (asset_catalog) { 35 if (asset_catalog) {
36 std::string asset_catalog_path = dir.as_string(); 36 std::string asset_catalog_path = dir.as_string();
37 *asset_catalog = SourceFile(SourceFile::SWAP_IN, &asset_catalog_path); 37 *asset_catalog = SourceFile(SourceFile::SWAP_IN, &asset_catalog_path);
38 } 38 }
39 return true; 39 return true;
40 } 40 }
41 41
42 BundleData::BundleData() {} 42 BundleData::BundleData() : binary_compress_(false) {}
43 43
44 BundleData::~BundleData() {} 44 BundleData::~BundleData() {}
45 45
46 void BundleData::AddBundleData(const Target* target) { 46 void BundleData::AddBundleData(const Target* target) {
47 DCHECK_EQ(target->output_type(), Target::BUNDLE_DATA); 47 DCHECK_EQ(target->output_type(), Target::BUNDLE_DATA);
48 bundle_deps_.push_back(target); 48 bundle_deps_.push_back(target);
49 } 49 }
50 50
51 void BundleData::OnTargetResolved(Target* owning_target) { 51 void BundleData::OnTargetResolved(Target* owning_target) {
52 // Only initialize file_rules_ and asset_catalog_sources for "create_bundle" 52 // Only initialize file_rules_ and asset_catalog_sources for "create_bundle"
53 // target (properties are only used by those targets). 53 // target (properties are only used by those targets).
54 if (owning_target->output_type() != Target::CREATE_BUNDLE) 54 if (owning_target->output_type() != Target::CREATE_BUNDLE)
55 return; 55 return;
56 56
57 for (const Target* target : bundle_deps_) { 57 for (const Target* target : bundle_deps_) {
58 SourceFiles file_rule_sources; 58 SourceFiles file_rule_sources;
59 for (const SourceFile& source_file : target->sources()) { 59 for (const SourceFile& source_file : target->sources()) {
60 if (IsSourceFileFromAssetCatalog(source_file, nullptr)) { 60 if (IsSourceFileFromAssetCatalog(source_file, nullptr)) {
61 asset_catalog_sources_.push_back(source_file); 61 asset_catalog_sources_.push_back(source_file);
62 } else { 62 } else {
63 file_rule_sources.push_back(source_file); 63 file_rule_sources.push_back(source_file);
64 } 64 }
65 } 65 }
66 66
67 if (!file_rule_sources.empty()) { 67 if (!file_rule_sources.empty()) {
68 DCHECK_EQ(target->action_values().outputs().list().size(), 1u); 68 DCHECK_EQ(target->action_values().outputs().list().size(), 1u);
69 file_rules_.push_back(BundleFileRule( 69 file_rules_.push_back(BundleFileRule(
70 file_rule_sources, target->action_values().outputs().list()[0])); 70 file_rule_sources, target->action_values().outputs().list()[0],
71 target->bundle_data().binary_compress()));
71 } 72 }
72 } 73 }
73 74
74 GetSourceFiles(&owning_target->sources()); 75 GetSourceFiles(&owning_target->sources());
75 } 76 }
76 77
77 void BundleData::GetSourceFiles(SourceFiles* sources) const { 78 void BundleData::GetSourceFiles(SourceFiles* sources) const {
78 for (const BundleFileRule& file_rule : file_rules_) { 79 for (const BundleFileRule& file_rule : file_rules_) {
79 sources->insert(sources->end(), file_rule.sources().begin(), 80 sources->insert(sources->end(), file_rule.sources().begin(),
80 file_rule.sources().end()); 81 file_rule.sources().end());
(...skipping 22 matching lines...) Expand all
103 104
104 if (!asset_catalog_sources_.empty()) 105 if (!asset_catalog_sources_.empty())
105 outputs_as_source->push_back(GetCompiledAssetCatalogPath()); 106 outputs_as_source->push_back(GetCompiledAssetCatalogPath());
106 } 107 }
107 108
108 SourceFile BundleData::GetCompiledAssetCatalogPath() const { 109 SourceFile BundleData::GetCompiledAssetCatalogPath() const {
109 DCHECK(!asset_catalog_sources_.empty()); 110 DCHECK(!asset_catalog_sources_.empty());
110 std::string assets_car_path = resources_dir_ + "/Assets.car"; 111 std::string assets_car_path = resources_dir_ + "/Assets.car";
111 return SourceFile(SourceFile::SWAP_IN, &assets_car_path); 112 return SourceFile(SourceFile::SWAP_IN, &assets_car_path);
112 } 113 }
OLDNEW
« no previous file with comments | « tools/gn/bundle_data.h ('k') | tools/gn/bundle_data_target_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698