-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
87 lines (71 loc) · 1.72 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
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rubygems/package_task"
require "rake/testtask"
require "rake/extensiontask"
require "rb_sys"
cross_rubies = %w[3.3.0 3.2.0 3.1.0 3.0.0]
cross_platforms = %w[
aarch64-linux
arm64-darwin
x86_64-darwin
x86_64-linux
x86_64-linux-musl
x64-mingw32
x64-mingw-ucrt
]
spec = Bundler.load_gemspec("y-rb.gemspec")
Gem::PackageTask.new(spec)
Rake::ExtensionTask.new("yrb", spec) do |ext|
ext.source_pattern = "*.{rs,toml}"
ext.cross_compile = true
ext.cross_platform = cross_platforms
ext.config_script = ENV["ALTERNATE_CONFIG_SCRIPT"] || "extconf.rb"
ext.cross_compiling do |c|
c.files.reject! { |file| File.fnmatch?("*.tar.gz", file) }
c.dependencies.reject! { |dep| dep.name == "rb-sys" }
end
end
namespace "gem" do
task "prepare" do
sh "bundle"
end
cross_platforms.each do |plat|
desc "Build the native gem for #{plat}"
task plat => "prepare" do
require "rake_compiler_dock"
ENV["RCD_IMAGE"] = "rbsys/#{plat}:#{RbSys::VERSION}"
RakeCompilerDock.sh <<~SH, platform: plat
bundle && \
RUBY_CC_VERSION="#{cross_rubies.join(":")}" \
rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem
SH
end
end
end
begin
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec, [] => [:compile])
task test: :spec
task default: %i[test]
RSpec::Core::RakeTask.new(:bench, [] => [:compile]) do |t|
t.rspec_opts = "--tag bench"
end
rescue LoadError
# Ok
end
begin
require "rubocop/rake_task"
RuboCop::RakeTask.new
rescue LoadError
# Ok
end
begin
require "yard"
YARD::Rake::YardocTask.new
task :docs do
`yard server --reload`
end
rescue LoadError
# Ok
end