forked from picoruby/picoruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
166 lines (140 loc) · 4.06 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# encoding: utf-8
# Build description.
# basic build file for mruby
MRUBY_ROOT = File.dirname(File.expand_path(__FILE__))
MRUBY_BUILD_HOST_IS_CYGWIN = RUBY_PLATFORM.include?('cygwin')
MRUBY_BUILD_HOST_IS_OPENBSD = RUBY_PLATFORM.include?('openbsd')
Rake.verbose(false) if Rake.verbose == Rake::DSL::DEFAULT
$LOAD_PATH << File.join(MRUBY_ROOT, "lib")
# load build systems
require "mruby/core_ext"
require "mruby/build"
require "picoruby/build"
# load configuration file
MRUBY_CONFIG = MRuby::Build.mruby_config_path
load MRUBY_CONFIG
# load basic rules
MRuby.each_target do |build|
build.define_rules
end
# load custom rules
load "#{MRUBY_ROOT}/tasks/core.rake"
load "#{MRUBY_ROOT}/tasks/mrblib.rake"
load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
# Customized for PicoRuby. This should be loaded before libmruby.rake
load "#{MRUBY_ROOT}/tasks/picogems.rake"
load "#{MRUBY_ROOT}/tasks/libmruby.rake"
load "#{MRUBY_ROOT}/tasks/bin.rake"
load "#{MRUBY_ROOT}/tasks/presym.rake"
#load "#{MRUBY_ROOT}/tasks/test.rake"
load "#{MRUBY_ROOT}/tasks/benchmark.rake"
load "#{MRUBY_ROOT}/tasks/gitlab.rake"
load "#{MRUBY_ROOT}/tasks/doc.rake"
##############################
# generic build targets, rules
task :default => :all
desc "build all targets, install (locally) in-repo"
task :all => :gensym do
Rake::Task[:build].invoke
puts
puts "Build summary:"
puts
MRuby.each_target do |build|
build.print_build_summary
end
# MRuby::Lockfile.write
end
task :build => MRuby.targets.flat_map{|_, build| build.products}
desc "clean all built and in-repo installed artifacts"
task :clean do
MRuby.each_target do |build|
if Dir.exist? build.gems['mruby-pico-compiler'].dir
Dir.chdir build.gems['mruby-pico-compiler'].dir do
sh "rake clean"
end
end
rm_rf build.build_dir
rm_f build.products
end
puts "Cleaned up target build folder"
end
desc "clean everything!"
task :deep_clean => %w[clean doc:clean] do
MRuby.each_target do |build|
rm_rf build.gem_clone_dir
end
FileUtils.cd "mrbgems/picoruby-mrubyc/repos" do
rm_rf "mrubyc"
end
end
##############################
# for PicoRuby
def picorubyfile
"#{`pwd`.chomp}/bin/picoruby"
end
def picorbcfile
"#{`pwd`.chomp}/bin/picorbc"
end
def picoruby_debug?
`#{picorubyfile} -v`.include? "debug build"
end
def picorbc_debug?
`#{picorbcfile} -v`.include? "debug build"
end
def clean_if(clean)
if File.exist? picorubyfile
if clean == :debug && picoruby_debug?
Rake::Task[:clean].invoke
elsif !picoruby_debug?
Rake::Task[:clean].invoke
end
elsif File.exist? picorbcfile
if clean == :debug && plicorbc_debug?
Rake::Task[:clean].invoke
elsif !picorbc_debug?
Rake::Task[:clean].invoke
end
else
# clean anyway
Rake::Task[:clean].invoke
end
end
desc "create production build"
task :production do
clean_if(:debug)
Rake::Task[:all].invoke
end
desc "create debug build"
task :debug do
clean_if(:production)
sh %q{PICORUBY_DEBUG_BUILD=yes rake all}
end
desc "run all tests"
task :test => [:steep, :test_compiler_mrubyc, :test_compiler_mruby]
desc "run compiler tests with mruby VM"
task :test_compiler_mruby => :debug do
ENV['USE_MRUBY'] = "yes"
ENV['PICORBC_COMMAND'] ||= picorbcfile
ENV['MRUBY_COMMAND'] ||= `RBENV_VERSION=mruby-3.2.0 rbenv which mruby`.chomp
if ENV['MRUBY_COMMAND'] && ENV['MRUBY_COMMAND'] != ""
sh "build/repos/host/mruby-pico-compiler/test/helper/test.rb"
else
puts "[WARN] test_compiler_mruby skipped because no mruby found"
end
end
desc "run compiler tests with mruby/c VM"
task :test_compiler_mrubyc => :debug do
ENV['MRUBY_COMMAND'] = picorubyfile
sh "build/repos/host/mruby-pico-compiler/test/helper/test.rb"
ENV['MRUBY_COMMAND'] = nil
end
current_dir = File.dirname(File.expand_path __FILE__)
picorbc_include_dir = "#{current_dir}/build/repos/host/mruby-pico-compiler/include"
desc "create picorbc executable"
task :picorbc => ["#{picorbc_include_dir}/ptr_size.h", "#{picorbc_include_dir}/parse.h"] do
Rake::Task["#{current_dir}/bin/picorbc"].invoke
end
desc "steep check"
task :steep do
sh "bundle exec steep check"
end