2011-05-24 13:17:58 -05:00
|
|
|
require 'bundler/setup'
|
2012-04-25 22:46:30 -05:00
|
|
|
require 'rspec/core/rake_task'
|
2014-06-14 12:26:44 +03:00
|
|
|
|
|
|
|
Bundler::GemHelper.install_tasks
|
2012-04-25 22:46:30 -05:00
|
|
|
RSpec::Core::RakeTask.new(:spec)
|
2011-05-24 13:17:58 -05:00
|
|
|
|
2014-06-14 12:26:44 +03:00
|
|
|
module Helpers
|
|
|
|
module_function
|
2014-06-14 13:32:45 +03:00
|
|
|
def binary_gemspec(platform = RUBY_PLATFORM)
|
2014-06-14 12:26:44 +03:00
|
|
|
gemspec = eval(File.read('libv8.gemspec'))
|
|
|
|
gemspec.platform = Gem::Platform.new(platform)
|
|
|
|
gemspec
|
|
|
|
end
|
2012-05-12 11:38:07 +01:00
|
|
|
|
2014-06-14 12:26:44 +03:00
|
|
|
def binary_gem_name
|
2014-06-14 13:32:45 +03:00
|
|
|
File.basename binary_gemspec.cache_file
|
2014-06-14 12:26:44 +03:00
|
|
|
end
|
2013-05-15 15:09:49 +03:00
|
|
|
end
|
|
|
|
|
2012-04-26 10:28:27 -05:00
|
|
|
desc "compile v8 via the ruby extension mechanism"
|
2013-06-19 16:25:06 +02:00
|
|
|
task :compile do
|
2012-04-26 10:28:27 -05:00
|
|
|
sh "ruby ext/libv8/extconf.rb"
|
|
|
|
end
|
|
|
|
|
2014-06-14 12:26:44 +03:00
|
|
|
desc "build a binary gem #{Helpers.binary_gem_name}"
|
2012-06-21 15:55:00 +03:00
|
|
|
task :binary => :compile do
|
2014-06-14 13:32:45 +03:00
|
|
|
gemspec = Helpers.binary_gemspec
|
2012-07-01 23:10:13 -05:00
|
|
|
gemspec.extensions.clear
|
2014-06-14 13:32:45 +03:00
|
|
|
|
2012-04-25 22:26:17 -05:00
|
|
|
# We don't need most things for the binary
|
2013-01-04 15:41:18 -06:00
|
|
|
gemspec.files = []
|
|
|
|
gemspec.files += ['lib/libv8.rb', 'lib/libv8/version.rb']
|
|
|
|
gemspec.files += ['ext/libv8/arch.rb', 'ext/libv8/location.rb', 'ext/libv8/paths.rb']
|
|
|
|
gemspec.files += ['ext/libv8/.location.yml']
|
2014-06-14 13:32:45 +03:00
|
|
|
|
2012-04-25 22:26:17 -05:00
|
|
|
# V8
|
|
|
|
gemspec.files += Dir['vendor/v8/include/*']
|
2012-05-01 15:04:47 -07:00
|
|
|
gemspec.files += Dir['vendor/v8/out/**/*.a']
|
2014-06-14 13:32:45 +03:00
|
|
|
|
2013-02-01 20:46:40 -05:00
|
|
|
FileUtils.chmod 'a+r', gemspec.files
|
2012-04-25 22:26:17 -05:00
|
|
|
FileUtils.mkdir_p 'pkg'
|
2014-06-14 13:32:45 +03:00
|
|
|
|
2013-03-22 10:53:42 -05:00
|
|
|
package = if Gem::VERSION < '2.0.0'
|
2013-03-28 09:04:22 -05:00
|
|
|
Gem::Builder.new(gemspec).build
|
2013-03-22 10:53:42 -05:00
|
|
|
else
|
|
|
|
require 'rubygems/package'
|
|
|
|
Gem::Package.build(gemspec)
|
|
|
|
end
|
2014-06-14 13:32:45 +03:00
|
|
|
|
2013-03-04 18:26:19 +02:00
|
|
|
FileUtils.mv(package, 'pkg')
|
2012-04-25 22:26:17 -05:00
|
|
|
end
|
|
|
|
|
2014-06-17 02:38:41 +03:00
|
|
|
task :clean_submodules do
|
|
|
|
sh "git submodule --quiet foreach git reset --hard"
|
|
|
|
sh "git submodule --quiet foreach git clean -df"
|
|
|
|
end
|
|
|
|
|
2012-04-25 22:26:17 -05:00
|
|
|
desc "clean up artifacts of the build"
|
2014-06-17 02:38:41 +03:00
|
|
|
task :clean => [:clean_submodules] do
|
2012-04-25 22:46:30 -05:00
|
|
|
sh "rm -rf pkg"
|
2012-04-26 10:28:27 -05:00
|
|
|
sh "git clean -df"
|
2011-06-15 15:55:18 -05:00
|
|
|
end
|
|
|
|
|
2014-06-14 12:26:44 +03:00
|
|
|
task :default => [:compile, :spec]
|
2014-06-17 02:38:41 +03:00
|
|
|
task :build => [:clean_submodules]
|