Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: packagerEdge.py

Issue 29825555: Issue 6291 - add ManifoldJS packaging for Edge (Closed) Base URL: https://hg.adblockplus.org/buildtools/file/9a56d76cd951
Left Patch Set: Created Aug. 8, 2018, 9:35 a.m.
Right Patch Set: Final patch set Created Aug. 9, 2018, 7:08 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « package.json ('k') | templates/edge/AppxBlockMap.xml.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 import os 5 import os
6 import shutil 6 import shutil
7 from StringIO import StringIO 7 from StringIO import StringIO
8 import subprocess 8 import subprocess
9 import tempfile 9 import tempfile
10 from xml.etree import ElementTree 10 from xml.etree import ElementTree
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 for name, path in metadata.items('appx_assets'): 48 for name, path in metadata.items('appx_assets'):
49 path = os.path.join(base_dir, path) 49 path = os.path.join(base_dir, path)
50 icon_path = '{}/{}'.format(ASSETS_DIR, name) 50 icon_path = '{}/{}'.format(ASSETS_DIR, name)
51 51
52 files.read(path, icon_path) 52 files.read(path, icon_path)
53 filenames.append(icon_path) 53 filenames.append(icon_path)
54 54
55 assets = packagerChrome.makeIcons(files, filenames) 55 assets = packagerChrome.makeIcons(files, filenames)
56 56
57 overwrite = ( 57 author = metadata.get('general', 'author')
58 ('_d:Identity', [ 58
59 overrides = [
60 ('_d:Identity', None, [
59 ('Name', packager.get_app_id(release_build, metadata)), 61 ('Name', packager.get_app_id(release_build, metadata)),
60 ('Publisher', metadata.get('general', 'publisher_id')), 62 ('Publisher', metadata.get('general', 'publisher_id')),
61 ]), 63 ]),
62 ('_d:Properties/_d:PublisherDisplayName', metadata.get('general', 64 ('_d:Properties/_d:PublisherDisplayName', author, []),
63 'author')), 65 ('_d:Properties/_d:Logo', assets[50], []),
64 ('_d:Properties/_d:Logo', assets[50]), 66 ('_d:Dependencies/_d:TargetDeviceFamily', None, [
65 ('_d:Dependencies/_d:TargetDeviceFamily', [
66 ('MaxVersionTested', v_max), 67 ('MaxVersionTested', v_max),
67 ('MinVersion', v_min), 68 ('MinVersion', v_min),
68 ]), 69 ]),
69 ('_d:Applications/_d:Application/uap:VisualElements', [ 70 ('_d:Applications/_d:Application/uap:VisualElements', None, [
70 ('Square150x150Logo', assets[150]), 71 ('Square150x150Logo', assets[150]),
71 ('Square44x44Logo', assets[44]), 72 ('Square44x44Logo', assets[44]),
72 ]), 73 ]),
73 ) 74 ]
Sebastian Noack 2018/08/08 19:19:04 I didn't notice before that sometimes you update t
tlucas 2018/08/08 22:10:07 Done.
74 75
75 tree = ElementTree.parse(manifest_path) 76 tree = ElementTree.parse(manifest_path)
76 root = tree.getroot() 77 root = tree.getroot()
77 78
78 for xpath, attributes in overwrite: 79 for xpath, text, attributes in overrides:
79 element = root.find(xpath, namespaces) 80 element = root.find(xpath, namespaces)
80 if isinstance(attributes, list): 81 if text:
81 for attr, value in attributes: 82 element.text = text
83 for attr, value in attributes:
82 element.set(attr, value) 84 element.set(attr, value)
83 else:
84 element.text = attributes
85 85
86 tree.write(manifest_path, encoding='utf-8', xml_declaration=True) 86 tree.write(manifest_path, encoding='utf-8', xml_declaration=True)
87 87
88 88
89 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API. 89 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API.
90 buildNum=None, releaseBuild=False, keyFile=None, 90 buildNum=None, releaseBuild=False, keyFile=None,
91 devenv=False): 91 devenv=False):
92 92
93 metadata = packager.readMetadata(baseDir, type) 93 metadata = packager.readMetadata(baseDir, type)
94 version = packager.getBuildVersion(baseDir, metadata, releaseBuild, 94 version = packager.getBuildVersion(baseDir, metadata, releaseBuild,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 cmd = ['npm', 'run', '--silent', 'package-edge'] 177 cmd = ['npm', 'run', '--silent', 'package-edge']
178 178
179 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__)) 179 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__))
180 180
181 package = os.path.join(manifold_folder, 'package', 181 package = os.path.join(manifold_folder, 'package',
182 'edgeExtension.appx') 182 'edgeExtension.appx')
183 183
184 shutil.copyfile(package, outfile) 184 shutil.copyfile(package, outfile)
185 finally: 185 finally:
186 shutil.rmtree(tmp_dir, ignore_errors=True) 186 shutil.rmtree(tmp_dir, ignore_errors=True)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld