Skip to content

Commit

Permalink
Rakefile fixups for easy Gem install + testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Ocampo-Gooding committed Jun 22, 2015
1 parent c21ccfd commit 1f4c9b9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
18 changes: 4 additions & 14 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@ rescue LoadError
puts 'Cannot load bundler/gem_tasks'
end

task default: :test

task prepare: "ext/lib/libsass.so"
require 'tasks/libsass'

file "ext/lib/libsass.so" do
gem_dir = File.expand_path(File.dirname(__FILE__)) + "/"
cd "ext/libsass"
sh 'make lib/libsass.so LDFLAGS="-Wall -O2"'
cd gem_dir
end
task default: :test

task test: :prepare do
desc "Run all tests"
task test: 'libsass:compile' do
$LOAD_PATH.unshift('lib', 'test')
Dir.glob('./test/**/*_test.rb') { |f| require f }
end

task :submodule do
sh "git submodule update --init"
end
3 changes: 3 additions & 0 deletions ext/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require_relative '../lib/tasks/libsass'

task default: 'libsass:compile'
21 changes: 21 additions & 0 deletions lib/tasks/libsass.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace :libsass do
desc "Compile libsass"
task compile: "ext/libsass/lib/libsass.so"

file "ext/libsass/.git" do
sh "git submodule update --init"
end

file "ext/libsass/lib/libsass.so" => "ext/libsass/.git" do
libsass_path = ""
if Dir.pwd.end_with?('/ext')
libsass_path = "libsass"
else
libsass_path = "ext/libsass"
end

cd libsass_path do
sh 'make lib/libsass.so LDFLAGS="-Wall -O2"'
end
end
end
5 changes: 3 additions & 2 deletions sassc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ Gem::Specification.new do |spec|
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib", "ext"]

spec.extensions = ["Rakefile"]
spec.require_paths = ["lib"]

spec.extensions = ["ext/Rakefile"]

spec.add_development_dependency "rake"
spec.add_development_dependency "minitest", "~> 5.5.1"
Expand Down

0 comments on commit 1f4c9b9

Please sign in to comment.