source: EcnlProtoTool/trunk/mruby-2.1.1/Rakefile@ 439

Last change on this file since 439 was 439, checked in by coas-nagasima, 4 years ago

mrubyを2.1.1に更新

File size: 4.5 KB
Line 
1# encoding: utf-8
2# Build description.
3# basic build file for mruby
4MRUBY_ROOT = File.dirname(File.expand_path(__FILE__))
5MRUBY_BUILD_HOST_IS_CYGWIN = RUBY_PLATFORM.include?('cygwin')
6MRUBY_BUILD_HOST_IS_OPENBSD = RUBY_PLATFORM.include?('openbsd')
7
8Rake.verbose(false) if Rake.verbose == Rake::DSL::DEFAULT
9
10$LOAD_PATH << File.join(MRUBY_ROOT, "lib")
11
12# load build systems
13require "mruby-core-ext"
14require "mruby/build"
15
16# load configuration file
17MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb"
18load MRUBY_CONFIG
19
20# load basic rules
21MRuby.each_target do |build|
22 build.define_rules
23end
24
25# load custom rules
26load "#{MRUBY_ROOT}/src/mruby_core.rake"
27load "#{MRUBY_ROOT}/mrblib/mrblib.rake"
28
29load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
30load "#{MRUBY_ROOT}/tasks/libmruby.rake"
31
32load "#{MRUBY_ROOT}/tasks/benchmark.rake"
33
34load "#{MRUBY_ROOT}/tasks/gitlab.rake"
35load "#{MRUBY_ROOT}/tasks/doc.rake"
36
37def install_D(src, dst)
38 rm_f dst
39 mkdir_p File.dirname(dst)
40 cp src, dst
41end
42
43##############################
44# generic build targets, rules
45task :default => :all
46
47bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
48
49depfiles = MRuby.targets['host'].bins.map do |bin|
50 install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
51 source_path = MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/#{bin}")
52
53 file install_path => source_path do |t|
54 install_D t.prerequisites.first, t.name
55 end
56
57 install_path
58end
59
60MRuby.each_target do |target|
61 gems.map do |gem|
62 current_dir = gem.dir.relative_path_from(Dir.pwd)
63 relative_from_root = gem.dir.relative_path_from(MRUBY_ROOT)
64 current_build_dir = File.expand_path "#{build_dir}/#{relative_from_root}"
65
66 if current_build_dir !~ /^#{Regexp.escape(build_dir)}/
67 current_build_dir = "#{build_dir}/mrbgems/#{gem.name}"
68 end
69
70 gem.bins.each do |bin|
71 exec = exefile("#{build_dir}/bin/#{bin}")
72 objs = Dir.glob("#{current_dir}/tools/#{bin}/*.{c,cpp,cxx,cc}").map { |f| objfile(f.pathmap("#{current_build_dir}/tools/#{bin}/%n")) }
73
74 file exec => objs + target.libraries do |t|
75 gem_flags = gems.map { |g| g.linker.flags }
76 gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
77 gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries }
78 gem_libraries = gems.map { |g| g.linker.libraries }
79 gem_library_paths = gems.map { |g| g.linker.library_paths }
80 linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries, gem_flags_after_libraries
81
82 gem.call_post_build_event target
83 end
84
85 if target == MRuby.targets['host']
86 install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
87
88 file install_path => exec do |t|
89 install_D t.prerequisites.first, t.name
90 end
91 depfiles += [ install_path ]
92 elsif target == MRuby.targets['host-debug']
93 unless MRuby.targets['host'].gems.map {|g| g.bins}.include?([bin])
94 install_path = MRuby.targets['host-debug'].exefile("#{bin_path}/#{bin}")
95
96 file install_path => exec do |t|
97 install_D t.prerequisites.first, t.name
98 end
99 depfiles += [ install_path ]
100 end
101 else
102 depfiles += [ exec ]
103 end
104 end
105 end
106end
107
108depfiles += MRuby.targets.map { |n, t|
109 t.libraries
110}.flatten
111
112depfiles += MRuby.targets.reject { |n, t| n == 'host' }.map { |n, t|
113 t.bins.map { |bin| t.exefile("#{t.build_dir}/bin/#{bin}") }
114}.flatten
115
116desc "build all targets, install (locally) in-repo"
117task :all => depfiles do
118 puts
119 puts "Build summary:"
120 puts
121 MRuby.each_target do
122 print_build_summary
123 end
124 MRuby::Lockfile.write
125end
126
127desc "run all mruby tests"
128task :test
129MRuby.each_target do
130 if test_enabled?
131 t = :"test_#{self.name}"
132 task t => ["all"] do
133 run_test
134 end
135 task :test => t
136 end
137
138 if bintest_enabled?
139 t = :"bintest_#{self.name}"
140 task t => ["all"] do
141 run_bintest
142 end
143 task :test => t
144 end
145end
146
147desc "clean all built and in-repo installed artifacts"
148task :clean do
149 MRuby.each_target do |t|
150 rm_rf t.build_dir
151 end
152 rm_f depfiles
153 puts "Cleaned up target build folder"
154end
155
156desc "clean everything!"
157task :deep_clean => ["clean", "clean_doc"] do
158 MRuby.each_target do |t|
159 rm_rf t.gem_clone_dir
160 end
161 puts "Cleaned up mrbgems build folder"
162end
Note: See TracBrowser for help on using the repository browser.