This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
99 lines (79 loc) · 2.55 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
exec(*(["bundle", "exec", $PROGRAM_NAME] + ARGV)) if ENV['BUNDLE_GEMFILE'].nil?
task :default => :test
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
spec = Bundler.load_gemspec("ore-rs.gemspec")
require "rubygems/package_task"
Gem::PackageTask.new(spec) do |pkg|
end
require "rake/extensiontask"
exttask = Rake::ExtensionTask.new("ore_rs", spec) do |ext|
ext.lib_dir = "lib"
ext.source_pattern = "*.{rs,toml}"
ext.cross_compile = true
ext.cross_platform = %w[x86_64-linux x86_64-darwin arm64-darwin aarch64-linux]
end
namespace :gem do
desc "Push all freshly-built gems to RubyGems"
task :push do
Rake::Task.tasks.select { |t| t.name =~ %r{^pkg/ore-rs-.*\.gem} && t.already_invoked }.each do |pkgtask|
sh "gem", "push", pkgtask.name
end
Rake::Task.tasks
.select { |t| t.name =~ %r{^gem:cross:} && exttask.cross_platform.include?(t.name.split(":").last) }
.select(&:already_invoked)
.each do |task|
platform = task.name.split(":").last
sh "gem", "push", "pkg/#{spec.full_name}-#{platform}.gem"
end
end
namespace :cross do
task :prepare do
require "rake_compiler_dock"
sh "bundle package"
end
exttask.cross_platform.each do |platform|
desc "Cross-compile all native gems in parallel"
multitask :all => platform
desc "Cross-compile a binary gem for #{platform}"
task platform => :prepare do
RakeCompilerDock.sh <<-EOT, platform: platform, image: "rbsys/rcd:#{platform}"
set -e
[[ "#{platform}" =~ ^a ]] && rustup default nightly
# This re-installs the nightly version of the relevant target after
# we so rudely switch the default toolchain
[ "#{platform}" = "arm64-darwin" ] && rustup target add aarch64-apple-darwin
[ "#{platform}" = "aarch64-linux" ] && rustup target add aarch64-unknown-linux-gnu
bundle install
rake native:#{platform} gem RUBY_CC_VERSION=3.1.0:3.0.0:2.7.0
EOT
end
end
end
end
task :release do
sh "git release"
end
require 'yard'
YARD::Rake::YardocTask.new :doc do |yardoc|
yardoc.files = %w{lib/**/*.rb - README.md}
end
desc "Run guard"
task :guard do
sh "guard --clear"
end
namespace :rust do
desc "Build Rust library"
task :build do
sh "cargo build --release"
end
end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new :test => :compile do |t|
t.pattern = "spec/**/*_spec.rb"
end