Skip to content

Commit f33bc38

Browse files
committed
Conditionally define cross-compilation tasks
Only define them if a suitable cross-compiler is found. Use `Rake::ExtensionCompiler.mingw_host` to determine if a compiler is available (this will raise an exception is none is found).
1 parent c72cf5a commit f33bc38

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tasks/native.rake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# use rake-compiler for building the extension
22
require 'rake/extensiontask'
3+
require 'rake/extensioncompiler'
34

45
# NOTE: version used by cross compilation of Windows native extension
56
# It do not affect compilation under other operating systems
@@ -26,8 +27,15 @@ RUBY_EXTENSION = Rake::ExtensionTask.new('sqlite3_native', HOE.spec) do |ext|
2627
ext.lib_dir = "lib/sqlite3/#{$1}"
2728
ext.config_options << "--enable-local"
2829
else
29-
ext.cross_compile = true
30-
ext.cross_platform = ['i386-mswin32-60', 'i386-mingw32', 'x64-mingw32']
30+
31+
# detect cross-compiler available
32+
begin
33+
Rake::ExtensionCompiler.mingw_host
34+
ext.cross_compile = true
35+
ext.cross_platform = ['i386-mswin32-60', 'i386-mingw32', 'x64-mingw32']
36+
rescue RuntimeError
37+
# noop
38+
end
3139
end
3240
end
3341

0 commit comments

Comments
 (0)