@@ -16,7 +16,6 @@ mruby_config=File.expand_path(ENV["MRUBY_CONFIG"] || "build_config.rb")
1616ENV [ 'MRUBY_ROOT' ] = mruby_root
1717ENV [ 'MRUBY_CONFIG' ] = mruby_config
1818Rake ::Task [ :mruby ] . invoke unless Dir . exist? ( mruby_root )
19- Dir . chdir ( mruby_root )
2019load "#{ mruby_root } /Rakefile"
2120
2221load File . join ( File . expand_path ( File . dirname ( __FILE__ ) ) , "mrbgem.rake" )
@@ -25,27 +24,31 @@ current_gem = MRuby::Gem.current
2524app_version = MRuby ::Gem . current . version
2625APP_VERSION = ( app_version . nil? || app_version . empty? ) ? "unknown" : app_version
2726
28- desc "compile all the binaries "
27+ desc "compile binary "
2928task :compile => [ :all ] do
30- MRuby . each_target do |target |
31- `#{ target . cc . command } --version`
32- abort ( "Command #{ target . cc . command } for #{ target . name } is missing." ) unless $?. success?
33- end
34- %W( #{ mruby_root } /build/x86_64-pc-linux-gnu/bin/#{ APP_NAME } #{ mruby_root } /build/i686-pc-linux-gnu/#{ APP_NAME } ") . each do |bin |
35- sh "strip --strip-unneeded #{ bin } " if File . exist? ( bin )
29+ Dir . chdir ( mruby_root ) do
30+ MRuby . each_target do |target |
31+ `#{ target . cc . command } --version`
32+ abort ( "Command #{ target . cc . command } for #{ target . name } is missing." ) unless $?. success?
33+ end
34+ %W( #{ mruby_root } /build/x86_64-pc-linux-gnu/bin/#{ APP_NAME } #{ mruby_root } /build/i686-pc-linux-gnu/#{ APP_NAME } ) . each do |bin |
35+ sh "strip --strip-unneeded #{ bin } " if File . exist? ( bin )
36+ end
3637 end
3738end
3839
3940namespace :test do
4041 desc "run mruby & unit tests"
4142 # only build mtest for host
4243 task :mtest => :compile do
43- # in order to get mruby/test/t/synatx.rb __FILE__ to pass,
44- # we need to make sure the tests are built relative from mruby_root
45- MRuby . each_target do |target |
46- # only run unit tests here
47- target . enable_bintest = false
48- run_test if target . test_enabled?
44+ Dir . chdir ( mruby_root ) do
45+ # in order to get mruby/test/t/synatx.rb __FILE__ to pass,
46+ # we need to make sure the tests are built relative from mruby_root
47+ MRuby . each_target do |target |
48+ # only run unit tests here
49+ target . enable_bintest = false
50+ run_test if target . test_enabled?
51+ end
4952 end
5053 end
5154
@@ -63,21 +66,25 @@ namespace :test do
6366
6467 desc "run integration tests"
6568 task :bintest => :compile do
66- MRuby . each_target do |target |
67- clean_env ( %w( MRUBY_ROOT MRUBY_CONFIG ) ) do
68- run_bintest if target . bintest_enabled?
69+ Dir . chdir ( mruby_root ) do
70+ MRuby . each_target do |target |
71+ clean_env ( %w( MRUBY_ROOT MRUBY_CONFIG ) ) do
72+ run_bintest if target . bintest_enabled?
73+ end
6974 end
7075 end
7176 end
7277end
7378
7479desc "run all tests"
7580Rake ::Task [ 'test' ] . clear
76- task :test => [ ' test:bintest' , ' test:mtest' ]
81+ task :test => [ " test:mtest" , " test:bintest" ]
7782
7883desc "cleanup"
7984task :clean do
80- sh "rake deep_clean"
85+ Dir . chdir ( mruby_root ) do
86+ sh "rake deep_clean"
87+ end
8188end
8289
8390desc "generate a release tarball"
@@ -133,8 +140,7 @@ Rake.application.tasks.each do |task|
133140 old_task = Rake . application . instance_variable_get ( '@tasks' ) . delete ( task . name )
134141 desc old_task . full_comment
135142 task old_task . name => old_task . prerequisites do
136- abort ( "Not running in docker, you should type \" docker-compose run <task>\" ." ) \
137- unless is_in_a_docker_container?
143+ abort ( "Not running in docker, you should type \" docker-compose run <task>\" ." ) unless is_in_a_docker_container?
138144 old_task . invoke
139145 end
140146 end
0 commit comments