| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
| 4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 | 6 |
| 7 import sys | 7 import sys |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import json | 10 import json |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 # ... = icon.png popup.html | 86 # ... = icon.png popup.html |
| 87 icon, popup = icons | 87 icon, popup = icons |
| 88 else: | 88 else: |
| 89 # ... = icon-19.png icon-38.png popup.html | 89 # ... = icon-19.png icon-38.png popup.html |
| 90 popup = icons.pop() | 90 popup = icons.pop() |
| 91 icon = makeIcons(files, icons) | 91 icon = makeIcons(files, icons) |
| 92 | 92 |
| 93 templateData[opt] = {'icon': icon, 'popup': popup} | 93 templateData[opt] = {'icon': icon, 'popup': popup} |
| 94 | 94 |
| 95 if metadata.has_option('general', 'icons'): | 95 if metadata.has_option('general', 'icons'): |
| 96 templateData['icons'] = makeIcons(files, metadata.get('general', 'icons').sp
lit()) | 96 templateData['icons'] = makeIcons(files, |
| 97 metadata.get('general', 'icons').split()) |
| 97 | 98 |
| 98 if metadata.has_option('general', 'permissions'): | 99 if metadata.has_option('general', 'permissions'): |
| 99 templateData['permissions'] = re.split(r'\s+', metadata.get('general', 'perm
issions')) | 100 templateData['permissions'] = metadata.get('general', 'permissions').split() |
| 100 if params['experimentalAPI']: | 101 if params['experimentalAPI']: |
| 101 templateData['permissions'].append('experimental') | 102 templateData['permissions'].append('experimental') |
| 102 | 103 |
| 104 if metadata.has_option('general', 'optionalPermissions'): |
| 105 templateData['optionalPermissions'] = metadata.get( |
| 106 'general', 'optionalPermissions').split() |
| 107 |
| 103 if metadata.has_option('general', 'backgroundScripts'): | 108 if metadata.has_option('general', 'backgroundScripts'): |
| 104 templateData['backgroundScripts'] = re.split(r'\s+', metadata.get('general',
'backgroundScripts')) | 109 templateData['backgroundScripts'] = metadata.get( |
| 110 'general', 'backgroundScripts').split() |
| 105 if params['devenv']: | 111 if params['devenv']: |
| 106 templateData['backgroundScripts'].append('devenvPoller__.js') | 112 templateData['backgroundScripts'].append('devenvPoller__.js') |
| 107 | 113 |
| 108 if metadata.has_option('general', 'webAccessible') and metadata.get('general',
'webAccessible') != '': | 114 if metadata.has_option('general', 'webAccessible') and metadata.get('general',
'webAccessible') != '': |
| 109 templateData['webAccessible'] = re.split(r'\s+', metadata.get('general', 'we
bAccessible')) | 115 templateData['webAccessible'] = metadata.get('general', |
| 116 'webAccessible').split() |
| 110 | 117 |
| 111 if metadata.has_section('contentScripts'): | 118 if metadata.has_section('contentScripts'): |
| 112 contentScripts = [] | 119 contentScripts = [] |
| 113 for run_at, scripts in metadata.items('contentScripts'): | 120 for run_at, scripts in metadata.items('contentScripts'): |
| 114 if scripts == '': | 121 if scripts == '': |
| 115 continue | 122 continue |
| 116 contentScripts.append({ | 123 contentScripts.append({ |
| 117 'matches': ['http://*/*', 'https://*/*'], | 124 'matches': ['http://*/*', 'https://*/*'], |
| 118 'js': re.split(r'\s+', scripts), | 125 'js': scripts.split(), |
| 119 'run_at': run_at, | 126 'run_at': run_at, |
| 120 'all_frames': True, | 127 'all_frames': True, |
| 121 'match_about_blank': True, | 128 'match_about_blank': True, |
| 122 }) | 129 }) |
| 123 templateData['contentScripts'] = contentScripts | 130 templateData['contentScripts'] = contentScripts |
| 124 | 131 |
| 125 manifest = template.render(templateData) | 132 manifest = template.render(templateData) |
| 126 | 133 |
| 127 # Normalize JSON structure | 134 # Normalize JSON structure |
| 128 licenseComment = re.compile(r'/\*.*?\*/', re.S) | 135 licenseComment = re.compile(r'/\*.*?\*/', re.S) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 141 from jshydra.abp_rewrite import doRewrite | 148 from jshydra.abp_rewrite import doRewrite |
| 142 | 149 |
| 143 for item in params['metadata'].items('convert_js'): | 150 for item in params['metadata'].items('convert_js'): |
| 144 file, sources = item | 151 file, sources = item |
| 145 baseDir = os.path.dirname(item.source) | 152 baseDir = os.path.dirname(item.source) |
| 146 | 153 |
| 147 # Make sure the file is inside an included directory | 154 # Make sure the file is inside an included directory |
| 148 if '/' in file and not files.isIncluded(file): | 155 if '/' in file and not files.isIncluded(file): |
| 149 continue | 156 continue |
| 150 | 157 |
| 151 sourceFiles = re.split(r'\s+', sources) | 158 sourceFiles = sources.split() |
| 152 args = [] | 159 args = [] |
| 153 try: | 160 try: |
| 154 argsStart = sourceFiles.index('--arg') | 161 argsStart = sourceFiles.index('--arg') |
| 155 args = sourceFiles[argsStart + 1:] | 162 args = sourceFiles[argsStart + 1:] |
| 156 sourceFiles = sourceFiles[0:argsStart] | 163 sourceFiles = sourceFiles[0:argsStart] |
| 157 except ValueError: | 164 except ValueError: |
| 158 pass | 165 pass |
| 159 | 166 |
| 160 # Source files of the conversion shouldn't be part of the build | 167 # Source files of the conversion shouldn't be part of the build |
| 161 for sourceFile in sourceFiles: | 168 for sourceFile in sourceFiles: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 sourceData = localeTools.readFile(sourceFile) | 222 sourceData = localeTools.readFile(sourceFile) |
| 216 | 223 |
| 217 # Resolve wildcard imports | 224 # Resolve wildcard imports |
| 218 if keys == '*' or keys == '=*': | 225 if keys == '*' or keys == '=*': |
| 219 importList = sourceData.keys() | 226 importList = sourceData.keys() |
| 220 importList = filter(lambda k: not k.startswith('_'), importList) | 227 importList = filter(lambda k: not k.startswith('_'), importList) |
| 221 if keys == '=*': | 228 if keys == '=*': |
| 222 importList = map(lambda k: '=' + k, importList) | 229 importList = map(lambda k: '=' + k, importList) |
| 223 keys = ' '.join(importList) | 230 keys = ' '.join(importList) |
| 224 | 231 |
| 225 for stringID in re.split(r'\s+', keys): | 232 for stringID in keys.split(): |
| 226 noMangling = False | 233 noMangling = False |
| 227 if stringID.startswith('='): | 234 if stringID.startswith('='): |
| 228 stringID = stringID[1:] | 235 stringID = stringID[1:] |
| 229 noMangling = True | 236 noMangling = True |
| 230 | 237 |
| 231 if stringID in sourceData: | 238 if stringID in sourceData: |
| 232 if noMangling: | 239 if noMangling: |
| 233 key = re.sub(r'\W', '_', stringID) | 240 key = re.sub(r'\W', '_', stringID) |
| 234 else: | 241 else: |
| 235 key = re.sub(r'\..*', '', parts[-1]) + '_' + re.sub(r'\W', '_', st
ringID) | 242 key = re.sub(r'\..*', '', parts[-1]) + '_' + re.sub(r'\W', '_', st
ringID) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 if type == 'chrome': | 360 if type == 'chrome': |
| 354 fixTranslationsForCWS(files) | 361 fixTranslationsForCWS(files) |
| 355 | 362 |
| 356 if devenv: | 363 if devenv: |
| 357 import buildtools | 364 import buildtools |
| 358 import random | 365 import random |
| 359 files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'),
relpath='devenvPoller__.js') | 366 files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'),
relpath='devenvPoller__.js') |
| 360 files['devenvVersion__'] = str(random.random()) | 367 files['devenvVersion__'] = str(random.random()) |
| 361 | 368 |
| 362 if (metadata.has_option('general', 'backgroundScripts') and | 369 if (metadata.has_option('general', 'backgroundScripts') and |
| 363 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip
ts')) and | 370 'lib/info.js' in metadata.get('general', 'backgroundScripts').split() and |
| 364 'lib/info.js' not in files): | 371 'lib/info.js' not in files): |
| 365 files['lib/info.js'] = createInfoModule(params) | 372 files['lib/info.js'] = createInfoModule(params) |
| 366 | 373 |
| 367 if metadata.has_option('general', 'testScripts'): | 374 if metadata.has_option('general', 'testScripts'): |
| 368 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl', | 375 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl', |
| 369 ('general', 'testScripts')) | 376 ('general', 'testScripts')) |
| 370 | 377 |
| 371 zipdata = files.zipToString() | 378 zipdata = files.zipToString() |
| 372 signature = None | 379 signature = None |
| 373 pubkey = None | 380 pubkey = None |
| 374 if keyFile != None: | 381 if keyFile != None: |
| 375 signature = signBinary(zipdata, keyFile) | 382 signature = signBinary(zipdata, keyFile) |
| 376 pubkey = getPublicKey(keyFile) | 383 pubkey = getPublicKey(keyFile) |
| 377 writePackage(outFile, pubkey, signature, zipdata) | 384 writePackage(outFile, pubkey, signature, zipdata) |
| OLD | NEW |