Skip to content

Commit

Permalink
Update libsass to master + other fixes
Browse files Browse the repository at this point in the history
Updates libsass to master to incorporate fixes for:

1. The :not selector. Fixes #91. sass/libsass#2697
2. Default precision changed to 10. sass/libsass#2716
3. Now builds with `cc` instead of hard-coding `gcc`. sass/libsass#2707
4. Building on Linux and Solaris. sass/libsass#2720

Also:
1. Adds Windows RubyInstaller compilation support via `rake-compiler`. Fixes #18.
2. Fixes `load_paths` separator on Windows. Fixes #93.
3. Changes the location of `libsass.so` from `ext/` to `lib/`. Fixes #95.
  • Loading branch information
glebm committed May 5, 2019
1 parent 58d09fe commit d2d6fb0
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
*.so
*.o
*.a
*.gem
mkmf.log
vendor/bundle
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "ext/libsass"]
path = ext/libsass
url = git://github.com/sass/libsass.git
url = https://github.com/sass/libsass.git
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This gem combines the speed of `libsass`, the [Sass C implementation](https://gi

### libsass Version

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

## Installation

Expand Down
11 changes: 8 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ rescue LoadError
puts 'Cannot load bundler/gem_tasks'
end

require 'tasks/libsass'

task default: :test

require 'rake/extensiontask'
Rake::ExtensionTask.new do |ext|
ext.name = 'libsass'
ext.ext_dir = 'ext'
ext.lib_dir = 'lib/sassc'
end

desc "Run all tests"
task test: 'libsass:compile' do
task test: 'compile:libsass' do
$LOAD_PATH.unshift('lib', 'test')
Dir.glob('./test/**/*_test.rb') { |f| require f }
end
3 changes: 0 additions & 3 deletions ext/Rakefile

This file was deleted.

32 changes: 32 additions & 0 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

gem_root = File.expand_path('..', __dir__)
libsass_dir = File.join(gem_root, 'ext', 'libsass')

if !File.directory?(libsass_dir) || Dir.empty?(libsass_dir)
Dir.chdir(gem_root) { system('git submodule update --init') }
end

File.write 'Makefile', <<-MAKEFILE
ifndef DESTDIR
LIBSASS_OUT = #{gem_root}/lib/sassc/libsass.so
else
LIBSASS_OUT = $(DESTDIR)$(PREFIX)/libsass.so
endif
SUB_DIR := #{libsass_dir}
SUB_TARGET := lib/libsass.so
libsass.so:#{' clean' if ENV['CLEAN']}
$(MAKE) -C '$(SUB_DIR)' lib/libsass.so
cp '$(SUB_DIR)/lib/libsass.so' libsass.so
install: libsass.so
cp libsass.so '$(LIBSASS_OUT)'
clean:
$(MAKE) -C '$(SUB_DIR)' clean
rm -f '$(LIBSASS_OUT)' libsass.so
.PHONY: clean install
MAKEFILE
2 changes: 1 addition & 1 deletion ext/libsass
Submodule libsass updated 157 files
2 changes: 1 addition & 1 deletion lib/sassc/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def output_style

def load_paths
paths = @options[:load_paths]
paths.join(":") if paths
paths.join(File::PATH_SEPARATOR) if paths
end
end
end
2 changes: 1 addition & 1 deletion lib/sassc/native.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Native

spec = Gem.loaded_specs["sassc"]
gem_root = spec.gem_dir
ffi_lib "#{gem_root}/ext/libsass/lib/libsass.so"
ffi_lib "#{gem_root}/lib/sassc/libsass.so"

require_relative "native/sass_value"

Expand Down
33 changes: 0 additions & 33 deletions lib/tasks/libsass.rb

This file was deleted.

18 changes: 9 additions & 9 deletions sassc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ Gem::Specification.new do |spec|

spec.require_paths = ["lib"]

spec.extensions = ["ext/Rakefile"]
spec.platform = Gem::Platform::RUBY
spec.extensions = ["ext/extconf.rb"]

spec.add_development_dependency "minitest", "~> 5.5.1"
spec.add_development_dependency "minitest-around"
spec.add_development_dependency "test_construct"
spec.add_development_dependency "pry"
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake-compiler"

spec.add_dependency "rake"
spec.add_dependency "ffi", "~> 1.9"

gem_dir = File.expand_path(File.dirname(__FILE__)) + "/"
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
Dir.chdir(submodule_path) do
submodule_relative_path = submodule_path.sub gem_dir, ""
# issue git ls-files in submodule's directory and
# prepend the submodule path to create absolute file paths
`git ls-files`.split($\).each do |filename|
spec.files << "#{submodule_relative_path}/#{filename}"
end

Dir.chdir(File.join(gem_dir, 'ext', 'libsass')) do
submodule_relative_path = File.join('ext', 'libsass')
`git ls-files`.split($\).each do |filename|
next if filename =~ %r{(^("?test|docs|script)/)|\.md$|\.yml$}
spec.files << File.join(submodule_relative_path, filename)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/engine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_precision_not_specified
SCSS
expected_output = <<-CSS
.foo {
baz: 0.33333; }
baz: 0.3333333333; }
CSS
output = Engine.new(template).render
assert_equal expected_output, output
Expand Down
2 changes: 1 addition & 1 deletion test/native_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module NativeTest

class General < MiniTest::Test
def test_it_reports_the_libsass_version
assert_equal "3.5.2", Native.version
assert_equal "3.5.2-87-gd225", Native.version
end
end

Expand Down

0 comments on commit d2d6fb0

Please sign in to comment.