Skip to content

Commit 10a743c

Browse files
authored
Merge pull request #96 from glebm/ext-lib
Update libsass to v3.6.0 and fixes various issues (windows, cross-compilation, binary gems)
2 parents e7da015 + e11789b commit 10a743c

File tree

13 files changed

+92
-62
lines changed

13 files changed

+92
-62
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
*.so
1313
*.o
1414
*.a
15+
*.gem
1516
mkmf.log
1617
vendor/bundle

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "ext/libsass"]
22
path = ext/libsass
3-
url = git://github.com/sass/libsass.git
3+
url = https://github.com/sass/libsass.git

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This gem combines the speed of `libsass`, the [Sass C implementation](https://gi
66

77
### libsass Version
88

9-
[3.5.2](https://github.com/sass/libsass/releases/tag/3.5.2)
9+
[d225a09a](https://github.com/sass/libsass/commit/d225a09a152050d569c077f97bb944c8dc819d6f)
1010

1111
## Installation
1212

Rakefile

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
begin
2-
require 'bundler/gem_tasks'
3-
rescue LoadError
4-
puts 'Cannot load bundler/gem_tasks'
5-
end
6-
7-
require 'tasks/libsass'
1+
require 'bundler/gem_tasks'
82

93
task default: :test
104

5+
require 'rake/extensiontask'
6+
gem_spec = Gem::Specification.load("sassc.gemspec")
7+
Rake::ExtensionTask.new('libsass', gem_spec) do |ext|
8+
ext.name = 'libsass'
9+
ext.ext_dir = 'ext'
10+
ext.lib_dir = 'lib/sassc'
11+
ext.cross_compile = true
12+
ext.cross_platform = %w[x86-mingw32 x64-mingw32 x86-linux x86_64-linux]
13+
ext.cross_compiling do |spec|
14+
spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
15+
end
16+
end
17+
18+
desc 'Compile all native gems via rake-compiler-dock (Docker)'
19+
task 'gem:native' do
20+
require 'rake_compiler_dock'
21+
RakeCompilerDock.sh "bundle && gem i rake --no-document && "\
22+
"rake cross native gem MAKE='nice make -j`nproc`' "\
23+
"RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0"
24+
end
25+
1126
desc "Run all tests"
12-
task test: 'libsass:compile' do
27+
task test: 'compile:libsass' do
1328
$LOAD_PATH.unshift('lib', 'test')
1429
Dir.glob('./test/**/*_test.rb') { |f| require f }
1530
end

ext/Rakefile

Lines changed: 0 additions & 3 deletions
This file was deleted.

ext/extconf.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
gem_root = File.expand_path('..', __dir__)
4+
libsass_dir = File.join(gem_root, 'ext', 'libsass')
5+
6+
if !File.directory?(libsass_dir) ||
7+
# '.', '..', and possibly '.git' from a failed checkout:
8+
Dir.entries(libsass_dir).size <= 3
9+
Dir.chdir(gem_root) { system('git submodule update --init') } or
10+
fail 'Could not fetch libsass'
11+
end
12+
13+
File.write 'Makefile', <<-MAKEFILE
14+
ifndef DESTDIR
15+
LIBSASS_OUT = #{gem_root}/lib/sassc/libsass.so
16+
else
17+
LIBSASS_OUT = $(DESTDIR)$(PREFIX)/libsass.so
18+
endif
19+
20+
SUB_DIR := #{libsass_dir}
21+
SUB_TARGET := lib/libsass.so
22+
23+
libsass.so:#{' clean' if ENV['CLEAN']}
24+
$(MAKE) -C '$(SUB_DIR)' lib/libsass.so
25+
cp '$(SUB_DIR)/lib/libsass.so' libsass.so
26+
strip libsass.so
27+
28+
install: libsass.so
29+
cp libsass.so '$(LIBSASS_OUT)'
30+
31+
clean:
32+
$(MAKE) -C '$(SUB_DIR)' clean
33+
rm -f '$(LIBSASS_OUT)' libsass.so
34+
35+
.PHONY: clean install
36+
MAKEFILE

ext/libsass

Submodule libsass updated 158 files

lib/sassc/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def output_style
133133

134134
def load_paths
135135
paths = (@options[:load_paths] || []) + SassC.load_paths
136-
paths.join(":") if paths.any?
136+
paths.join(File::PATH_SEPARATOR) unless paths.empty?
137137
end
138138
end
139139
end

lib/sassc/native.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ module Native
88

99
spec = Gem.loaded_specs["sassc"]
1010
gem_root = spec.gem_dir
11-
ffi_lib "#{gem_root}/ext/libsass/lib/libsass.so"
11+
12+
ruby_version_so_path = "#{gem_root}/lib/sassc/#{RUBY_VERSION[/\d+.\d+/]}/libsass.so"
13+
if File.exist?(ruby_version_so_path)
14+
ffi_lib ruby_version_so_path
15+
else
16+
ffi_lib "#{gem_root}/lib/sassc/libsass.so"
17+
end
1218

1319
require_relative "native/sass_value"
1420

lib/tasks/libsass.rb

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)