-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Rakefile
94 lines (76 loc) · 2.54 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
# frozen_string_literal: true
require 'rake/extensiontask'
require 'rake_compiler_dock'
require 'rspec/core/rake_task'
require_relative 'ext/re2/recipes'
re2_gemspec = Gem::Specification.load('re2.gemspec')
abseil_recipe, re2_recipe = load_recipes
# Add Abseil and RE2's latest archives to the gem files. (Note these will be
# removed from the precompiled native gems.)
abseil_archive = File.join("ports/archives", File.basename(abseil_recipe.files[0][:url]))
re2_archive = File.join("ports/archives", File.basename(re2_recipe.files[0][:url]))
re2_gemspec.files << abseil_archive
re2_gemspec.files << re2_archive
cross_platforms = %w[
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
x64-mingw-ucrt
x64-mingw32
x86-linux-gnu
x86-linux-musl
x86-mingw32
x86_64-darwin
x86_64-linux-gnu
x86_64-linux-musl
].freeze
ENV['RUBY_CC_VERSION'] = %w[3.4.0 3.3.5 3.2.0 3.1.0].join(':')
Gem::PackageTask.new(re2_gemspec).define
Rake::ExtensionTask.new('re2', re2_gemspec) do |e|
e.cross_compile = true
e.cross_config_options << '--enable-cross-build'
e.config_options << '--disable-system-libraries'
e.cross_platform = cross_platforms
e.cross_compiling do |spec|
spec.files.reject! { |path| File.fnmatch?('ports/*', path) }
spec.dependencies.reject! { |dep| dep.name == 'mini_portile2' }
end
end
RSpec::Core::RakeTask.new(:spec)
begin
require 'ruby_memcheck'
require 'ruby_memcheck/rspec/rake_task'
namespace :spec do
RubyMemcheck::RSpec::RakeTask.new(valgrind: :compile)
end
rescue LoadError
# Only define the spec:valgrind task if ruby_memcheck is installed
end
namespace :gem do
cross_platforms.each do |platform|
# Compile each platform's native gem, packaging up the result. Note we add
# /usr/local/bin to the PATH as it contains the newest version of CMake in
# the rake-compiler-dock images.
desc "Compile and build native gem for #{platform} platform"
task platform do
RakeCompilerDock.sh <<~SCRIPT, platform: platform, verbose: true
gem install bundler --no-document &&
bundle &&
bundle exec rake native:#{platform} pkg/#{re2_gemspec.full_name}-#{Gem::Platform.new(platform)}.gem PATH="/usr/local/bin:$PATH"
SCRIPT
end
end
end
# Set up file tasks for Abseil and RE2's archives so they are automatically
# downloaded when required by the gem task.
file abseil_archive do
abseil_recipe.download
end
file re2_archive do
re2_recipe.download
end
task default: :spec
CLEAN.add("lib/**/*.{o,so,bundle}", "pkg")
CLOBBER.add("ports")