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

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

Issue 1752033002: Add "create_bundle" target in order to support bundle with gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-bundle-data
Patch Set: Add unit tests, address comments, update docs and format with clang-format Created 4 years, 9 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_file_rule.h ('k') | tools/gn/command_desc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "tools/gn/bundle_file_rule.h"
6
7 #include "tools/gn/output_file.h"
8 #include "tools/gn/settings.h"
9 #include "tools/gn/substitution_pattern.h"
10 #include "tools/gn/substitution_writer.h"
11 #include "tools/gn/target.h"
12
13 BundleFileRule::BundleFileRule(const std::vector<SourceFile> sources,
14 const SubstitutionPattern& pattern)
15 : sources_(sources), pattern_(pattern) {}
16
17 BundleFileRule::~BundleFileRule() {}
18
19 SourceFile BundleFileRule::ApplyPatternToSource(
20 const Settings* settings,
21 const BundleData& bundle_data,
22 const SourceFile& source_file) const {
23 std::string output_path;
24 for (const auto& subrange : pattern_.ranges()) {
25 switch (subrange.type) {
26 case SUBSTITUTION_LITERAL:
27 output_path.append(subrange.literal);
28 break;
29 case SUBSTITUTION_BUNDLE_ROOT_DIR:
30 output_path.append(bundle_data.root_dir());
31 break;
32 case SUBSTITUTION_BUNDLE_RESOURCES_DIR:
33 output_path.append(bundle_data.resources_dir());
34 break;
35 case SUBSTITUTION_BUNDLE_EXECUTABLE_DIR:
36 output_path.append(bundle_data.executable_dir());
37 break;
38 case SUBSTITUTION_BUNDLE_PLUGINS_DIR:
39 output_path.append(bundle_data.plugins_dir());
40 break;
41 default:
42 output_path.append(SubstitutionWriter::GetSourceSubstitution(
43 settings, source_file, subrange.type,
44 SubstitutionWriter::OUTPUT_ABSOLUTE, SourceDir()));
45 break;
46 }
47 }
48 return SourceFile(SourceFile::SWAP_IN, &output_path);
49 }
50
51 OutputFile BundleFileRule::ApplyPatternToSourceAsOutputFile(
52 const Settings* settings,
53 const BundleData& bundle_data,
54 const SourceFile& source_file) const {
55 return OutputFile(settings->build_settings(),
56 ApplyPatternToSource(settings, bundle_data, source_file));
57 }
OLDNEW
« no previous file with comments | « tools/gn/bundle_file_rule.h ('k') | tools/gn/command_desc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698