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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/bundle_file_rule.cc
diff --git a/tools/gn/bundle_file_rule.cc b/tools/gn/bundle_file_rule.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0f42c8f197e955c5cd2a46485332fc92e6a0ea6f
--- /dev/null
+++ b/tools/gn/bundle_file_rule.cc
@@ -0,0 +1,57 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tools/gn/bundle_file_rule.h"
+
+#include "tools/gn/output_file.h"
+#include "tools/gn/settings.h"
+#include "tools/gn/substitution_pattern.h"
+#include "tools/gn/substitution_writer.h"
+#include "tools/gn/target.h"
+
+BundleFileRule::BundleFileRule(const std::vector<SourceFile> sources,
+ const SubstitutionPattern& pattern)
+ : sources_(sources), pattern_(pattern) {}
+
+BundleFileRule::~BundleFileRule() {}
+
+SourceFile BundleFileRule::ApplyPatternToSource(
+ const Settings* settings,
+ const BundleData& bundle_data,
+ const SourceFile& source_file) const {
+ std::string output_path;
+ for (const auto& subrange : pattern_.ranges()) {
+ switch (subrange.type) {
+ case SUBSTITUTION_LITERAL:
+ output_path.append(subrange.literal);
+ break;
+ case SUBSTITUTION_BUNDLE_ROOT_DIR:
+ output_path.append(bundle_data.root_dir());
+ break;
+ case SUBSTITUTION_BUNDLE_RESOURCES_DIR:
+ output_path.append(bundle_data.resources_dir());
+ break;
+ case SUBSTITUTION_BUNDLE_EXECUTABLE_DIR:
+ output_path.append(bundle_data.executable_dir());
+ break;
+ case SUBSTITUTION_BUNDLE_PLUGINS_DIR:
+ output_path.append(bundle_data.plugins_dir());
+ break;
+ default:
+ output_path.append(SubstitutionWriter::GetSourceSubstitution(
+ settings, source_file, subrange.type,
+ SubstitutionWriter::OUTPUT_ABSOLUTE, SourceDir()));
+ break;
+ }
+ }
+ return SourceFile(SourceFile::SWAP_IN, &output_path);
+}
+
+OutputFile BundleFileRule::ApplyPatternToSourceAsOutputFile(
+ const Settings* settings,
+ const BundleData& bundle_data,
+ const SourceFile& source_file) const {
+ return OutputFile(settings->build_settings(),
+ ApplyPatternToSource(settings, bundle_data, source_file));
+}
« 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