-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathRakefile
More file actions
85 lines (71 loc) · 2.11 KB
/
Rakefile
File metadata and controls
85 lines (71 loc) · 2.11 KB
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
require 'fileutils'
require 'shellwords'
MRUBY_VERSION = '3.4.0'
file :mruby do
if RUBY_PLATFORM.match(/solaris/)
sh "git clone --branch=#{MRUBY_VERSION} https://github.com/mruby/mruby"
else
sh "curl -L --fail --retry 3 --retry-delay 1 https://github.com/mruby/mruby/archive/#{MRUBY_VERSION}.tar.gz -s -o - | tar zxf -"
FileUtils.mv("mruby-#{MRUBY_VERSION}", 'mruby')
end
end
CROSS_TARGETS = %w[
linux-x86_64
linux-i386
linux-armhf
linux-aarch64
darwin-x86_64
darwin-aarch64
]
STRIP_TARGETS = %w[
linux-x86_64
linux-i386
]
# avoid redefining constants in mruby Rakefile
mruby_root = File.expand_path(ENV['MRUBY_ROOT'] || "#{Dir.pwd}/mruby")
mruby_config = File.expand_path(ENV['MRUBY_CONFIG'] || 'build_config.rb')
ENV['MRUBY_ROOT'] = mruby_root
ENV['MRUBY_CONFIG'] = mruby_config
Rake::Task[:mruby].invoke unless Dir.exist?(mruby_root)
Dir.chdir(mruby_root)
load "#{mruby_root}/Rakefile"
desc 'run serverspec'
task 'test:integration' do
Dir.chdir(__dir__) do
sh 'bundle check || bundle install -j4'
sh 'bundle exec rspec'
end
end
desc 'compile binary'
task compile: :all
desc 'cleanup'
task :clean do
sh 'rake deep_clean'
end
desc 'cross compile for release'
task 'release:build' => CROSS_TARGETS.map { |target| "release:build:#{target}" }
CROSS_TARGETS.each do |target|
desc "Build for #{target}"
task "release:build:#{target}" do
Dir.chdir(__dir__) do
# Workaround: Running `rake compile` twice breaks mattn/mruby-onig-regexp
FileUtils.rm_rf('mruby/build')
sh "rake compile BUILD_TARGET=#{target.shellescape}"
FileUtils.mkdir_p('mitamae-build')
os, arch = target.split('-', 2)
bin = "mitamae-build/mitamae-#{arch}-#{os}"
sh "cp mruby/build/#{target.shellescape}/bin/mitamae #{bin.shellescape}"
if STRIP_TARGETS.include?(target)
sh "strip --strip-unneeded #{bin.shellescape}"
end
end
end
end
desc 'compress binaries in mitamae-build'
task 'release:compress' do
Dir.chdir(File.expand_path('./mitamae-build', __dir__)) do
Dir.glob('mitamae-*').each do |path|
sh "tar zcvf #{path}.tar.gz #{path}"
end
end
end