-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
83 lines (66 loc) · 1.87 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
require "fileutils"
MRUBY_VERSION = "3.0.0"
task :mruby do
sh "git clone --branch=#{MRUBY_VERSION} --depth=1 https://github.com/mruby/mruby"
end
APP_NAME = ENV["APP_NAME"] || "acli"
APP_ROOT = ENV["APP_ROOT"] || Dir.pwd
# avoid redefining constants in mruby Rakefile
mruby_root = File.expand_path(ENV["MRUBY_ROOT"] || "#{APP_ROOT}/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?(File.join(mruby_root, "lib"))
Dir.chdir(mruby_root)
load "#{mruby_root}/Rakefile"
desc "compile binary"
task compile: [:all] do
%W(#{mruby_root}/build/x86_64-pc-linux-gnu/bin/#{APP_NAME} #{mruby_root}/build/i686-pc-linux-gnu/#{APP_NAME}").each do |bin|
sh "strip --strip-unneeded #{bin}" if File.exist?(bin)
end
end
Rake::Task["test"].clear
desc "run all tests"
task test: ["nextify", "test:build:lib", "test:run:lib", "test:run:bin"]
desc "cleanup"
task :clean do
sh "rake deep_clean"
end
desc "clean host build without deleting gems"
task :host_clean do
sh "rm -rf #{File.join(mruby_root, "build", "host")}"
end
desc "run build"
task run: :default do
exec File.join(mruby_root, "bin", APP_NAME)
end
desc "run mirb"
task irb: :default do
exec File.join(mruby_root, "bin", "mirb")
end
Rake::Task["run"].clear
desc "run compiled binary"
task run: :compile do
args =
if (split_index = ARGV.index("--"))
ARGV[(split_index+1)..-1]
else
[]
end
sh "bin/acli #{args.join(" ")}"
end
desc "transpile source code with ruby-next"
task :nextify do
Dir.chdir(APP_ROOT) do
sh "ruby-next nextify -V"
end
end
namespace :rbnext do
desc "generate core extensions file"
task core_ext: [] do
Dir.chdir(APP_ROOT) do
sh "ruby-next core_ext -o mrblib/acli/core_ext.rb"
end
end
end
Rake::Task[:gensym].enhance [:nextify]