-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
49 lines (39 loc) · 1.1 KB
/
Rakefile
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
MRUBY_CONFIG = File.expand_path(ENV['MRUBY_CONFIG'] || 'build_config.rb')
rb_scripts = Dir.glob('./scripts/*.rb').sort
mrb_script = 'build/scripts_compiled.h'
mruby_lib = 'mruby/build/host/lib/libmruby.a'
task default: :game
file :mruby do
sh 'git clone --depth 1 git://github.com/mruby/mruby.git'
end
desc 'test game scripts'
task :test do
sh 'rspec'
end
desc 'cleanup'
task :clean do
sh 'rm -rf mruby'
sh 'rm -rf build'
end
file mruby_lib => :mruby do
sh "cd mruby && MRUBY_CONFIG=#{MRUBY_CONFIG} rake all"
end
file mrb_script => rb_scripts + [mruby_lib] do |_task|
sh 'mkdir -p build'
mrbc = 'mruby/build/host/bin/mrbc'
sh "#{mrbc} -g -o #{mrb_script} -Bmrb_scripts #{rb_scripts.join(' ')}"
end
file 'build/game' => [mrb_script, mruby_lib, 'src/main.cpp'] do
sh 'mkdir -p build'
compiler = (ENV['CXX'] || 'g++')
libs = '-lsfml-graphics -lsfml-window -lsfml-system'
includes = '-Imruby/include'
sh "#{compiler} #{includes} src/main.cpp #{libs} #{mruby_lib} -o build/game"
end
desc 'build game'
task game: ['build/game'] do
end
desc 'run game'
task run: :game do
sh './build/game'
end