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 --- target/ArduinoDue.rb | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 target/ArduinoDue.rb (limited to 'target/ArduinoDue.rb') 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 -- cgit v1.2.3 From 1520c97e172484af7cbd0f51512cd3ac0025e228 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 16 Aug 2020 17:56:50 +0900 Subject: Add default `host` target for cross compiling. You don't have to define explicit `host` build target any more. --- lib/mruby/build.rb | 11 +++++++++++ target/ArduinoDue.rb | 16 ---------------- target/IntelGalileo.rb | 17 ----------------- target/RX630.rb | 16 ---------------- target/android_arm64-v8a.rb | 15 --------------- target/android_armeabi.rb | 15 --------------- target/android_armeabi_v7a_neon_hard.rb | 15 --------------- target/chipKITMax32.rb | 16 ---------------- target/cross-32bit.rb | 7 ++++--- target/dreamcast_shelf.rb | 14 -------------- 10 files changed, 15 insertions(+), 127 deletions(-) (limited to 'target/ArduinoDue.rb') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 40fd0f9fe..c101a237f 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -370,6 +370,17 @@ EOS attr_accessor :host_target, :build_target def initialize(name, build_dir=nil, &block) + unless MRuby.targets['host'] + # add minimal 'host' + MRuby::Build.new('host') do |conf| + if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR'] + toolchain :visualcpp + else + toolchain :gcc + end + conf.gem :core => 'mruby-bin-mrbc' + end + end @endian = nil @test_runner = Command::CrossTestRunner.new(self) super diff --git a/target/ArduinoDue.rb b/target/ArduinoDue.rb index 09646a700..5859f8508 100644 --- a/target/ArduinoDue.rb +++ b/target/ArduinoDue.rb @@ -1,19 +1,3 @@ -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 # diff --git a/target/IntelGalileo.rb b/target/IntelGalileo.rb index 42f39c456..e996efa5b 100644 --- a/target/IntelGalileo.rb +++ b/target/IntelGalileo.rb @@ -1,20 +1,3 @@ -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 # diff --git a/target/RX630.rb b/target/RX630.rb index 1b1f425c1..01c883958 100644 --- a/target/RX630.rb +++ b/target/RX630.rb @@ -1,19 +1,3 @@ -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/ # diff --git a/target/android_arm64-v8a.rb b/target/android_arm64-v8a.rb index 70b0f4b97..7fab2f063 100644 --- a/target/android_arm64-v8a.rb +++ b/target/android_arm64-v8a.rb @@ -1,18 +1,3 @@ -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 = { diff --git a/target/android_armeabi.rb b/target/android_armeabi.rb index 17330242a..41a657c3b 100644 --- a/target/android_armeabi.rb +++ b/target/android_armeabi.rb @@ -1,18 +1,3 @@ -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 = { diff --git a/target/android_armeabi_v7a_neon_hard.rb b/target/android_armeabi_v7a_neon_hard.rb index 3788bba7f..6129b238e 100644 --- a/target/android_armeabi_v7a_neon_hard.rb +++ b/target/android_armeabi_v7a_neon_hard.rb @@ -1,18 +1,3 @@ -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 = { diff --git a/target/chipKITMax32.rb b/target/chipKITMax32.rb index 8617d8d10..bbee221f5 100644 --- a/target/chipKITMax32.rb +++ b/target/chipKITMax32.rb @@ -1,19 +1,3 @@ -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 # diff --git a/target/cross-32bit.rb b/target/cross-32bit.rb index 310ffc833..82d5d023f 100644 --- a/target/cross-32bit.rb +++ b/target/cross-32bit.rb @@ -1,13 +1,14 @@ # Define cross build settings -MRuby::CrossBuild.new('32bit') do |conf| +MRuby::CrossBuild.new('cross-32bit') do |conf| toolchain :gcc conf.cc.flags << "-m32" conf.linker.flags << "-m32" - conf.build_mrbtest_lib_only + # conf.build_mrbtest_lib_only - conf.gem 'examples/mrbgems/c_and_ruby_extension_example' + conf.gem :core => "mruby-bin-mruby" + conf.gem "#{MRUBY_ROOT}/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 index 85b2ff20d..3ae53184d 100644 --- a/target/dreamcast_shelf.rb +++ b/target/dreamcast_shelf.rb @@ -1,17 +1,3 @@ -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 -- cgit v1.2.3