1
0
Fork 0
mirror of https://github.com/rubyjs/libv8 synced 2023-03-27 23:21:48 -04:00
libv8/Rakefile

96 lines
2.8 KiB
Text
Raw Normal View History

# This is a sanity check to enforce that the v8 submodule is initialized
# before we try to run any rake tasks.
if !File.exist? File.join('lib', 'libv8', 'v8', 'SConstruct') then
puts "V8 source appears to be missing. Updating..."
`git submodule update --init`
end
# Now we include the bundler stuff...
# We had to do the fetch first since our version code requires that we have
# the V8 source
2011-05-24 14:17:58 -04:00
require 'bundler'
require 'bundler/setup'
Bundler::GemHelper.install_tasks
# desc "remove all generated artifacts except built v8 objects"
# task :clean do
# sh "rm -rf pkg"
# sh "rm -rf ext/v8/Makefile"
# sh "rm -rf ext/v8/*.bundle ext/v8/*.so"
# sh "rm -rf lib/v8/*.bundle lib/v8/*.so"
# end
#
# desc "build v8 with debugging symbols (much slower)"
# task "v8:debug" do
# sh "cd ext/v8/upstream && make debug"
# end
# Rake::ExtensionTask.new("libv8", eval(File.read("libv8.gemspec"))) do |ext|
# ext.lib_dir = "lib/libv8"
# end
2011-07-07 15:58:21 -04:00
latest_v8 = nil
Dir.chdir(File.join('lib', 'libv8', 'v8')) do
latest_v8 = `git tag`.split.map{|v| Gem::Version.new(v)}.sort.last.to_s
end
desc "Check out a version of V8"
task :checkout, :version do |t, options|
options.with_defaults(:version => latest_v8)
Dir.chdir(File.join('lib', 'libv8', 'v8')) do
`git fetch`
# We're checking out the latest tag. Sorted using Gem::Version
2011-07-07 15:58:21 -04:00
versions = `git tag`.split.map{|v| Gem::Version.new(v)}.sort
fail "Version #{options.version} does not exist! Aborting..." if !versions.member?(Gem::Version.new(options.version))
puts "Checking out version #{options.version}"
`git checkout -f tags/#{options.version}`
2011-05-25 16:41:01 -04:00
end
end
2011-05-24 14:17:58 -04:00
desc "Compile the V8 JavaScript engine"
2011-07-07 15:58:21 -04:00
task :compile, [:version] do |t, options|
options.with_defaults(:version => latest_v8)
puts "Compiling V8 (#{options.version})..."
Rake::Task[:checkout].invoke(options.version)
2011-05-24 14:17:58 -04:00
Dir.chdir(File.join('lib', 'libv8')) do
`make`
2011-05-25 16:41:01 -04:00
end
end
desc "Clean up from the build"
2011-07-07 15:58:21 -04:00
task :clean do |t, options|
2011-05-25 16:41:01 -04:00
Dir.chdir(File.join('lib', 'libv8')) do
`make clean`
2011-05-24 14:17:58 -04:00
end
2011-05-25 16:41:01 -04:00
end
2011-07-07 15:58:34 -04:00
desc "List all versions of V8"
task :list do
Dir.chdir(File.join('lib', 'libv8', 'v8')) do
puts `git tag`.split.map{|v| Gem::Version.new(v)}.sort
end
end
2011-05-25 16:41:01 -04:00
desc "Create a binary gem for this current platform"
2011-07-07 15:58:21 -04:00
task :binary, [:version] => [:compile] do |t, options|
2011-05-25 16:41:01 -04:00
gemspec = eval(File.read('libv8.gemspec'))
gemspec.extensions.clear
gemspec.platform = Gem::Platform.new(RUBY_PLATFORM)
# We don't need most things for the binary
gemspec.files = []
# Lib
gemspec.files << 'lib/libv8.rb'
gemspec.files << 'lib/libv8/version.rb'
# V8
Dir.glob('lib/libv8/v8/include/*').each { |f| gemspec.files << f }
2011-05-27 15:02:35 -04:00
gemspec.files << "lib/libv8/build/v8/libv8.a"
gemspec.files << "lib/libv8/build/v8/libv8preparser.a"
2011-05-25 16:41:01 -04:00
FileUtils.mkdir_p 'pkg'
FileUtils.mv(Gem::Builder.new(gemspec).build, 'pkg')
2011-06-15 16:55:18 -04:00
end
2011-07-07 15:58:21 -04:00
task :default => :binary