2011-05-24 14:17:58 -04:00
require 'bundler/setup'
2012-04-25 23:46:30 -04:00
require 'rspec/core/rake_task'
2017-12-19 05:12:09 -05:00
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',
2017-07-21 18:29:43 -04:00
# 'x86_64-linux-musl'
2017-07-21 14:34:58 -04:00
]
2014-06-14 05:26:44 -04:00
module Helpers
module_function
2014-06-17 07:46:26 -04:00
def binary_gemspec(platform = Gem::Platform.local)
2020-07-17 17:08:14 -04:00
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
2014-06-17 07:46:26 -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
2012-04-26 11:28:27 -04:00
desc "compile v8 via the ruby extension mechanism"
2015-07-03 03:53:25 -04:00
task :compile do
2012-04-26 11:28:27 -04:00
sh "ruby ext/libv8/extconf.rb"
end
2014-06-14 05:26:44 -04:00
desc "build a binary gem #{Helpers.binary_gem_name}"
2012-06-21 08:55:00 -04:00
task :binary => :compile do
2020-07-17 17:08:14 -04:00
gemspec = Helpers.binary_gemspec
2014-06-14 06:32:45 -04:00
2014-06-17 04:09:39 -04:00
FileUtils.chmod 0644, gemspec.files
2012-04-25 23:26:17 -04:00
FileUtils.mkdir_p 'pkg'
2014-06-14 06:32:45 -04:00
2020-07-17 17:08:14 -04:00
package = Gem::Package.build gemspec
2014-06-17 09:01:04 -04:00
FileUtils.mv package, 'pkg'
2012-04-25 23:26:17 -04:00
end
framework for building binary gems
I'm tired of our releases getting held up because building the binaries
is such a yak shave. We're in dire need of some automation. I tried
spiking some things out with Docker, but for the time being, it was
easier to just go with Vagrant.
Currently, our release process for binary gems involves
1. a source release at an even point (e.g. 3.16.14.8)
2. a version bump to serve as the basis for binary releases
3. a mish-mash of gem builds and pushes for osx, linux, freebsd, etc...
In order to make things eaiser for us to manage these binary builds, I'm
proposing a standardized build using Vagrant. For each supported
release, a Vagrant file goes into /release/<arch>/Vagrantfile
The vagrantfile is responsible for provisioning a modern
ruby toolchain including bundler, git, git-svn, ruby and ruby source and
headers.
It should also clone the libv8 source into the /libv8
This can then be used to build the binary gem for that platform.
This PR includes the Vagrantfile for x86_64-linux
2015-06-26 19:36:57 -04:00
namespace :build do
2017-07-21 14:34:58 -04:00
DISTRIBUTIONS.each do |arch|
framework for building binary gems
I'm tired of our releases getting held up because building the binaries
is such a yak shave. We're in dire need of some automation. I tried
spiking some things out with Docker, but for the time being, it was
easier to just go with Vagrant.
Currently, our release process for binary gems involves
1. a source release at an even point (e.g. 3.16.14.8)
2. a version bump to serve as the basis for binary releases
3. a mish-mash of gem builds and pushes for osx, linux, freebsd, etc...
In order to make things eaiser for us to manage these binary builds, I'm
proposing a standardized build using Vagrant. For each supported
release, a Vagrant file goes into /release/<arch>/Vagrantfile
The vagrantfile is responsible for provisioning a modern
ruby toolchain including bundler, git, git-svn, ruby and ruby source and
headers.
It should also clone the libv8 source into the /libv8
This can then be used to build the binary gem for that platform.
This PR includes the Vagrantfile for x86_64-linux
2015-06-26 19:36:57 -04:00
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
framework for building binary gems
I'm tired of our releases getting held up because building the binaries
is such a yak shave. We're in dire need of some automation. I tried
spiking some things out with Docker, but for the time being, it was
easier to just go with Vagrant.
Currently, our release process for binary gems involves
1. a source release at an even point (e.g. 3.16.14.8)
2. a version bump to serve as the basis for binary releases
3. a mish-mash of gem builds and pushes for osx, linux, freebsd, etc...
In order to make things eaiser for us to manage these binary builds, I'm
proposing a standardized build using Vagrant. For each supported
release, a Vagrant file goes into /release/<arch>/Vagrantfile
The vagrantfile is responsible for provisioning a modern
ruby toolchain including bundler, git, git-svn, ruby and ruby source and
headers.
It should also clone the libv8 source into the /libv8
This can then be used to build the binary gem for that platform.
This PR includes the Vagrantfile for x86_64-linux
2015-06-26 19:36:57 -04:00
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'"
2017-07-18 15:43:38 -04:00
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
2017-07-18 15:19:40 -04:00
end
2016-11-21 13:43:55 -05:00
sh "vagrant destroy -f"
framework for building binary gems
I'm tired of our releases getting held up because building the binaries
is such a yak shave. We're in dire need of some automation. I tried
spiking some things out with Docker, but for the time being, it was
easier to just go with Vagrant.
Currently, our release process for binary gems involves
1. a source release at an even point (e.g. 3.16.14.8)
2. a version bump to serve as the basis for binary releases
3. a mish-mash of gem builds and pushes for osx, linux, freebsd, etc...
In order to make things eaiser for us to manage these binary builds, I'm
proposing a standardized build using Vagrant. For each supported
release, a Vagrant file goes into /release/<arch>/Vagrantfile
The vagrantfile is responsible for provisioning a modern
ruby toolchain including bundler, git, git-svn, ruby and ruby source and
headers.
It should also clone the libv8 source into the /libv8
This can then be used to build the binary gem for that platform.
This PR includes the Vagrantfile for x86_64-linux
2015-06-26 19:36:57 -04:00
end
end
end
2015-07-03 03:53:25 -04:00
end
framework for building binary gems
I'm tired of our releases getting held up because building the binaries
is such a yak shave. We're in dire need of some automation. I tried
spiking some things out with Docker, but for the time being, it was
easier to just go with Vagrant.
Currently, our release process for binary gems involves
1. a source release at an even point (e.g. 3.16.14.8)
2. a version bump to serve as the basis for binary releases
3. a mish-mash of gem builds and pushes for osx, linux, freebsd, etc...
In order to make things eaiser for us to manage these binary builds, I'm
proposing a standardized build using Vagrant. For each supported
release, a Vagrant file goes into /release/<arch>/Vagrantfile
The vagrantfile is responsible for provisioning a modern
ruby toolchain including bundler, git, git-svn, ruby and ruby source and
headers.
It should also clone the libv8 source into the /libv8
This can then be used to build the binary gem for that platform.
This PR includes the Vagrantfile for x86_64-linux
2015-06-26 19:36:57 -04:00
2017-07-21 14:34:58 -04:00
desc "Build binary gems for all supported distributions"
2017-07-21 18:29:43 -04:00
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
2014-06-16 19:38:41 -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"
2015-07-05 09:35:33 -04:00
sh "git submodule update --init"
2014-06-16 19:38:41 -04:00
end
2012-04-25 23:26:17 -04:00
desc "clean up artifacts of the build"
2014-06-16 19:38:41 -04:00
task :clean => [:clean_submodules] do
2012-04-25 23:46:30 -04:00
sh "rm -rf pkg"
2017-10-23 17:01:15 -04:00
sh "rm -rf vendor/v8"
2015-07-03 16:02:43 -04:00
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]
2017-12-19 05:12:09 -05:00
2020-07-18 16:16:55 -04:00
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
2020-07-18 16:16:55 -04:00
next unless Gem::Platform.local.os == 'darwin'
2017-12-19 05:12:09 -05:00
2020-07-18 16:16:55 -04:00
[15, 16, 17, 18, 19].each do |version|
%w(x86_64 universal).each do |cpu|
2020-07-18 12:24:54 -04:00
2020-07-18 16:16:55 -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
2020-07-18 16:16:55 -04:00
package = Gem::Package.build gemspec
FileUtils.mv package, 'pkg'
end
2017-12-19 05:12:09 -05:00
end
end
2020-07-21 19:02:44 -04:00
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