Unverified Commit 1b719762 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #5226 from shuujii/guess-toolchain-when-MRubyBuild-toolchain-argument-is-omitted

Guess toolchain when `MRuby::Build#toolchain` argument is omitted
parents c1c8c25e 0396f3f0
MRuby::Build.new do |conf| MRuby::Build.new do |conf|
# load specific toolchain settings # load specific toolchain settings
conf.toolchain
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
# Use mrbgems # Use mrbgems
# conf.gem 'examples/mrbgems/ruby_extension_example' # conf.gem 'examples/mrbgems/ruby_extension_example'
......
MRuby::Build.new do |conf| MRuby::Build.new do |conf|
toolchain :gcc conf.toolchain
# include the default GEMs # include the default GEMs
conf.gembox 'default' conf.gembox 'default'
......
MRuby::Build.new('host') do |conf| MRuby::Build.new('host') do |conf|
# load specific toolchain settings # load specific toolchain settings
conf.toolchain
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
conf.enable_debug conf.enable_debug
...@@ -20,7 +14,7 @@ MRuby::Build.new('host') do |conf| ...@@ -20,7 +14,7 @@ MRuby::Build.new('host') do |conf|
conf.gem :core => "mruby-bin-debugger" conf.gem :core => "mruby-bin-debugger"
# test # test
enable_test conf.enable_test
# bintest # bintest
enable_bintest conf.enable_bintest
end end
# Define cross build settings # Define cross build settings
MRuby::CrossBuild.new('no-float') do |conf| MRuby::CrossBuild.new('no-float') do |conf|
toolchain :gcc conf.toolchain
# include the GEM box # include the GEM box
conf.compilers.each do |c| conf.compilers.each do |c|
......
MRuby::Build.new('full-debug') do |conf| MRuby::Build.new('full-debug') do |conf|
toolchain :gcc conf.toolchain
conf.enable_debug conf.enable_debug
# include all core GEMs # include all core GEMs
...@@ -10,7 +10,7 @@ MRuby::Build.new('full-debug') do |conf| ...@@ -10,7 +10,7 @@ MRuby::Build.new('full-debug') do |conf|
end end
MRuby::Build.new do |conf| MRuby::Build.new do |conf|
toolchain :gcc conf.toolchain
# include all core GEMs # include all core GEMs
conf.gembox 'full-core' conf.gembox 'full-core'
...@@ -22,7 +22,7 @@ MRuby::Build.new do |conf| ...@@ -22,7 +22,7 @@ MRuby::Build.new do |conf|
end end
MRuby::Build.new('cxx_abi') do |conf| MRuby::Build.new('cxx_abi') do |conf|
toolchain :gcc conf.toolchain
conf.gembox 'full-core' conf.gembox 'full-core'
conf.cc.flags += %w(-fpermissive) conf.cc.flags += %w(-fpermissive)
...@@ -31,7 +31,7 @@ MRuby::Build.new('cxx_abi') do |conf| ...@@ -31,7 +31,7 @@ MRuby::Build.new('cxx_abi') do |conf|
end end
conf.enable_test conf.enable_test
enable_cxx_abi conf.enable_cxx_abi
build_mrbc_exec conf.build_mrbc_exec
end end
...@@ -22,6 +22,18 @@ module MRuby ...@@ -22,6 +22,18 @@ module MRuby
class Toolchain class Toolchain
class << self class << self
attr_accessor :toolchains attr_accessor :toolchains
def guess
if cc = ENV["CC"] || ENV["CXX"]
return "clang" if cc.include?("clang")
else
return "clang" if RUBY_PLATFORM =~ /darwin|(?:free|open)bsd/
return "gcc" if RUBY_PLATFORM.include?("cygwin")
return "visualcpp" if ENV.include?("VisualStudioVersion")
return "visualcpp" if ENV.include?("VSINSTALLDIR")
end
"gcc"
end
end end
def initialize(name, &block) def initialize(name, &block)
...@@ -29,7 +41,7 @@ module MRuby ...@@ -29,7 +41,7 @@ module MRuby
MRuby::Toolchain.toolchains[@name] = self MRuby::Toolchain.toolchains[@name] = self
end end
def setup(conf,params={}) def setup(conf, params={})
conf.instance_exec(conf, params, &@initializer) conf.instance_exec(conf, params, &@initializer)
end end
...@@ -221,7 +233,7 @@ EOS ...@@ -221,7 +233,7 @@ EOS
@enable_bintest @enable_bintest
end end
def toolchain(name, params={}) def toolchain(name=Toolchain.guess, params={})
name = name.to_s name = name.to_s
tc = Toolchain.toolchains[name] || begin tc = Toolchain.toolchains[name] || begin
path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake" path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment