2 Copyright 2017 Dmitry Arkhipov
3 Distributed under the Boost Software License, Version 1.0. (See
4 accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
14 import "class" : new ;
20 This tool converts SASS and SCSS files into CSS. This tool explicitly supports
21 both the version written in C (sassc) and the original Ruby implementation
22 (scss) but other variants might also work. In addition to tool-specific
23 features, described in this section, the tool recognizes features `<flags>`
28 feature.feature sass : : implicit propagated symmetric ;
32 == Feature: `sass-style`
34 Sets the output style. Available values are
36 * `nested`: each property is put on its own line, rules are indented based on
37 how deeply they are nested;
38 * `expanded`: each property is put on its own line, rules are not indented;
39 * `compact`: each rule is put on a single line, nested rules occupy adjacent
40 lines, while groups of unrelated rules are separated by newlines;
41 * `compressed`: takes minimum amount of space: all unnecessary whitespace is
42 removed, property values are compressed to have minimal representation.
44 The feature is `optional` and is not `propagated` to dependent targets. If no
45 style is specified, then, if property set contains property `<optimization>on`,
46 `compressed` style is selected. Otherwise, `nested` style is selected.
50 feature.subfeature sass
52 : nested expanded compact compressed
58 == Feature: `sass-line-numbers`
60 Enables emitting comments showing original line numbers for rules. This can be
61 useful for debugging a stylesheet. Available values are `on` and `off`. The
62 feature is `optional` and is not `propagated` to dependent targets. If no value
63 for this feature is specified, then one is copied from the feature
68 feature.subfeature sass : line-numbers : on off : optional ;
74 To use the `sass` tool you need to declare it in a configuration file with the
75 `using` rule. The initialization takes the following arguments:
77 * `command`: the command, with any extra arguments, to execute.
79 For example you could insert the following in your `user-config.jam`:
82 using sass : /usr/local/bin/psass -p2 ; # Perl libsass-based version
85 If no `command` is given, `sassc` is tried, after which `scss` is tried.
89 rule init ( command * )
93 # Setup only if we were called via "using .. ;"
97 generators.register [ new sass-generator sass.convert : SASS : CSS ] ;
103 # If none was specified by the user, first try sassc, then scss
104 SASS = [ common.find-tool sassc ] ;
105 SASS ?= [ common.find-tool scss ] ;
109 # Otherwise we attempt to resolve each component of the command to
110 # account for script interpreter wrappers.
111 SASS = [ sequence.transform maybe-find-tool : $(command) ] ;
115 class sass-generator : generator
117 import property-set ;
119 rule run ( project name ? : property-set : sources + )
121 local style = [ $(property-set).get <sass-style> ] ;
122 local line-numbers = [ $(property-set).get <sass-line-numbers> ] ;
124 # Only one source file is sensible; we accept only sass and scss files
125 if ( ! $(sources[2]) ) && ( [ $(sources[1]).type ] in SASS )
127 # If no output name was given, guess it from sources
130 name = [ generator.determine-output-name $(sources) ] ;
133 # If output style was not given, then it is determined by
134 # <optimization> feature
137 switch [ $(property-set).get <optimization> ]
139 case "off" : style = nested ;
140 case * : style = compressed ;
144 # If line-numbers feature wasn't specified, copy it from
146 line-numbers ?= [ $(property-set).get <debug-symbols> ] ;
149 # We build a reduced property set so that we are not toolset dependent.
151 = <sass-style>$(style)
152 <sass-line-numbers>$(line-numbers)
155 [ sequence.filter recognized-feature : [ $(property-set).raw ] ] ;
156 raw-set = [ feature.expand-composites $(raw-set) ] ;
157 raw-set += [ $(property-set).incidental ] ;
158 property-set = [ property-set.create $(raw-set) ] ;
160 [ generator.run $(project) $(name)
166 local rule recognized-feature ( feature )
169 if $(feature:G) in <include> <flags>
178 toolset.flags sass STYLE : <sass-style> ;
179 toolset.flags sass LINE_NUMBERS <sass-line-numbers>on : --line-numbers ;
180 toolset.flags sass INCLUDES : <include> ;
181 toolset.flags sass FLAGS : <flags> ;
185 "$(SASS)" -t$(_)"$(STYLE)" $(LINE_NUMBERS) -I$(_)"$(INCLUDES)" $(FLAGS) "$(>)" $(_)"$(<)"
188 local rule maybe-find-tool ( command )
190 local tool = [ common.find-tool $(command) ] ;