Chromium Code Reviews| 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 #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/filesystem_utils.h" | |
| 8 #include "tools/gn/output_file.h" | 9 #include "tools/gn/output_file.h" |
| 9 #include "tools/gn/settings.h" | 10 #include "tools/gn/settings.h" |
| 10 #include "tools/gn/target.h" | 11 #include "tools/gn/target.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 // Return directory of |path| without the trailing directory separator. | 15 // Return directory of |path| without the trailing directory separator. |
| 15 base::StringPiece FindDirNoTrailingSeparator(const base::StringPiece& path) { | 16 base::StringPiece FindDirNoTrailingSeparator(const base::StringPiece& path) { |
| 16 base::StringPiece::size_type pos = path.find_last_of("/\\"); | 17 base::StringPiece::size_type pos = path.find_last_of("/\\"); |
| 17 if (pos == base::StringPiece::npos) | 18 if (pos == base::StringPiece::npos) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 SourceFiles* outputs_as_source) const { | 97 SourceFiles* outputs_as_source) const { |
| 97 for (const BundleFileRule& file_rule : file_rules_) { | 98 for (const BundleFileRule& file_rule : file_rules_) { |
| 98 for (const SourceFile& source : file_rule.sources()) { | 99 for (const SourceFile& source : file_rule.sources()) { |
| 99 outputs_as_source->push_back( | 100 outputs_as_source->push_back( |
| 100 file_rule.ApplyPatternToSource(settings, *this, source)); | 101 file_rule.ApplyPatternToSource(settings, *this, source)); |
| 101 } | 102 } |
| 102 } | 103 } |
| 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()); |
| 107 | |
| 108 if (!root_dir_.empty()) | |
| 109 outputs_as_source->push_back(GetBundleRootDirOutput(settings)); | |
| 106 } | 110 } |
| 107 | 111 |
| 108 SourceFile BundleData::GetCompiledAssetCatalogPath() const { | 112 SourceFile BundleData::GetCompiledAssetCatalogPath() const { |
| 109 DCHECK(!asset_catalog_sources_.empty()); | 113 DCHECK(!asset_catalog_sources_.empty()); |
| 110 std::string assets_car_path = resources_dir_ + "/Assets.car"; | 114 std::string assets_car_path = resources_dir_ + "/Assets.car"; |
| 111 return SourceFile(SourceFile::SWAP_IN, &assets_car_path); | 115 return SourceFile(SourceFile::SWAP_IN, &assets_car_path); |
| 112 } | 116 } |
| 117 | |
| 118 SourceFile BundleData::GetBundleRootDirOutput(const Settings* settings) const { | |
| 119 const SourceDir& root_out_dir = settings->build_settings()->build_dir(); | |
|
brettw
2016/04/18 20:16:14
This variable should be called build_dir or root_b
Robert Sesek
2016/04/19 15:37:51
Done.
| |
| 120 base::StringPiece bundle_root_relative = | |
| 121 base::StringPiece(root_dir()).substr(root_out_dir.value().length()); | |
|
brettw
2016/04/18 20:16:14
I'm confused by this code. The root_dir() returns
Robert Sesek
2016/04/19 15:37:51
The CreateBundleTargetGenerator extracts these fro
brettw
2016/04/21 19:14:00
Yes, I think these should be changed (unless there
Robert Sesek
2016/04/21 21:03:20
I'll do this in a follow-up CL.
| |
| 122 | |
| 123 size_t first_component = bundle_root_relative.find('/'); | |
| 124 if (first_component != std::string::npos) { | |
| 125 base::StringPiece outermost_bundle_dir = | |
| 126 bundle_root_relative.substr(0, first_component); | |
| 127 std::string return_value(root_out_dir.value()); | |
| 128 outermost_bundle_dir.AppendToString(&return_value); | |
| 129 return SourceFile(SourceFile::SWAP_IN, &return_value); | |
| 130 } | |
| 131 return SourceFile(root_dir()); | |
| 132 } | |
| OLD | NEW |