From 1e156974d5b717d84e5a35ec5e611206de653602 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 15 Apr 2020 17:38:59 +0900 Subject: Generate a table for preallocated symbols (`presym`). `presym` are symbols used in the C source files. `gensym` rake rule scans the entire C source files and collect symbols referenced from them. --- Rakefile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 4115d9e8e..a0bd27c41 100644 --- a/Rakefile +++ b/Rakefile @@ -103,6 +103,46 @@ MRuby.each_target do |target| end end +cfiles = (Dir.glob("#{MRUBY_ROOT}/src/*.c")+ + Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{src,core}/*.c")).uniq +presym_file="#{MRUBY_ROOT}/build/presym" +desc "preallocated symbols" +file presym_file => cfiles do + symbols = cfiles.map do |f| + src = File.read(f) + [src.scan(/intern_lit\([^\n"]*"([^\n "]*)"/), + src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/), + src.scan(/mrb_define_class\([^\n"]*"([^\n"]*)"/), + src.scan(/mrb_define_module\([^\n"]*"([^\n"]*)"/), + src.scan(/MRB_SYM\([a-zA-Z0-9_]*\)"/)] + end + symbols = symbols.flatten.uniq.sort + presyms = File.readlines(presym_file, chomp: true) rescue [] + if presyms != symbols + File.write(presym_file, symbols.join("\n")) + end +end + +presym_inc=presym_file+".inc" +file presym_inc => presym_file do + presyms = File.readlines(presym_file, chomp: true) + File.open(presym_inc, "w") do |f| + f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n" + f.print "/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */\n\n" + presyms.each.with_index do |sym,i| + if /\A[a-zA-Z0-9_]+\Z/ =~ sym + f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n" + else + f.print "MRB_PRESYM_SYM(#{sym}, #{i+1})\n" + end + end + f.print "#define MRB_PRESYM_MAX #{presyms.size}" + end +end + +task :gensym => presym_inc +depfiles += ["gensym"] + depfiles += MRuby.targets.map { |n, t| t.libraries }.flatten -- cgit v1.2.3 From f221f4e0fa08da25498042b2cd61331af40294e5 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 25 Apr 2020 14:00:24 +0900 Subject: Update Rakefile to generate presym. --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index a0bd27c41..0e60726f4 100644 --- a/Rakefile +++ b/Rakefile @@ -104,6 +104,7 @@ MRuby.each_target do |target| end cfiles = (Dir.glob("#{MRUBY_ROOT}/src/*.c")+ + Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{core,src}/*.c")+ Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{src,core}/*.c")).uniq presym_file="#{MRUBY_ROOT}/build/presym" desc "preallocated symbols" @@ -114,7 +115,7 @@ file presym_file => cfiles do src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_class\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_module\([^\n"]*"([^\n"]*)"/), - src.scan(/MRB_SYM\([a-zA-Z0-9_]*\)"/)] + src.scan(/MRB_SYM\(([a-zA-Z0-9_]+)\)/)] end symbols = symbols.flatten.uniq.sort presyms = File.readlines(presym_file, chomp: true) rescue [] @@ -123,6 +124,7 @@ file presym_file => cfiles do end end +file presym_file => cfiles presym_inc=presym_file+".inc" file presym_inc => presym_file do presyms = File.readlines(presym_file, chomp: true) -- cgit v1.2.3 From 721f934b9b01f4644d63f2b838e141cf0e6cda91 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 27 Apr 2020 08:57:20 +0900 Subject: Scan `.rb` files as well to generate `presym` table. --- Rakefile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 0e60726f4..7ef67b3da 100644 --- a/Rakefile +++ b/Rakefile @@ -106,25 +106,34 @@ end cfiles = (Dir.glob("#{MRUBY_ROOT}/src/*.c")+ Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{core,src}/*.c")+ Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{src,core}/*.c")).uniq +rbfiles = (Dir.glob("#{MRUBY_ROOT}/mrblib/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/mrblib/*.rb")).uniq presym_file="#{MRUBY_ROOT}/build/presym" +predef_symbols = nil desc "preallocated symbols" -file presym_file => cfiles do - symbols = cfiles.map do |f| +file presym_file => cfiles+rbfiles do + csymbols = cfiles.map do |f| src = File.read(f) [src.scan(/intern_lit\([^\n"]*"([^\n "]*)"/), src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_class\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_module\([^\n"]*"([^\n"]*)"/), - src.scan(/MRB_SYM\(([a-zA-Z0-9_]+)\)/)] + src.scan(/MRB_SYM\((\w+)\)/)] end - symbols = symbols.flatten.uniq.sort + rbsymbols = rbfiles.map do |f| + src = File.read(f) + [src.scan(/\bclass +([A-Z]\w*)/), + src.scan(/\bmodule +([A-Z]\w*)/), + src.scan(/\bdef +(\w+)/)] + end + symbols = (csymbols+rbsymbols).flatten.uniq.sort presyms = File.readlines(presym_file, chomp: true) rescue [] if presyms != symbols File.write(presym_file, symbols.join("\n")) end end -file presym_file => cfiles presym_inc=presym_file+".inc" file presym_inc => presym_file do presyms = File.readlines(presym_file, chomp: true) @@ -132,7 +141,7 @@ file presym_inc => presym_file do f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n" f.print "/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */\n\n" presyms.each.with_index do |sym,i| - if /\A[a-zA-Z0-9_]+\Z/ =~ sym + if /\A\w+\Z/ =~ sym f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n" else f.print "MRB_PRESYM_SYM(#{sym}, #{i+1})\n" -- cgit v1.2.3 From a2fbb98fa63b1397f30706797b975b42484ed941 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 28 Apr 2020 15:47:30 +0900 Subject: Remove `build/presym` and `build/presym.inc` on `rake clean`. --- Rakefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 7ef67b3da..2b866a8f5 100644 --- a/Rakefile +++ b/Rakefile @@ -199,6 +199,8 @@ task :clean do rm_rf t.build_dir end rm_f depfiles + rm_f presym_file + rm_f presym_inc puts "Cleaned up target build folder" end -- cgit v1.2.3 From 317406159393d0f24f8db512b5ef7f0de9f7b128 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 28 Apr 2020 22:52:35 +0900 Subject: Prepend `gensym` rule to `depfiles`. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 2b866a8f5..22e9c463f 100644 --- a/Rakefile +++ b/Rakefile @@ -152,7 +152,7 @@ file presym_inc => presym_file do end task :gensym => presym_inc -depfiles += ["gensym"] +depfiles.unshift "gensym" depfiles += MRuby.targets.map { |n, t| t.libraries -- cgit v1.2.3 From 5738ed04746ae277b273cffcb0ab08200e53b51b Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 28 Apr 2020 22:58:17 +0900 Subject: Keep `build/presym` through `rake clean`. --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 22e9c463f..ce3da1d9a 100644 --- a/Rakefile +++ b/Rakefile @@ -199,8 +199,6 @@ task :clean do rm_rf t.build_dir end rm_f depfiles - rm_f presym_file - rm_f presym_inc puts "Cleaned up target build folder" end @@ -209,5 +207,7 @@ task :deep_clean => ["clean", "clean_doc"] do MRuby.each_target do |t| rm_rf t.gem_clone_dir end + rm_f presym_file + rm_f presym_inc puts "Cleaned up mrbgems build folder" end -- cgit v1.2.3 From fdbfeaf533fd75143f5d3af3ec6c585b9da746c4 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 1 May 2020 07:40:38 +0900 Subject: Build process updated: You have to specify `TARGET` to specify a configuration, e.g. ``` rake TARGET=host-debug all test ``` When you port `mruby` to a new configuration: 1. copy an existing configuration under `target` directory 2. modify the new configuration file 3. build using the new configuration 4. send PR if you please --- Rakefile | 3 +- appveyor_config.rb | 46 ------- build_config.rb | 152 --------------------- examples/targets/build_config_ArduinoDue.rb | 90 ------------ examples/targets/build_config_IntelEdison.rb | 69 ---------- examples/targets/build_config_IntelGalileo.rb | 106 -------------- examples/targets/build_config_RX630.rb | 81 ----------- examples/targets/build_config_android_arm64-v8a.rb | 26 ---- examples/targets/build_config_android_armeabi.rb | 26 ---- .../build_config_android_armeabi_v7a_neon_hard.rb | 28 ---- examples/targets/build_config_chipKITMax32.rb | 86 ------------ examples/targets/build_config_dreamcast_shelf.rb | 108 --------------- lib/mruby/lockfile.rb | 2 +- target/ArduinoDue.rb | 90 ++++++++++++ target/IntelEdison.rb | 69 ++++++++++ target/IntelGalileo.rb | 106 ++++++++++++++ target/RX630.rb | 81 +++++++++++ target/android_arm64-v8a.rb | 26 ++++ target/android_armeabi.rb | 26 ++++ target/android_armeabi_v7a_neon_hard.rb | 28 ++++ target/appveyor.rb | 46 +++++++ target/bench.rb | 11 ++ target/chipKITMax32.rb | 86 ++++++++++++ target/cross-32bit.rb | 13 ++ target/dreamcast_shelf.rb | 108 +++++++++++++++ target/host-debug.rb | 24 ++++ target/host.rb | 98 +++++++++++++ target/travis.rb | 40 ++++++ tasks/benchmark.rake | 6 +- travis_config.rb | 40 ------ 30 files changed, 856 insertions(+), 865 deletions(-) delete mode 100644 appveyor_config.rb delete mode 100644 build_config.rb delete mode 100644 examples/targets/build_config_ArduinoDue.rb delete mode 100644 examples/targets/build_config_IntelEdison.rb delete mode 100644 examples/targets/build_config_IntelGalileo.rb delete mode 100644 examples/targets/build_config_RX630.rb delete mode 100644 examples/targets/build_config_android_arm64-v8a.rb delete mode 100644 examples/targets/build_config_android_armeabi.rb delete mode 100644 examples/targets/build_config_android_armeabi_v7a_neon_hard.rb delete mode 100644 examples/targets/build_config_chipKITMax32.rb delete mode 100644 examples/targets/build_config_dreamcast_shelf.rb create mode 100644 target/ArduinoDue.rb create mode 100644 target/IntelEdison.rb create mode 100644 target/IntelGalileo.rb create mode 100644 target/RX630.rb create mode 100644 target/android_arm64-v8a.rb create mode 100644 target/android_armeabi.rb create mode 100644 target/android_armeabi_v7a_neon_hard.rb create mode 100644 target/appveyor.rb create mode 100644 target/bench.rb create mode 100644 target/chipKITMax32.rb create mode 100644 target/cross-32bit.rb create mode 100644 target/dreamcast_shelf.rb create mode 100644 target/host-debug.rb create mode 100644 target/host.rb create mode 100644 target/travis.rb delete mode 100644 travis_config.rb (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index ce3da1d9a..6ccdcd958 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,8 @@ require "mruby-core-ext" require "mruby/build" # load configuration file -MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb" +MRUBY_TARGET = ENV['MRUBY_TARGET'] || ENV['TARGET'] || "host" +MRUBY_CONFIG = "#{MRUBY_ROOT}/target/#{MRUBY_TARGET}.rb" load MRUBY_CONFIG # load basic rules diff --git a/appveyor_config.rb b/appveyor_config.rb deleted file mode 100644 index 25745daa8..000000000 --- a/appveyor_config.rb +++ /dev/null @@ -1,46 +0,0 @@ -def setup_option(conf) - conf.cc.flags[0].delete("/Zi") unless ENV['CFLAGS'] - conf.cxx.flags[0].delete("/Zi") unless ENV['CFLAGS'] || ENV['CXXFLAGS'] - conf.linker.flags << "/DEBUG:NONE" unless ENV['LDFLAGS'] -end - -MRuby::Build.new('full-debug') do |conf| - toolchain :visualcpp - enable_debug - - # include all core GEMs - conf.gembox 'full-core' - conf.cc.defines += %w(MRB_GC_STRESS MRB_METHOD_CACHE MRB_ENABLE_DEBUG_HOOK) - setup_option(conf) - - conf.enable_test -end - -MRuby::Build.new do |conf| - toolchain :visualcpp - - # include all core GEMs - conf.gembox 'full-core' - conf.compilers.each do |c| - c.defines += %w(MRB_GC_FIXED_ARENA) - end - setup_option(conf) - conf.enable_bintest - conf.enable_test -end - -MRuby::Build.new('cxx_abi') do |conf| - toolchain :visualcpp - - conf.gembox 'full-core' - conf.compilers.each do |c| - c.defines += %w(MRB_GC_FIXED_ARENA) - end - setup_option(conf) - conf.enable_bintest - conf.enable_test - - enable_cxx_abi - - build_mrbc_exec -end diff --git a/build_config.rb b/build_config.rb deleted file mode 100644 index 254a28ce0..000000000 --- a/build_config.rb +++ /dev/null @@ -1,152 +0,0 @@ -MRuby::Build.new do |conf| - # load specific toolchain settings - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - # Turn on `enable_debug` for better debugging - # enable_debug - - # Use mrbgems - # conf.gem 'examples/mrbgems/ruby_extension_example' - # conf.gem 'examples/mrbgems/c_extension_example' do |g| - # g.cc.flags << '-g' # append cflags in this gem - # end - # conf.gem 'examples/mrbgems/c_and_ruby_extension_example' - # conf.gem :core => 'mruby-eval' - # conf.gem :mgem => 'mruby-onig-regexp' - # conf.gem :github => 'mattn/mruby-onig-regexp' - # conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v' - - # include the default GEMs - conf.gembox 'default' - # C compiler settings - # conf.cc do |cc| - # cc.command = ENV['CC'] || 'gcc' - # cc.flags = [ENV['CFLAGS'] || %w()] - # cc.include_paths = ["#{root}/include"] - # cc.defines = %w() - # cc.option_include_path = %q[-I"%s"] - # cc.option_define = '-D%s' - # cc.compile_options = %Q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"] - # end - - # mrbc settings - # conf.mrbc do |mrbc| - # mrbc.compile_options = "-g -B%{funcname} -o-" # The -g option is required for line numbers - # end - - # Linker settings - # conf.linker do |linker| - # linker.command = ENV['LD'] || 'gcc' - # linker.flags = [ENV['LDFLAGS'] || []] - # linker.flags_before_libraries = [] - # linker.libraries = %w() - # linker.flags_after_libraries = [] - # linker.library_paths = [] - # linker.option_library = '-l%s' - # linker.option_library_path = '-L%s' - # linker.link_options = "%{flags} -o "%{outfile}" %{objs} %{libs}" - # end - - # Archiver settings - # conf.archiver do |archiver| - # archiver.command = ENV['AR'] || 'ar' - # archiver.archive_options = 'rs "%{outfile}" %{objs}' - # end - - # Parser generator settings - # conf.yacc do |yacc| - # yacc.command = ENV['YACC'] || 'bison' - # yacc.compile_options = %q[-o "%{outfile}" "%{infile}"] - # end - - # gperf settings - # conf.gperf do |gperf| - # gperf.command = 'gperf' - # gperf.compile_options = %q[-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" "%{infile}" > "%{outfile}"] - # end - - # file extensions - # conf.exts do |exts| - # exts.object = '.o' - # exts.executable = '' # '.exe' if Windows - # exts.library = '.a' - # end - - # file separetor - # conf.file_separator = '/' - - # bintest - # conf.enable_bintest -end - -MRuby::Build.new('host-debug') do |conf| - # load specific toolchain settings - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # include the default GEMs - conf.gembox 'default' - - # C compiler settings - conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK) - - # Generate mruby debugger command (require mruby-eval) - conf.gem :core => "mruby-bin-debugger" - - # bintest - # conf.enable_bintest -end - -MRuby::Build.new('test') do |conf| - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - conf.enable_bintest - conf.enable_test - - conf.gembox 'default' -end - -#MRuby::Build.new('bench') do |conf| -# # Gets set by the VS command prompts. -# if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] -# toolchain :visualcpp -# else -# toolchain :gcc -# conf.cc.flags << '-O3' -# end -# -# conf.gembox 'default' -#end - -# Define cross build settings -# MRuby::CrossBuild.new('32bit') do |conf| -# toolchain :gcc -# -# conf.cc.flags << "-m32" -# conf.linker.flags << "-m32" -# -# conf.build_mrbtest_lib_only -# -# conf.gem 'examples/mrbgems/c_and_ruby_extension_example' -# -# conf.test_runner.command = 'env' -# end diff --git a/examples/targets/build_config_ArduinoDue.rb b/examples/targets/build_config_ArduinoDue.rb deleted file mode 100644 index 09646a700..000000000 --- a/examples/targets/build_config_ArduinoDue.rb +++ /dev/null @@ -1,90 +0,0 @@ -MRuby::Build.new do |conf| - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # include the default GEMs - conf.gembox 'default' - -end - -# Cross Compiling configuration for Arduino Due -# http://arduino.cc/en/Main/ArduinoBoardDue -# -# Requires Arduino IDE >= 1.5 -MRuby::CrossBuild.new("ArduinoDue") do |conf| - toolchain :gcc - - # Mac OS X, Arduino IDE <= 1.5.6 - # ARDUINO_PATH = '/Applications/Arduino.app/Contents/Resources/Java' - # Mac OS X, Arduino IDE >= 1.5.7 - # ARDUINO_PATH = '/Applications/Arduino.app/Contents/Java' - # GNU Linux - ARDUINO_PATH = '/opt/arduino' - # Arduino IDE <= 1.5.6 - BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/g++_arm_none_eabi/bin" - # Arduino IDE >= 1.5.7 - # BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin" - SAM_PATH = "#{ARDUINO_PATH}/hardware/arduino/sam" - TARGET_PATH = "#{SAM_PATH}/variants/arduino_due_x" - - conf.cc do |cc| - cc.command = "#{BIN_PATH}/arm-none-eabi-gcc" - cc.include_paths << ["#{SAM_PATH}/system/libsam", "#{SAM_PATH}/system/CMSIS/CMSIS/Include/", - "#{SAM_PATH}/system/CMSIS/Device/ATMEL/", - "#{SAM_PATH}/cores/arduino", "#{SAM_PATH}/libraries","#{TARGET_PATH}"] - cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 - -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM - -D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due") - cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] - - #configuration for low memory environment - cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) - cc.defines << %w(KHASH_DEFAULT_SIZE=8) - cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) - cc.defines << %w(MRB_GC_STRESS) - #cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio. - #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval - end - - conf.cxx do |cxx| - cxx.command = conf.cc.command.dup - cxx.include_paths = conf.cc.include_paths.dup - cxx.flags = conf.cc.flags.dup - cxx.flags << %w(-fno-rtti -fno-exceptions) - cxx.defines = conf.cc.defines.dup - cxx.compile_options = conf.cc.compile_options.dup - end - - conf.archiver do |archiver| - archiver.command = "#{BIN_PATH}/arm-none-eabi-ar" - archiver.archive_options = 'rcs "%{outfile}" %{objs}' - end - - #no executables - conf.bins = [] - - #do not build executable test - conf.build_mrbtest_lib_only - - #disable C++ exception - conf.disable_cxx_exception - - #gems from core - conf.gem :core => "mruby-print" - conf.gem :core => "mruby-math" - conf.gem :core => "mruby-enum-ext" - - #light-weight regular expression - conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" - - #Arduino API - #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" - -end diff --git a/examples/targets/build_config_IntelEdison.rb b/examples/targets/build_config_IntelEdison.rb deleted file mode 100644 index a22f9cfd2..000000000 --- a/examples/targets/build_config_IntelEdison.rb +++ /dev/null @@ -1,69 +0,0 @@ -# Cross-compiling setup for Intel Edison (poky linux) platform -# Get SDK from here: https://software.intel.com/en-us/iot/hardware/edison/downloads -# REMEMBER to check and update the SDK root in the constant POKY_EDISON_PATH - -MRuby::Build.new do |conf| - toolchain :gcc - conf.gembox 'default' - conf.cc.defines = %w(ENABLE_READLINE) - conf.gembox 'default' - - #lightweight regular expression - conf.gem :github => "pbosetti/mruby-hs-regexp", :branch => "master" - -end - -# Define cross build settings -MRuby::CrossBuild.new('core2-32-poky-linux') do |conf| - toolchain :gcc - - # Mac OS X - # - POKY_EDISON_PATH = '/opt/poky-edison/1.7.2' - - POKY_EDISON_SYSROOT = "#{POKY_EDISON_PATH}/sysroots/core2-32-poky-linux" - POKY_EDISON_X86_PATH = "#{POKY_EDISON_PATH}/sysroots/i386-pokysdk-darwin" - POKY_EDISON_BIN_PATH = "#{POKY_EDISON_X86_PATH}/usr/bin/i586-poky-linux" - - - conf.cc do |cc| - cc.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-gcc" - cc.include_paths << ["#{POKY_EDISON_SYSROOT}/usr/include", "#{POKY_EDISON_X86_PATH}/usr/include"] - cc.flags = %w(-m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mstackrealign -fno-omit-frame-pointer) - cc.flags << %w(-O2 -pipe -g -feliminate-unused-debug-types) - cc.flags << "--sysroot=#{POKY_EDISON_SYSROOT}" - cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] - cc.defines = %w(ENABLE_READLINE) - end - - conf.cxx do |cxx| - cxx.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-g++" - cxx.include_paths = conf.cc.include_paths.dup - cxx.include_paths << ["#{POKY_EDISON_SYSROOT}/usr/include/c++/4.9.1"] - cxx.flags = conf.cc.flags.dup - cxx.defines = conf.cc.defines.dup - cxx.compile_options = conf.cc.compile_options.dup - end - - conf.archiver do |archiver| - archiver.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-ar" - archiver.archive_options = 'rcs "%{outfile}" %{objs}' - end - - conf.linker do |linker| - linker.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-g++" - linker.flags = %w(-m32 -march=i586) - linker.flags << "--sysroot=#{POKY_EDISON_SYSROOT}" - linker.flags << %w(-O1) - linker.libraries = %w(m pthread) - end - - #do not build executable test - conf.build_mrbtest_lib_only - - conf.gembox 'default' - - #lightweight regular expression - conf.gem :github => "pbosetti/mruby-hs-regexp", :branch => "master" - -end diff --git a/examples/targets/build_config_IntelGalileo.rb b/examples/targets/build_config_IntelGalileo.rb deleted file mode 100644 index 42f39c456..000000000 --- a/examples/targets/build_config_IntelGalileo.rb +++ /dev/null @@ -1,106 +0,0 @@ -MRuby::Build.new do |conf| - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # include the default GEMs - conf.gembox 'default' - -end - - -# Cross Compiling configuration for Intel Galileo on Arduino environment -# http://arduino.cc/en/ArduinoCertified/IntelGalileo -# -# Requires Arduino IDE for Intel Galileo -MRuby::CrossBuild.new("Galileo") do |conf| - toolchain :gcc - - # Mac OS X - # Assume you renamed Arduino.app to Arduino_Galileo.app - GALILEO_ARDUINO_PATH = '/Applications/Arduino_Galileo.app/Contents/Resources/Java' - # GNU Linux - #ARDUINO_GALILEO_PATH = '/opt/arduino' - - GALILEO_BIN_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i386-pokysdk-darwin/usr/bin/i586-poky-linux-uclibc" - GALILEO_SYSROOT = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc" - GALILEO_X86_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/arduino/x86" - - - conf.cc do |cc| - cc.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-gcc" - cc.include_paths << ["#{GALILEO_X86_PATH}/cores/arduino", "#{GALILEO_X86_PATH}/variants/galileo_fab_d"] - cc.flags = %w(-m32 -march=i586 -c -g -Os -w - -ffunction-sections -fdata-sections -MMD -DARDUINO=153) - cc.flags << "--sysroot=#{GALILEO_SYSROOT}" - cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] - end - - conf.cxx do |cxx| - cxx.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++" - cxx.include_paths = conf.cc.include_paths.dup - cxx.include_paths << "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc/usr/include/c++" - cxx.include_paths << "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc/usr/include/c++/i586-poky-linux-uclibc" - cxx.flags = conf.cc.flags.dup - cxx.defines = conf.cc.defines.dup - cxx.compile_options = conf.cc.compile_options.dup - end - - conf.archiver do |archiver| - archiver.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-ar" - archiver.archive_options = 'rcs "%{outfile}" %{objs}' - end - - conf.linker do |linker| - linker.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++" - linker.flags = %w(-m32 -march=i586) - linker.flags << "--sysroot=#{GALILEO_SYSROOT}" - linker.flags << %w(-Os -Wl,--gc-sections) - linker.libraries = %w(m pthread) - end - - #no executables - conf.bins = [] - - #do not build executable test - conf.build_mrbtest_lib_only - - #official mrbgems - conf.gem :core => "mruby-sprintf" - conf.gem :core => "mruby-print" - conf.gem :core => "mruby-math" - conf.gem :core => "mruby-time" - conf.gem :core => "mruby-struct" - conf.gem :core => "mruby-enum-ext" - conf.gem :core => "mruby-string-ext" - conf.gem :core => "mruby-numeric-ext" - conf.gem :core => "mruby-array-ext" - conf.gem :core => "mruby-hash-ext" - conf.gem :core => "mruby-range-ext" - conf.gem :core => "mruby-proc-ext" - conf.gem :core => "mruby-symbol-ext" - conf.gem :core => "mruby-random" - conf.gem :core => "mruby-object-ext" - conf.gem :core => "mruby-objectspace" - conf.gem :core => "mruby-fiber" - conf.gem :core => "mruby-toplevel-ext" - - #lightweigh regular expression - conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" - - #Arduino API - #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" do |g| - # g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Wire" - # g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Servo" - - #enable unsupported Servo class - # g.cxx.defines << "MRUBY_ARDUINO_GALILEO_ENABLE_SERVO" - #end - -end diff --git a/examples/targets/build_config_RX630.rb b/examples/targets/build_config_RX630.rb deleted file mode 100644 index 8b1bbb42f..000000000 --- a/examples/targets/build_config_RX630.rb +++ /dev/null @@ -1,81 +0,0 @@ -MRuby::Build.new do |conf| - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # include the default GEMs - conf.gembox 'default' - -end - -# Cross Compiling configuration for RX630 -# http://gadget.renesas.com/ -# -# Requires gnurx_v14.03 -MRuby::CrossBuild.new("RX630") do |conf| - toolchain :gcc - - # Linux - BIN_PATH = "/usr/share/gnurx_v14.03_elf-1/bin" - - conf.cc do |cc| - cc.command = "#{BIN_PATH}/rx-elf-gcc" - cc.flags = "-Wall -g -O2 -flto -mcpu=rx600 -m64bit-doubles" - cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] - - #configuration for low memory environment - cc.defines << %w(MRB_USE_FLOAT) - cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) - cc.defines << %w(KHASH_DEFAULT_SIZE=8) - cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) - cc.defines << %w(MRB_GC_STRESS) - cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio. - #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval - end - - conf.cxx do |cxx| - cxx.command = conf.cc.command.dup - cxx.include_paths = conf.cc.include_paths.dup - cxx.flags = conf.cc.flags.dup - cxx.defines = conf.cc.defines.dup - cxx.compile_options = conf.cc.compile_options.dup - end - - conf.linker do |linker| - linker.command="#{BIN_PATH}/rx-elf-ld" - end - - conf.archiver do |archiver| - archiver.command = "#{BIN_PATH}/rx-elf-ar" - archiver.archive_options = 'rcs "%{outfile}" %{objs}' - end - - #no executables - conf.bins = [] - - #do not build executable test - conf.build_mrbtest_lib_only - - #disable C++ exception - conf.disable_cxx_exception - - #gems from core - conf.gem :core => "mruby-sprintf" - conf.gem :core => "mruby-print" - conf.gem :core => "mruby-math" - conf.gem :core => "mruby-enum-ext" - conf.gem :core => "mruby-numeric-ext" - - #light-weight regular expression - #conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" - - #Arduino API - #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" - -end diff --git a/examples/targets/build_config_android_arm64-v8a.rb b/examples/targets/build_config_android_arm64-v8a.rb deleted file mode 100644 index 70b0f4b97..000000000 --- a/examples/targets/build_config_android_arm64-v8a.rb +++ /dev/null @@ -1,26 +0,0 @@ -MRuby::Build.new do |conf| - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # include the default GEMs - conf.gembox 'default' -end - -# Requires Android NDK r13 or later. -MRuby::CrossBuild.new('android-arm64-v8a') do |conf| - params = { - :arch => 'arm64-v8a', - :platform => 'android-24', - :toolchain => :clang, - } - toolchain :android, params - - conf.gembox 'default' -end diff --git a/examples/targets/build_config_android_armeabi.rb b/examples/targets/build_config_android_armeabi.rb deleted file mode 100644 index 17330242a..000000000 --- a/examples/targets/build_config_android_armeabi.rb +++ /dev/null @@ -1,26 +0,0 @@ -MRuby::Build.new do |conf| - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # include the default GEMs - conf.gembox 'default' -end - -# Requires Android NDK r13 or later. -MRuby::CrossBuild.new('android-armeabi') do |conf| - params = { - :arch => 'armeabi', - :platform => 'android-24', - :toolchain => :clang, - } - toolchain :android, params - - conf.gembox 'default' -end diff --git a/examples/targets/build_config_android_armeabi_v7a_neon_hard.rb b/examples/targets/build_config_android_armeabi_v7a_neon_hard.rb deleted file mode 100644 index 3788bba7f..000000000 --- a/examples/targets/build_config_android_armeabi_v7a_neon_hard.rb +++ /dev/null @@ -1,28 +0,0 @@ -MRuby::Build.new do |conf| - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # include the default GEMs - conf.gembox 'default' -end - -# Requires Android NDK r13 or later. -MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf| - params = { - :arch => 'armeabi-v7a', - :mfpu => 'neon', - :mfloat_abi => 'hard', - :platform => 'android-24', - :toolchain => :clang, - } - toolchain :android, params - - conf.gembox 'default' -end diff --git a/examples/targets/build_config_chipKITMax32.rb b/examples/targets/build_config_chipKITMax32.rb deleted file mode 100644 index 8617d8d10..000000000 --- a/examples/targets/build_config_chipKITMax32.rb +++ /dev/null @@ -1,86 +0,0 @@ -MRuby::Build.new do |conf| - - # Gets set by the VS command prompts. - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # include the default GEMs - conf.gembox 'default' - -end - -# Cross Compiling configuration for Digilent chipKIT Max32 -# http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32 -# -# Requires MPIDE (https://github.com/chipKIT32/chipKIT32-MAX) -# -# This configuration is based on @kyab's version -# http://d.hatena.ne.jp/kyab/20130201 -MRuby::CrossBuild.new("chipKITMax32") do |conf| - toolchain :gcc - - # Mac OS X - # MPIDE_PATH = '/Applications/Mpide.app/Contents/Resources/Java' - # GNU Linux - MPIDE_PATH = '/opt/mpide-0023-linux-20120903' - - PIC32_PATH = "#{MPIDE_PATH}/hardware/pic32" - - conf.cc do |cc| - cc.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-gcc" - cc.include_paths << ["#{PIC32_PATH}/cores/pic32", - "#{PIC32_PATH}/variants/Max32", - "#{PIC32_PATH}/libraries"] - cc.flags = %w(-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align - -fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_ - -DMPIDEVER=0x01000202 -DMPIDE=23) - cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] - - #configuration for low memory environment - cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) - cc.defines << %w(KHASH_DEFAULT_SIZE=8) - cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) - cc.defines << %w(MRB_GC_STRESS) - #cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio. - #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval - end - - conf.cxx do |cxx| - cxx.command = conf.cc.command.dup - cxx.include_paths = conf.cc.include_paths.dup - cxx.flags = conf.cc.flags.dup - cxx.defines = conf.cc.defines.dup - cxx.compile_options = conf.cc.compile_options.dup - end - - conf.archiver do |archiver| - archiver.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-ar" - archiver.archive_options = 'rcs "%{outfile}" %{objs}' - end - - #no executables - conf.bins = [] - - #do not build test executable - conf.build_mrbtest_lib_only - - #disable C++ exception - conf.disable_cxx_exception - - #gems from core - conf.gem :core => "mruby-print" - conf.gem :core => "mruby-math" - conf.gem :core => "mruby-enum-ext" - - #light-weight regular expression - conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" - - #Arduino API - #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" - -end diff --git a/examples/targets/build_config_dreamcast_shelf.rb b/examples/targets/build_config_dreamcast_shelf.rb deleted file mode 100644 index 85b2ff20d..000000000 --- a/examples/targets/build_config_dreamcast_shelf.rb +++ /dev/null @@ -1,108 +0,0 @@ -MRuby::Build.new do |conf| - # Gets set by the VS command prompts - if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] - toolchain :visualcpp - else - toolchain :gcc - end - - enable_debug - - # Include the default GEMs - conf.gembox 'default' -end - -# Cross Compiling configuration for the Sega Dreamcast -# This configuration requires KallistiOS (KOS) -# https://dreamcast.wiki -# -# Tested on GNU/Linux, MinGW-w64/MSYS2, Cygwin, macOS and MinGW/MSYS (see below) -# -MRuby::CrossBuild.new("dreamcast") do |conf| - toolchain :gcc - - # Support for DreamSDK (based on MinGW/MSYS) - # To compile mruby with DreamSDK, RubyInstaller for Windows should be installed - DREAMSDK_HOME = ENV["DREAMSDK_HOME"] - MSYS_ROOT = !(DREAMSDK_HOME.nil? || DREAMSDK_HOME.empty?) ? "#{DREAMSDK_HOME}/msys/1.0" : "" - - # Setting paths - DREAMCAST_PATH = "#{MSYS_ROOT}/opt/toolchains/dc" - KOS_PATH = "#{DREAMCAST_PATH}/kos" - BIN_PATH = "#{DREAMCAST_PATH}/sh-elf/bin" - - # C compiler - # Flags were extracted from KallistiOS environment files - conf.cc do |cc| - cc.command = "#{BIN_PATH}/sh-elf-gcc" - cc.include_paths << ["#{KOS_PATH}/include", "#{KOS_PATH}/kernel/arch/dreamcast/include", "#{KOS_PATH}/addons/include", "#{KOS_PATH}/../kos-ports/include"] - cc.flags << ["-O2", "-fomit-frame-pointer", "-ml", "-m4-single-only", "-ffunction-sections", "-fdata-sections", "-Wall", "-g", "-fno-builtin", "-ml", "-m4-single-only", "-Wl,-Ttext=0x8c010000", "-Wl,--gc-sections", "-T#{KOS_PATH}/utils/ldscripts/shlelf.xc", "-nodefaultlibs"] - cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] - cc.defines << %w(_arch_dreamcast) - cc.defines << %w(_arch_sub_pristine) - end - - # C++ compiler - conf.cxx do |cxx| - cxx.command = conf.cc.command.dup - cxx.include_paths = conf.cc.include_paths.dup - cxx.flags = conf.cc.flags.dup - cxx.flags << %w(-fno-rtti -fno-exceptions) - cxx.defines = conf.cc.defines.dup - cxx.compile_options = conf.cc.compile_options.dup - end - - # Linker - # There is an issue when making the mruby library with KallistiOS: - # 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly - # specified here at least for now. - conf.linker do |linker| - linker.command="#{BIN_PATH}/sh-elf-gcc" - linker.flags << ["#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_kill.o", "#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_getpid.o", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"] - linker.library_paths << ["#{KOS_PATH}/lib/dreamcast", "#{KOS_PATH}/addons/lib/dreamcast", "#{KOS_PATH}/../kos-ports/lib"] - end - - # Archiver - conf.archiver do |archiver| - archiver.command = "#{BIN_PATH}/sh-elf-ar" - archiver.archive_options = 'rcs "%{outfile}" %{objs}' - end - - # No executables - conf.bins = [] - - # Do not build executable test - conf.build_mrbtest_lib_only - - # Disable C++ exception - conf.disable_cxx_exception - - # Gems from core - # removing mruby-io - conf.gem :core => "mruby-metaprog" - conf.gem :core => "mruby-pack" - conf.gem :core => "mruby-sprintf" - conf.gem :core => "mruby-print" - conf.gem :core => "mruby-math" - conf.gem :core => "mruby-time" - conf.gem :core => "mruby-struct" - conf.gem :core => "mruby-compar-ext" - conf.gem :core => "mruby-enum-ext" - conf.gem :core => "mruby-string-ext" - conf.gem :core => "mruby-numeric-ext" - conf.gem :core => "mruby-array-ext" - conf.gem :core => "mruby-hash-ext" - conf.gem :core => "mruby-range-ext" - conf.gem :core => "mruby-proc-ext" - conf.gem :core => "mruby-symbol-ext" - conf.gem :core => "mruby-random" - conf.gem :core => "mruby-object-ext" - conf.gem :core => "mruby-objectspace" - conf.gem :core => "mruby-fiber" - conf.gem :core => "mruby-enumerator" - conf.gem :core => "mruby-enum-lazy" - conf.gem :core => "mruby-toplevel-ext" - conf.gem :core => "mruby-kernel-ext" - conf.gem :core => "mruby-class-ext" - conf.gem :core => "mruby-compiler" -end diff --git a/lib/mruby/lockfile.rb b/lib/mruby/lockfile.rb index 0d2455b4c..ee16e2ad8 100644 --- a/lib/mruby/lockfile.rb +++ b/lib/mruby/lockfile.rb @@ -26,7 +26,7 @@ module MRuby end def instance - @instance ||= new("#{MRUBY_CONFIG}.lock") + @instance ||= new("#{MRUBY_ROOT}/build/#{MRUBY_TARGET}.lock") end end diff --git a/target/ArduinoDue.rb b/target/ArduinoDue.rb new file mode 100644 index 000000000..09646a700 --- /dev/null +++ b/target/ArduinoDue.rb @@ -0,0 +1,90 @@ +MRuby::Build.new do |conf| + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # include the default GEMs + conf.gembox 'default' + +end + +# Cross Compiling configuration for Arduino Due +# http://arduino.cc/en/Main/ArduinoBoardDue +# +# Requires Arduino IDE >= 1.5 +MRuby::CrossBuild.new("ArduinoDue") do |conf| + toolchain :gcc + + # Mac OS X, Arduino IDE <= 1.5.6 + # ARDUINO_PATH = '/Applications/Arduino.app/Contents/Resources/Java' + # Mac OS X, Arduino IDE >= 1.5.7 + # ARDUINO_PATH = '/Applications/Arduino.app/Contents/Java' + # GNU Linux + ARDUINO_PATH = '/opt/arduino' + # Arduino IDE <= 1.5.6 + BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/g++_arm_none_eabi/bin" + # Arduino IDE >= 1.5.7 + # BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin" + SAM_PATH = "#{ARDUINO_PATH}/hardware/arduino/sam" + TARGET_PATH = "#{SAM_PATH}/variants/arduino_due_x" + + conf.cc do |cc| + cc.command = "#{BIN_PATH}/arm-none-eabi-gcc" + cc.include_paths << ["#{SAM_PATH}/system/libsam", "#{SAM_PATH}/system/CMSIS/CMSIS/Include/", + "#{SAM_PATH}/system/CMSIS/Device/ATMEL/", + "#{SAM_PATH}/cores/arduino", "#{SAM_PATH}/libraries","#{TARGET_PATH}"] + cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 + -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM + -D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due") + cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] + + #configuration for low memory environment + cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) + cc.defines << %w(KHASH_DEFAULT_SIZE=8) + cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) + cc.defines << %w(MRB_GC_STRESS) + #cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio. + #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval + end + + conf.cxx do |cxx| + cxx.command = conf.cc.command.dup + cxx.include_paths = conf.cc.include_paths.dup + cxx.flags = conf.cc.flags.dup + cxx.flags << %w(-fno-rtti -fno-exceptions) + cxx.defines = conf.cc.defines.dup + cxx.compile_options = conf.cc.compile_options.dup + end + + conf.archiver do |archiver| + archiver.command = "#{BIN_PATH}/arm-none-eabi-ar" + archiver.archive_options = 'rcs "%{outfile}" %{objs}' + end + + #no executables + conf.bins = [] + + #do not build executable test + conf.build_mrbtest_lib_only + + #disable C++ exception + conf.disable_cxx_exception + + #gems from core + conf.gem :core => "mruby-print" + conf.gem :core => "mruby-math" + conf.gem :core => "mruby-enum-ext" + + #light-weight regular expression + conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" + + #Arduino API + #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" + +end diff --git a/target/IntelEdison.rb b/target/IntelEdison.rb new file mode 100644 index 000000000..a22f9cfd2 --- /dev/null +++ b/target/IntelEdison.rb @@ -0,0 +1,69 @@ +# Cross-compiling setup for Intel Edison (poky linux) platform +# Get SDK from here: https://software.intel.com/en-us/iot/hardware/edison/downloads +# REMEMBER to check and update the SDK root in the constant POKY_EDISON_PATH + +MRuby::Build.new do |conf| + toolchain :gcc + conf.gembox 'default' + conf.cc.defines = %w(ENABLE_READLINE) + conf.gembox 'default' + + #lightweight regular expression + conf.gem :github => "pbosetti/mruby-hs-regexp", :branch => "master" + +end + +# Define cross build settings +MRuby::CrossBuild.new('core2-32-poky-linux') do |conf| + toolchain :gcc + + # Mac OS X + # + POKY_EDISON_PATH = '/opt/poky-edison/1.7.2' + + POKY_EDISON_SYSROOT = "#{POKY_EDISON_PATH}/sysroots/core2-32-poky-linux" + POKY_EDISON_X86_PATH = "#{POKY_EDISON_PATH}/sysroots/i386-pokysdk-darwin" + POKY_EDISON_BIN_PATH = "#{POKY_EDISON_X86_PATH}/usr/bin/i586-poky-linux" + + + conf.cc do |cc| + cc.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-gcc" + cc.include_paths << ["#{POKY_EDISON_SYSROOT}/usr/include", "#{POKY_EDISON_X86_PATH}/usr/include"] + cc.flags = %w(-m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mstackrealign -fno-omit-frame-pointer) + cc.flags << %w(-O2 -pipe -g -feliminate-unused-debug-types) + cc.flags << "--sysroot=#{POKY_EDISON_SYSROOT}" + cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] + cc.defines = %w(ENABLE_READLINE) + end + + conf.cxx do |cxx| + cxx.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-g++" + cxx.include_paths = conf.cc.include_paths.dup + cxx.include_paths << ["#{POKY_EDISON_SYSROOT}/usr/include/c++/4.9.1"] + cxx.flags = conf.cc.flags.dup + cxx.defines = conf.cc.defines.dup + cxx.compile_options = conf.cc.compile_options.dup + end + + conf.archiver do |archiver| + archiver.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-ar" + archiver.archive_options = 'rcs "%{outfile}" %{objs}' + end + + conf.linker do |linker| + linker.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-g++" + linker.flags = %w(-m32 -march=i586) + linker.flags << "--sysroot=#{POKY_EDISON_SYSROOT}" + linker.flags << %w(-O1) + linker.libraries = %w(m pthread) + end + + #do not build executable test + conf.build_mrbtest_lib_only + + conf.gembox 'default' + + #lightweight regular expression + conf.gem :github => "pbosetti/mruby-hs-regexp", :branch => "master" + +end diff --git a/target/IntelGalileo.rb b/target/IntelGalileo.rb new file mode 100644 index 000000000..42f39c456 --- /dev/null +++ b/target/IntelGalileo.rb @@ -0,0 +1,106 @@ +MRuby::Build.new do |conf| + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # include the default GEMs + conf.gembox 'default' + +end + + +# Cross Compiling configuration for Intel Galileo on Arduino environment +# http://arduino.cc/en/ArduinoCertified/IntelGalileo +# +# Requires Arduino IDE for Intel Galileo +MRuby::CrossBuild.new("Galileo") do |conf| + toolchain :gcc + + # Mac OS X + # Assume you renamed Arduino.app to Arduino_Galileo.app + GALILEO_ARDUINO_PATH = '/Applications/Arduino_Galileo.app/Contents/Resources/Java' + # GNU Linux + #ARDUINO_GALILEO_PATH = '/opt/arduino' + + GALILEO_BIN_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i386-pokysdk-darwin/usr/bin/i586-poky-linux-uclibc" + GALILEO_SYSROOT = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc" + GALILEO_X86_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/arduino/x86" + + + conf.cc do |cc| + cc.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-gcc" + cc.include_paths << ["#{GALILEO_X86_PATH}/cores/arduino", "#{GALILEO_X86_PATH}/variants/galileo_fab_d"] + cc.flags = %w(-m32 -march=i586 -c -g -Os -w + -ffunction-sections -fdata-sections -MMD -DARDUINO=153) + cc.flags << "--sysroot=#{GALILEO_SYSROOT}" + cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] + end + + conf.cxx do |cxx| + cxx.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++" + cxx.include_paths = conf.cc.include_paths.dup + cxx.include_paths << "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc/usr/include/c++" + cxx.include_paths << "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc/usr/include/c++/i586-poky-linux-uclibc" + cxx.flags = conf.cc.flags.dup + cxx.defines = conf.cc.defines.dup + cxx.compile_options = conf.cc.compile_options.dup + end + + conf.archiver do |archiver| + archiver.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-ar" + archiver.archive_options = 'rcs "%{outfile}" %{objs}' + end + + conf.linker do |linker| + linker.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++" + linker.flags = %w(-m32 -march=i586) + linker.flags << "--sysroot=#{GALILEO_SYSROOT}" + linker.flags << %w(-Os -Wl,--gc-sections) + linker.libraries = %w(m pthread) + end + + #no executables + conf.bins = [] + + #do not build executable test + conf.build_mrbtest_lib_only + + #official mrbgems + conf.gem :core => "mruby-sprintf" + conf.gem :core => "mruby-print" + conf.gem :core => "mruby-math" + conf.gem :core => "mruby-time" + conf.gem :core => "mruby-struct" + conf.gem :core => "mruby-enum-ext" + conf.gem :core => "mruby-string-ext" + conf.gem :core => "mruby-numeric-ext" + conf.gem :core => "mruby-array-ext" + conf.gem :core => "mruby-hash-ext" + conf.gem :core => "mruby-range-ext" + conf.gem :core => "mruby-proc-ext" + conf.gem :core => "mruby-symbol-ext" + conf.gem :core => "mruby-random" + conf.gem :core => "mruby-object-ext" + conf.gem :core => "mruby-objectspace" + conf.gem :core => "mruby-fiber" + conf.gem :core => "mruby-toplevel-ext" + + #lightweigh regular expression + conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" + + #Arduino API + #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" do |g| + # g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Wire" + # g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Servo" + + #enable unsupported Servo class + # g.cxx.defines << "MRUBY_ARDUINO_GALILEO_ENABLE_SERVO" + #end + +end diff --git a/target/RX630.rb b/target/RX630.rb new file mode 100644 index 000000000..8b1bbb42f --- /dev/null +++ b/target/RX630.rb @@ -0,0 +1,81 @@ +MRuby::Build.new do |conf| + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # include the default GEMs + conf.gembox 'default' + +end + +# Cross Compiling configuration for RX630 +# http://gadget.renesas.com/ +# +# Requires gnurx_v14.03 +MRuby::CrossBuild.new("RX630") do |conf| + toolchain :gcc + + # Linux + BIN_PATH = "/usr/share/gnurx_v14.03_elf-1/bin" + + conf.cc do |cc| + cc.command = "#{BIN_PATH}/rx-elf-gcc" + cc.flags = "-Wall -g -O2 -flto -mcpu=rx600 -m64bit-doubles" + cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] + + #configuration for low memory environment + cc.defines << %w(MRB_USE_FLOAT) + cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) + cc.defines << %w(KHASH_DEFAULT_SIZE=8) + cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) + cc.defines << %w(MRB_GC_STRESS) + cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio. + #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval + end + + conf.cxx do |cxx| + cxx.command = conf.cc.command.dup + cxx.include_paths = conf.cc.include_paths.dup + cxx.flags = conf.cc.flags.dup + cxx.defines = conf.cc.defines.dup + cxx.compile_options = conf.cc.compile_options.dup + end + + conf.linker do |linker| + linker.command="#{BIN_PATH}/rx-elf-ld" + end + + conf.archiver do |archiver| + archiver.command = "#{BIN_PATH}/rx-elf-ar" + archiver.archive_options = 'rcs "%{outfile}" %{objs}' + end + + #no executables + conf.bins = [] + + #do not build executable test + conf.build_mrbtest_lib_only + + #disable C++ exception + conf.disable_cxx_exception + + #gems from core + conf.gem :core => "mruby-sprintf" + conf.gem :core => "mruby-print" + conf.gem :core => "mruby-math" + conf.gem :core => "mruby-enum-ext" + conf.gem :core => "mruby-numeric-ext" + + #light-weight regular expression + #conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" + + #Arduino API + #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" + +end diff --git a/target/android_arm64-v8a.rb b/target/android_arm64-v8a.rb new file mode 100644 index 000000000..70b0f4b97 --- /dev/null +++ b/target/android_arm64-v8a.rb @@ -0,0 +1,26 @@ +MRuby::Build.new do |conf| + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # include the default GEMs + conf.gembox 'default' +end + +# Requires Android NDK r13 or later. +MRuby::CrossBuild.new('android-arm64-v8a') do |conf| + params = { + :arch => 'arm64-v8a', + :platform => 'android-24', + :toolchain => :clang, + } + toolchain :android, params + + conf.gembox 'default' +end diff --git a/target/android_armeabi.rb b/target/android_armeabi.rb new file mode 100644 index 000000000..17330242a --- /dev/null +++ b/target/android_armeabi.rb @@ -0,0 +1,26 @@ +MRuby::Build.new do |conf| + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # include the default GEMs + conf.gembox 'default' +end + +# Requires Android NDK r13 or later. +MRuby::CrossBuild.new('android-armeabi') do |conf| + params = { + :arch => 'armeabi', + :platform => 'android-24', + :toolchain => :clang, + } + toolchain :android, params + + conf.gembox 'default' +end diff --git a/target/android_armeabi_v7a_neon_hard.rb b/target/android_armeabi_v7a_neon_hard.rb new file mode 100644 index 000000000..3788bba7f --- /dev/null +++ b/target/android_armeabi_v7a_neon_hard.rb @@ -0,0 +1,28 @@ +MRuby::Build.new do |conf| + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # include the default GEMs + conf.gembox 'default' +end + +# Requires Android NDK r13 or later. +MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf| + params = { + :arch => 'armeabi-v7a', + :mfpu => 'neon', + :mfloat_abi => 'hard', + :platform => 'android-24', + :toolchain => :clang, + } + toolchain :android, params + + conf.gembox 'default' +end diff --git a/target/appveyor.rb b/target/appveyor.rb new file mode 100644 index 000000000..25745daa8 --- /dev/null +++ b/target/appveyor.rb @@ -0,0 +1,46 @@ +def setup_option(conf) + conf.cc.flags[0].delete("/Zi") unless ENV['CFLAGS'] + conf.cxx.flags[0].delete("/Zi") unless ENV['CFLAGS'] || ENV['CXXFLAGS'] + conf.linker.flags << "/DEBUG:NONE" unless ENV['LDFLAGS'] +end + +MRuby::Build.new('full-debug') do |conf| + toolchain :visualcpp + enable_debug + + # include all core GEMs + conf.gembox 'full-core' + conf.cc.defines += %w(MRB_GC_STRESS MRB_METHOD_CACHE MRB_ENABLE_DEBUG_HOOK) + setup_option(conf) + + conf.enable_test +end + +MRuby::Build.new do |conf| + toolchain :visualcpp + + # include all core GEMs + conf.gembox 'full-core' + conf.compilers.each do |c| + c.defines += %w(MRB_GC_FIXED_ARENA) + end + setup_option(conf) + conf.enable_bintest + conf.enable_test +end + +MRuby::Build.new('cxx_abi') do |conf| + toolchain :visualcpp + + conf.gembox 'full-core' + conf.compilers.each do |c| + c.defines += %w(MRB_GC_FIXED_ARENA) + end + setup_option(conf) + conf.enable_bintest + conf.enable_test + + enable_cxx_abi + + build_mrbc_exec +end diff --git a/target/bench.rb b/target/bench.rb new file mode 100644 index 000000000..30ec56ad3 --- /dev/null +++ b/target/bench.rb @@ -0,0 +1,11 @@ +MRuby::Build.new('bench') do |conf| + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + conf.cc.flags << '-O3' + end + + conf.gembox 'default' +end diff --git a/target/chipKITMax32.rb b/target/chipKITMax32.rb new file mode 100644 index 000000000..8617d8d10 --- /dev/null +++ b/target/chipKITMax32.rb @@ -0,0 +1,86 @@ +MRuby::Build.new do |conf| + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # include the default GEMs + conf.gembox 'default' + +end + +# Cross Compiling configuration for Digilent chipKIT Max32 +# http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32 +# +# Requires MPIDE (https://github.com/chipKIT32/chipKIT32-MAX) +# +# This configuration is based on @kyab's version +# http://d.hatena.ne.jp/kyab/20130201 +MRuby::CrossBuild.new("chipKITMax32") do |conf| + toolchain :gcc + + # Mac OS X + # MPIDE_PATH = '/Applications/Mpide.app/Contents/Resources/Java' + # GNU Linux + MPIDE_PATH = '/opt/mpide-0023-linux-20120903' + + PIC32_PATH = "#{MPIDE_PATH}/hardware/pic32" + + conf.cc do |cc| + cc.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-gcc" + cc.include_paths << ["#{PIC32_PATH}/cores/pic32", + "#{PIC32_PATH}/variants/Max32", + "#{PIC32_PATH}/libraries"] + cc.flags = %w(-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align + -fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_ + -DMPIDEVER=0x01000202 -DMPIDE=23) + cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] + + #configuration for low memory environment + cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) + cc.defines << %w(KHASH_DEFAULT_SIZE=8) + cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) + cc.defines << %w(MRB_GC_STRESS) + #cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio. + #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval + end + + conf.cxx do |cxx| + cxx.command = conf.cc.command.dup + cxx.include_paths = conf.cc.include_paths.dup + cxx.flags = conf.cc.flags.dup + cxx.defines = conf.cc.defines.dup + cxx.compile_options = conf.cc.compile_options.dup + end + + conf.archiver do |archiver| + archiver.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-ar" + archiver.archive_options = 'rcs "%{outfile}" %{objs}' + end + + #no executables + conf.bins = [] + + #do not build test executable + conf.build_mrbtest_lib_only + + #disable C++ exception + conf.disable_cxx_exception + + #gems from core + conf.gem :core => "mruby-print" + conf.gem :core => "mruby-math" + conf.gem :core => "mruby-enum-ext" + + #light-weight regular expression + conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" + + #Arduino API + #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" + +end diff --git a/target/cross-32bit.rb b/target/cross-32bit.rb new file mode 100644 index 000000000..310ffc833 --- /dev/null +++ b/target/cross-32bit.rb @@ -0,0 +1,13 @@ +# Define cross build settings +MRuby::CrossBuild.new('32bit') do |conf| + toolchain :gcc + + conf.cc.flags << "-m32" + conf.linker.flags << "-m32" + + conf.build_mrbtest_lib_only + + conf.gem 'examples/mrbgems/c_and_ruby_extension_example' + + conf.test_runner.command = 'env' +end diff --git a/target/dreamcast_shelf.rb b/target/dreamcast_shelf.rb new file mode 100644 index 000000000..85b2ff20d --- /dev/null +++ b/target/dreamcast_shelf.rb @@ -0,0 +1,108 @@ +MRuby::Build.new do |conf| + # Gets set by the VS command prompts + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # Include the default GEMs + conf.gembox 'default' +end + +# Cross Compiling configuration for the Sega Dreamcast +# This configuration requires KallistiOS (KOS) +# https://dreamcast.wiki +# +# Tested on GNU/Linux, MinGW-w64/MSYS2, Cygwin, macOS and MinGW/MSYS (see below) +# +MRuby::CrossBuild.new("dreamcast") do |conf| + toolchain :gcc + + # Support for DreamSDK (based on MinGW/MSYS) + # To compile mruby with DreamSDK, RubyInstaller for Windows should be installed + DREAMSDK_HOME = ENV["DREAMSDK_HOME"] + MSYS_ROOT = !(DREAMSDK_HOME.nil? || DREAMSDK_HOME.empty?) ? "#{DREAMSDK_HOME}/msys/1.0" : "" + + # Setting paths + DREAMCAST_PATH = "#{MSYS_ROOT}/opt/toolchains/dc" + KOS_PATH = "#{DREAMCAST_PATH}/kos" + BIN_PATH = "#{DREAMCAST_PATH}/sh-elf/bin" + + # C compiler + # Flags were extracted from KallistiOS environment files + conf.cc do |cc| + cc.command = "#{BIN_PATH}/sh-elf-gcc" + cc.include_paths << ["#{KOS_PATH}/include", "#{KOS_PATH}/kernel/arch/dreamcast/include", "#{KOS_PATH}/addons/include", "#{KOS_PATH}/../kos-ports/include"] + cc.flags << ["-O2", "-fomit-frame-pointer", "-ml", "-m4-single-only", "-ffunction-sections", "-fdata-sections", "-Wall", "-g", "-fno-builtin", "-ml", "-m4-single-only", "-Wl,-Ttext=0x8c010000", "-Wl,--gc-sections", "-T#{KOS_PATH}/utils/ldscripts/shlelf.xc", "-nodefaultlibs"] + cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] + cc.defines << %w(_arch_dreamcast) + cc.defines << %w(_arch_sub_pristine) + end + + # C++ compiler + conf.cxx do |cxx| + cxx.command = conf.cc.command.dup + cxx.include_paths = conf.cc.include_paths.dup + cxx.flags = conf.cc.flags.dup + cxx.flags << %w(-fno-rtti -fno-exceptions) + cxx.defines = conf.cc.defines.dup + cxx.compile_options = conf.cc.compile_options.dup + end + + # Linker + # There is an issue when making the mruby library with KallistiOS: + # 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly + # specified here at least for now. + conf.linker do |linker| + linker.command="#{BIN_PATH}/sh-elf-gcc" + linker.flags << ["#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_kill.o", "#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_getpid.o", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"] + linker.library_paths << ["#{KOS_PATH}/lib/dreamcast", "#{KOS_PATH}/addons/lib/dreamcast", "#{KOS_PATH}/../kos-ports/lib"] + end + + # Archiver + conf.archiver do |archiver| + archiver.command = "#{BIN_PATH}/sh-elf-ar" + archiver.archive_options = 'rcs "%{outfile}" %{objs}' + end + + # No executables + conf.bins = [] + + # Do not build executable test + conf.build_mrbtest_lib_only + + # Disable C++ exception + conf.disable_cxx_exception + + # Gems from core + # removing mruby-io + conf.gem :core => "mruby-metaprog" + conf.gem :core => "mruby-pack" + conf.gem :core => "mruby-sprintf" + conf.gem :core => "mruby-print" + conf.gem :core => "mruby-math" + conf.gem :core => "mruby-time" + conf.gem :core => "mruby-struct" + conf.gem :core => "mruby-compar-ext" + conf.gem :core => "mruby-enum-ext" + conf.gem :core => "mruby-string-ext" + conf.gem :core => "mruby-numeric-ext" + conf.gem :core => "mruby-array-ext" + conf.gem :core => "mruby-hash-ext" + conf.gem :core => "mruby-range-ext" + conf.gem :core => "mruby-proc-ext" + conf.gem :core => "mruby-symbol-ext" + conf.gem :core => "mruby-random" + conf.gem :core => "mruby-object-ext" + conf.gem :core => "mruby-objectspace" + conf.gem :core => "mruby-fiber" + conf.gem :core => "mruby-enumerator" + conf.gem :core => "mruby-enum-lazy" + conf.gem :core => "mruby-toplevel-ext" + conf.gem :core => "mruby-kernel-ext" + conf.gem :core => "mruby-class-ext" + conf.gem :core => "mruby-compiler" +end diff --git a/target/host-debug.rb b/target/host-debug.rb new file mode 100644 index 000000000..4e89d162c --- /dev/null +++ b/target/host-debug.rb @@ -0,0 +1,24 @@ +MRuby::Build.new('host-debug') do |conf| + # load specific toolchain settings + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + enable_debug + + # include the default GEMs + conf.gembox 'full-core' + + # C compiler settings + conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK) + + # Generate mruby debugger command (require mruby-eval) + conf.gem :core => "mruby-bin-debugger" + + # bintest + # conf.enable_bintest +end diff --git a/target/host.rb b/target/host.rb new file mode 100644 index 000000000..4f0286882 --- /dev/null +++ b/target/host.rb @@ -0,0 +1,98 @@ +MRuby::Build.new do |conf| + # load specific toolchain settings + + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + # Use mrbgems + # conf.gem 'examples/mrbgems/ruby_extension_example' + # conf.gem 'examples/mrbgems/c_extension_example' do |g| + # g.cc.flags << '-g' # append cflags in this gem + # end + # conf.gem 'examples/mrbgems/c_and_ruby_extension_example' + # conf.gem :core => 'mruby-eval' + # conf.gem :mgem => 'mruby-onig-regexp' + # conf.gem :github => 'mattn/mruby-onig-regexp' + # conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v' + + # include the GEM box + conf.gembox 'full-core' + + # C compiler settings + # conf.cc do |cc| + # cc.command = ENV['CC'] || 'gcc' + # cc.flags = [ENV['CFLAGS'] || %w()] + # cc.include_paths = ["#{root}/include"] + # cc.defines = %w() + # cc.option_include_path = %q[-I"%s"] + # cc.option_define = '-D%s' + # cc.compile_options = %Q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"] + # end + + # mrbc settings + # conf.mrbc do |mrbc| + # mrbc.compile_options = "-g -B%{funcname} -o-" # The -g option is required for line numbers + # end + + # Linker settings + # conf.linker do |linker| + # linker.command = ENV['LD'] || 'gcc' + # linker.flags = [ENV['LDFLAGS'] || []] + # linker.flags_before_libraries = [] + # linker.libraries = %w() + # linker.flags_after_libraries = [] + # linker.library_paths = [] + # linker.option_library = '-l%s' + # linker.option_library_path = '-L%s' + # linker.link_options = "%{flags} -o "%{outfile}" %{objs} %{libs}" + # end + + # Archiver settings + # conf.archiver do |archiver| + # archiver.command = ENV['AR'] || 'ar' + # archiver.archive_options = 'rs "%{outfile}" %{objs}' + # end + + # Parser generator settings + # conf.yacc do |yacc| + # yacc.command = ENV['YACC'] || 'bison' + # yacc.compile_options = %q[-o "%{outfile}" "%{infile}"] + # end + + # gperf settings + # conf.gperf do |gperf| + # gperf.command = 'gperf' + # gperf.compile_options = %q[-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" "%{infile}" > "%{outfile}"] + # end + + # file extensions + # conf.exts do |exts| + # exts.object = '.o' + # exts.executable = '' # '.exe' if Windows + # exts.library = '.a' + # end + + # file separetor + # conf.file_separator = '/' + + # Turn on `enable_debug` for better debugging + # enable_debug + enable_debug + conf.enable_bintest + conf.enable_test +end + +MRuby::Build.new('test') do |conf| + # Gets set by the VS command prompts. + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + + conf.gembox 'default' +end diff --git a/target/travis.rb b/target/travis.rb new file mode 100644 index 000000000..f4bef0a52 --- /dev/null +++ b/target/travis.rb @@ -0,0 +1,40 @@ +MRuby::Build.new('full-debug') do |conf| + toolchain :gcc + enable_debug + + # include all core GEMs + conf.gembox 'full-core' + conf.cc.flags += %w(-Werror=declaration-after-statement) + conf.cc.defines += %w(MRB_GC_STRESS MRB_METHOD_CACHE MRB_ENABLE_DEBUG_HOOK) + + conf.enable_test +end + +MRuby::Build.new do |conf| + toolchain :gcc + + # include all core GEMs + conf.gembox 'full-core' + conf.cc.flags += %w(-Werror=declaration-after-statement) + conf.compilers.each do |c| + c.defines += %w(MRB_GC_FIXED_ARENA) + end + conf.enable_bintest + conf.enable_test +end + +MRuby::Build.new('cxx_abi') do |conf| + toolchain :gcc + + conf.gembox 'full-core' + conf.cc.flags += %w(-fpermissive) + conf.compilers.each do |c| + c.defines += %w(MRB_GC_FIXED_ARENA) + end + conf.enable_bintest + conf.enable_test + + enable_cxx_abi + + build_mrbc_exec +end diff --git a/tasks/benchmark.rake b/tasks/benchmark.rake index 6352f5c17..661fd2ada 100644 --- a/tasks/benchmark.rake +++ b/tasks/benchmark.rake @@ -9,11 +9,7 @@ def bm_files end def build_config_name - if ENV['MRUBY_CONFIG'] - File.basename(ENV['MRUBY_CONFIG'], '.rb').gsub('build_config_', '') - else - "build" - end + MRUBY_TARGET end def plot_file diff --git a/travis_config.rb b/travis_config.rb deleted file mode 100644 index f4bef0a52..000000000 --- a/travis_config.rb +++ /dev/null @@ -1,40 +0,0 @@ -MRuby::Build.new('full-debug') do |conf| - toolchain :gcc - enable_debug - - # include all core GEMs - conf.gembox 'full-core' - conf.cc.flags += %w(-Werror=declaration-after-statement) - conf.cc.defines += %w(MRB_GC_STRESS MRB_METHOD_CACHE MRB_ENABLE_DEBUG_HOOK) - - conf.enable_test -end - -MRuby::Build.new do |conf| - toolchain :gcc - - # include all core GEMs - conf.gembox 'full-core' - conf.cc.flags += %w(-Werror=declaration-after-statement) - conf.compilers.each do |c| - c.defines += %w(MRB_GC_FIXED_ARENA) - end - conf.enable_bintest - conf.enable_test -end - -MRuby::Build.new('cxx_abi') do |conf| - toolchain :gcc - - conf.gembox 'full-core' - conf.cc.flags += %w(-fpermissive) - conf.compilers.each do |c| - c.defines += %w(MRB_GC_FIXED_ARENA) - end - conf.enable_bintest - conf.enable_test - - enable_cxx_abi - - build_mrbc_exec -end -- cgit v1.2.3 From b3db34c2a8323acd6035f439a2e32d8ab66614c2 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 12 May 2020 18:42:33 +0900 Subject: Remove `presym` files before writing just to make sure. --- Rakefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 6ccdcd958..8064d2000 100644 --- a/Rakefile +++ b/Rakefile @@ -131,6 +131,7 @@ file presym_file => cfiles+rbfiles do symbols = (csymbols+rbsymbols).flatten.uniq.sort presyms = File.readlines(presym_file, chomp: true) rescue [] if presyms != symbols + rm_f presym_file File.write(presym_file, symbols.join("\n")) end end @@ -138,6 +139,7 @@ end presym_inc=presym_file+".inc" file presym_inc => presym_file do presyms = File.readlines(presym_file, chomp: true) + rm_f presym_inc File.open(presym_inc, "w") do |f| f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n" f.print "/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */\n\n" -- cgit v1.2.3 From 5a88904fe886fc79f8e6a3f47ec7a782c987c96c Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 12 May 2020 18:59:43 +0900 Subject: Use `File.open` instead of `File.write` shortcut. --- Rakefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 8064d2000..d475bcff7 100644 --- a/Rakefile +++ b/Rakefile @@ -132,7 +132,11 @@ file presym_file => cfiles+rbfiles do presyms = File.readlines(presym_file, chomp: true) rescue [] if presyms != symbols rm_f presym_file - File.write(presym_file, symbols.join("\n")) + File.open(presym_file, "w") do |f| + symbols.each do|line| + f.puts line + end + end end end -- cgit v1.2.3 From 8d90c7c0fa755f90262f986899e60e8fc99af4d3 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 12 May 2020 21:25:26 +0900 Subject: Remove unused variable from `Rakefile`. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index d475bcff7..56951b02a 100644 --- a/Rakefile +++ b/Rakefile @@ -111,7 +111,7 @@ rbfiles = (Dir.glob("#{MRUBY_ROOT}/mrblib/*.rb")+ Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/*.rb")+ Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/mrblib/*.rb")).uniq presym_file="#{MRUBY_ROOT}/build/presym" -predef_symbols = nil + desc "preallocated symbols" file presym_file => cfiles+rbfiles do csymbols = cfiles.map do |f| -- cgit v1.2.3 From acd5317fb1832c82cd1c6773ecbbb3f07b19fb06 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 15 May 2020 15:50:09 +0900 Subject: Create `build` directory first before `gensym`. --- Rakefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 56951b02a..8c7533b43 100644 --- a/Rakefile +++ b/Rakefile @@ -104,6 +104,7 @@ MRuby.each_target do |target| end end +mkdir_p "#{MRUBY_ROOT}/build" cfiles = (Dir.glob("#{MRUBY_ROOT}/src/*.c")+ Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{core,src}/*.c")+ Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{src,core}/*.c")).uniq -- cgit v1.2.3 From 1bcf6d9f3cacf6a5c54ee0c74d0dad0f0e9ed436 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 15 May 2020 16:44:36 +0900 Subject: Create `MRB_OPSYM()` macro to refer symbols corresponding operators. For example, `MRB_OPSYM(add)` refers a symbol for `+`. --- Rakefile | 35 +++++++++++++++++++++++++++++++++++ include/mruby/presym.h | 5 ++++- src/symbol.c | 2 ++ 3 files changed, 41 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 8c7533b43..2aa96fc1a 100644 --- a/Rakefile +++ b/Rakefile @@ -146,11 +146,46 @@ file presym_inc => presym_file do presyms = File.readlines(presym_file, chomp: true) rm_f presym_inc File.open(presym_inc, "w") do |f| + op_table = { + "!" => "not", + "!=" => "neq", + "!~" => "nmatch", + "%" => "mod", + "&" => "and", + "&&" => "andand", + "*" => "mul", + "**" => "pow", + "+" => "add", + "+@" => "plus", + "-" => "sub", + "-@" => "minus", + "/" => "div", + "<" => "lt", + "<=" => "le", + "<<" => "lshift", + "<=>" => "cmp", + "==" => "eq", + "===" => "eqq", + "=~" => "match", + ">" => "gt", + ">=" => "ge", + ">>" => "rshift", + "[]" => "aref", + "[]=" => "aset", + "^" => "xor", + "`" => "tick", + "|" => "or", + "||" => "oror", + "~" => "neg", + } f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n" + f.print "/* MRB_PRESYM_OPSYM(op, sym, num) - symbol which is an operator id */\n" f.print "/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */\n\n" presyms.each.with_index do |sym,i| if /\A\w+\Z/ =~ sym f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n" + elsif op_table.key?(sym) + f.print "MRB_PRESYM_OPSYM(#{sym}, #{op_table[sym]}, #{i+1})\n" else f.print "MRB_PRESYM_SYM(#{sym}, #{i+1})\n" end diff --git a/include/mruby/presym.h b/include/mruby/presym.h index ff3cc7ac5..bd3918c52 100644 --- a/include/mruby/presym.h +++ b/include/mruby/presym.h @@ -9,14 +9,17 @@ #undef MRB_PRESYM_MAX #define MRB_PRESYM_CSYM(sym, num) MRB_PRESYM__##sym = (num<<1), -#define MRB_PRESYM_SYM(sym, num) +#define MRB_PRESYM_OPSYM(op, sym, num) MRB_PRESYM_op_##sym = (num<<1), +#define MRB_PRESYM_SYM(sym, num) enum mruby_presym { #include <../build/presym.inc> }; #undef MRB_PRESYM_CSYM +#undef MRB_PRESYM_OPSYM #undef MRB_PRESYM_SYM #define MRB_SYM(sym) MRB_PRESYM__##sym +#define MRB_OPSYM(sym) MRB_PRESYM_op_##sym #endif /* MRUBY_PRESYM_H */ diff --git a/src/symbol.c b/src/symbol.c index 35c3c3015..5f30ccb39 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -14,8 +14,10 @@ #undef MRB_PRESYM_MAX #undef MRB_PRESYM_CSYM +#undef MRB_PRESYM_OPSYM #undef MRB_PRESYM_SYM #define MRB_PRESYM_CSYM(sym, num) #sym, +#define MRB_PRESYM_OPSYM(op, sym, num) #op, #define MRB_PRESYM_SYM(sym, num) #sym, static const char *presym_table[] = { -- cgit v1.2.3 From 6128ae61a81d12892eac5397af74e4ce6ab99b06 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 15 May 2020 17:46:18 +0900 Subject: Simplified `Rakefile`. --- Rakefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 2aa96fc1a..f4a5c7573 100644 --- a/Rakefile +++ b/Rakefile @@ -132,19 +132,13 @@ file presym_file => cfiles+rbfiles do symbols = (csymbols+rbsymbols).flatten.uniq.sort presyms = File.readlines(presym_file, chomp: true) rescue [] if presyms != symbols - rm_f presym_file - File.open(presym_file, "w") do |f| - symbols.each do|line| - f.puts line - end - end + File.write(presym_file, symbols.join("\n")) end end presym_inc=presym_file+".inc" file presym_inc => presym_file do presyms = File.readlines(presym_file, chomp: true) - rm_f presym_inc File.open(presym_inc, "w") do |f| op_table = { "!" => "not", -- cgit v1.2.3 From 246c76e261ee033210527cfcd37c8eb4bfe680c7 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 15 May 2020 18:04:57 +0900 Subject: Rename `MRB_OPSYM()` to `MRB_QSYM()`. Where `QSYM` means quoted symbols, which cannot be represented C symbols, so specify aliases instead. - operators: name of the operation, e.g. add for `+` - predicates: add `_p` suffix instead of `?` - bang methods: add `_b` suffix instead of `!` - instance variables: add `a_` prefix instead of `@` - global variables: add `d_` prefix instead of `@` - class variables: unsupported; don't use them --- Rakefile | 16 ++++++++++++++-- include/mruby/presym.h | 6 +++--- src/kernel.c | 2 +- src/symbol.c | 4 ++-- 4 files changed, 20 insertions(+), 8 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index f4a5c7573..9de12fb57 100644 --- a/Rakefile +++ b/Rakefile @@ -173,13 +173,25 @@ file presym_inc => presym_file do "~" => "neg", } f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n" - f.print "/* MRB_PRESYM_OPSYM(op, sym, num) - symbol which is an operator id */\n" + f.print "/* MRB_PRESYM_QSYM(sym, name, num) - symbol with alias name */\n" f.print "/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */\n\n" presyms.each.with_index do |sym,i| if /\A\w+\Z/ =~ sym f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n" elsif op_table.key?(sym) - f.print "MRB_PRESYM_OPSYM(#{sym}, #{op_table[sym]}, #{i+1})\n" + f.print "MRB_PRESYM_QSYM(#{sym}, #{op_table[sym]}, #{i+1})\n" + elsif /\?\Z/ =~ sym + s = sym.dup; s[-1] = "_p" + f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + elsif /\!\Z/ =~ sym + s = sym.dup; s[-1] = "_b" + f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + elsif /\A@/ =~ sym + s = sym.dup; s[0] = "a_" + f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + elsif /\A$/ =~ sym + s = sym.dup; s[0] = "d_" + f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" else f.print "MRB_PRESYM_SYM(#{sym}, #{i+1})\n" end diff --git a/include/mruby/presym.h b/include/mruby/presym.h index bd3918c52..33e51fe18 100644 --- a/include/mruby/presym.h +++ b/include/mruby/presym.h @@ -9,7 +9,7 @@ #undef MRB_PRESYM_MAX #define MRB_PRESYM_CSYM(sym, num) MRB_PRESYM__##sym = (num<<1), -#define MRB_PRESYM_OPSYM(op, sym, num) MRB_PRESYM_op_##sym = (num<<1), +#define MRB_PRESYM_QSYM(src, sym, num) MRB_PRESYM_q_##sym = (num<<1), #define MRB_PRESYM_SYM(sym, num) enum mruby_presym { @@ -17,9 +17,9 @@ enum mruby_presym { }; #undef MRB_PRESYM_CSYM -#undef MRB_PRESYM_OPSYM +#undef MRB_PRESYM_QSYM #undef MRB_PRESYM_SYM #define MRB_SYM(sym) MRB_PRESYM__##sym -#define MRB_OPSYM(sym) MRB_PRESYM_op_##sym +#define MRB_QSYM(sym) MRB_PRESYM_q_##sym #endif /* MRUBY_PRESYM_H */ diff --git a/src/kernel.c b/src/kernel.c index d2074c16b..bc42a75d7 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -766,7 +766,7 @@ mrb_obj_ceqq(mrb_state *mrb, mrb_value self) { mrb_value v = mrb_get_arg1(mrb); mrb_int i, len; - mrb_sym eqq = MRB_OPSYM(eqq); + mrb_sym eqq = MRB_QSYM(eqq); mrb_value ary; if (mrb_array_p(self)) { diff --git a/src/symbol.c b/src/symbol.c index 5f30ccb39..6a72a83c6 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -14,10 +14,10 @@ #undef MRB_PRESYM_MAX #undef MRB_PRESYM_CSYM -#undef MRB_PRESYM_OPSYM +#undef MRB_PRESYM_QSYM #undef MRB_PRESYM_SYM #define MRB_PRESYM_CSYM(sym, num) #sym, -#define MRB_PRESYM_OPSYM(op, sym, num) #op, +#define MRB_PRESYM_QSYM(sym, name, num) #sym, #define MRB_PRESYM_SYM(sym, num) #sym, static const char *presym_table[] = { -- cgit v1.2.3 From e2063fc267c384a73fc6e432cfee04d8ada2cc97 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 15 May 2020 19:17:29 +0900 Subject: Add operators to `presym` from `Rakefile`. --- Rakefile | 78 ++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 36 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 9de12fb57..c5dc31f19 100644 --- a/Rakefile +++ b/Rakefile @@ -112,8 +112,39 @@ rbfiles = (Dir.glob("#{MRUBY_ROOT}/mrblib/*.rb")+ Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/*.rb")+ Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/mrblib/*.rb")).uniq presym_file="#{MRUBY_ROOT}/build/presym" +op_table = { + "!" => "not", + "!=" => "neq", + "!~" => "nmatch", + "%" => "mod", + "&" => "and", + "&&" => "andand", + "*" => "mul", + "**" => "pow", + "+" => "add", + "+@" => "plus", + "-" => "sub", + "-@" => "minus", + "/" => "div", + "<" => "lt", + "<=" => "le", + "<<" => "lshift", + "<=>" => "cmp", + "==" => "eq", + "===" => "eqq", + "=~" => "match", + ">" => "gt", + ">=" => "ge", + ">>" => "rshift", + "[]" => "aref", + "[]=" => "aset", + "^" => "xor", + "`" => "tick", + "|" => "or", + "||" => "oror", + "~" => "neg", +} -desc "preallocated symbols" file presym_file => cfiles+rbfiles do csymbols = cfiles.map do |f| src = File.read(f) @@ -121,7 +152,10 @@ file presym_file => cfiles+rbfiles do src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_class\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_module\([^\n"]*"([^\n"]*)"/), - src.scan(/MRB_SYM\((\w+)\)/)] + src.scan(/MRB_SYM\((\w+)\)/), + src.scan(/MRB_QSYM\((\w+)\)/).map{|x,| + x.sub!(/_p$/, "?") || x.sub!(/_b$/, "!") || x.sub!(/_e$/, "=") || x.sub!(/^a_/, "@") || x.sub!(/^d_/, "$") + }.compact] end rbsymbols = rbfiles.map do |f| src = File.read(f) @@ -129,7 +163,7 @@ file presym_file => cfiles+rbfiles do src.scan(/\bmodule +([A-Z]\w*)/), src.scan(/\bdef +(\w+)/)] end - symbols = (csymbols+rbsymbols).flatten.uniq.sort + symbols = (csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.sort presyms = File.readlines(presym_file, chomp: true) rescue [] if presyms != symbols File.write(presym_file, symbols.join("\n")) @@ -140,38 +174,6 @@ presym_inc=presym_file+".inc" file presym_inc => presym_file do presyms = File.readlines(presym_file, chomp: true) File.open(presym_inc, "w") do |f| - op_table = { - "!" => "not", - "!=" => "neq", - "!~" => "nmatch", - "%" => "mod", - "&" => "and", - "&&" => "andand", - "*" => "mul", - "**" => "pow", - "+" => "add", - "+@" => "plus", - "-" => "sub", - "-@" => "minus", - "/" => "div", - "<" => "lt", - "<=" => "le", - "<<" => "lshift", - "<=>" => "cmp", - "==" => "eq", - "===" => "eqq", - "=~" => "match", - ">" => "gt", - ">=" => "ge", - ">>" => "rshift", - "[]" => "aref", - "[]=" => "aset", - "^" => "xor", - "`" => "tick", - "|" => "or", - "||" => "oror", - "~" => "neg", - } f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n" f.print "/* MRB_PRESYM_QSYM(sym, name, num) - symbol with alias name */\n" f.print "/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */\n\n" @@ -186,6 +188,9 @@ file presym_inc => presym_file do elsif /\!\Z/ =~ sym s = sym.dup; s[-1] = "_b" f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + elsif /\=\Z/ =~ sym + s = sym.dup; s[-1] = "_e" + f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" elsif /\A@/ =~ sym s = sym.dup; s[0] = "a_" f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" @@ -200,8 +205,9 @@ file presym_inc => presym_file do end end +desc "preallocated symbols" task :gensym => presym_inc -depfiles.unshift "gensym" +#task :all => :gensym depfiles += MRuby.targets.map { |n, t| t.libraries -- cgit v1.2.3 From 0881e3449619c4c917287d7e4bd441f9c86b18b2 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 15 May 2020 20:33:43 +0900 Subject: Add dependency from `all` to `gensym`. You don't need to invoke `rake gensym` explicitly any longer. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index c5dc31f19..4fb7c9cb8 100644 --- a/Rakefile +++ b/Rakefile @@ -207,7 +207,7 @@ end desc "preallocated symbols" task :gensym => presym_inc -#task :all => :gensym +task :all => :gensym depfiles += MRuby.targets.map { |n, t| t.libraries -- cgit v1.2.3 From 312f54b580797613207059a16164313dcb558f73 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 16 May 2020 21:39:08 +0900 Subject: Add `Rakefile` to `build/presym` dependency. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 4fb7c9cb8..7b50eeffe 100644 --- a/Rakefile +++ b/Rakefile @@ -145,7 +145,7 @@ op_table = { "~" => "neg", } -file presym_file => cfiles+rbfiles do +file presym_file => cfiles+rbfiles+[__FILE__] do csymbols = cfiles.map do |f| src = File.read(f) [src.scan(/intern_lit\([^\n"]*"([^\n "]*)"/), -- cgit v1.2.3 From 7ab7cadbbb012d9431928d9cfae09451eab86613 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 5 Jun 2020 09:53:48 +0900 Subject: Stringify non C identifier symbols to stop macro errors by old gcc. --- Rakefile | 14 +++++++------- include/mruby/presym.h | 2 +- src/symbol.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 7b50eeffe..1452d7903 100644 --- a/Rakefile +++ b/Rakefile @@ -181,24 +181,24 @@ file presym_inc => presym_file do if /\A\w+\Z/ =~ sym f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n" elsif op_table.key?(sym) - f.print "MRB_PRESYM_QSYM(#{sym}, #{op_table[sym]}, #{i+1})\n" + f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{op_table[sym]}, #{i+1})\n" elsif /\?\Z/ =~ sym s = sym.dup; s[-1] = "_p" - f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" elsif /\!\Z/ =~ sym s = sym.dup; s[-1] = "_b" - f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" elsif /\=\Z/ =~ sym s = sym.dup; s[-1] = "_e" - f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" elsif /\A@/ =~ sym s = sym.dup; s[0] = "a_" - f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" elsif /\A$/ =~ sym s = sym.dup; s[0] = "d_" - f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n" + f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" else - f.print "MRB_PRESYM_SYM(#{sym}, #{i+1})\n" + f.print "MRB_PRESYM_SYM(\"#{sym}\", #{i+1})\n" end end f.print "#define MRB_PRESYM_MAX #{presyms.size}" diff --git a/include/mruby/presym.h b/include/mruby/presym.h index 33e51fe18..3cc12e8fb 100644 --- a/include/mruby/presym.h +++ b/include/mruby/presym.h @@ -9,7 +9,7 @@ #undef MRB_PRESYM_MAX #define MRB_PRESYM_CSYM(sym, num) MRB_PRESYM__##sym = (num<<1), -#define MRB_PRESYM_QSYM(src, sym, num) MRB_PRESYM_q_##sym = (num<<1), +#define MRB_PRESYM_QSYM(str, sym, num) MRB_PRESYM_q_##sym = (num<<1), #define MRB_PRESYM_SYM(sym, num) enum mruby_presym { diff --git a/src/symbol.c b/src/symbol.c index 6a72a83c6..9981bad7c 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -17,8 +17,8 @@ #undef MRB_PRESYM_QSYM #undef MRB_PRESYM_SYM #define MRB_PRESYM_CSYM(sym, num) #sym, -#define MRB_PRESYM_QSYM(sym, name, num) #sym, -#define MRB_PRESYM_SYM(sym, num) #sym, +#define MRB_PRESYM_QSYM(str, name, num) str, +#define MRB_PRESYM_SYM(str, num) str, static const char *presym_table[] = { #include <../build/presym.inc> -- cgit v1.2.3 From 26da07db15c3628c6bb473ce4ae4bc98fa3f431b Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 5 Jun 2020 10:10:36 +0900 Subject: Avoid using `chomp:true` option to `File.readlines`. The option is not available in the old version of Ruby. --- Rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 1452d7903..e07ca16a8 100644 --- a/Rakefile +++ b/Rakefile @@ -164,7 +164,8 @@ file presym_file => cfiles+rbfiles+[__FILE__] do src.scan(/\bdef +(\w+)/)] end symbols = (csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.sort - presyms = File.readlines(presym_file, chomp: true) rescue [] + presyms = File.readlines(presym_file) rescue [] + presyms.each{|x| x.chomp!} if presyms != symbols File.write(presym_file, symbols.join("\n")) end -- cgit v1.2.3 From a68f005fd70050ce51284936c212efbc353ae735 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 5 Jun 2020 10:45:30 +0900 Subject: Remove remaining `chomp:true` option from `Rakefile`. --- Rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index e07ca16a8..d5a7b95bb 100644 --- a/Rakefile +++ b/Rakefile @@ -173,7 +173,8 @@ end presym_inc=presym_file+".inc" file presym_inc => presym_file do - presyms = File.readlines(presym_file, chomp: true) + presyms = File.readlines(presym_file) + presyms.each{|x| x.chomp!} File.open(presym_inc, "w") do |f| f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n" f.print "/* MRB_PRESYM_QSYM(sym, name, num) - symbol with alias name */\n" -- cgit v1.2.3 From f1c06eef7c17a5bf2ea4a35021d563af5f3147a9 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 9 Jun 2020 22:28:53 +0900 Subject: Scan more symbols from Ruby files by `rake gensym`. --- Rakefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index d5a7b95bb..75ed5c905 100644 --- a/Rakefile +++ b/Rakefile @@ -152,6 +152,7 @@ file presym_file => cfiles+rbfiles+[__FILE__] do src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_class\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_module\([^\n"]*"([^\n"]*)"/), + src.scan(/mrb_define_module_function\([^\n"]*"([^\n"]*)"/), src.scan(/MRB_SYM\((\w+)\)/), src.scan(/MRB_QSYM\((\w+)\)/).map{|x,| x.sub!(/_p$/, "?") || x.sub!(/_b$/, "!") || x.sub!(/_e$/, "=") || x.sub!(/^a_/, "@") || x.sub!(/^d_/, "$") @@ -161,7 +162,11 @@ file presym_file => cfiles+rbfiles+[__FILE__] do src = File.read(f) [src.scan(/\bclass +([A-Z]\w*)/), src.scan(/\bmodule +([A-Z]\w*)/), - src.scan(/\bdef +(\w+)/)] + src.scan(/\bdef +(\w+[!?]?)/), + src.scan(/\balias +(\w+[!?]?)/), + src.scan(/\b([A-Z]\w+) *=/), + src.scan(/(@\w+)/), + src.scan(/:(\w+)/)] end symbols = (csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.sort presyms = File.readlines(presym_file) rescue [] -- cgit v1.2.3 From 52507b1083ba1c562ae506d63a07a51a26815c21 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 11 Jun 2020 15:37:49 +0900 Subject: Generate C struct from `irep` instead of binary dump. --- Rakefile | 58 ++++++++---- include/mruby.h | 8 +- include/mruby/compile.h | 4 +- include/mruby/error.h | 4 +- include/mruby/proc.h | 7 +- lib/mruby/build/command.rb | 2 +- lib/mruby/gem.rb | 17 ++-- mrbgems/mruby-compiler/core/codegen.c | 2 +- mrbgems/mruby-compiler/core/parse.y | 4 +- mrbgems/mruby-compiler/core/y.tab.c | 4 +- mrbgems/mruby-enumerator/mrblib/enumerator.rb | 1 + mrbgems/mruby-metaprog/src/metaprog.c | 7 +- mrbgems/mruby-socket/src/socket.c | 4 +- mrbgems/mruby-symbol-ext/test/symbol.rb | 6 +- mrbgems/mruby-test/driver.c | 4 +- mrbgems/mruby-test/mrbgem.rake | 14 +-- mrblib/init_mrblib.c | 11 --- mrblib/mrblib.rake | 17 +++- src/class.c | 3 + src/dump.c | 123 +++++++++----------------- src/gc.c | 11 ++- src/kernel.c | 4 +- src/load.c | 6 ++ src/proc.c | 4 +- src/symbol.c | 9 ++ src/variable.c | 12 +-- src/vm.c | 26 +++--- test/presym | 4 + 28 files changed, 201 insertions(+), 175 deletions(-) create mode 100644 test/presym (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 75ed5c905..2198b27fd 100644 --- a/Rakefile +++ b/Rakefile @@ -106,11 +106,17 @@ end mkdir_p "#{MRUBY_ROOT}/build" cfiles = (Dir.glob("#{MRUBY_ROOT}/src/*.c")+ - Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{core,src}/*.c")+ - Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{src,core}/*.c")).uniq -rbfiles = (Dir.glob("#{MRUBY_ROOT}/mrblib/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/mrblib/*.rb")).uniq + Dir.glob("#{MRUBY_ROOT}/mrbgems/**/*.c")+ + Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{src,test,core}/*.c")).uniq +rbfiles = (Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{mrblib,test}/*.rb")).uniq +psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,test}/**/presym") +symbols = [] +psfiles.each do |file| + symbols += File.readlines(file).grep_v(/^# /) +end +symbols.each{|x| x.chomp!} presym_file="#{MRUBY_ROOT}/build/presym" op_table = { "!" => "not", @@ -145,30 +151,42 @@ op_table = { "~" => "neg", } -file presym_file => cfiles+rbfiles+[__FILE__] do +file presym_file => cfiles+rbfiles+psfiles+[__FILE__] do csymbols = cfiles.map do |f| src = File.read(f) [src.scan(/intern_lit\([^\n"]*"([^\n "]*)"/), src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/), + src.scan(/mrb_define_class_method\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_class\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_module\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_module_function\([^\n"]*"([^\n"]*)"/), + src.scan(/mrb_define_const\([^\n"]*"([^\n"]*)"/), + src.scan(/mrb_define_global_const\([^\n"]*"([^\n"]*)"/), src.scan(/MRB_SYM\((\w+)\)/), src.scan(/MRB_QSYM\((\w+)\)/).map{|x,| - x.sub!(/_p$/, "?") || x.sub!(/_b$/, "!") || x.sub!(/_e$/, "=") || x.sub!(/^a_/, "@") || x.sub!(/^d_/, "$") + x.sub!(/_p$/, "?") || x.sub!(/_b$/, "!") || x.sub!(/_e$/, "=") || x.sub!(/^0_/, "@") || x.sub!(/^00_/, "@@") }.compact] end rbsymbols = rbfiles.map do |f| src = File.read(f) + src.force_encoding(Encoding::BINARY) [src.scan(/\bclass +([A-Z]\w*)/), src.scan(/\bmodule +([A-Z]\w*)/), - src.scan(/\bdef +(\w+[!?]?)/), + src.scan(/\bdef +(\w+[!?=]?)/), src.scan(/\balias +(\w+[!?]?)/), - src.scan(/\b([A-Z]\w+) *=/), - src.scan(/(@\w+)/), - src.scan(/:(\w+)/)] + src.scan(/\b([A-Z]\w*) *=[^=]/), + src.scan(/(\$[a-zA-Z_]\w*)/), + src.scan(/(\$[$!?]\w*)/), + src.scan(/(@@?[a-zA-Z_]\w*)/), + src.scan(/[^.]\.([a-zA-Z_]\w*[!?]?)/), + src.scan(/\.([a-zA-Z_]\w* *=)/).map{|x|x.map{|s|s.gsub(' ', '')}}, + src.scan(/\b([a-zA-Z_]\w*):/), + src.scan(/:([a-zA-Z_]\w*[!?=]?)/), + src.scan(/[\(\[\{ ]:"([^"]+)"/).map{|x|x.map{|s|s.gsub('\#', '#')}}, + src.scan(/[ \(\[\{]:'([^']+)'/) + ] end - symbols = (csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.sort + symbols = (symbols+csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.sort.map{|x| x.gsub("\n", '\n')} presyms = File.readlines(presym_file) rescue [] presyms.each{|x| x.chomp!} if presyms != symbols @@ -182,10 +200,12 @@ file presym_inc => presym_file do presyms.each{|x| x.chomp!} File.open(presym_inc, "w") do |f| f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n" - f.print "/* MRB_PRESYM_QSYM(sym, name, num) - symbol with alias name */\n" - f.print "/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */\n\n" + f.print "/* MRB_PRESYM_QSYM(name, sym, num) - symbol with alias name */\n" + f.print "/* MRB_PRESYM_SYM(name, num) - symbol which is not valid C id */\n" presyms.each.with_index do |sym,i| - if /\A\w+\Z/ =~ sym + if sym.bytes.detect{|x|x>0x80} || /\A\$/ =~ sym + f.print "MRB_PRESYM_SYM(\"#{sym}\", #{i+1})\n" + elsif /\A\w+\Z/ =~ sym f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n" elsif op_table.key?(sym) f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{op_table[sym]}, #{i+1})\n" @@ -198,11 +218,11 @@ file presym_inc => presym_file do elsif /\=\Z/ =~ sym s = sym.dup; s[-1] = "_e" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" - elsif /\A@/ =~ sym - s = sym.dup; s[0] = "a_" + elsif /\A@@/ =~ sym + s = sym.dup; s[0,2] = "00_" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" - elsif /\A$/ =~ sym - s = sym.dup; s[0] = "d_" + elsif /\A@/ =~ sym + s = sym.dup; s[0] = "0_" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" else f.print "MRB_PRESYM_SYM(\"#{sym}\", #{i+1})\n" diff --git a/include/mruby.h b/include/mruby.h index 59188e6b5..27c428e85 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -147,7 +147,7 @@ typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud); typedef struct { mrb_sym mid; - struct RProc *proc; + const struct RProc *proc; mrb_value *stackent; uint16_t ridx; uint16_t epos; @@ -1202,9 +1202,9 @@ MRB_API void mrb_close(mrb_state *mrb); MRB_API void* mrb_default_allocf(mrb_state*, void*, size_t, void*); MRB_API mrb_value mrb_top_self(mrb_state *mrb); -MRB_API mrb_value mrb_top_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep); -MRB_API mrb_value mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep); -MRB_API mrb_value mrb_vm_exec(mrb_state *mrb, struct RProc *proc, const mrb_code *iseq); +MRB_API mrb_value mrb_top_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, unsigned int stack_keep); +MRB_API mrb_value mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, unsigned int stack_keep); +MRB_API mrb_value mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *iseq); /* compatibility macros */ #define mrb_toplevel_run_keep(m,p,k) mrb_top_run((m),(p),mrb_top_self(m),(k)) #define mrb_toplevel_run(m,p) mrb_toplevel_run_keep((m),(p),0) diff --git a/include/mruby/compile.h b/include/mruby/compile.h index e8ab91eb9..36adf5a32 100644 --- a/include/mruby/compile.h +++ b/include/mruby/compile.h @@ -33,7 +33,7 @@ typedef struct mrbc_context { mrb_bool no_exec:1; mrb_bool keep_lv:1; mrb_bool no_optimize:1; - struct RProc *upper; + const struct RProc *upper; size_t parser_nerr; } mrbc_context; @@ -153,7 +153,7 @@ struct mrb_parser_state { mrb_bool no_optimize:1; mrb_bool capture_errors:1; - struct RProc *upper; + const struct RProc *upper; struct mrb_parser_message error_buffer[10]; struct mrb_parser_message warn_buffer[10]; diff --git a/include/mruby/error.h b/include/mruby/error.h index d24b5b0c3..72f6c5f3d 100644 --- a/include/mruby/error.h +++ b/include/mruby/error.h @@ -35,7 +35,7 @@ MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value); #if defined(MRB_64BIT) || defined(MRB_USE_FLOAT) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING) struct RBreak { MRB_OBJECT_HEADER; - struct RProc *proc; + const struct RProc *proc; mrb_value val; }; #define mrb_break_value_get(brk) ((brk)->val) @@ -43,7 +43,7 @@ struct RBreak { #else struct RBreak { MRB_OBJECT_HEADER; - struct RProc *proc; + const struct RProc *proc; union mrb_value_union value; }; #define RBREAK_VALUE_TT_MASK ((1 << 8) - 1) diff --git a/include/mruby/proc.h b/include/mruby/proc.h index 2d06210ef..fe0cf2eb0 100644 --- a/include/mruby/proc.h +++ b/include/mruby/proc.h @@ -44,7 +44,7 @@ struct RProc { const mrb_irep *irep; mrb_func_t func; } body; - struct RProc *upper; + const struct RProc *upper; union { struct RClass *target_class; struct REnv *env; @@ -93,9 +93,6 @@ MRB_API struct RProc *mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int void mrb_proc_copy(struct RProc *a, struct RProc *b); mrb_int mrb_proc_arity(const struct RProc *p); -/* implementation of #send method */ -mrb_value mrb_f_send(mrb_state *mrb, mrb_value self); - /* following functions are defined in mruby-proc-ext so please include it when using */ MRB_API struct RProc *mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const mrb_value *argv); MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx); @@ -137,6 +134,8 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx); #include KHASH_DECLARE(mt, mrb_sym, mrb_method_t, TRUE) +MRB_API mrb_value mrb_load_proc(mrb_state *mrb, const struct RProc *proc); + MRB_END_DECL #endif /* MRUBY_PROC_H */ diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 84ce78cb9..39981cc32 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -310,7 +310,7 @@ module MRuby def initialize(build) super @command = nil - @compile_options = "-B%{funcname} -o-" + @compile_options = "-S -B%{funcname} -o-" end def run(out, infiles, funcname) diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb index 6fcaad9c1..d6b1a6851 100644 --- a/lib/mruby/gem.rb +++ b/lib/mruby/gem.rb @@ -174,7 +174,7 @@ module MRuby def generate_gem_init(fname) open(fname, 'w') do |f| print_gem_init_header f - build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}" unless rbfiles.empty? + build.mrbc.run f, rbfiles, "gem_mrblib_#{funcname}_proc" unless rbfiles.empty? f.puts %Q[void mrb_#{funcname}_gem_init(mrb_state *mrb);] f.puts %Q[void mrb_#{funcname}_gem_final(mrb_state *mrb);] f.puts %Q[] @@ -183,7 +183,7 @@ module MRuby f.puts %Q[ struct REnv *e;] unless rbfiles.empty? f.puts %Q[ mrb_#{funcname}_gem_init(mrb);] if objs != [objfile("#{build_dir}/gem_init")] unless rbfiles.empty? - f.puts %Q[ mrb_load_irep(mrb, gem_mrblib_irep_#{funcname});] + f.puts %Q[ mrb_load_proc(mrb, gem_mrblib_#{funcname}_proc);] f.puts %Q[ if (mrb->exc) {] f.puts %Q[ mrb_print_error(mrb);] f.puts %Q[ mrb_close(mrb);] @@ -215,10 +215,13 @@ module MRuby def print_gem_init_header(f) print_gem_comment(f) - f.puts %Q[#include ] unless rbfiles.empty? - f.puts %Q[#include ] - f.puts %Q[#include ] unless rbfiles.empty? - f.puts %Q[#include ] unless rbfiles.empty? + unless rbfiles.empty? + f.puts %Q[#include ] + f.puts %Q[#include ] + f.puts %Q[#include ] + else + f.puts %Q[#include ] + end end def print_gem_test_header(f) @@ -226,7 +229,7 @@ module MRuby f.puts %Q[#include ] f.puts %Q[#include ] f.puts %Q[#include ] - f.puts %Q[#include ] + f.puts %Q[#include ] f.puts %Q[#include ] f.puts %Q[#include ] unless test_args.empty? end diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 0000e6dbe..5d29dcb2d 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -706,7 +706,7 @@ lv_idx(codegen_scope *s, mrb_sym id) static int search_upvar(codegen_scope *s, mrb_sym id, int *idx) { - struct RProc *u; + const struct RProc *u; int lv = 0; codegen_scope *up = s->prev; diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index cb4126713..c7c3d2a2f 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -265,7 +265,7 @@ local_unnest(parser_state *p) static mrb_bool local_var_p(parser_state *p, mrb_sym sym) { - struct RProc *u; + const struct RProc *u; node *l = p->locals; while (l) { @@ -282,7 +282,7 @@ local_var_p(parser_state *p, mrb_sym sym) const struct mrb_irep *ir = u->body.irep; uint_fast16_t n = ir->nlocals; const struct mrb_lvinfo *v = ir->lv; - for (; n > 1; n --, v ++) { + for (; v && n > 1; n--, v++) { if (v->name == sym) return TRUE; } if (MRB_PROC_SCOPE_P(u)) break; diff --git a/mrbgems/mruby-compiler/core/y.tab.c b/mrbgems/mruby-compiler/core/y.tab.c index 504ec6d04..dbcc6a5bd 100644 --- a/mrbgems/mruby-compiler/core/y.tab.c +++ b/mrbgems/mruby-compiler/core/y.tab.c @@ -328,7 +328,7 @@ local_unnest(parser_state *p) static mrb_bool local_var_p(parser_state *p, mrb_sym sym) { - struct RProc *u; + const struct RProc *u; node *l = p->locals; while (l) { @@ -345,7 +345,7 @@ local_var_p(parser_state *p, mrb_sym sym) const struct mrb_irep *ir = u->body.irep; uint_fast16_t n = ir->nlocals; const struct mrb_lvinfo *v = ir->lv; - for (; n > 1; n --, v ++) { + for (; v && n > 1; n--, v++) { if (v->name == sym) return TRUE; } if (MRB_PROC_SCOPE_P(u)) break; diff --git a/mrbgems/mruby-enumerator/mrblib/enumerator.rb b/mrbgems/mruby-enumerator/mrblib/enumerator.rb index 5a98dc964..f007b8553 100644 --- a/mrbgems/mruby-enumerator/mrblib/enumerator.rb +++ b/mrbgems/mruby-enumerator/mrblib/enumerator.rb @@ -130,6 +130,7 @@ class Enumerator @feedvalue = nil @stop_exc = false end + attr_accessor :obj, :meth, :args attr_reader :fib diff --git a/mrbgems/mruby-metaprog/src/metaprog.c b/mrbgems/mruby-metaprog/src/metaprog.c index 8a4a6dc69..7a7639410 100644 --- a/mrbgems/mruby-metaprog/src/metaprog.c +++ b/mrbgems/mruby-metaprog/src/metaprog.c @@ -132,7 +132,7 @@ mrb_obj_ivar_set(mrb_state *mrb, mrb_value self) static mrb_value mrb_local_variables(mrb_state *mrb, mrb_value self) { - struct RProc *proc; + const struct RProc *proc; const mrb_irep *irep; mrb_value vars; size_t i; @@ -664,7 +664,7 @@ mrb_mod_s_constants(mrb_state *mrb, mrb_value mod) static mrb_value mrb_mod_s_nesting(mrb_state *mrb, mrb_value mod) { - struct RProc *proc; + const struct RProc *proc; mrb_value ary; struct RClass *c = NULL; @@ -684,6 +684,9 @@ mrb_mod_s_nesting(mrb_state *mrb, mrb_value mod) return ary; } +/* implementation of #send method */ +mrb_value mrb_f_send(mrb_state *mrb, mrb_value self); + void mrb_mruby_metaprog_gem_init(mrb_state* mrb) { diff --git a/mrbgems/mruby-socket/src/socket.c b/mrbgems/mruby-socket/src/socket.c index f158959a7..001021b81 100644 --- a/mrbgems/mruby-socket/src/socket.c +++ b/mrbgems/mruby-socket/src/socket.c @@ -200,7 +200,7 @@ mrb_addrinfo_getnameinfo(mrb_state *mrb, mrb_value self) host = mrb_str_buf_new(mrb, NI_MAXHOST); serv = mrb_str_buf_new(mrb, NI_MAXSERV); - sastr = mrb_iv_get(mrb, self, MRB_QSYM(a_sockaddr)); + sastr = mrb_iv_get(mrb, self, MRB_QSYM(0_sockaddr)); if (!mrb_string_p(sastr)) { mrb_raise(mrb, E_SOCKET_ERROR, "invalid sockaddr"); } @@ -222,7 +222,7 @@ mrb_addrinfo_unix_path(mrb_state *mrb, mrb_value self) { mrb_value sastr; - sastr = mrb_iv_get(mrb, self, MRB_QSYM(a_sockaddr)); + sastr = mrb_iv_get(mrb, self, MRB_QSYM(0_sockaddr)); if (((struct sockaddr *)RSTRING_PTR(sastr))->sa_family != AF_UNIX) mrb_raise(mrb, E_SOCKET_ERROR, "need AF_UNIX address"); if (RSTRING_LEN(sastr) < (mrb_int)offsetof(struct sockaddr_un, sun_path) + 1) { diff --git a/mrbgems/mruby-symbol-ext/test/symbol.rb b/mrbgems/mruby-symbol-ext/test/symbol.rb index db686e5f4..34c3c6ba5 100644 --- a/mrbgems/mruby-symbol-ext/test/symbol.rb +++ b/mrbgems/mruby-symbol-ext/test/symbol.rb @@ -13,13 +13,13 @@ end %w[size length].each do |n| assert("Symbol##{n}") do assert_equal 5, :hello.__send__(n) - assert_equal 4, :"aA\0b".__send__(n) + assert_equal 4, :"aA b".__send__(n) if __ENCODING__ == "UTF-8" assert_equal 8, :"こんにちは世界!".__send__(n) - assert_equal 4, :"aあ\0b".__send__(n) + assert_equal 4, :"aあ b".__send__(n) else assert_equal 22, :"こんにちは世界!".__send__(n) - assert_equal 6, :"aあ\0b".__send__(n) + assert_equal 6, :"aあ b".__send__(n) end end end diff --git a/mrbgems/mruby-test/driver.c b/mrbgems/mruby-test/driver.c index a5f723927..fe1a475d5 100644 --- a/mrbgems/mruby-test/driver.c +++ b/mrbgems/mruby-test/driver.c @@ -18,7 +18,7 @@ #include #include -extern const uint8_t mrbtest_assert_irep[]; +extern const struct RProc mrbtest_assert_proc[]; void mrbgemtest_init(mrb_state* mrb); void mrb_init_test_vformat(mrb_state* mrb); @@ -300,7 +300,7 @@ main(int argc, char **argv) } mrb_init_test_driver(mrb, verbose); - mrb_load_irep(mrb, mrbtest_assert_irep); + mrb_load_proc(mrb, mrbtest_assert_proc); mrbgemtest_init(mrb); ret = eval_test(mrb); mrb_close(mrb); diff --git a/mrbgems/mruby-test/mrbgem.rake b/mrbgems/mruby-test/mrbgem.rake index ced252ae6..9e8e4041f 100644 --- a/mrbgems/mruby-test/mrbgem.rake +++ b/mrbgems/mruby-test/mrbgem.rake @@ -28,7 +28,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| file assert_c => [assert_rb, build.mrbcfile] do |t| mkdir_p File.dirname(t.name) open(t.name, 'w') do |f| - mrbc.run f, assert_rb, 'mrbtest_assert_irep' + mrbc.run f, assert_rb, 'mrbtest_assert_proc' end end @@ -56,12 +56,12 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| 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[];] + f.puts %Q[extern const struct RProc mrbtest_assert_proc[];] else - g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload" + g.build.mrbc.run f, test_preload, "gem_test_#{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}" + g.build.mrbc.run f, rbfile, "gem_test_#{g.funcname}_#{i}_proc" end f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] unless g.test_objs.empty? dep_list.each do |d| @@ -90,9 +90,9 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| 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);] + f.puts %Q[ mrb_load_proc(mrb2, mrbtest_assert_proc);] else - f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_preload);] + f.puts %Q[ mrb_load_proc(mrb2, gem_test_#{g.funcname}_preload);] end f.puts %Q[ if (mrb2->exc) {] f.puts %Q[ mrb_print_error(mrb2);] @@ -113,7 +113,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| 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[ mrb_load_proc(mrb2, gem_test_#{g.funcname}_#{i}_proc);] f.puts %Q[ ] f.puts %Q[ mrb_t_pass_result(mrb, mrb2);] diff --git a/mrblib/init_mrblib.c b/mrblib/init_mrblib.c index 4d4bcd25a..e69de29bb 100644 --- a/mrblib/init_mrblib.c +++ b/mrblib/init_mrblib.c @@ -1,11 +0,0 @@ -#include -#include - -extern const uint8_t mrblib_irep[]; - -void -mrb_init_mrblib(mrb_state *mrb) -{ - mrb_load_irep(mrb, mrblib_irep); -} - diff --git a/mrblib/mrblib.rake b/mrblib/mrblib.rake index 6fba0adc1..724d328fa 100644 --- a/mrblib/mrblib.rake +++ b/mrblib/mrblib.rake @@ -11,8 +11,21 @@ MRuby.each_target do mkdir_p File.dirname(t.name) open(t.name, 'w') do |f| _pp "GEN", "*.rb", "#{t.name.relative_path}" - f.puts File.read("#{current_dir}/init_mrblib.c") - mrbc.run f, rbfiles, 'mrblib_irep' + f.puts %Q[/*] + f.puts %Q[ * This file is loading the mrblib] + 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[ */] + mrbc.run f, rbfiles, 'mrblib_proc' + f.puts <u.i64); break; case IREP_TT_FLOAT: - fprintf(fp, "{IREP_TT_FLOAT, {.f="MRB_FLOAT_FMT"}},\n", p->u.f); + if (p->u.f == 0) { + fprintf(fp, "{IREP_TT_FLOAT, {.f=%#.1f}},\n", p->u.f); + } + else { + fprintf(fp, "{IREP_TT_FLOAT, {.f="MRB_FLOAT_FMT"}},\n", p->u.f); + } break; } } @@ -951,83 +956,28 @@ dump_pool(mrb_state *mrb, const mrb_pool_value *p, FILE *fp) const char *s = p->u.str; fprintf(fp, "{IREP_TT_STR|(%d<<2), {.str=\"", len); for (i=0; i", "cmp"}, - {"==", "eq"}, - {"===", "eqq"}, - {"=~", "match"}, - {">", "gt"}, - {">=", "ge"}, - {">>", "rshift"}, - {"[]", "aref"}, - {"[]=", "aset"}, - {"^", "xor"}, - {"`", "tick"}, - {"|", "or"}, - {"||", "oror"}, - {"~", "neg"}, - {0}, -}; - +mrb_bool mrb_sym_static_p(mrb_state *mrb, mrb_sym sym); + static int dump_sym(mrb_state *mrb, mrb_sym sym, FILE *fp) { - mrb_int len; - const char *name = mrb_sym_name_len(mrb, sym, &len); - int i; - - if (len == 0 || len != strlen(name)) - return MRB_DUMP_INVALID_ARGUMENT; - for (i=0; op_table[i].op; i++) { - if (strcmp(name, op_table[i].op) == 0) { - fprintf(fp, "MRB_QSYM(%s),", op_table[i].name); - return MRB_DUMP_OK; - } - } - if (name[0] == '@') { - fprintf(fp, "MRB_QSYM(a_%s),", name+1); - } - else if (name[0] == '$') { - fprintf(fp, "MRB_QSYM(d_%s),", name+1); - } - else if (name[len-1] == '!') { - fprintf(fp, "MRB_QSYM(%.*s_b),", (int)len-1, name); - } - else if (name[len-1] == '?') { - fprintf(fp, "MRB_QSYM(%.*s_p),", (int)len-1, name); - } - else if (name[len-1] == '=') { - fprintf(fp, "MRB_QSYM(%.*s_e),", (int)len-1, name); + const char *name; + if (sym == 0) return MRB_DUMP_INVALID_ARGUMENT; + name = mrb_sym_name(mrb, sym); + if (!name) { + fprintf(stderr, "undefined symbol (%d) - define presym\n", sym); } - else { - fprintf(fp, "MRB_SYM(%s),", name); + if (!mrb_sym_static_p(mrb, sym)) { + fprintf(stderr, "no static symbol (%s) - define presym\n", name); } + fprintf(fp, "%d /* %s */,", sym, name); return MRB_DUMP_OK; } @@ -1065,8 +1015,7 @@ dump_irep_struct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, len=irep->slen; fprintf(fp, "static const mrb_sym %s_syms_%d[%d] = {", name, n, len); for (i=0; isyms[i], fp) != MRB_DUMP_OK) - return MRB_DUMP_INVALID_ARGUMENT; + dump_sym(mrb, irep->syms[i], fp); } fputs("};\n", fp); } @@ -1078,13 +1027,17 @@ dump_irep_struct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, fprintf(fp, "0x%02x,", irep->iseq[i]); } fputs("};\n", fp); - /* dump irep */ - if (n == 0) { /* topleve irep */ - fprintf(fp, "static const mrb_irep %s = {\n", name); - } - else { - fprintf(fp, "static const mrb_irep %s_irep_%d = {\n", name, n); + /* dump lv */ + if (irep->lv) { + len=irep->nlocals; + fprintf(fp, "static const struct mrb_lvinfo %s_lv_%d[%d] = {", name, n, len); + for (i=0; i+1lv[i].name, irep->lv[i].r); + } + fputs("};\n", fp); } + /* dump irep */ + fprintf(fp, "static const mrb_irep %s_irep_%d = {\n", name, n); fprintf(fp, " %d,%d,\n", irep->nlocals, irep->nregs); fprintf(fp, " MRB_IREP_STATIC,%s_iseq_%d,\n", name, n); if (irep->pool) { @@ -1105,9 +1058,14 @@ dump_irep_struct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, else { fputs( "NULL,\n", fp); } - fputs( " NULL,\t\t\t\t\t/* lv */\n", fp); + if (irep->lv) { + fprintf(fp, "%s_lv_%d,\n", name, n); + } + else { + fputs( " NULL,\t\t\t\t\t/* lv */\n", fp); + } fputs( " NULL,\t\t\t\t\t/* debug_info */\n", fp); - fprintf(fp, " %d,%d,%d,%d,0\n};", irep->ilen, irep->plen, irep->slen, irep->rlen); + fprintf(fp, " %d,%d,%d,%d,0\n};\n", irep->ilen, irep->plen, irep->slen, irep->rlen); return MRB_DUMP_OK; } @@ -1116,13 +1074,20 @@ int mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, const char *initname) { int max = 1; + int n; + if (fp == NULL || initname == NULL || initname[0] == '\0') { return MRB_DUMP_INVALID_ARGUMENT; } - if (fprintf(fp, "#include \n" "#include \n\n") < 0) { + if (fprintf(fp, "#include \n" "#include \n\n") < 0) { return MRB_DUMP_WRITE_FAULT; } - return dump_irep_struct(mrb, irep, flags, fp, initname, 0, &max); + n = dump_irep_struct(mrb, irep, flags, fp, initname, 0, &max); + if (n != MRB_DUMP_OK) return n; + fprintf(fp, "#ifdef __cplusplus\nextern struct RProc %s[];\n#endif\n", initname); + fprintf(fp, "struct RProc %s[] = {{\n", initname); + fprintf(fp, "NULL,NULL,MRB_TT_PROC,7,0,{&%s_irep_0},NULL,{NULL},\n}};\n", initname); + return MRB_DUMP_OK; } #endif /* MRB_DISABLE_STDIO */ diff --git a/src/gc.c b/src/gc.c index 897fa256f..4bee82364 100644 --- a/src/gc.c +++ b/src/gc.c @@ -35,6 +35,11 @@ * Gray - Marked, But the child objects are unmarked. * Black - Marked, the child objects are also marked. + Extra color + + * Red - Static (ROM object) no need to be collected. + - All child objects should be Red as well. + == Two White Types There're two white color types in a flip-flop fashion: White-A and White-B, @@ -185,6 +190,7 @@ gettimeofday_time(void) #define GC_WHITE_A 1 #define GC_WHITE_B (1 << 1) #define GC_BLACK (1 << 2) +#define GC_RED 7 #define GC_WHITES (GC_WHITE_A | GC_WHITE_B) #define GC_COLOR_MASK 7 @@ -194,7 +200,8 @@ gettimeofday_time(void) #define paint_partial_white(s, o) ((o)->color = (s)->current_white_part) #define is_gray(o) ((o)->color == GC_GRAY) #define is_white(o) ((o)->color & GC_WHITES) -#define is_black(o) ((o)->color & GC_BLACK) +#define is_black(o) ((o)->color == GC_BLACK) +#define is_red(o) ((o)->color == GC_RED) #define flip_white_part(s) ((s)->current_white_part = other_white_part(s)) #define other_white_part(s) ((s)->current_white_part ^ GC_WHITES) #define is_dead(s, o) (((o)->color & other_white_part(s) & GC_WHITES) || (o)->tt == MRB_TT_FREE) @@ -584,7 +591,7 @@ add_gray_list(mrb_state *mrb, mrb_gc *gc, struct RBasic *obj) static int ci_nregs(mrb_callinfo *ci) { - struct RProc *p = ci->proc; + const struct RProc *p = ci->proc; int n = 0; if (!p) { diff --git a/src/kernel.c b/src/kernel.c index 519052f4b..e4948143d 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -19,7 +19,7 @@ mrb_func_basic_p(mrb_state *mrb, mrb_value obj, mrb_sym mid, mrb_func_t func) { struct RClass *c = mrb_class(mrb, obj); mrb_method_t m = mrb_method_search_vm(mrb, &c, mid); - struct RProc *p; + const struct RProc *p; if (MRB_METHOD_UNDEF_P(m)) return FALSE; if (MRB_METHOD_FUNC_P(m)) @@ -143,7 +143,7 @@ mrb_f_block_given_p_m(mrb_state *mrb, mrb_value self) mrb_value *bp; int bidx; struct REnv *e = NULL; - struct RProc *p; + const struct RProc *p; if (ci <= cibase) { /* toplevel does not have block */ diff --git a/src/load.c b/src/load.c index 39644c34b..31059e833 100644 --- a/src/load.c +++ b/src/load.c @@ -676,6 +676,12 @@ mrb_load_irep_buf(mrb_state *mrb, const void *buf, size_t bufsize) return mrb_load_irep_buf_cxt(mrb, buf, bufsize, NULL); } +MRB_API mrb_value +mrb_load_proc(mrb_state *mrb, const struct RProc *proc) +{ + return mrb_vm_run(mrb, proc, mrb_top_self(mrb), 0); +} + #ifndef MRB_DISABLE_STDIO mrb_irep* diff --git a/src/proc.c b/src/proc.c index 2da2ec77e..14ba407d8 100644 --- a/src/proc.c +++ b/src/proc.c @@ -80,7 +80,7 @@ static void closure_setup(mrb_state *mrb, struct RProc *p) { mrb_callinfo *ci = mrb->c->ci; - struct RProc *up = p->upper; + const struct RProc *up = p->upper; struct REnv *e = NULL; if (ci && ci->env) { @@ -170,7 +170,7 @@ mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int nlocals) MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx) { - struct RProc *p = mrb->c->ci->proc; + const struct RProc *p = mrb->c->ci->proc; struct REnv *e; if (!p || !MRB_PROC_CFUNC_P(p)) { diff --git a/src/symbol.c b/src/symbol.c index 9981bad7c..3723335cd 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -330,6 +330,15 @@ mrb_sym_name_len(mrb_state *mrb, mrb_sym sym, mrb_int *lenp) return sym2name_len(mrb, sym, mrb->symbuf, lenp); } +mrb_bool +mrb_sym_static_p(mrb_state *mrb, mrb_sym sym) +{ + if (SYMBOL_INLINE_P(sym)) return TRUE; + sym >>= SYMBOL_NORMAL_SHIFT; + if (sym > MRB_PRESYM_MAX) return FALSE; + return TRUE; +} + void mrb_free_symtbl(mrb_state *mrb) { diff --git a/src/variable.c b/src/variable.c index 8fcbd6427..526d88c80 100644 --- a/src/variable.c +++ b/src/variable.c @@ -741,11 +741,11 @@ mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym) { struct RClass *c; - struct RProc *p = mrb->c->ci->proc; + const struct RProc *p = mrb->c->ci->proc; for (;;) { c = MRB_PROC_TARGET_CLASS(p); - if (c->tt != MRB_TT_SCLASS) break; + if (c && c->tt != MRB_TT_SCLASS) break; p = p->upper; } return mrb_mod_cv_get(mrb, c, sym); @@ -755,11 +755,11 @@ void mrb_vm_cv_set(mrb_state *mrb, mrb_sym sym, mrb_value v) { struct RClass *c; - struct RProc *p = mrb->c->ci->proc; + const struct RProc *p = mrb->c->ci->proc; for (;;) { c = MRB_PROC_TARGET_CLASS(p); - if (c->tt != MRB_TT_SCLASS) break; + if (c && c->tt != MRB_TT_SCLASS) break; p = p->upper; } mrb_mod_cv_set(mrb, c, sym, v); @@ -817,9 +817,10 @@ mrb_vm_const_get(mrb_state *mrb, mrb_sym sym) struct RClass *c; struct RClass *c2; mrb_value v; - struct RProc *proc; + const struct RProc *proc; c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc); + if (!c) c = mrb->object_class; if (iv_get(mrb, c->iv, sym, &v)) { return v; } @@ -862,6 +863,7 @@ mrb_vm_const_set(mrb_state *mrb, mrb_sym sym, mrb_value v) struct RClass *c; c = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc); + if (!c) c = mrb->object_class; mrb_obj_iv_set(mrb, (struct RObject*)c, sym, v); } diff --git a/src/vm.c b/src/vm.c index c3fa12d3d..62805b7ed 100644 --- a/src/vm.c +++ b/src/vm.c @@ -224,7 +224,7 @@ mrb_stack_extend(mrb_state *mrb, mrb_int room) static inline struct REnv* uvenv(mrb_state *mrb, int up) { - struct RProc *proc = mrb->c->ci->proc; + const struct RProc *proc = mrb->c->ci->proc; struct REnv *e; while (up--) { @@ -247,8 +247,8 @@ uvenv(mrb_state *mrb, int up) return NULL; } -static inline struct RProc* -top_proc(mrb_state *mrb, struct RProc *proc) +static inline const struct RProc* +top_proc(mrb_state *mrb, const struct RProc *proc) { while (proc->upper) { if (MRB_PROC_SCOPE_P(proc) || MRB_PROC_STRICT_P(proc)) @@ -327,7 +327,7 @@ cipop(mrb_state *mrb) } void mrb_exc_set(mrb_state *mrb, mrb_value exc); -static mrb_value mrb_run(mrb_state *mrb, struct RProc* proc, mrb_value self); +static mrb_value mrb_run(mrb_state *mrb, const struct RProc* proc, mrb_value self); static void ecall(mrb_state *mrb) @@ -423,7 +423,7 @@ mrb_funcall_id(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc, ...) static int ci_nregs(mrb_callinfo *ci) { - struct RProc *p; + const struct RProc *p; int n = 0; if (!ci) return 3; @@ -821,7 +821,7 @@ mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const } static struct RBreak* -break_new(mrb_state *mrb, struct RProc *p, mrb_value val) +break_new(mrb_state *mrb, const struct RProc *p, mrb_value val) { struct RBreak *brk; @@ -918,7 +918,7 @@ argnum_error(mrb_state *mrb, mrb_int num) #endif MRB_API mrb_value -mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep) +mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, unsigned int stack_keep) { const mrb_irep *irep = proc->body.irep; mrb_value result; @@ -961,7 +961,7 @@ check_target_class(mrb_state *mrb) void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self); MRB_API mrb_value -mrb_vm_exec(mrb_state *mrb, struct RProc *proc, const mrb_code *pc) +mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc) { /* mrb_assert(MRB_PROC_CFUNC_P(proc)) */ const mrb_code *pc0 = pc; @@ -1534,7 +1534,7 @@ RETRY_TRY_BLOCK: struct RClass *cls; mrb_callinfo *ci = mrb->c->ci; mrb_value recv, blk; - struct RProc *p = ci->proc; + const struct RProc *p = ci->proc; mrb_sym mid = ci->mid; struct RClass* target_class = MRB_PROC_TARGET_CLASS(p); @@ -1975,7 +1975,7 @@ RETRY_TRY_BLOCK: else { int acc; mrb_value v; - struct RProc *dst; + const struct RProc *dst; ci = mrb->c->ci; v = regs[a]; @@ -2612,6 +2612,7 @@ RETRY_TRY_BLOCK: super = regs[a+1]; if (mrb_nil_p(base)) { baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc); + if (!baseclass) baseclass = mrb->object_class; base = mrb_obj_value(baseclass); } c = mrb_vm_define_class(mrb, base, super, id); @@ -2628,6 +2629,7 @@ RETRY_TRY_BLOCK: base = regs[a]; if (mrb_nil_p(base)) { baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc); + if (!baseclass) baseclass = mrb->object_class; base = mrb_obj_value(baseclass); } cls = mrb_vm_define_module(mrb, base, id); @@ -2782,7 +2784,7 @@ RETRY_TRY_BLOCK: } static mrb_value -mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) +mrb_run(mrb_state *mrb, const struct RProc *proc, mrb_value self) { if (mrb->c->ci->argc < 0) { return mrb_vm_run(mrb, proc, self, 3); /* receiver, args and block) */ @@ -2793,7 +2795,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) } MRB_API mrb_value -mrb_top_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep) +mrb_top_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, unsigned int stack_keep) { mrb_value v; diff --git a/test/presym b/test/presym new file mode 100644 index 000000000..1e551143b --- /dev/null +++ b/test/presym @@ -0,0 +1,4 @@ +# List of symbols that cannot be detected by Rakefile +# Those symbols are not defined (to cause exceptions) +doesNotExistAsAMethodNameForVerySure +UnknownConstant -- cgit v1.2.3 From ef9df5dc7d32b79e6b4e0d6924eeae2cc614dfce Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 14 Aug 2020 14:15:29 +0900 Subject: Allow `MRUBY_CONFIG` to specify target file out of source tree. --- Rakefile | 9 +++++++-- doc/mruby3.md | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 2198b27fd..52b4c75c1 100644 --- a/Rakefile +++ b/Rakefile @@ -14,8 +14,13 @@ require "mruby-core-ext" require "mruby/build" # load configuration file -MRUBY_TARGET = ENV['MRUBY_TARGET'] || ENV['TARGET'] || "host" -MRUBY_CONFIG = "#{MRUBY_ROOT}/target/#{MRUBY_TARGET}.rb" +if ENV['MRUBY_CONFIG'] + MRUBY_CONFIG = ENV['MRUBY_CONFIG'] + MRUBY_TARGET = File.basename(MRUBY_CONFIG, ".rb") +else + MRUBY_TARGET = ENV['MRUBY_TARGET'] || ENV['TARGET'] || "host" + MRUBY_CONFIG = "#{MRUBY_ROOT}/target/#{MRUBY_TARGET}.rb" +end load MRUBY_CONFIG # load basic rules diff --git a/doc/mruby3.md b/doc/mruby3.md index 75bd5870e..29da25cbc 100644 --- a/doc/mruby3.md +++ b/doc/mruby3.md @@ -43,6 +43,10 @@ in `target/host.rb`. There are many other targets for example: `target/host.rb` comes with comments to help writing a new target description. +If you want to have your target description out of the +source tree, you can specify the path to the description +file in `MRUBY_CONFIG`. + = Build Target Contribution When you write a new target description, please -- cgit v1.2.3 From b7fe929232544120cb81615851b0315ec1a8b360 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 20 Aug 2020 15:11:10 +0900 Subject: Update `Rakefile`. So that you can omit `host` target. Now `host-debug` works. --- Rakefile | 20 ++++++++++++-------- lib/mruby/build.rb | 10 ++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 52b4c75c1..9a0a69ec6 100644 --- a/Rakefile +++ b/Rakefile @@ -52,15 +52,19 @@ task :default => :all bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin" -depfiles = MRuby.targets['host'].bins.map do |bin| - install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}") - source_path = MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/#{bin}") - - file install_path => source_path do |t| - install_D t.prerequisites.first, t.name +if MRuby.targets['host'] + target = MRuby.targets['host'] + depfiles = target.bins.map do |bin| + install_path = target.exefile("#{bin_path}/#{bin}") + source_path = target.exefile("#{target.build_dir}/bin/#{bin}") + + file install_path => source_path do |t| + install_D t.prerequisites.first, t.name + end + install_path end - - install_path +else + depfiles = [] end MRuby.each_target do |target| diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index c101a237f..3ad7f3c4c 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -247,9 +247,10 @@ EOS def mrbcfile return @mrbcfile if @mrbcfile - mrbc_build = MRuby.targets['host'] - gems.each { |v| mrbc_build = self if v.name == 'mruby-bin-mrbc' } - @mrbcfile = mrbc_build.exefile("#{mrbc_build.build_dir}/bin/mrbc") + unless gems.detect { |v| v.name == 'mruby-bin-mrbc' } + gem :core => "mruby-bin-mrbc" + end + @mrbcfile = self.exefile("#{self.build_dir}/bin/mrbc") end def compilers @@ -387,7 +388,8 @@ EOS end def mrbcfile - MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/mrbc") + host = MRuby.targets['host'] + host.exefile("#{host.build_dir}/bin/mrbc") end def run_test -- cgit v1.2.3 From afcf19b727aeca5932689b28777863815fe145cf Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 4 Sep 2020 22:04:41 +0900 Subject: Scan source code lines from downloaded mrbgems; fix #5071 --- Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 9a0a69ec6..ec6ed32bd 100644 --- a/Rakefile +++ b/Rakefile @@ -116,11 +116,11 @@ end mkdir_p "#{MRUBY_ROOT}/build" cfiles = (Dir.glob("#{MRUBY_ROOT}/src/*.c")+ Dir.glob("#{MRUBY_ROOT}/mrbgems/**/*.c")+ - Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{src,test,core}/*.c")).uniq + Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,test,core}/*.c")).uniq rbfiles = (Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/*.rb")+ Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/{mrblib,test}/*.rb")).uniq -psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,test}/**/presym") + Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/*.rb")).uniq +psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,test,build/repos}/**/presym") symbols = [] psfiles.each do |file| symbols += File.readlines(file).grep_v(/^# /) @@ -185,7 +185,7 @@ file presym_file => cfiles+rbfiles+psfiles+[__FILE__] do src.scan(/\balias +(\w+[!?]?)/), src.scan(/\b([A-Z]\w*) *=[^=]/), src.scan(/(\$[a-zA-Z_]\w*)/), - src.scan(/(\$[$!?]\w*)/), + src.scan(/(\$[$!?0-9]\w*)/), src.scan(/(@@?[a-zA-Z_]\w*)/), src.scan(/[^.]\.([a-zA-Z_]\w*[!?]?)/), src.scan(/\.([a-zA-Z_]\w* *=)/).map{|x|x.map{|s|s.gsub(' ', '')}}, -- cgit v1.2.3 From 932b93fd12a3da6748b21ce74caf998a6d97cdbd Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 5 Sep 2020 13:18:00 +0900 Subject: Skip C comments from scan target; close #5072 The original PR was skipping Ruby comments as well, but caused some issues in test suites. --- Rakefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index ec6ed32bd..0088a2e2a 100644 --- a/Rakefile +++ b/Rakefile @@ -163,6 +163,7 @@ op_table = { file presym_file => cfiles+rbfiles+psfiles+[__FILE__] do csymbols = cfiles.map do |f| src = File.read(f) + src.gsub!(/\/\/.+(\n|$)/, "\n") [src.scan(/intern_lit\([^\n"]*"([^\n "]*)"/), src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/), src.scan(/mrb_define_class_method\([^\n"]*"([^\n"]*)"/), -- cgit v1.2.3 From 0c242e278d406dd158c0b048c4fdc13c62824827 Mon Sep 17 00:00:00 2001 From: Uchio Kondo Date: Sat, 5 Sep 2020 08:57:49 +0900 Subject: Ensure exact match for symbols like foo!/foo?/foo= e.g. symbols like "foo[]=" make invalid C codes --- Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 0088a2e2a..20e6fe5fd 100644 --- a/Rakefile +++ b/Rakefile @@ -174,7 +174,7 @@ file presym_file => cfiles+rbfiles+psfiles+[__FILE__] do src.scan(/mrb_define_global_const\([^\n"]*"([^\n"]*)"/), src.scan(/MRB_SYM\((\w+)\)/), src.scan(/MRB_QSYM\((\w+)\)/).map{|x,| - x.sub!(/_p$/, "?") || x.sub!(/_b$/, "!") || x.sub!(/_e$/, "=") || x.sub!(/^0_/, "@") || x.sub!(/^00_/, "@@") + x.sub!(/_p$/, "?") || x.sub!(/_b$/, "!") || x.sub!(/_e$/, "=") || x.sub!(/^0_/, "@") || x.sub!(/^00_/, "@@") }.compact] end rbsymbols = rbfiles.map do |f| @@ -219,13 +219,13 @@ file presym_inc => presym_file do f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n" elsif op_table.key?(sym) f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{op_table[sym]}, #{i+1})\n" - elsif /\?\Z/ =~ sym + elsif /\A\w+\?\Z/ =~ sym s = sym.dup; s[-1] = "_p" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" - elsif /\!\Z/ =~ sym + elsif /\A\w+\!\Z/ =~ sym s = sym.dup; s[-1] = "_b" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" - elsif /\=\Z/ =~ sym + elsif /\A\w+\=\Z/ =~ sym s = sym.dup; s[-1] = "_e" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" elsif /\A@@/ =~ sym -- cgit v1.2.3 From cbb46f69754607e5a7c058e2eed795d002c9a914 Mon Sep 17 00:00:00 2001 From: Kondo Uchio Date: Sat, 5 Sep 2020 14:36:44 +0900 Subject: Exact match to allowed method/variable names --- Rakefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 20e6fe5fd..7cf0e7959 100644 --- a/Rakefile +++ b/Rakefile @@ -219,13 +219,13 @@ file presym_inc => presym_file do f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n" elsif op_table.key?(sym) f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{op_table[sym]}, #{i+1})\n" - elsif /\A\w+\?\Z/ =~ sym + elsif /\A[A-Za-z_]\w*\?\Z/ =~ sym s = sym.dup; s[-1] = "_p" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" - elsif /\A\w+\!\Z/ =~ sym + elsif /\A[A-Za-z_]\w*\!\Z/ =~ sym s = sym.dup; s[-1] = "_b" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" - elsif /\A\w+\=\Z/ =~ sym + elsif /\A[A-Za-z_]\w*\=\Z/ =~ sym s = sym.dup; s[-1] = "_e" f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n" elsif /\A@@/ =~ sym -- cgit v1.2.3 From 0d8793047ddfb425c589414955615d874e49d455 Mon Sep 17 00:00:00 2001 From: Uchio Kondo Date: Sat, 5 Sep 2020 08:42:55 +0900 Subject: Scan ruby files in directories --- Rakefile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 7cf0e7959..bf1b6ae04 100644 --- a/Rakefile +++ b/Rakefile @@ -114,12 +114,19 @@ MRuby.each_target do |target| end mkdir_p "#{MRUBY_ROOT}/build" -cfiles = (Dir.glob("#{MRUBY_ROOT}/src/*.c")+ - Dir.glob("#{MRUBY_ROOT}/mrbgems/**/*.c")+ - Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,test,core}/*.c")).uniq -rbfiles = (Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/*.rb")).uniq +cfiles = ( + Dir.glob("#{MRUBY_ROOT}/src/*.c")+ + Dir.glob("#{MRUBY_ROOT}/mrbgems/**/*.c")+ + Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,test,core}/*.c") +).uniq +rbfiles = ( + Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/**/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/**/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/**/*.rb") +).uniq psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,test,build/repos}/**/presym") symbols = [] psfiles.each do |file| -- cgit v1.2.3 From ed97c1779e953653125d7e17597c1893e6b2374c Mon Sep 17 00:00:00 2001 From: Kondo Uchio Date: Sat, 5 Sep 2020 14:33:58 +0900 Subject: Remove duplicated pattern --- Rakefile | 3 --- 1 file changed, 3 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index bf1b6ae04..92d5000da 100644 --- a/Rakefile +++ b/Rakefile @@ -120,11 +120,8 @@ cfiles = ( Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,test,core}/*.c") ).uniq rbfiles = ( - Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/*.rb")+ Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/**/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/*.rb")+ Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/**/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/*.rb")+ Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/**/*.rb") ).uniq psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,test,build/repos}/**/presym") -- cgit v1.2.3 From 7932523052cd45747f9878cf0b1dc5a899191c79 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 14 Sep 2020 09:16:52 +0900 Subject: Remove `host-debug` internal target. Target `host-debug` to use `host` internal target with debugging configuration. --- Rakefile | 9 --------- target/host-debug.rb | 5 ++++- 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 92d5000da..1234daf66 100644 --- a/Rakefile +++ b/Rakefile @@ -97,15 +97,6 @@ MRuby.each_target do |target| install_D t.prerequisites.first, t.name end 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("#{bin_path}/#{bin}") - - file install_path => exec do |t| - install_D t.prerequisites.first, t.name - end - depfiles += [ install_path ] - end else depfiles += [ exec ] end diff --git a/target/host-debug.rb b/target/host-debug.rb index 423286888..ad4106065 100644 --- a/target/host-debug.rb +++ b/target/host-debug.rb @@ -1,4 +1,4 @@ -MRuby::Build.new('host-debug') do |conf| +MRuby::Build.new('host') do |conf| # load specific toolchain settings # Gets set by the VS command prompts. @@ -19,5 +19,8 @@ MRuby::Build.new('host-debug') do |conf| # Generate mruby debugger command (require mruby-eval) conf.gem :core => "mruby-bin-debugger" + # test + enable_test # bintest + enable_bintest end -- cgit v1.2.3 From 5b40bb8d159c1432bb87973b2b5f42473dd0c623 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 14 Oct 2020 15:52:14 +0900 Subject: Avoid using C struct dump for test Ruby code. Files under `test/t` and `mrbgem/*/test` are for tests, not for actual execution. So symbols in those files need not to be pre-allocated. This change slightly reduce the memory consumption. --- Rakefile | 10 +++++----- lib/mruby/build/command.rb | 6 +++--- mrbgems/mruby-test/driver.c | 4 ++-- mrbgems/mruby-test/mrbgem.rake | 14 +++++++------- test/presym | 4 ---- 5 files changed, 17 insertions(+), 21 deletions(-) delete mode 100644 test/presym (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 1234daf66..5c5a6e8eb 100644 --- a/Rakefile +++ b/Rakefile @@ -108,14 +108,14 @@ mkdir_p "#{MRUBY_ROOT}/build" cfiles = ( Dir.glob("#{MRUBY_ROOT}/src/*.c")+ Dir.glob("#{MRUBY_ROOT}/mrbgems/**/*.c")+ - Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,test,core}/*.c") + Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,core}/*.c") ).uniq rbfiles = ( - Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/**/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/**/*.rb")+ - Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/**/*.rb") + Dir.glob("#{MRUBY_ROOT}/mrblib/**/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/**/*.rb")+ + Dir.glob("#{MRUBY_ROOT}/build/repos/**/mrblib/**/*.rb") ).uniq -psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,test,build/repos}/**/presym") +psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,build/repos}/**/presym") symbols = [] psfiles.each do |file| symbols += File.readlines(file).grep_v(/^# /) diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 39981cc32..3d47c304f 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -310,16 +310,16 @@ module MRuby def initialize(build) super @command = nil - @compile_options = "-S -B%{funcname} -o-" + @compile_options = "-B%{funcname} -o-" end - def run(out, infiles, funcname) + def run(out, infiles, funcname, cdump = true) @command ||= @build.mrbcfile infiles = [infiles].flatten infiles.each do |f| _pp "MRBC", f.relative_path, nil, :indent => 2 end - cmd = %Q["#{filename @command}" #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}] + cmd = %Q["#{filename @command}" #{cdump ? "-S" : ""} #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}] puts cmd if Rake.verbose IO.popen(cmd, 'r+') do |io| out.puts io.read diff --git a/mrbgems/mruby-test/driver.c b/mrbgems/mruby-test/driver.c index 3bd52e175..f780e7e57 100644 --- a/mrbgems/mruby-test/driver.c +++ b/mrbgems/mruby-test/driver.c @@ -18,7 +18,7 @@ #include #include -extern const struct RProc mrbtest_assert_proc[]; +extern const uint8_t mrbtest_assert_irep[]; void mrbgemtest_init(mrb_state* mrb); void mrb_init_test_vformat(mrb_state* mrb); @@ -300,7 +300,7 @@ main(int argc, char **argv) } mrb_init_test_driver(mrb, verbose); - mrb_load_proc(mrb, mrbtest_assert_proc); + mrb_load_irep(mrb, mrbtest_assert_irep); mrbgemtest_init(mrb); ret = eval_test(mrb); mrb_close(mrb); diff --git a/mrbgems/mruby-test/mrbgem.rake b/mrbgems/mruby-test/mrbgem.rake index 9e8e4041f..0df683f7f 100644 --- a/mrbgems/mruby-test/mrbgem.rake +++ b/mrbgems/mruby-test/mrbgem.rake @@ -28,7 +28,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| file assert_c => [assert_rb, build.mrbcfile] do |t| mkdir_p File.dirname(t.name) open(t.name, 'w') do |f| - mrbc.run f, assert_rb, 'mrbtest_assert_proc' + mrbc.run f, assert_rb, 'mrbtest_assert_irep', false end end @@ -56,12 +56,12 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| f.puts %Q[ * All manual changes will get lost.] f.puts %Q[ */] if test_preload.nil? - f.puts %Q[extern const struct RProc mrbtest_assert_proc[];] + f.puts %Q[extern const uint8_t mrbtest_assert_irep[];] else - g.build.mrbc.run f, test_preload, "gem_test_#{g.funcname}_preload" + g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload", false end g.test_rbfiles.flatten.each_with_index do |rbfile, i| - g.build.mrbc.run f, rbfile, "gem_test_#{g.funcname}_#{i}_proc" + g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}", false end f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] unless g.test_objs.empty? dep_list.each do |d| @@ -90,9 +90,9 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| 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_proc(mrb2, mrbtest_assert_proc);] + f.puts %Q[ mrb_load_irep(mrb2, mrbtest_assert_irep);] else - f.puts %Q[ mrb_load_proc(mrb2, gem_test_#{g.funcname}_preload);] + 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);] @@ -113,7 +113,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| f.puts %Q[ mrb_#{g.funcname}_gem_test(mrb2);] if g.custom_test_init? - f.puts %Q[ mrb_load_proc(mrb2, gem_test_#{g.funcname}_#{i}_proc);] + 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);] diff --git a/test/presym b/test/presym deleted file mode 100644 index 1e551143b..000000000 --- a/test/presym +++ /dev/null @@ -1,4 +0,0 @@ -# List of symbols that cannot be detected by Rakefile -# Those symbols are not defined (to cause exceptions) -doesNotExistAsAMethodNameForVerySure -UnknownConstant -- cgit v1.2.3