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
|
MRuby.each_target do
current_dir = File.dirname(__FILE__).relative_path_from(Dir.pwd)
relative_from_root = File.dirname(__FILE__).relative_path_from(MRUBY_ROOT)
current_build_dir = "#{build_dir}/#{relative_from_root}"
lex_def = "#{current_dir}/lex.def"
objs = Dir.glob("#{current_dir}/*.c").map { |f|
next nil if cxx_abi_enabled? and f =~ /(codegen|error|vm).c$/
objfile(f.pathmap("#{current_build_dir}/%n"))
}.compact
if cxx_abi_enabled?
cxx_abi_dependency = %w(codegen error vm)
cxx_abi_objs = cxx_abi_dependency.map { |v|
src = "#{current_build_dir}/#{v}.cxx"
file src => "#{current_dir}/#{v}.c" do |t|
File.open(t.name, 'w') do |f|
f.write <<EOS
#define __STDC_CONSTANT_MACROS
#define __STDC_LIMIT_MACROS
extern "C" {
#include "#{MRUBY_ROOT}/#{t.prerequisites.first}"
}
#{v == 'error'? 'mrb_int mrb_jmpbuf::jmpbuf_id = 0;' : ''}
EOS
end
end
file objfile(src) => src do |t|
cxx.run t.name, t.prerequisites.first, [], [current_dir]
end
objfile src
}
cxx_abi_objs << objfile("#{current_build_dir}/y.tab")
file "#{current_build_dir}/y.tab.cxx" => "#{current_build_dir}/y.tab.c" do |t|
File.open(t.name, 'w') do |f|
f.write <<EOS
#define __STDC_CONSTANT_MACROS
#define __STDC_LIMIT_MACROS
extern "C" {
#include "#{t.prerequisites.first}"
}
EOS
end
end
file objfile("#{current_build_dir}/y.tab") => ["#{current_build_dir}/y.tab.cxx", lex_def] do |t|
cxx.run t.name, t.prerequisites.first, [], [current_dir]
end
objs += cxx_abi_objs
else
objs += [objfile("#{current_build_dir}/y.tab")]
file objfile("#{current_build_dir}/y.tab") => ["#{current_build_dir}/y.tab.c", lex_def] do |t|
cc.run t.name, t.prerequisites.first, [], [current_dir]
end
end
self.libmruby << objs
file libfile("#{build_dir}/lib/libmruby_core") => objs do |t|
archiver.run t.name, t.prerequisites
end
# Parser
file "#{current_build_dir}/y.tab.c" => ["#{current_dir}/parse.y"] do |t|
yacc.run t.name, t.prerequisites.first
end
# Lexical analyzer
file lex_def => "#{current_dir}/keywords" do |t|
gperf.run t.name, t.prerequisites.first
end
end
|