summaryrefslogtreecommitdiffhomepage
path: root/Rakefile
blob: da42755f844ca21d97ec29f4dd597138c0d43db5 (plain)
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
# encoding: utf-8
# Build description.
# basic build file for mruby

load 'tasks/ruby_ext.rake'
load 'tasks/mruby_build.rake'
load 'tasks/mruby_gem_spec.rake'

##############################
# compile flags
load File.expand_path(ENV['CONFIG'] || './build_config.rb')

load 'tasks/rules.rake'
load 'src/mruby_core.rake'
load 'mrblib/mrblib.rake'
load 'tools/mrbc/mrbc.rake'

load 'tasks/mrbgems.rake'
load 'tasks/libmruby.rake'
load 'tools/mruby/mruby.rake'
load 'tools/mirb/mirb.rake'
load 'test/mrbtest.rake'

##############################
# generic build targets, rules
task :default => :all

binfiles = [exefile('bin/mruby'), exefile('bin/mirb'), exefile('bin/mrbc')]

desc "build all targets, install (locally) in-repo"
task :all => binfiles + MRuby.targets.map { |t| [exefile("#{t.build_dir}/bin/mruby"), exefile("#{t.build_dir}/bin/mirb"), exefile("#{t.build_dir}/bin/mrbc")] }.flatten

file exefile('bin/mruby') => exefile('build/host/bin/mruby') do |t|
  FileUtils.cp t.prerequisites.first, t.name
end

file exefile('bin/mirb') => exefile('build/host/bin/mirb') do |t|
  FileUtils.cp t.prerequisites.first, t.name
end

file exefile('bin/mrbc') => exefile('build/host/bin/mrbc') do |t|
  FileUtils.cp t.prerequisites.first, t.name
end

desc "run all mruby tests"
task :test => MRuby.targets.map { |t| exefile("#{t.build_dir}/test/mrbtest") } do
  sh "#{filename exefile('build/host/test/mrbtest')}"
  if MRuby.targets.count > 1
    puts "\nYou should run #{MRuby.targets.map{ |t| t.name == 'host' ? nil : "#{t.build_dir}/test/mrbtest" }.compact.join(', ')} on target device."
  end
end

desc "clean all built and in-repo installed artifacts"
task :clean do
  MRuby.targets.each do |t|
    FileUtils.rm_rf t.build_dir
  end
  FileUtils.rm_f binfiles
end