From 6460ef77bcceb17d80d1b46a07b28fada19737c8 Mon Sep 17 00:00:00 2001 From: take_cheeze Date: Mon, 6 Apr 2015 15:20:13 +0900 Subject: Compile mruby compiler as mrbgem. Compiler codes is moved to "mruby-compiler". Executable `mrbc` is moved to "mruby-bin-mrbc". --- Rakefile | 1 - 1 file changed, 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 66f54a4e2..0f33c5ee8 100644 --- a/Rakefile +++ b/Rakefile @@ -21,7 +21,6 @@ end # load custom rules load "#{MRUBY_ROOT}/src/mruby_core.rake" load "#{MRUBY_ROOT}/mrblib/mrblib.rake" -load "#{MRUBY_ROOT}/tools/mrbc/mrbc.rake" load "#{MRUBY_ROOT}/tasks/mrbgems.rake" load "#{MRUBY_ROOT}/tasks/libmruby.rake" -- cgit v1.2.3 From be2c156876c5b6cd4c9937c2d266f1862597af58 Mon Sep 17 00:00:00 2001 From: Huei-Horng Yo Date: Tue, 9 Jun 2015 21:07:12 +0800 Subject: Detect if ncurses' backend is terminfo or termcap. fixes #2662 Borrowed from @mattn's code at: https://github.com/mruby/mruby/issues/2662#issuecomment-65535705 Signed-off-by: Huei-Horng Yo --- Rakefile | 1 + mrbgems/mruby-bin-mirb/mrbgem.rake | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 0f33c5ee8..89dab05e7 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,7 @@ # basic build file for mruby MRUBY_ROOT = File.dirname(File.expand_path(__FILE__)) MRUBY_BUILD_HOST_IS_CYGWIN = RUBY_PLATFORM.include?('cygwin') +MRUBY_BUILD_HOST_IS_OPENBSD = RUBY_PLATFORM.include?('openbsd') # load build systems load "#{MRUBY_ROOT}/tasks/ruby_ext.rake" diff --git a/mrbgems/mruby-bin-mirb/mrbgem.rake b/mrbgems/mruby-bin-mirb/mrbgem.rake index 98df38499..e77114515 100644 --- a/mrbgems/mruby-bin-mirb/mrbgem.rake +++ b/mrbgems/mruby-bin-mirb/mrbgem.rake @@ -6,10 +6,16 @@ MRuby::Gem::Specification.new('mruby-bin-mirb') do |spec| if spec.build.cc.search_header_path 'readline/readline.h' spec.cc.defines << "ENABLE_READLINE" if spec.build.cc.search_header_path 'termcap.h' - if MRUBY_BUILD_HOST_IS_CYGWIN then - spec.linker.libraries << 'ncurses' - else - spec.linker.libraries << 'termcap' + if MRUBY_BUILD_HOST_IS_CYGWIN || MRUBY_BUILD_HOST_IS_OPENBSD + if spec.build.cc.search_header_path 'termcap.h' + if MRUBY_BUILD_HOST_IS_CYGWIN then + spec.linker.libraries << 'ncurses' + elsif spec.linker.has_library('libterminfo') then + spec.linker.libraries << 'terminfo' + else + spec.linker.libraries << 'termcap' + end + end end end if RUBY_PLATFORM.include?('netbsd') -- cgit v1.2.3 From 133d57cb0d989b956bac899ccc5171351d15fc06 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Sat, 22 Aug 2015 10:21:52 -0400 Subject: Add mruby-test build config and update :test task to use mrbgem binary Removed old mrbgems_test.rake which was merged into mrbgem spec --- Rakefile | 9 +++-- build_config.rb | 10 ++++++ tasks/mrbgems_test.rake | 94 ------------------------------------------------- tasks/mruby_build.rake | 2 +- 4 files changed, 15 insertions(+), 100 deletions(-) delete mode 100644 tasks/mrbgems_test.rake (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 89dab05e7..574c1365a 100644 --- a/Rakefile +++ b/Rakefile @@ -26,9 +26,6 @@ load "#{MRUBY_ROOT}/mrblib/mrblib.rake" load "#{MRUBY_ROOT}/tasks/mrbgems.rake" load "#{MRUBY_ROOT}/tasks/libmruby.rake" -load "#{MRUBY_ROOT}/tasks/mrbgems_test.rake" -load "#{MRUBY_ROOT}/test/mrbtest.rake" - load "#{MRUBY_ROOT}/tasks/benchmark.rake" ############################## @@ -117,9 +114,11 @@ task :all => depfiles do end desc "run all mruby tests" -task :test => ["all"] + MRuby.targets.values.map { |t| t.build_mrbtest_lib_only? ? t.libfile("#{t.build_dir}/test/mrbtest") : t.exefile("#{t.build_dir}/test/mrbtest") } do +task :test => ["all"] do MRuby.each_target do - run_test unless build_mrbtest_lib_only? + if gems.find { |v| v.name == 'mruby-test' } + run_test unless build_mrbtest_lib_only? + end end end diff --git a/build_config.rb b/build_config.rb index 3408f19a1..e1178d6b2 100644 --- a/build_config.rb +++ b/build_config.rb @@ -108,6 +108,16 @@ MRuby::Build.new('host-debug') do |conf| # conf.enable_bintest end +MRuby::Build.new('test') do |conf| + toolchain :gcc + + enable_debug + conf.enable_bintest + + conf.gembox 'default' + conf.gem :core => "mruby-test" +end + # Define cross build settings # MRuby::CrossBuild.new('32bit') do |conf| # toolchain :gcc diff --git a/tasks/mrbgems_test.rake b/tasks/mrbgems_test.rake deleted file mode 100644 index 0ee508360..000000000 --- a/tasks/mrbgems_test.rake +++ /dev/null @@ -1,94 +0,0 @@ -MRuby.each_target do - gem_table = gems.generate_gem_table self - - gems.each do |g| - test_rbobj = g.test_rbireps.ext(exts.object) - g.test_objs << test_rbobj - dep_list = gems.tsort_dependencies(g.test_dependencies, gem_table).select(&:generate_functions) - - file test_rbobj => g.test_rbireps - file g.test_rbireps => [g.test_rbfiles].flatten + [File.join(g.dir, 'mrbgem.rake'), g.build.mrbcfile, __FILE__, "#{MRUBY_ROOT}/tasks/mrbgem_spec.rake"] do |t| - FileUtils.mkdir_p File.dirname(t.name) - open(t.name, 'w') do |f| - g.print_gem_test_header(f) - test_preload = g.test_preload and [g.dir, MRUBY_ROOT].map {|dir| - File.expand_path(g.test_preload, dir) - }.find {|file| File.exist?(file) } - - f.puts %Q[/*] - f.puts %Q[ * This file contains a test code for #{g.name} gem.] - f.puts %Q[ *] - f.puts %Q[ * IMPORTANT:] - f.puts %Q[ * This file was generated!] - f.puts %Q[ * All manual changes will get lost.] - f.puts %Q[ */] - if test_preload.nil? - f.puts %Q[extern const uint8_t mrbtest_assert_irep[];] - else - g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload" - end - g.test_rbfiles.flatten.each_with_index do |rbfile, i| - g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}" - end - f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] unless g.test_objs.empty? - dep_list.each do |d| - f.puts %Q[void GENERATED_TMP_mrb_#{d.funcname}_gem_init(mrb_state *mrb);] - f.puts %Q[void GENERATED_TMP_mrb_#{d.funcname}_gem_final(mrb_state *mrb);] - end - f.puts %Q[void mrb_init_test_driver(mrb_state *mrb, mrb_bool verbose);] - f.puts %Q[void mrb_t_pass_result(mrb_state *dst, mrb_state *src);] - f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb) {] - unless g.test_rbfiles.empty? - f.puts %Q[ mrb_state *mrb2;] - unless g.test_args.empty? - f.puts %Q[ mrb_value test_args_hash;] - end - f.puts %Q[ int ai;] - g.test_rbfiles.count.times do |i| - f.puts %Q[ ai = mrb_gc_arena_save(mrb);] - f.puts %Q[ mrb2 = mrb_open_core(mrb_default_allocf, NULL);] - f.puts %Q[ if (mrb2 == NULL) {] - f.puts %Q[ fprintf(stderr, "Invalid mrb_state, exiting \%s", __FUNCTION__);] - f.puts %Q[ exit(EXIT_FAILURE);] - f.puts %Q[ }] - dep_list.each do |d| - f.puts %Q[ GENERATED_TMP_mrb_#{d.funcname}_gem_init(mrb2);] - f.puts %Q[ mrb_state_atexit(mrb2, GENERATED_TMP_mrb_#{d.funcname}_gem_final);] - end - f.puts %Q[ mrb_init_test_driver(mrb2, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"))));] - if test_preload.nil? - f.puts %Q[ mrb_load_irep(mrb2, mrbtest_assert_irep);] - else - f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_preload);] - end - f.puts %Q[ if (mrb2->exc) {] - f.puts %Q[ mrb_print_error(mrb2);] - f.puts %Q[ exit(EXIT_FAILURE);] - f.puts %Q[ }] - f.puts %Q[ mrb_const_set(mrb2, mrb_obj_value(mrb2->object_class), mrb_intern_lit(mrb2, "GEMNAME"), mrb_str_new(mrb2, "#{g.name}", #{g.name.length}));] - - unless g.test_args.empty? - f.puts %Q[ test_args_hash = mrb_hash_new_capa(mrb, #{g.test_args.length}); ] - g.test_args.each do |arg_name, arg_value| - escaped_arg_name = arg_name.gsub('\\', '\\\\\\\\').gsub('"', '\"') - escaped_arg_value = arg_value.gsub('\\', '\\\\\\\\').gsub('"', '\"') - f.puts %Q[ mrb_hash_set(mrb2, test_args_hash, mrb_str_new(mrb2, "#{escaped_arg_name.to_s}", #{escaped_arg_name.to_s.length}), mrb_str_new(mrb2, "#{escaped_arg_value.to_s}", #{escaped_arg_value.to_s.length})); ] - end - f.puts %Q[ mrb_const_set(mrb2, mrb_obj_value(mrb2->object_class), mrb_intern_lit(mrb2, "TEST_ARGS"), test_args_hash); ] - end - - f.puts %Q[ mrb_#{g.funcname}_gem_test(mrb2);] if g.custom_test_init? - - f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_#{i});] - f.puts %Q[ ] - - f.puts %Q[ mrb_t_pass_result(mrb, mrb2);] - f.puts %Q[ mrb_close(mrb2);] - f.puts %Q[ mrb_gc_arena_restore(mrb, ai);] - end - end - f.puts %Q[}] - end - end - end -end diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake index 9f8b4eda5..b3a5dcdad 100644 --- a/tasks/mruby_build.rake +++ b/tasks/mruby_build.rake @@ -249,7 +249,7 @@ EOS def run_test puts ">>> Test #{name} <<<" - mrbtest = exefile("#{build_dir}/test/mrbtest") + mrbtest = exefile("#{build_dir}/bin/mrbtest") sh "#{filename mrbtest.relative_path}#{$verbose ? ' -v' : ''}" puts run_bintest if @enable_bintest -- cgit v1.2.3 From bacb8268682e8d931a00e7894ed7904bc789d8c4 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Wed, 2 Sep 2015 23:11:18 -0400 Subject: Add build_mrbtest after config block is evaluated This allows us to add `enable_test` anywhere in a build target, without having to worry about the order in which they are included. Previously, there was a bug that occured when adding 'mruby-test' gem to dependencies before additional gems. Instead of adding the 'mruby-test' gem dependency manually to a test build, we now only need to call `enable_test` in the target. This also allows us to call `test_enabled?` downstream when running mruby tests ourselves. /cc #2924 --- Rakefile | 4 +--- build_config.rb | 2 +- mrbgems/mruby-test/mrbgem.rake | 2 +- tasks/mruby_build.rake | 21 ++++++++++++++++++--- travis_config.rb | 12 ++---------- 5 files changed, 23 insertions(+), 18 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 574c1365a..8a8912af5 100644 --- a/Rakefile +++ b/Rakefile @@ -116,9 +116,7 @@ end desc "run all mruby tests" task :test => ["all"] do MRuby.each_target do - if gems.find { |v| v.name == 'mruby-test' } - run_test unless build_mrbtest_lib_only? - end + run_test if test_enabled? end end diff --git a/build_config.rb b/build_config.rb index 34b92637c..d3c1ebc1f 100644 --- a/build_config.rb +++ b/build_config.rb @@ -114,9 +114,9 @@ MRuby::Build.new('test') do |conf| enable_debug conf.enable_bintest + conf.enable_test conf.gembox 'default' - conf.gem :core => "mruby-test" end # Define cross build settings diff --git a/mrbgems/mruby-test/mrbgem.rake b/mrbgems/mruby-test/mrbgem.rake index 8370f4713..b6b247ff6 100644 --- a/mrbgems/mruby-test/mrbgem.rake +++ b/mrbgems/mruby-test/mrbgem.rake @@ -32,7 +32,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| end end - gem_table = build.gems.generate_gem_table self + gem_table = build.gems.generate_gem_table build build.gems.each do |g| test_rbobj = g.test_rbireps.ext(exts.object) diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake index b3a5dcdad..6863b635a 100644 --- a/tasks/mruby_build.rake +++ b/tasks/mruby_build.rake @@ -46,7 +46,7 @@ module MRuby include LoadGems attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir attr_reader :libmruby, :gems, :toolchains - attr_writer :enable_bintest + attr_writer :enable_bintest, :enable_test COMPILERS = %w(cc cxx objc asm) COMMANDS = COMPILERS + %w(linker archiver yacc gperf git exts mrbc) @@ -85,6 +85,8 @@ module MRuby @build_mrbtest_lib_only = false @cxx_abi_enabled = false @cxx_exception_disabled = false + @enable_bintest = false + @enable_test = false @toolchains = [] MRuby.targets[@name] = self @@ -94,6 +96,7 @@ module MRuby MRuby.targets[@name].instance_eval(&block) build_mrbc_exec if name == 'host' + build_mrbtest if test_enabled? end def enable_debug @@ -170,6 +173,18 @@ EOS MRUBY_ROOT end + def enable_test + @enable_test = true + end + + def test_enabled? + @enable_test + end + + def build_mrbtest + gem :core => 'mruby-test' + end + def build_mrbc_exec gem :core => 'mruby-bin-mrbc' end @@ -252,7 +267,7 @@ EOS mrbtest = exefile("#{build_dir}/bin/mrbtest") sh "#{filename mrbtest.relative_path}#{$verbose ? ' -v' : ''}" puts - run_bintest if @enable_bintest + run_bintest if bintest_enabled? end def run_bintest @@ -297,7 +312,7 @@ EOS end def run_test - mrbtest = exefile("#{build_dir}/test/mrbtest") + mrbtest = exefile("#{build_dir}/bin/mrbtest") if (@test_runner.command == nil) puts "You should run #{mrbtest} on target device." puts diff --git a/travis_config.rb b/travis_config.rb index 458473f96..4ee6d752b 100644 --- a/travis_config.rb +++ b/travis_config.rb @@ -22,6 +22,7 @@ MRuby::Build.new do |conf| c.defines += %w(MRB_GC_FIXED_ARENA) end conf.enable_bintest + conf.enable_test end MRuby::Build.new('cxx_abi') do |conf| @@ -33,18 +34,9 @@ MRuby::Build.new('cxx_abi') do |conf| c.defines += %w(MRB_GC_FIXED_ARENA) end conf.enable_bintest + conf.enable_test enable_cxx_abi build_mrbc_exec end - -MRuby::Build.new('test') do |conf| - toolchain :gcc - - enable_debug - conf.enable_bintest - - conf.gembox 'full-core' - conf.gem :core => "mruby-test" -end -- cgit v1.2.3 From 291265ec86e2b4a8d66b33be3e2d65fa6744da84 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 11 Sep 2015 00:15:01 +0900 Subject: Customize installation directory using INSTALL_DIR environment variable Previously, minirake installed several commands (e.g., mrbc) in repository locally under bin directory. But there was no knob for users to change this directory. It effectively made `make distcheck` fail if mruby was embedded into project managed by autotools. This change adds a way for the user to change installation directory by setting INSTALL_DIR environment variable. --- Rakefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 8a8912af5..3e03b1096 100644 --- a/Rakefile +++ b/Rakefile @@ -32,7 +32,7 @@ load "#{MRUBY_ROOT}/tasks/benchmark.rake" # generic build targets, rules task :default => :all -bin_path = "#{MRUBY_ROOT}/bin" +bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin" FileUtils.mkdir_p bin_path, { :verbose => $verbose } depfiles = MRuby.targets['host'].bins.map do |bin| @@ -71,7 +71,7 @@ MRuby.each_target do |target| end if target == MRuby.targets['host'] - install_path = MRuby.targets['host'].exefile("#{MRUBY_ROOT}/bin/#{bin}") + install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}") file install_path => exec do |t| FileUtils.rm_f t.name, { :verbose => $verbose } @@ -80,7 +80,7 @@ MRuby.each_target do |target| depfiles += [ install_path ] elsif target == MRuby.targets['host-debug'] unless MRuby.targets['host'].gems.map {|g| g.bins}.include?([bin]) - install_path = MRuby.targets['host-debug'].exefile("#{MRUBY_ROOT}/bin/#{bin}") + install_path = MRuby.targets['host-debug'].exefile("#{bin_path}/#{bin}") file install_path => exec do |t| FileUtils.rm_f t.name, { :verbose => $verbose } -- cgit v1.2.3