[439] | 1 | MRuby::Build.new do |conf|
|
---|
| 2 | # Gets set by the VS command prompts
|
---|
| 3 | if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
---|
| 4 | toolchain :visualcpp
|
---|
| 5 | else
|
---|
| 6 | toolchain :gcc
|
---|
| 7 | end
|
---|
| 8 |
|
---|
| 9 | enable_debug
|
---|
| 10 |
|
---|
| 11 | # Include the default GEMs
|
---|
| 12 | conf.gembox 'default'
|
---|
| 13 | end
|
---|
| 14 |
|
---|
| 15 | # Cross Compiling configuration for the Sega Dreamcast
|
---|
| 16 | # This configuration requires KallistiOS (KOS)
|
---|
| 17 | # https://dreamcast.wiki
|
---|
| 18 | #
|
---|
| 19 | # Tested on GNU/Linux, MinGW-w64/MSYS2, Cygwin, macOS and MinGW/MSYS (see below)
|
---|
| 20 | #
|
---|
| 21 | MRuby::CrossBuild.new("dreamcast") do |conf|
|
---|
| 22 | toolchain :gcc
|
---|
| 23 |
|
---|
| 24 | # Support for DreamSDK (based on MinGW/MSYS)
|
---|
| 25 | # To compile mruby with DreamSDK, RubyInstaller for Windows should be installed
|
---|
| 26 | DREAMSDK_HOME = ENV["DREAMSDK_HOME"]
|
---|
| 27 | MSYS_ROOT = !(DREAMSDK_HOME.nil? || DREAMSDK_HOME.empty?) ? "#{DREAMSDK_HOME}/msys/1.0" : ""
|
---|
| 28 |
|
---|
| 29 | # Setting paths
|
---|
| 30 | DREAMCAST_PATH = "#{MSYS_ROOT}/opt/toolchains/dc"
|
---|
| 31 | KOS_PATH = "#{DREAMCAST_PATH}/kos"
|
---|
| 32 | BIN_PATH = "#{DREAMCAST_PATH}/sh-elf/bin"
|
---|
| 33 |
|
---|
| 34 | # C compiler
|
---|
| 35 | # Flags were extracted from KallistiOS environment files
|
---|
| 36 | conf.cc do |cc|
|
---|
| 37 | cc.command = "#{BIN_PATH}/sh-elf-gcc"
|
---|
| 38 | cc.include_paths << ["#{KOS_PATH}/include", "#{KOS_PATH}/kernel/arch/dreamcast/include", "#{KOS_PATH}/addons/include", "#{KOS_PATH}/../kos-ports/include"]
|
---|
| 39 | 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"]
|
---|
| 40 | cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
---|
| 41 | cc.defines << %w(_arch_dreamcast)
|
---|
| 42 | cc.defines << %w(_arch_sub_pristine)
|
---|
| 43 | end
|
---|
| 44 |
|
---|
| 45 | # C++ compiler
|
---|
| 46 | conf.cxx do |cxx|
|
---|
| 47 | cxx.command = conf.cc.command.dup
|
---|
| 48 | cxx.include_paths = conf.cc.include_paths.dup
|
---|
| 49 | cxx.flags = conf.cc.flags.dup
|
---|
| 50 | cxx.flags << %w(-fno-rtti -fno-exceptions)
|
---|
| 51 | cxx.defines = conf.cc.defines.dup
|
---|
| 52 | cxx.compile_options = conf.cc.compile_options.dup
|
---|
| 53 | end
|
---|
| 54 |
|
---|
| 55 | # Linker
|
---|
| 56 | # There is an issue when making the mruby library with KallistiOS:
|
---|
| 57 | # 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly
|
---|
| 58 | # specified here at least for now.
|
---|
| 59 | conf.linker do |linker|
|
---|
| 60 | linker.command="#{BIN_PATH}/sh-elf-gcc"
|
---|
| 61 | 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"]
|
---|
| 62 | linker.library_paths << ["#{KOS_PATH}/lib/dreamcast", "#{KOS_PATH}/addons/lib/dreamcast", "#{KOS_PATH}/../kos-ports/lib"]
|
---|
| 63 | end
|
---|
| 64 |
|
---|
| 65 | # Archiver
|
---|
| 66 | conf.archiver do |archiver|
|
---|
| 67 | archiver.command = "#{BIN_PATH}/sh-elf-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 | # removing mruby-io
|
---|
| 82 | conf.gem :core => "mruby-metaprog"
|
---|
| 83 | conf.gem :core => "mruby-pack"
|
---|
| 84 | conf.gem :core => "mruby-sprintf"
|
---|
| 85 | conf.gem :core => "mruby-print"
|
---|
| 86 | conf.gem :core => "mruby-math"
|
---|
| 87 | conf.gem :core => "mruby-time"
|
---|
| 88 | conf.gem :core => "mruby-struct"
|
---|
| 89 | conf.gem :core => "mruby-compar-ext"
|
---|
| 90 | conf.gem :core => "mruby-enum-ext"
|
---|
| 91 | conf.gem :core => "mruby-string-ext"
|
---|
| 92 | conf.gem :core => "mruby-numeric-ext"
|
---|
| 93 | conf.gem :core => "mruby-array-ext"
|
---|
| 94 | conf.gem :core => "mruby-hash-ext"
|
---|
| 95 | conf.gem :core => "mruby-range-ext"
|
---|
| 96 | conf.gem :core => "mruby-proc-ext"
|
---|
| 97 | conf.gem :core => "mruby-symbol-ext"
|
---|
| 98 | conf.gem :core => "mruby-random"
|
---|
| 99 | conf.gem :core => "mruby-object-ext"
|
---|
| 100 | conf.gem :core => "mruby-objectspace"
|
---|
| 101 | conf.gem :core => "mruby-fiber"
|
---|
| 102 | conf.gem :core => "mruby-enumerator"
|
---|
| 103 | conf.gem :core => "mruby-enum-lazy"
|
---|
| 104 | conf.gem :core => "mruby-toplevel-ext"
|
---|
| 105 | conf.gem :core => "mruby-kernel-ext"
|
---|
| 106 | conf.gem :core => "mruby-class-ext"
|
---|
| 107 | conf.gem :core => "mruby-compiler"
|
---|
| 108 | end
|
---|