Upgrade to 1.46.0
[platform/upstream/nghttp2.git] / third-party / mruby / mrbgems / mruby-compiler / mrbgem.rake
1 MRuby::Gem::Specification.new 'mruby-compiler' do |spec|
2   spec.license = 'MIT'
3   spec.author  = 'mruby developers'
4   spec.summary = 'mruby compiler library'
5
6   lex_def = "#{dir}/core/lex.def"
7   core_objs = Dir.glob("#{dir}/core/*.c").map { |f|
8     next nil if build.cxx_exception_enabled? and f =~ /(codegen).c$/
9     objfile(f.pathmap("#{build_dir}/core/%n"))
10   }.compact
11
12   if build.cxx_exception_enabled?
13     core_objs <<
14       build.compile_as_cxx("#{dir}/core/y.tab.c", "#{build_dir}/core/y.tab.cxx",
15                            objfile("#{build_dir}/y.tab"), ["#{dir}/core"]) <<
16       build.compile_as_cxx("#{dir}/core/codegen.c", "#{build_dir}/core/codegen.cxx")
17   else
18     core_objs << objfile("#{build_dir}/core/y.tab")
19     file objfile("#{build_dir}/core/y.tab") => "#{dir}/core/y.tab.c" do |t|
20       cc.run t.name, t.prerequisites.first, [], ["#{dir}/core"]
21     end
22   end
23
24   # Parser
25   file "#{dir}/core/y.tab.c" => ["#{dir}/core/parse.y", lex_def] do |t|
26     yacc.run t.name, t.prerequisites.first
27     content = File.read(t.name).gsub(/^#line +\d+ +"\K.*$/){$&.relative_path}
28     File.write(t.name, content)
29   end
30
31   # Lexical analyzer
32   file lex_def => "#{dir}/core/keywords" do |t|
33     gperf.run t.name, t.prerequisites.first
34   end
35
36   file build.libmruby_core_static => core_objs
37   build.libmruby << core_objs
38 end