Commit 24cb7544 by Sassan Haradji Committed by GitHub

Merge pull request #585 from sassanh/master

added compiler_options field
parents d6acb9c4 bdb4acde
...@@ -27,7 +27,7 @@ class Compiler(object): ...@@ -27,7 +27,7 @@ class Compiler(object):
def compilers(self): def compilers(self):
return [to_class(compiler) for compiler in settings.COMPILERS] return [to_class(compiler) for compiler in settings.COMPILERS]
def compile(self, paths, force=False): def compile(self, paths, compiler_options={}, force=False):
def _compile(input_path): def _compile(input_path):
for compiler in self.compilers: for compiler in self.compilers:
compiler = compiler(verbose=self.verbose, storage=self.storage) compiler = compiler(verbose=self.verbose, storage=self.storage)
...@@ -39,7 +39,8 @@ class Compiler(object): ...@@ -39,7 +39,8 @@ class Compiler(object):
outfile = compiler.output_path(infile, compiler.output_extension) outfile = compiler.output_path(infile, compiler.output_extension)
outdated = compiler.is_outdated(infile, outfile) outdated = compiler.is_outdated(infile, outfile)
compiler.compile_file(infile, outfile, compiler.compile_file(infile, outfile,
outdated=outdated, force=force) outdated=outdated, force=force,
**compiler_options)
return compiler.output_path(input_path, compiler.output_extension) return compiler.output_path(input_path, compiler.output_extension)
else: else:
......
...@@ -59,6 +59,10 @@ class Package(object): ...@@ -59,6 +59,10 @@ class Package(object):
def manifest(self): def manifest(self):
return self.config.get('manifest', True) return self.config.get('manifest', True)
@property
def compiler_options(self):
return self.config.get('compiler_options', {})
class Packager(object): class Packager(object):
def __init__(self, storage=None, verbose=False, css_packages=None, js_packages=None): def __init__(self, storage=None, verbose=False, css_packages=None, js_packages=None):
...@@ -95,14 +99,22 @@ class Packager(object): ...@@ -95,14 +99,22 @@ class Packager(object):
output_filename=package.output_filename, output_filename=package.output_filename,
variant=package.variant, **kwargs) variant=package.variant, **kwargs)
def compile(self, paths, force=False): def compile(self, paths, compiler_options={}, force=False):
return self.compiler.compile(paths, force=force) return self.compiler.compile(
paths,
compiler_options=compiler_options,
force=force,
)
def pack(self, package, compress, signal, **kwargs): def pack(self, package, compress, signal, **kwargs):
output_filename = package.output_filename output_filename = package.output_filename
if self.verbose: if self.verbose:
print("Saving: %s" % output_filename) print("Saving: %s" % output_filename)
paths = self.compile(package.paths, force=True) paths = self.compile(
package.paths,
compiler_options=package.compiler_options,
force=True,
)
content = compress(paths, **kwargs) content = compress(paths, **kwargs)
self.save_file(output_filename, content) self.save_file(output_filename, content)
signal.send(sender=self, package=package, **kwargs) signal.send(sender=self, package=package, **kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment