Skip to content

Commit 589d490

Browse files
committed
Update implementation for libsass 3.2.0-beta.1
https://github.com/sass/libsass/releases/tag/3.2.0-beta.1
1 parent 4967ffa commit 589d490

24 files changed

+278
-128
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
*~

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "libsass"]
22
path = libsass
3-
url = git://github.com/mgreter/libsass.git
3+
url = git://github.com/sass/libsass.git
44
[submodule "t/sass-spec"]
55
path = t/sass-spec
6-
url = git://github.com/mgreter/sass-spec.git
6+
url = git://github.com/sass/sass-spec.git

Build.PL

Lines changed: 7 additions & 7 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,7 +202,7 @@ 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
207207
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

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: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ our @EXPORT = qw(
5050
SASS2SCSS_CONVERT_COMMENT
5151
);
5252

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

5555
require XSLoader;
5656
XSLoader::load('CSS::Sass', $VERSION);
@@ -59,6 +59,7 @@ require CSS::Sass::Type;
5959
sub new {
6060
my ($class, %options) = @_;
6161
# Ensure initial sub structures on options
62+
$options{plugin_paths} = [] unless exists $options{plugin_paths};
6263
$options{include_paths} = [] unless exists $options{include_paths};
6364
$options{sass_functions} = {} unless exists $options{sass_functions};
6465
# Create and return new object with options
@@ -86,6 +87,10 @@ sub sass_compile {
8687
!$options{include_paths} ? ()
8788
: (include_paths => join($^O eq 'MSWin32' ? ';' : ':',
8889
@{$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}})),
8994
});
9095
wantarray ? ($r->{output_string}, $r->{error_message}, $r) : $r->{output_string}
9196
}
@@ -102,6 +107,10 @@ sub sass_compile_file {
102107
!$options{include_paths} ? ()
103108
: (include_paths => join($^O eq 'MSWin32' ? ';' : ':',
104109
@{$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}})),
105114
});
106115
wantarray ? ($r->{output_string}, $r->{error_message}, $r) : $r->{output_string}
107116
}
@@ -151,8 +160,8 @@ CSS::Sass - Compile .scss files using libsass
151160
152161
153162
# Object Oriented API w/ options
154-
my $sass = CSS::Sass->new(include_paths => ['some/include/path'],
155-
image_path => 'base_url',
163+
my $sass = CSS::Sass->new(plugin_paths => ['plugins'],
164+
include_paths => ['some/include/path'],
156165
output_style => SASS_STYLE_COMPRESSED,
157166
source_map_file => 'output.css.map',
158167
source_comments => 1,
@@ -182,7 +191,6 @@ CSS::Sass - Compile .scss files using libsass
182191
# Functional API w/ options
183192
my ($css, $err, $srcmap) = sass_compile('A { color: red; }',
184193
include_paths => ['some/include/path'],
185-
image_path => 'base_url',
186194
output_style => SASS_STYLE_NESTED,
187195
source_map_file => 'output.css.map');
188196
@@ -286,6 +294,10 @@ Setting this option enables the source-map generating. The file will not
286294
actually be created, but its content will be returned to the caller. It
287295
will also enable sourceMappingURL comment by default. See C<no_src_map_url>.
288296
297+
=item C<source_map_root>
298+
299+
A path (string) that is directly embedded in the source map as C<sourceRoot>.
300+
289301
=item C<source_map_embed>
290302
291303
Embeds the complete source-map content into the sourceMappingURL, by using
@@ -307,17 +319,11 @@ Setting this options makes C<source_map_embed> useless.
307319
This is an arrayref that holds the list a of paths to search (in addition to
308320
the current directory) when following Sass C<@import> directives.
309321
310-
=item C<image_path>
311-
312-
This is a string that holds the base URL. This is only used in the
313-
(non-standard) C<image-url()> Sass function. For example, if C<image_path>
314-
is set to C<'file:///tmp/a/b/c'>, then the follwoing Sass code:
315-
316-
.something { background-image: image-url("my/path"); }
317-
318-
...will compile to this:
322+
=item C<plugin_paths>
319323
320-
.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!
321327
322328
=item C<dont_die>
323329

0 commit comments

Comments
 (0)