Skip to content

Commit

Permalink
Merge pull request #585 from sassanh/master
Browse files Browse the repository at this point in the history
added compiler_options field
  • Loading branch information
sassanh committed May 13, 2017
2 parents d6acb9c + bdb4acd commit 24cb754
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pipeline/compilers/__init__.py
Expand Up @@ -27,7 +27,7 @@ def __init__(self, storage=None, verbose=False):
def compilers(self):
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):
for compiler in self.compilers:
compiler = compiler(verbose=self.verbose, storage=self.storage)
Expand All @@ -39,7 +39,8 @@ def _compile(input_path):
outfile = compiler.output_path(infile, compiler.output_extension)
outdated = compiler.is_outdated(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)
else:
Expand Down
18 changes: 15 additions & 3 deletions pipeline/packager.py
Expand Up @@ -59,6 +59,10 @@ def variant(self):
def manifest(self):
return self.config.get('manifest', True)

@property
def compiler_options(self):
return self.config.get('compiler_options', {})


class Packager(object):
def __init__(self, storage=None, verbose=False, css_packages=None, js_packages=None):
Expand Down Expand Up @@ -95,14 +99,22 @@ def pack_stylesheets(self, package, **kwargs):
output_filename=package.output_filename,
variant=package.variant, **kwargs)

def compile(self, paths, force=False):
return self.compiler.compile(paths, force=force)
def compile(self, paths, compiler_options={}, force=False):
return self.compiler.compile(
paths,
compiler_options=compiler_options,
force=force,
)

def pack(self, package, compress, signal, **kwargs):
output_filename = package.output_filename
if self.verbose:
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)
self.save_file(output_filename, content)
signal.send(sender=self, package=package, **kwargs)
Expand Down

0 comments on commit 24cb754

Please sign in to comment.