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_file_rule.h" | 5 #include "tools/gn/bundle_file_rule.h" |
6 | 6 |
7 #include "tools/gn/output_file.h" | 7 #include "tools/gn/output_file.h" |
8 #include "tools/gn/settings.h" | 8 #include "tools/gn/settings.h" |
9 #include "tools/gn/substitution_pattern.h" | 9 #include "tools/gn/substitution_pattern.h" |
10 #include "tools/gn/substitution_writer.h" | 10 #include "tools/gn/substitution_writer.h" |
11 #include "tools/gn/target.h" | 11 #include "tools/gn/target.h" |
12 | 12 |
13 BundleFileRule::BundleFileRule(const std::vector<SourceFile> sources, | 13 BundleFileRule::BundleFileRule(const Target* bundle_data_target, |
| 14 const std::vector<SourceFile> sources, |
14 const SubstitutionPattern& pattern) | 15 const SubstitutionPattern& pattern) |
15 : sources_(sources), pattern_(pattern) {} | 16 : target_(bundle_data_target), sources_(sources), pattern_(pattern) { |
| 17 // target_ may be null during testing. |
| 18 DCHECK(!target_ || target_->output_type() == Target::BUNDLE_DATA); |
| 19 } |
16 | 20 |
17 BundleFileRule::BundleFileRule(const BundleFileRule& other) = default; | 21 BundleFileRule::BundleFileRule(const BundleFileRule& other) = default; |
18 | 22 |
19 BundleFileRule::~BundleFileRule() {} | 23 BundleFileRule::~BundleFileRule() {} |
20 | 24 |
21 SourceFile BundleFileRule::ApplyPatternToSource( | 25 SourceFile BundleFileRule::ApplyPatternToSource( |
22 const Settings* settings, | 26 const Settings* settings, |
23 const BundleData& bundle_data, | 27 const BundleData& bundle_data, |
24 const SourceFile& source_file) const { | 28 const SourceFile& source_file) const { |
25 std::string output_path; | 29 std::string output_path; |
(...skipping 24 matching lines...) Expand all Loading... |
50 return SourceFile(SourceFile::SWAP_IN, &output_path); | 54 return SourceFile(SourceFile::SWAP_IN, &output_path); |
51 } | 55 } |
52 | 56 |
53 OutputFile BundleFileRule::ApplyPatternToSourceAsOutputFile( | 57 OutputFile BundleFileRule::ApplyPatternToSourceAsOutputFile( |
54 const Settings* settings, | 58 const Settings* settings, |
55 const BundleData& bundle_data, | 59 const BundleData& bundle_data, |
56 const SourceFile& source_file) const { | 60 const SourceFile& source_file) const { |
57 return OutputFile(settings->build_settings(), | 61 return OutputFile(settings->build_settings(), |
58 ApplyPatternToSource(settings, bundle_data, source_file)); | 62 ApplyPatternToSource(settings, bundle_data, source_file)); |
59 } | 63 } |
OLD | NEW |