summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-12-16 20:25:35 +0900
committerGitHub <[email protected]>2020-12-16 20:25:35 +0900
commit1b7197622f770ce4ae3f3f2aaae1ea427ff3b902 (patch)
treeef1ada52d79a83c0463bee1c5bcc4beb9345172e
parentc1c8c25e70a54e6a82ab8cea05c115b94eb3d5ab (diff)
parent0396f3f0fd6e574ae859d24f058abcf1ada66f6b (diff)
downloadmruby-1b7197622f770ce4ae3f3f2aaae1ea427ff3b902.tar.gz
mruby-1b7197622f770ce4ae3f3f2aaae1ea427ff3b902.zip
Merge pull request #5226 from shuujii/guess-toolchain-when-MRubyBuild-toolchain-argument-is-omitted
Guess toolchain when `MRuby::Build#toolchain` argument is omitted
-rw-r--r--build_config/default.rb8
-rw-r--r--build_config/host-cxx.rb2
-rw-r--r--build_config/host-debug.rb12
-rw-r--r--build_config/no-float.rb2
-rw-r--r--build_config/travis.rb10
-rw-r--r--lib/mruby/build.rb16
6 files changed, 25 insertions, 25 deletions
diff --git a/build_config/default.rb b/build_config/default.rb
index 04bc60540..894f1055b 100644
--- a/build_config/default.rb
+++ b/build_config/default.rb
@@ -1,12 +1,6 @@
MRuby::Build.new do |conf|
# load specific toolchain settings
-
- # Gets set by the VS command prompts.
- if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
- toolchain :visualcpp
- else
- toolchain :gcc
- end
+ conf.toolchain
# Use mrbgems
# conf.gem 'examples/mrbgems/ruby_extension_example'
diff --git a/build_config/host-cxx.rb b/build_config/host-cxx.rb
index ae313e45d..15cb0c347 100644
--- a/build_config/host-cxx.rb
+++ b/build_config/host-cxx.rb
@@ -1,5 +1,5 @@
MRuby::Build.new do |conf|
- toolchain :gcc
+ conf.toolchain
# include the default GEMs
conf.gembox 'default'
diff --git a/build_config/host-debug.rb b/build_config/host-debug.rb
index 9be1f6574..600a4d78f 100644
--- a/build_config/host-debug.rb
+++ b/build_config/host-debug.rb
@@ -1,12 +1,6 @@
MRuby::Build.new('host') do |conf|
# load specific toolchain settings
-
- # Gets set by the VS command prompts.
- if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
- toolchain :visualcpp
- else
- toolchain :gcc
- end
+ conf.toolchain
conf.enable_debug
@@ -20,7 +14,7 @@ MRuby::Build.new('host') do |conf|
conf.gem :core => "mruby-bin-debugger"
# test
- enable_test
+ conf.enable_test
# bintest
- enable_bintest
+ conf.enable_bintest
end
diff --git a/build_config/no-float.rb b/build_config/no-float.rb
index 1138188e3..7df7c2e46 100644
--- a/build_config/no-float.rb
+++ b/build_config/no-float.rb
@@ -1,6 +1,6 @@
# Define cross build settings
MRuby::CrossBuild.new('no-float') do |conf|
- toolchain :gcc
+ conf.toolchain
# include the GEM box
conf.compilers.each do |c|
diff --git a/build_config/travis.rb b/build_config/travis.rb
index 3c6647b45..7da8c1bf4 100644
--- a/build_config/travis.rb
+++ b/build_config/travis.rb
@@ -1,5 +1,5 @@
MRuby::Build.new('full-debug') do |conf|
- toolchain :gcc
+ conf.toolchain
conf.enable_debug
# include all core GEMs
@@ -10,7 +10,7 @@ MRuby::Build.new('full-debug') do |conf|
end
MRuby::Build.new do |conf|
- toolchain :gcc
+ conf.toolchain
# include all core GEMs
conf.gembox 'full-core'
@@ -22,7 +22,7 @@ MRuby::Build.new do |conf|
end
MRuby::Build.new('cxx_abi') do |conf|
- toolchain :gcc
+ conf.toolchain
conf.gembox 'full-core'
conf.cc.flags += %w(-fpermissive)
@@ -31,7 +31,7 @@ MRuby::Build.new('cxx_abi') do |conf|
end
conf.enable_test
- enable_cxx_abi
+ conf.enable_cxx_abi
- build_mrbc_exec
+ conf.build_mrbc_exec
end
diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb
index 2e67fe5a6..83722a0e8 100644
--- a/lib/mruby/build.rb
+++ b/lib/mruby/build.rb
@@ -22,6 +22,18 @@ module MRuby
class Toolchain
class << self
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
def initialize(name, &block)
@@ -29,7 +41,7 @@ module MRuby
MRuby::Toolchain.toolchains[@name] = self
end
- def setup(conf,params={})
+ def setup(conf, params={})
conf.instance_exec(conf, params, &@initializer)
end
@@ -221,7 +233,7 @@ EOS
@enable_bintest
end
- def toolchain(name, params={})
+ def toolchain(name=Toolchain.guess, params={})
name = name.to_s
tc = Toolchain.toolchains[name] || begin
path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake"