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

161 lines
4.4 KiB
Text
Raw Normal View History

2011-05-24 14:17:58 -04:00
require 'bundler/setup'
2012-04-25 23:46:30 -04:00
require 'rspec/core/rake_task'
require 'tmpdir'
2020-07-18 12:24:54 -04:00
require 'rubygems/package'
2014-06-14 05:26:44 -04:00
Bundler::GemHelper.install_tasks
2014-06-17 09:01:04 -04:00
RSpec::Core::RakeTask.new :spec
2011-05-24 14:17:58 -04:00
2017-07-21 14:34:58 -04:00
DISTRIBUTIONS = [
'x86_64-linux',
'x86-linux',
'x86_64-freebsd-10',
'x86_64-freebsd-11',
'amd64-freebsd-10',
'amd64-freebsd-11',
'arm-linux',
2017-07-26 11:16:19 -04:00
'aarch64-linux',
# 'x86_64-linux-musl'
2017-07-21 14:34:58 -04:00
]
2014-06-14 05:26:44 -04:00
module Helpers
module_function
def binary_gemspec(platform = Gem::Platform.local)
eval(File.read 'libv8.gemspec').tap do |gemspec|
gemspec.platform = platform
gemspec.extensions.clear
# We don't need most things for the binary
gemspec.files = []
gemspec.files += ['lib/libv8.rb', 'lib/libv8/version.rb']
gemspec.files += ['ext/libv8/location.rb', 'ext/libv8/paths.rb']
gemspec.files += ['ext/libv8/.location.yml']
# V8
gemspec.files += Dir['vendor/v8/include/**/*.h']
gemspec.files += Dir['vendor/v8/out.gn/**/*.a']
end
2014-06-14 05:26:44 -04:00
end
2012-05-12 06:38:07 -04:00
def binary_gem_name(platform = Gem::Platform.local)
File.basename binary_gemspec(platform).cache_file
2014-06-14 05:26:44 -04:00
end
2013-05-15 08:09:49 -04:00
end
desc "compile v8 via the ruby extension mechanism"
task :compile do
sh "ruby ext/libv8/extconf.rb"
end
2014-06-14 05:26:44 -04:00
desc "build a binary gem #{Helpers.binary_gem_name}"
task :binary => :compile do
gemspec = Helpers.binary_gemspec
2014-06-14 06:32:45 -04:00
FileUtils.chmod 0644, gemspec.files
FileUtils.mkdir_p 'pkg'
2014-06-14 06:32:45 -04:00
package = Gem::Package.build gemspec
2014-06-17 09:01:04 -04:00
FileUtils.mv package, 'pkg'
end
namespace :build do
2017-07-21 14:34:58 -04:00
DISTRIBUTIONS.each do |arch|
desc "build binary gem for #{arch}"
task arch do
arch_dir = Pathname(__FILE__).dirname.join("release/#{arch}")
Dir.chdir(arch_dir) do
2016-05-03 17:56:57 -04:00
ENV['RUBYLIB'] = nil # https://github.com/mitchellh/vagrant/issues/6158
sh "vagrant up"
2016-05-12 19:28:08 -04:00
sh "vagrant ssh -c 'rm -rf ~/libv8'"
sh "vagrant ssh -c 'git clone /libv8/.git ~/libv8 --recursive'"
2016-05-03 17:56:57 -04:00
sh "vagrant ssh -c 'cd ~/libv8 && bundle install --path vendor/bundle'"
sh "vagrant ssh -c 'cd ~/libv8 && env MAKEFLAGS=-j4 bundle exec rake binary'"
2017-07-21 07:00:55 -04:00
sh "vagrant status | grep scaleway" do |ok, res|
if ok
sh "vagrant ssh --no-tty -c 'cd ~/libv8/pkg && tar -cf - *.gem' 2>/dev/null | tar -xv"
else
sh "vagrant ssh -c 'cp ~/libv8/pkg/*.gem /vagrant'"
end
end
sh "vagrant destroy -f"
end
end
end
end
2017-07-21 14:34:58 -04:00
desc "Build binary gems for all supported distributions"
task :binary_release => [:build] + DISTRIBUTIONS.map {|distribution| "build:#{distribution}"} do
sh "cd #{File.dirname(__FILE__)} && mkdir -p pkg"
sh "cd #{File.dirname(__FILE__)} && mv release/**/*.gem pkg/"
end
2017-07-21 14:34:58 -04:00
task :clean_submodules do
sh "git submodule --quiet foreach git reset --hard"
2014-06-17 08:16:02 -04:00
sh "git submodule --quiet foreach git clean -dxf"
sh "git submodule update --init"
end
desc "clean up artifacts of the build"
task :clean => [:clean_submodules] do
2012-04-25 23:46:30 -04:00
sh "rm -rf pkg"
sh "rm -rf vendor/v8"
sh "git clean -dxf -e .bundle -e vendor/bundle"
2011-06-15 16:55:18 -04:00
end
2014-06-14 05:26:44 -04:00
task :default => [:compile, :spec]
2015-07-03 15:55:40 -04:00
task :build => [:clean]
desc 'Generate OSX platform builds. Although any v8 OSX compile will run on any Mac OS version down to 10.10, RubyGems requires us to submit all of the different platforms seperately. Requires `compile` to already have been run, but is seperate for Travis reasons.'
2020-07-18 12:24:54 -04:00
task :osx_varients do
gemspec = Helpers.binary_gemspec
next unless Gem::Platform.local.os == 'darwin'
[15, 16, 17, 18, 19].each do |version|
%w(x86_64 universal).each do |cpu|
2020-07-18 12:24:54 -04:00
gemspec.platform = Gem::Platform.local.tap do |platform|
platform.cpu = cpu
platform.version = version
end
2020-07-18 12:24:54 -04:00
package = Gem::Package.build gemspec
FileUtils.mv package, 'pkg'
end
end
end
desc 'Push a release from github'
task :push_github_release do
releases = (15..19).map do |i|
["-universal-darwin-#{i}", "-x86_64-darwin-#{i}"]
end.flatten
releases << ""
releases << "-x86_64-linux"
FileUtils.mkdir_p("pkg")
Dir.chdir("pkg") do
releases.each do |release|
cmd = "wget https://github.com/rubyjs/libv8/releases/download/v#{Libv8::VERSION}/libv8-#{Libv8::VERSION}#{release}.gem"
puts cmd
puts `#{cmd}`
end
otp = 111111
Dir["*#{Libv8::VERSION}*.gem"].each do |f|
puts "pushing #{f}"
begin
result = `gem push #{f} --otp #{otp}`
if result =~ /OTP code is incorrect/
puts "enter otp"
otp = STDIN.gets.strip
redo
end
end
puts result
end
end
end