| Index: packagerChrome.py |
| =================================================================== |
| --- a/packagerChrome.py |
| +++ b/packagerChrome.py |
| @@ -10,6 +10,7 @@ |
| from StringIO import StringIO |
| import struct |
| import sys |
| +from collections import OrderedDict |
| import packager |
| from packager import readMetadata, getMetadataPath, getDefaultFileName, getBuildVersion, getTemplate, Files |
| @@ -145,30 +146,26 @@ |
| def convertJS(params, files): |
| from jshydra.abp_rewrite import rewrite_js |
| + output_files = OrderedDict() |
| for item in params['metadata'].items('convert_js'): |
| - file, sources = item |
| - baseDir = os.path.dirname(item.source) |
| + filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', item[0]).groups() |
| + if arg is None: |
| + output_files[filename] = (item[1].split(), item.source, []) |
| + else: |
| + output_files[filename][2].append('{}={}'.format(arg, item[1])) |
|
Vasily Kuznetsov
2016/08/29 16:56:40
Perhaps we should issue a more user-friendly messa
Sebastian Noack
2016/08/30 12:40:31
Well, it's simpler to avoid that error than handli
Vasily Kuznetsov
2016/08/30 13:30:18
Indeed. Actually you can make the code even cleane
Sebastian Noack
2016/08/30 14:06:50
Yeah, that is even better. Done.
|
| - # Make sure the file is inside an included directory |
| - if '/' in file and not files.isIncluded(file): |
| + for filename, (input_files, origin, args) in output_files.iteritems(): |
| + if '/' in filename and not files.isIncluded(filename): |
| continue |
| - sourceFiles = sources.split() |
| - args = [] |
| - try: |
| - argsStart = sourceFiles.index('--arg') |
| - args = sourceFiles[argsStart + 1:] |
| - sourceFiles = sourceFiles[0:argsStart] |
| - except ValueError: |
| - pass |
| + base_dir = os.path.dirname(origin) |
| + jshydra_args = ['--arg', ' '.join(args)] |
| - # Source files of the conversion shouldn't be part of the build |
| - for sourceFile in sourceFiles: |
| - if sourceFile in files: |
| - del files[sourceFile] |
| + for input_filename in input_files: |
| + jshydra_args.append(os.path.join(base_dir, input_filename)) |
| + files.pop(input_filename, None) |
| - sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), sourceFiles) |
| - files[file] = rewrite_js(['--arg', ' '.join(args)] + sourceFiles) |
| + files[filename] = rewrite_js(jshydra_args) |
| def toJson(data): |