8 self.libmruby_objs << objfile("#{build_dir}/mrbgems/gem_init")
9 file objfile("#{build_dir}/mrbgems/gem_init") => ["#{build_dir}/mrbgems/gem_init.c", "#{build_dir}/LEGAL"]
10 file "#{build_dir}/mrbgems/gem_init.c" => [MRUBY_CONFIG, __FILE__] do |t|
11 FileUtils.mkdir_p "#{build_dir}/mrbgems"
12 open(t.name, 'w') do |f|
13 gem_func_gems = gems.select { |g| g.generate_functions }
14 gem_func_decls = gem_func_gems.each_with_object('') do |g, s|
15 s << "void GENERATED_TMP_mrb_#{g.funcname}_gem_init(mrb_state*);\n" \
16 "void GENERATED_TMP_mrb_#{g.funcname}_gem_final(mrb_state*);\n"
18 gem_init_calls = gem_func_gems.each_with_object('') do |g, s|
19 s << " GENERATED_TMP_mrb_#{g.funcname}_gem_init(mrb);\n"
21 gem_final_calls = gem_func_gems.reverse_each.with_object('') do |g, s|
22 s << " GENERATED_TMP_mrb_#{g.funcname}_gem_final(mrb);\n"
25 f.puts %Q[ * This file contains a list of all]
26 f.puts %Q[ * initializing methods which are]
27 f.puts %Q[ * necessary to bootstrap all gems.]
29 f.puts %Q[ * IMPORTANT:]
30 f.puts %Q[ * This file was generated!]
31 f.puts %Q[ * All manual changes will get lost.]
34 f.puts %Q[#include <mruby.h>]
36 f.write gem_func_decls
37 unless gem_final_calls.empty?
39 f.puts %Q[static void]
40 f.puts %Q[mrb_final_mrbgems(mrb_state *mrb) {]
41 f.write gem_final_calls
46 f.puts %Q[mrb_init_mrbgems(mrb_state *mrb) {]
47 f.write gem_init_calls
48 f.puts %Q[ mrb_state_atexit(mrb, mrb_final_mrbgems);] unless gem_final_calls.empty?
55 file "#{build_dir}/LEGAL" => [MRUBY_CONFIG, __FILE__] do |t|
56 FileUtils.mkdir_p File.dirname t.name
57 open(t.name, 'w+') do |f|
59 Copyright (c) #{Time.now.year} mruby developers
61 Permission is hereby granted, free of charge, to any person obtaining a
62 copy of this software and associated documentation files (the "Software"),
63 to deal in the Software without restriction, including without limitation
64 the rights to use, copy, modify, merge, publish, distribute, sublicense,
65 and/or sell copies of the Software, and to permit persons to whom the
66 Software is furnished to do so, subject to the following conditions:
68 The above copyright notice and this permission notice shall be included in
69 all copies or substantial portions of the Software.
71 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
74 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
76 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
77 DEALINGS IN THE SOFTWARE.
85 Due to the reason that you choosed additional mruby packages (GEMS),
86 please check the following additional licenses too:
90 authors = [g.authors].flatten.sort.join(", ")
92 f.puts "GEM: #{g.name}"
93 f.puts "Copyright (c) #{Time.now.year} #{authors}"
94 f.puts "License: #{g.licenses}"