Skip to content

Commit 6088074

Browse files
committed
Merge pull request #8 from sass/develop
Preparation for libsass 3.2.0 release
2 parents e8a2367 + 589d490 commit 6088074

25 files changed

+512
-212
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ lib/**/*.c
2121
lib/**/*.xs
2222
lib/**/*.pod
2323
lib/**/*/*.pod
24+
lib/CSS/Sass.base
25+
lib/CSS/Sass.def
26+
lib/CSS/Sass.exp
27+
lib/CSS/Sass.lds
2428
.libsass.version
2529
*~

Build.PL

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ if (-d ".git") {
1818
system "git submodule update";
1919
open $manifest, ">", "MANIFEST" or die "MANIFEST: $!";
2020
print $manifest "MANIFEST\n";
21-
print $manifest ".libsass.version\n";
2221
while (my $module = shift @modules)
2322
{
2423
my $cwd = getcwd;
@@ -36,17 +35,17 @@ if (-d ".git") {
3635
}
3736
}
3837

39-
if (-e "libsass/.git") {
38+
if (-e "libsass/.git" && ! -f "libsass/VERSION") {
4039
chdir "libsass";
4140
my $libsass_version = `git describe --abbrev=4 --dirty --always --tags`;
4241
chdir "..";
4342
require File::Slurp;
4443
chomp $libsass_version;
45-
File::Slurp::write_file(".libsass.version", { 'binmode' => ':raw' }, $libsass_version);
44+
File::Slurp::write_file("libsass/VERSION", { 'binmode' => ':raw' }, $libsass_version);
4645
}
47-
if (-f ".libsass.version") {
46+
if (-f "libsass/VERSION") {
4847
require File::Slurp;
49-
$libsass_version = File::Slurp::read_file(".libsass.version", { 'binmode' => ':raw' });
48+
$libsass_version = File::Slurp::read_file("libsass/VERSION", { 'binmode' => ':raw' });
5049
print "using libsass version $libsass_version\n";
5150
}
5251

@@ -161,7 +160,8 @@ SUBCLASS
161160
my $cover = $ARGV[0] && $ARGV[0] eq "cover=1" ? 1 : 0;
162161

163162
# create compile flags to include the libsass version (escape correctly)
164-
my $version = qq( -DLIBSASS_VERSION=\\"\\\\\\"$libsass_version\\\\\\"\\");
163+
my $version = ($^O ne "MSWin32") ? qq( -DLIBSASS_VERSION=\\"$libsass_version\\") :
164+
qq( -DLIBSASS_VERSION=\\"\\\\\\"$libsass_version\\\\\\"\\");
165165

166166
my %config = (
167167
module_name => 'CSS::Sass',
@@ -202,11 +202,11 @@ my %config = (
202202
extra_linker_flags => ($cover ? '-lgcov -fprofile-arcs -ftest-coverage' : ''),
203203
c_source => { 'libsass' => [ sort qw(
204204
ast.cpp sass2scss.cpp node.cpp sass_util.cpp remove_placeholders.cpp json.cpp
205-
base64vlq.cpp bind.cpp constants.cpp context.cpp contextualize.cpp copy_c_str.cpp
205+
base64vlq.cpp bind.cpp constants.cpp context.cpp contextualize.cpp plugins.cpp
206206
error_handling.cpp eval.cpp expand.cpp cencode.c functions.cpp inspect.cpp
207-
extend.cpp file.cpp output_compressed.cpp output_nested.cpp parser.cpp prelexer.cpp
207+
extend.cpp file.cpp output.cpp parser.cpp prelexer.cpp emitter.cpp position.cpp
208208
sass.cpp sass_interface.cpp sass_functions.cpp sass_values.cpp sass_context.cpp
209-
source_map.cpp to_c.cpp to_string.cpp units.cpp utf8_string.cpp util.cpp cssize.cpp position.cpp
209+
source_map.cpp to_c.cpp to_string.cpp units.cpp utf8_string.cpp util.cpp cssize.cpp
210210
) ]
211211
},
212212
config => { ld => 'c++' }, # Need to link with a C++ linker since libsass is C++ (even though the .xs file is not)

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,21 @@ psass [options] [ source | - ]
5959
-v, --version print version
6060
-h, --help print this help
6161
-p, --precision precision for float output
62+
-o, --output-file=file output file to write result to
6263
-t, --output-style=style output style [nested|compressed]
64+
-L, --plugin-path=path plugin load path (repeatable)
6365
-I, --include-path=path sass include path (repeatable)
6466
-c, --source-comments enable source debug comments
65-
-m, --source-map-file=file create and write source map to file
67+
-e, --source-map-embed embed source-map in mapping url
68+
-s, --source-map-contents include original contents
69+
-m, --source-map-file=file create and write source-map to file
6670
--no-source-map-url omit sourceMappingUrl from output
6771
```
6872

6973
Copyright And Licence
7074
---------------------
7175

72-
Copyright © 2013 by David Caldwell
76+
Copyright © 2013 by David Caldwell
7377
Copyright © 2014 by Marcel Greter
7478

7579
This library is released under the MIT license.

bin/psass.pl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
use CSS::Sass qw(SASS_STYLE_NESTED);
2121
use CSS::Sass qw(SASS_STYLE_COMPRESSED);
2222

23+
####################################################################################################
24+
# normalize command arguments to utf8
25+
####################################################################################################
26+
27+
# get cmd arg encoding
28+
use Encode::Locale qw();
29+
# convert cmd args to utf8
30+
use Encode qw(decode encode);
31+
# now just decode every command arguments
32+
@ARGV = map { decode(locale => $_, 1) } @ARGV;
33+
2334
####################################################################################################
2435
# config variables
2536
####################################################################################################
@@ -42,7 +53,8 @@ sub version {
4253
printf " sass2scss: %s\n", CSS::Sass::sass2scss_version();
4354
exit 0 };
4455

45-
# include paths
56+
# paths arrays
57+
my @plugin_paths;
4658
my @include_paths;
4759

4860
# get options
@@ -57,6 +69,7 @@ sub version {
5769
'source-map-embed|e!' => \ $source_map_embed,
5870
'source-map-contents|s!' => \ $source_map_contents,
5971
'no-source-map-url!' => \ $omit_source_map_url,
72+
'plugin-path|L=s' => sub { push @plugin_paths, $_[1] },
6073
'include-path|I=s' => sub { push @include_paths, $_[1] }
6174
);
6275

@@ -88,6 +101,7 @@ sub version {
88101
precision => $precision,
89102
output_path => $output_file,
90103
output_style => $output_style,
104+
plugin_paths => \ @plugin_paths,
91105
include_paths => \ @include_paths,
92106
source_comments => $source_comments,
93107
source_map_file => $source_map_file,
@@ -104,6 +118,7 @@ sub version {
104118
precision => $precision,
105119
output_path => $output_file,
106120
output_style => $output_style,
121+
plugin_paths => \ @plugin_paths,
107122
include_paths => \ @include_paths,
108123
source_comments => $source_comments,
109124
source_map_file => $source_map_file,
@@ -151,6 +166,7 @@ =head1 SYNOPSIS
151166
-p, --precision precision for float output
152167
-o, --output-file=file output file to write result to
153168
-t, --output-style=style output style [nested|compressed]
169+
-L, --plugin-path=path plugin load path (repeatable)
154170
-I, --include-path=path sass include path (repeatable)
155171
-c, --source-comments enable source debug comments
156172
-e, --source-map-embed embed source-map in mapping url

lib/CSS/Sass.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ CSS::Sass - Compile .scss files using libsass
2424

2525

2626
# Object Oriented API w/ options
27-
my $sass = CSS::Sass->new(include_paths => ['some/include/path'],
28-
image_path => 'base_url',
27+
my $sass = CSS::Sass->new(plugin_paths => ['plugins'],
28+
include_paths => ['some/include/path'],
2929
output_style => SASS_STYLE_COMPRESSED,
3030
source_map_file => 'output.css.map',
3131
source_comments => 1,
@@ -55,7 +55,6 @@ CSS::Sass - Compile .scss files using libsass
5555
# Functional API w/ options
5656
my ($css, $err, $srcmap) = sass_compile('A { color: red; }',
5757
include_paths => ['some/include/path'],
58-
image_path => 'base_url',
5958
output_style => SASS_STYLE_NESTED,
6059
source_map_file => 'output.css.map');
6160

@@ -143,6 +142,10 @@ feature parity and heading towards 3.4. It can compile .scss and .sass files.
143142
actually be created, but its content will be returned to the caller. It
144143
will also enable sourceMappingURL comment by default. See `no_src_map_url`.
145144

145+
- `source_map_root`
146+
147+
A path (string) that is directly embedded in the source map as `sourceRoot`.
148+
146149
- `source_map_embed`
147150

148151
Embeds the complete source-map content into the sourceMappingURL, by using
@@ -164,17 +167,11 @@ feature parity and heading towards 3.4. It can compile .scss and .sass files.
164167
This is an arrayref that holds the list a of paths to search (in addition to
165168
the current directory) when following Sass `@import` directives.
166169

167-
- `image_path`
168-
169-
This is a string that holds the base URL. This is only used in the
170-
(non-standard) `image-url()` Sass function. For example, if `image_path`
171-
is set to `'file:///tmp/a/b/c'`, then the follwoing Sass code:
172-
173-
.something { background-image: image-url("my/path"); }
174-
175-
...will compile to this:
170+
- `plugin_paths`
176171

177-
.something { background-image: url("file:///tmp/a/b/c/my/path"); }
172+
This is an arrayref that holds a list of paths to search for third-party
173+
plugins. It will automatically load any <dll> or <so> library within that
174+
directory. This is currently a highly experimental libsass feature!
178175

179176
- `dont_die`
180177

lib/CSS/Sass.pm

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ our @EXPORT_OK = qw(
3838

3939
our @EXPORT = qw(
4040
SASS_STYLE_NESTED
41+
SASS_STYLE_EXPANDED
42+
SASS_STYLE_COMPACT
4143
SASS_STYLE_COMPRESSED
4244
SASS2SCSS_PRETTIFY_0
4345
SASS2SCSS_PRETTIFY_1
@@ -48,7 +50,7 @@ our @EXPORT = qw(
4850
SASS2SCSS_CONVERT_COMMENT
4951
);
5052

51-
our $VERSION = "v3.1.1";
53+
our $VERSION = "v3.2.0";
5254

5355
require XSLoader;
5456
XSLoader::load('CSS::Sass', $VERSION);
@@ -57,6 +59,7 @@ require CSS::Sass::Type;
5759
sub new {
5860
my ($class, %options) = @_;
5961
# Ensure initial sub structures on options
62+
$options{plugin_paths} = [] unless exists $options{plugin_paths};
6063
$options{include_paths} = [] unless exists $options{include_paths};
6164
$options{sass_functions} = {} unless exists $options{sass_functions};
6265
# Create and return new object with options
@@ -84,6 +87,10 @@ sub sass_compile {
8487
!$options{include_paths} ? ()
8588
: (include_paths => join($^O eq 'MSWin32' ? ';' : ':',
8689
@{$options{include_paths}})),
90+
# Override plugin_paths with a ':' separated list
91+
!$options{plugin_paths} ? ()
92+
: (plugin_paths => join($^O eq 'MSWin32' ? ';' : ':',
93+
@{$options{plugin_paths}})),
8794
});
8895
wantarray ? ($r->{output_string}, $r->{error_message}, $r) : $r->{output_string}
8996
}
@@ -100,6 +107,10 @@ sub sass_compile_file {
100107
!$options{include_paths} ? ()
101108
: (include_paths => join($^O eq 'MSWin32' ? ';' : ':',
102109
@{$options{include_paths}})),
110+
# Override plugin_paths with a ':' separated list
111+
!$options{plugin_paths} ? ()
112+
: (plugin_paths => join($^O eq 'MSWin32' ? ';' : ':',
113+
@{$options{plugin_paths}})),
103114
});
104115
wantarray ? ($r->{output_string}, $r->{error_message}, $r) : $r->{output_string}
105116
}
@@ -149,8 +160,8 @@ CSS::Sass - Compile .scss files using libsass
149160
150161
151162
# Object Oriented API w/ options
152-
my $sass = CSS::Sass->new(include_paths => ['some/include/path'],
153-
image_path => 'base_url',
163+
my $sass = CSS::Sass->new(plugin_paths => ['plugins'],
164+
include_paths => ['some/include/path'],
154165
output_style => SASS_STYLE_COMPRESSED,
155166
source_map_file => 'output.css.map',
156167
source_comments => 1,
@@ -180,7 +191,6 @@ CSS::Sass - Compile .scss files using libsass
180191
# Functional API w/ options
181192
my ($css, $err, $srcmap) = sass_compile('A { color: red; }',
182193
include_paths => ['some/include/path'],
183-
image_path => 'base_url',
184194
output_style => SASS_STYLE_NESTED,
185195
source_map_file => 'output.css.map');
186196
@@ -284,6 +294,10 @@ Setting this option enables the source-map generating. The file will not
284294
actually be created, but its content will be returned to the caller. It
285295
will also enable sourceMappingURL comment by default. See C<no_src_map_url>.
286296
297+
=item C<source_map_root>
298+
299+
A path (string) that is directly embedded in the source map as C<sourceRoot>.
300+
287301
=item C<source_map_embed>
288302
289303
Embeds the complete source-map content into the sourceMappingURL, by using
@@ -305,17 +319,11 @@ Setting this options makes C<source_map_embed> useless.
305319
This is an arrayref that holds the list a of paths to search (in addition to
306320
the current directory) when following Sass C<@import> directives.
307321
308-
=item C<image_path>
309-
310-
This is a string that holds the base URL. This is only used in the
311-
(non-standard) C<image-url()> Sass function. For example, if C<image_path>
312-
is set to C<'file:///tmp/a/b/c'>, then the follwoing Sass code:
313-
314-
.something { background-image: image-url("my/path"); }
315-
316-
...will compile to this:
322+
=item C<plugin_paths>
317323
318-
.something { background-image: url("file:///tmp/a/b/c/my/path"); }
324+
This is an arrayref that holds a list of paths to search for third-party
325+
plugins. It will automatically load any <dll> or <so> library within that
326+
directory. This is currently a highly experimental libsass feature!
319327
320328
=item C<dont_die>
321329

0 commit comments

Comments
 (0)