source: EcnlProtoTool/trunk/mruby-1.2.0/Rakefile@ 321

Last change on this file since 321 was 270, checked in by coas-nagasima, 7 years ago

mruby版ECNLプロトタイピング・ツールを追加

File size: 4.6 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
8# load build systems
9load "#{MRUBY_ROOT}/tasks/ruby_ext.rake"
10load "#{MRUBY_ROOT}/tasks/mruby_build.rake"
11load "#{MRUBY_ROOT}/tasks/mrbgem_spec.rake"
12
13# load configuration file
14MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb"
15load MRUBY_CONFIG
16
17# load basic rules
18MRuby.each_target do |build|
19 build.define_rules
20end
21
22# load custom rules
23load "#{MRUBY_ROOT}/src/mruby_core.rake"
24load "#{MRUBY_ROOT}/mrblib/mrblib.rake"
25
26load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
27load "#{MRUBY_ROOT}/tasks/libmruby.rake"
28
29load "#{MRUBY_ROOT}/tasks/benchmark.rake"
30
31##############################
32# generic build targets, rules
33task :default => :all
34
35bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
36FileUtils.mkdir_p bin_path, { :verbose => $verbose }
37
38depfiles = MRuby.targets['host'].bins.map do |bin|
39 install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
40 source_path = MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/#{bin}")
41
42 file install_path => source_path do |t|
43 FileUtils.rm_f t.name, { :verbose => $verbose }
44 FileUtils.cp t.prerequisites.first, t.name, { :verbose => $verbose }
45 end
46
47 install_path
48end
49
50MRuby.each_target do |target|
51 gems.map do |gem|
52 current_dir = gem.dir.relative_path_from(Dir.pwd)
53 relative_from_root = gem.dir.relative_path_from(MRUBY_ROOT)
54 current_build_dir = File.expand_path "#{build_dir}/#{relative_from_root}"
55
56 if current_build_dir !~ /^#{build_dir}/
57 current_build_dir = "#{build_dir}/mrbgems/#{gem.name}"
58 end
59
60 gem.bins.each do |bin|
61 exec = exefile("#{build_dir}/bin/#{bin}")
62 objs = Dir.glob("#{current_dir}/tools/#{bin}/*.{c,cpp,cxx,cc}").map { |f| objfile(f.pathmap("#{current_build_dir}/tools/#{bin}/%n")) }
63
64 file exec => objs + [libfile("#{build_dir}/lib/libmruby")] do |t|
65 gem_flags = gems.map { |g| g.linker.flags }
66 gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
67 gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries }
68 gem_libraries = gems.map { |g| g.linker.libraries }
69 gem_library_paths = gems.map { |g| g.linker.library_paths }
70 linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries, gem_flags_after_libraries
71 end
72
73 if target == MRuby.targets['host']
74 install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
75
76 file install_path => exec do |t|
77 FileUtils.rm_f t.name, { :verbose => $verbose }
78 FileUtils.cp t.prerequisites.first, t.name, { :verbose => $verbose }
79 end
80 depfiles += [ install_path ]
81 elsif target == MRuby.targets['host-debug']
82 unless MRuby.targets['host'].gems.map {|g| g.bins}.include?([bin])
83 install_path = MRuby.targets['host-debug'].exefile("#{bin_path}/#{bin}")
84
85 file install_path => exec do |t|
86 FileUtils.rm_f t.name, { :verbose => $verbose }
87 FileUtils.cp t.prerequisites.first, t.name, { :verbose => $verbose }
88 end
89 depfiles += [ install_path ]
90 end
91 else
92 depfiles += [ exec ]
93 end
94 end
95 end
96end
97
98depfiles += MRuby.targets.map { |n, t|
99 [t.libfile("#{t.build_dir}/lib/libmruby")]
100}.flatten
101
102depfiles += MRuby.targets.reject { |n, t| n == 'host' }.map { |n, t|
103 t.bins.map { |bin| t.exefile("#{t.build_dir}/bin/#{bin}") }
104}.flatten
105
106desc "build all targets, install (locally) in-repo"
107task :all => depfiles do
108 puts
109 puts "Build summary:"
110 puts
111 MRuby.each_target do
112 print_build_summary
113 end
114end
115
116desc "run all mruby tests"
117task :test => ["all"] do
118 MRuby.each_target do
119 run_test if test_enabled?
120 end
121end
122
123desc "clean all built and in-repo installed artifacts"
124task :clean do
125 MRuby.each_target do |t|
126 FileUtils.rm_rf t.build_dir, { :verbose => $verbose }
127 end
128 FileUtils.rm_f depfiles, { :verbose => $verbose }
129 puts "Cleaned up target build folder"
130end
131
132desc "clean everything!"
133task :deep_clean => ["clean"] do
134 MRuby.each_target do |t|
135 FileUtils.rm_rf t.gem_clone_dir, { :verbose => $verbose }
136 end
137 puts "Cleaned up mrbgems build folder"
138end
139
140desc 'generate document'
141task :doc do
142 begin
143 sh "mrbdoc"
144 rescue
145 puts "ERROR: To generate documents, you should install yard-mruby gem."
146 puts " $ gem install yard-mruby"
147 end
148end
Note: See TracBrowser for help on using the repository browser.