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

Unified Diff: mojo/public/tools/manifest/manifest_collator.py

Issue 1828733004: Load application manifests from resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/mojo_application_manifest.gypi ('k') | mojo/services/catalog/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/manifest/manifest_collator.py
diff --git a/mojo/public/tools/manifest/manifest_collator.py b/mojo/public/tools/manifest/manifest_collator.py
index e05763bb3ea20d0809096c4a536e4637afd1e5ef..fa95e37f21aa7d1c31c054a3925eca7f20bc5cbf 100755
--- a/mojo/public/tools/manifest/manifest_collator.py
+++ b/mojo/public/tools/manifest/manifest_collator.py
@@ -11,6 +11,7 @@ import shutil
import sys
import urlparse
+
def ParseJSONFile(filename):
with open(filename) as json_file:
try:
@@ -19,18 +20,46 @@ def ParseJSONFile(filename):
print "%s is not a valid JSON document" % filename
return None
+
+def MergeDicts(left, right):
+ for k, v in right.iteritems():
+ if k not in left:
+ left[k] = v
+ else:
+ if isinstance(v, dict):
+ assert isinstance(left[k], dict)
+ MergeDicts(left[k], v)
+ elif isinstance(v, list):
+ assert isinstance(left[k], list)
+ left[k].extend(v)
+ else:
+ raise "Refusing to merge conflicting non-collection values."
+ return left
+
+
+def MergeBaseManifest(parent, base):
+ MergeDicts(parent["capabilities"], base["capabilities"])
+
+
def main():
parser = argparse.ArgumentParser(
description="Collate Mojo application manifests.")
parser.add_argument("--parent")
parser.add_argument("--output")
parser.add_argument("--application-name")
+ parser.add_argument("--base-manifest", default=None)
args, children = parser.parse_known_args()
parent = ParseJSONFile(args.parent)
if parent == None:
return 1
+ if args.base_manifest:
+ base = ParseJSONFile(args.base_manifest)
+ if base == None:
+ return 1
+ MergeBaseManifest(parent, base)
+
app_path = parent['name'].split(':')[1]
if app_path.startswith('//'):
raise ValueError("Application name path component '%s' must not start " \
« no previous file with comments | « mojo/public/mojo_application_manifest.gypi ('k') | mojo/services/catalog/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698