1 | MRuby::Build.new do |conf|
|
---|
2 |
|
---|
3 | # Gets set by the VS command prompts.
|
---|
4 | if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
---|
5 | toolchain :visualcpp
|
---|
6 | else
|
---|
7 | toolchain :gcc
|
---|
8 | end
|
---|
9 |
|
---|
10 | enable_debug
|
---|
11 |
|
---|
12 | # include the default GEMs
|
---|
13 | conf.gembox 'default'
|
---|
14 |
|
---|
15 | end
|
---|
16 |
|
---|
17 | # Cross Compiling configuration for Arduino Due
|
---|
18 | # http://arduino.cc/en/Main/ArduinoBoardDue
|
---|
19 | #
|
---|
20 | # Requires Arduino IDE >= 1.5
|
---|
21 | MRuby::CrossBuild.new("ArduinoDue") do |conf|
|
---|
22 | toolchain :gcc
|
---|
23 |
|
---|
24 | # Mac OS X, Arduino IDE <= 1.5.6
|
---|
25 | # ARDUINO_PATH = '/Applications/Arduino.app/Contents/Resources/Java'
|
---|
26 | # Mac OS X, Arduino IDE >= 1.5.7
|
---|
27 | # ARDUINO_PATH = '/Applications/Arduino.app/Contents/Java'
|
---|
28 | # GNU Linux
|
---|
29 | ARDUINO_PATH = '/opt/arduino'
|
---|
30 | # Arduino IDE <= 1.5.6
|
---|
31 | BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/g++_arm_none_eabi/bin"
|
---|
32 | # Arduino IDE >= 1.5.7
|
---|
33 | # BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin"
|
---|
34 | SAM_PATH = "#{ARDUINO_PATH}/hardware/arduino/sam"
|
---|
35 | TARGET_PATH = "#{SAM_PATH}/variants/arduino_due_x"
|
---|
36 |
|
---|
37 | conf.cc do |cc|
|
---|
38 | cc.command = "#{BIN_PATH}/arm-none-eabi-gcc"
|
---|
39 | cc.include_paths << ["#{SAM_PATH}/system/libsam", "#{SAM_PATH}/system/CMSIS/CMSIS/Include/",
|
---|
40 | "#{SAM_PATH}/system/CMSIS/Device/ATMEL/",
|
---|
41 | "#{SAM_PATH}/cores/arduino", "#{SAM_PATH}/libraries","#{TARGET_PATH}"]
|
---|
42 | cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500
|
---|
43 | -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM
|
---|
44 | -D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due")
|
---|
45 | cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
|
---|
46 |
|
---|
47 | #configuration for low memory environment
|
---|
48 | cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
---|
49 | cc.defines << %w(MRB_USE_IV_SEGLIST)
|
---|
50 | cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
---|
51 | cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
|
---|
52 | cc.defines << %w(MRB_GC_STRESS)
|
---|
53 | #cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
|
---|
54 | #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
---|
55 | end
|
---|
56 |
|
---|
57 | conf.cxx do |cxx|
|
---|
58 | cxx.command = conf.cc.command.dup
|
---|
59 | cxx.include_paths = conf.cc.include_paths.dup
|
---|
60 | cxx.flags = conf.cc.flags.dup
|
---|
61 | cxx.flags << %w(-fno-rtti -fno-exceptions)
|
---|
62 | cxx.defines = conf.cc.defines.dup
|
---|
63 | cxx.compile_options = conf.cc.compile_options.dup
|
---|
64 | end
|
---|
65 |
|
---|
66 | conf.archiver do |archiver|
|
---|
67 | archiver.command = "#{BIN_PATH}/arm-none-eabi-ar"
|
---|
68 | archiver.archive_options = 'rcs %{outfile} %{objs}'
|
---|
69 | end
|
---|
70 |
|
---|
71 | #no executables
|
---|
72 | conf.bins = []
|
---|
73 |
|
---|
74 | #do not build executable test
|
---|
75 | conf.build_mrbtest_lib_only
|
---|
76 |
|
---|
77 | #disable C++ exception
|
---|
78 | conf.disable_cxx_exception
|
---|
79 |
|
---|
80 | #gems from core
|
---|
81 | conf.gem :core => "mruby-print"
|
---|
82 | conf.gem :core => "mruby-math"
|
---|
83 | conf.gem :core => "mruby-enum-ext"
|
---|
84 |
|
---|
85 | #light-weight regular expression
|
---|
86 | conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
|
---|
87 |
|
---|
88 | #Arduino API
|
---|
89 | #conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
|
---|
90 |
|
---|
91 | end
|
---|