From bfee6871aa38cd03316d573aaeb64eaeffa48a2f Mon Sep 17 00:00:00 2001 From: SiZiOUS Date: Thu, 31 Jul 2025 22:12:54 +0200 Subject: [PATCH 1/5] `dreamcast_shelf build config`: updating file header --- build_config/dreamcast_shelf.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build_config/dreamcast_shelf.rb b/build_config/dreamcast_shelf.rb index 3427f83ac..d6bd401bc 100644 --- a/build_config/dreamcast_shelf.rb +++ b/build_config/dreamcast_shelf.rb @@ -5,12 +5,16 @@ # http://gamedev.allusion.net/softprj/kos/ # # This configuration has been improved to be used as KallistiOS Port (kos-ports) -# Updated: 2023-12-24 +# Updated: 2025-07-31 # # Tested on GNU/Linux, macOS and Windows (MinGW-w64/MSYS2, Cygwin, DreamSDK) # DreamSDK is based on MinGW/MSYS: https://dreamsdk.org/ # # Install mruby for Sega Dreamcast using the "mruby" kos-port. +# See: https://github.com/kallistios/kallistios +# +# If you want to see examples, check the /examples/dreamcast/mruby directory +# in the KallistiOS repository. # MRuby::CrossBuild.new("dreamcast") do |conf| toolchain :gcc From 55bcd35bedc67252b2fd648976f3f95ae589371d Mon Sep 17 00:00:00 2001 From: SiZiOUS Date: Thu, 31 Jul 2025 23:40:42 +0200 Subject: [PATCH 2/5] `dreamcast_shelf build config`: use KallistiOS wrappers See: https://dreamcast.wiki/Using_Ruby_for_Sega_Dreamcast_development --- build_config/dreamcast_shelf.rb | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/build_config/dreamcast_shelf.rb b/build_config/dreamcast_shelf.rb index d6bd401bc..da41b9d29 100644 --- a/build_config/dreamcast_shelf.rb +++ b/build_config/dreamcast_shelf.rb @@ -21,44 +21,33 @@ MRuby::CrossBuild.new("dreamcast") do |conf| # Getting critical environment variables KOS_BASE = ENV["KOS_BASE"] - KOS_CC_BASE = ENV["KOS_CC_BASE"] - if (KOS_BASE.nil? || KOS_BASE.empty? || KOS_CC_BASE.nil? || KOS_CC_BASE.empty?) - raise "Error: KallistiOS is required; KOS_BASE/KOS_CC_BASE needs to be declared; Stop." + # Check environment variables + if (KOS_BASE.nil? || KOS_BASE.empty?) + raise "Error: KallistiOS is required; KOS_BASE need to be declared; Stop." end + + # Root directory for KallistiOS wrappers + KOS_WRAPPERS = "#{KOS_BASE}/utils/build_wrappers" - # C compiler - # All flags and settings below were extracted from KallistiOS environment files + # C compiler conf.cc do |cc| - cc.command = "#{KOS_CC_BASE}/bin/sh-elf-gcc" - cc.include_paths << ["#{KOS_BASE}/include", "#{KOS_BASE}/kernel/arch/dreamcast/include", "#{KOS_BASE}/addons/include", "#{KOS_BASE}/../kos-ports/include"] - cc.flags << ["-O2", "-fomit-frame-pointer", "-fno-builtin", "-ml", "-m4-single-only", "-ffunction-sections", "-fdata-sections", "-matomic-model=soft-imask", "-ftls-model=local-exec", "-Wall", "-g"] - cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] - cc.defines << %w(_arch_dreamcast) - cc.defines << %w(_arch_sub_pristine) + cc.command = "#{KOS_WRAPPERS}/kos-cc" 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-operator-names) - cxx.defines = conf.cc.defines.dup - cxx.compile_options = conf.cc.compile_options.dup + cxx.command = "#{KOS_WRAPPERS}/kos-c++" end # Linker conf.linker do |linker| - linker.command = "#{KOS_CC_BASE}/bin/sh-elf-gcc" - linker.flags << ["-Wl,-Ttext=0x8c010000", "-Wl,--gc-sections", "-T#{KOS_BASE}/utils/ldscripts/shlelf.xc", "-nodefaultlibs", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"] - linker.library_paths << ["#{KOS_BASE}/lib/dreamcast", "#{KOS_BASE}/addons/lib/dreamcast", "#{KOS_BASE}/../kos-ports/lib"] + linker.command = "#{KOS_WRAPPERS}/kos-ld" end # Archiver conf.archiver do |archiver| - archiver.command = "#{KOS_CC_BASE}/bin/sh-elf-ar" - archiver.archive_options = 'rcs "%{outfile}" %{objs}' + archiver.command = "#{KOS_WRAPPERS}/kos-ar" end # No executables needed for KallistiOS From 676af02024df53945db4e1e96e516adc6825a689 Mon Sep 17 00:00:00 2001 From: SiZiOUS Date: Fri, 1 Aug 2025 00:07:28 +0200 Subject: [PATCH 3/5] `dreamcast_shelf build config`: minor fix for KOS_BASE check --- build_config/dreamcast_shelf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_config/dreamcast_shelf.rb b/build_config/dreamcast_shelf.rb index da41b9d29..ff294d888 100644 --- a/build_config/dreamcast_shelf.rb +++ b/build_config/dreamcast_shelf.rb @@ -23,7 +23,7 @@ MRuby::CrossBuild.new("dreamcast") do |conf| KOS_BASE = ENV["KOS_BASE"] # Check environment variables - if (KOS_BASE.nil? || KOS_BASE.empty?) + if KOS_BASE.to_s.empty? raise "Error: KallistiOS is required; KOS_BASE need to be declared; Stop." end From c8510fa5c62313458b57ddc0a521629a05a067d9 Mon Sep 17 00:00:00 2001 From: SiZiOUS Date: Fri, 1 Aug 2025 00:43:42 +0200 Subject: [PATCH 4/5] `dreamcast_shelf build config`: renaming `KOS_WRAPPERS` to `KOS_WRAPPERS_BASE` --- build_config/dreamcast_shelf.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build_config/dreamcast_shelf.rb b/build_config/dreamcast_shelf.rb index ff294d888..9cef36f39 100644 --- a/build_config/dreamcast_shelf.rb +++ b/build_config/dreamcast_shelf.rb @@ -26,28 +26,28 @@ MRuby::CrossBuild.new("dreamcast") do |conf| if KOS_BASE.to_s.empty? raise "Error: KallistiOS is required; KOS_BASE need to be declared; Stop." end - - # Root directory for KallistiOS wrappers - KOS_WRAPPERS = "#{KOS_BASE}/utils/build_wrappers" - # C compiler + # Root directory for KallistiOS wrappers + KOS_WRAPPERS_BASE = "#{KOS_BASE}/utils/build_wrappers" + + # C compiler conf.cc do |cc| - cc.command = "#{KOS_WRAPPERS}/kos-cc" + cc.command = "#{KOS_WRAPPERS_BASE}/kos-cc" end # C++ compiler conf.cxx do |cxx| - cxx.command = "#{KOS_WRAPPERS}/kos-c++" + cxx.command = "#{KOS_WRAPPERS_BASE}/kos-c++" end # Linker conf.linker do |linker| - linker.command = "#{KOS_WRAPPERS}/kos-ld" + linker.command = "#{KOS_WRAPPERS_BASE}/kos-ld" end # Archiver conf.archiver do |archiver| - archiver.command = "#{KOS_WRAPPERS}/kos-ar" + archiver.command = "#{KOS_WRAPPERS_BASE}/kos-ar" end # No executables needed for KallistiOS From 8f85f41775affc38b0926d3e309ca9de39879f71 Mon Sep 17 00:00:00 2001 From: SiZiOUS Date: Sat, 2 Aug 2025 02:00:57 +0200 Subject: [PATCH 5/5] `dreamcast_shelf build config`: better handling for DreamSDK --- build_config/dreamcast_shelf.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build_config/dreamcast_shelf.rb b/build_config/dreamcast_shelf.rb index 9cef36f39..e65465f48 100644 --- a/build_config/dreamcast_shelf.rb +++ b/build_config/dreamcast_shelf.rb @@ -8,7 +8,7 @@ # Updated: 2025-07-31 # # Tested on GNU/Linux, macOS and Windows (MinGW-w64/MSYS2, Cygwin, DreamSDK) -# DreamSDK is based on MinGW/MSYS: https://dreamsdk.org/ +# DreamSDK is based on both MinGW/MSYS and MinGW-w64/MSYS2: https://dreamsdk.org/ # # Install mruby for Sega Dreamcast using the "mruby" kos-port. # See: https://github.com/kallistios/kallistios @@ -21,6 +21,7 @@ MRuby::CrossBuild.new("dreamcast") do |conf| # Getting critical environment variables KOS_BASE = ENV["KOS_BASE"] + KOS_CC_BASE = ENV["KOS_CC_BASE"] # Check environment variables if KOS_BASE.to_s.empty? @@ -28,7 +29,12 @@ MRuby::CrossBuild.new("dreamcast") do |conf| end # Root directory for KallistiOS wrappers - KOS_WRAPPERS_BASE = "#{KOS_BASE}/utils/build_wrappers" + # This will handle specific DreamSDK wrappers if needed + KOS_WRAPPERS_BASE = if ENV["ENVIRONMENT_NAME"] == "DreamSDK" && ENV["RAKE_AVAILABLE"] == "0" + "#{KOS_CC_BASE}/bin" + else + "#{KOS_BASE}/utils/build_wrappers" + end # C compiler conf.cc do |cc|