diff options
| author | Yuichiro MASUI <[email protected]> | 2012-12-29 05:37:55 +0900 |
|---|---|---|
| committer | Yuichiro MASUI <[email protected]> | 2013-01-03 02:24:15 +0900 |
| commit | 7c469c0b9dadd1de09fed18c3e5cc551012c38c1 (patch) | |
| tree | b79aa703ef7c528896c4f1be8280d0691314008b /Rakefile | |
| parent | a48fc0d7952ad1f10ae777637269fe6a3f9ad0a2 (diff) | |
| download | mruby-7c469c0b9dadd1de09fed18c3e5cc551012c38c1.tar.gz mruby-7c469c0b9dadd1de09fed18c3e5cc551012c38c1.zip | |
Rebuild CRuby based building script without Makefile
Tested CRuby 1.8.6 and 1.9.3
You can see building configuration in build_config.rb
Diffstat (limited to 'Rakefile')
| -rw-r--r-- | Rakefile | 124 |
1 files changed, 36 insertions, 88 deletions
@@ -1,111 +1,59 @@ +# encoding: utf-8 # Build description. # basic build file for mruby -# compiler, linker (gcc), archiver, parser generator -CC = ENV['CC'] || 'gcc' -LL = ENV['LL'] || 'gcc' -AR = ENV['AR'] || 'ar' -YACC = ENV['YACC'] || 'bison' -MAKE = ENV['MAKE'] || 'make' - -# mruby source root path -MRUBY_ROOT = ENV['MRUBY_ROOT'] || File.expand_path(File.dirname(__FILE__)) - -# by default GEMs are deactivated -ENABLE_GEMS = ENV['ENABLE_GEMS'] == 'true' - -# the default file which contains the active GEMs -ACTIVE_GEMS = ENV['ACTIVE_GEMS'] || File.join(MRUBY_ROOT, '/mrbgems/GEMS.active') - -# default compile option -COMPILE_MODE = ENV['COMPILE_MODE'] || :debug - +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') -case COMPILE_MODE.to_s -when 'release' - CFLAGS = ['-O3'] -when 'small' - CFLAGS = ['-Os'] -else # including 'debug' - e = ENV['CFLAGS'] - CFLAGS = if e then [e] else ['-g', '-O3'] end -end -LDFLAGS = [ENV['LDFLAGS']] -LIBS = [ENV['LIBS'] || '-lm'] - -if ENABLE_GEMS - require './mrbgems/build_tasks' - Rake::Task[:load_mrbgems_flags].invoke -else - CFLAGS << "-DDISABLE_GEMS" -end - -CFLAGS << "-Wall" << "-Werror-implicit-function-declaration" << "-I#{MRUBY_ROOT}/include" - -if ENV['OS'] == 'Windows_NT' - MAKE_FLAGS = "--no-print-directory CC=#{CC} LL=#{LL} AR=#{AR} YACC=#{YACC} CFLAGS=\"#{CFLAGS.join(' ')}\" LDFLAGS=\"#{LDFLAGS.join(' ')}\" LIBS=\"#{LIBS.join(' ')}\" ENABLE_GEMS=\"#{ENABLE_GEMS}\" MRUBY_ROOT=\"#{MRUBY_ROOT}\"" -else - MAKE_FLAGS = "--no-print-directory CC='#{CC}' LL='#{LL}' AR='#{AR}' YACC='#{YACC}' CFLAGS='#{CFLAGS.join(' ')}' LDFLAGS='#{LDFLAGS.join(' ')}' LIBS='#{LIBS.join(' ')}' ENABLE_GEMS='#{ENABLE_GEMS}' MRUBY_ROOT='#{MRUBY_ROOT}'" -end +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' ############################## -# internal variables +# generic build targets, rules +task :default => :all -CP = ENV['CP'] ||= 'cp' -RM_F = ENV['RM_F'] ||= 'rm -f' -CAT = ENV['CAT'] ||= 'cat' +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 -############################## -# generic build targets, rules +file exefile('bin/mruby') => exefile('build/host/bin/mruby') do |t| + FileUtils.cp t.prerequisites.first, t.name +end -task :default => :all +file exefile('bin/mirb') => exefile('build/host/bin/mirb') do |t| + FileUtils.cp t.prerequisites.first, t.name +end -desc "build all targets, install (locally) in-repo" -task :all do - sh "#{MAKE} -C src #{MAKE_FLAGS}" - sh "#{MAKE} -C mrblib #{MAKE_FLAGS}" - if ENABLE_GEMS - puts "-- MAKE mrbgems --" - Rake::Task['mrbgems_all'].invoke - end - sh "#{MAKE} -C tools/mruby #{MAKE_FLAGS}" - sh "#{MAKE} -C tools/mirb #{MAKE_FLAGS}" +file exefile('bin/mrbc') => exefile('build/host/bin/mrbc') do |t| + FileUtils.cp t.prerequisites.first, t.name end -desc "sh all mruby tests" -task :test => [:all] do - sh "#{MAKE} -C test #{MAKE_FLAGS}" +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 - sh "#{MAKE} clean -C src #{MAKE_FLAGS}" - sh "#{MAKE} clean -C mrblib #{MAKE_FLAGS}" - if ENABLE_GEMS - puts "-- MAKE mrbgems --" - Rake::Task['mrbgems_clean'].invoke + MRuby.targets.each do |t| + FileUtils.rm_rf t.build_dir end - sh "#{MAKE} clean -C tools/mruby #{MAKE_FLAGS}" - sh "#{MAKE} clean -C tools/mirb #{MAKE_FLAGS}" - sh "#{MAKE} clean -C test #{MAKE_FLAGS}" -end - -desc "show build config summary" -task :showconfig do - puts " CC = #{CC}" - puts " LL = #{LL}" - puts " AR = #{AR}" - puts " YACC = #{YACC}" - puts " MAKE = #{MAKE}" - puts "" - puts " CFLAGS = #{CFLAGS.join(' ')}" - puts " LDFLAGS = #{LDFLAGS.join(' ')}" - puts " LIBS = #{LIBS.join(' ')}" - puts "" - puts " ENABLE_GEMS = #{ENABLE_GEMS}" + FileUtils.rm_f binfiles end |
