Increase flexibility of CrossBuild
MODIFY
mrbgems/mruby-io/mrbgem.rake
mrbgems/mruby-io/mrbgem.rake
@@ -7,10 +7,22 @@ MRuby::Gem::Specification.new('mruby-io') do |spec|
case RUBY_PLATFORM
when /mingw|mswin|msys/
+ really_for_window = true
+
+ if build.kind_of?(MRuby::CrossBuild)
+ if %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
+ really_for_window = true
+ else
+ really_for_window = false
+ end
+ end
+
+ if really_for_window
spec.linker.libraries += ['Ws2_32']
#spec.cc.include_paths += ["C:/Windows/system/include"]
spec.linker.library_paths += ["C:/Windows/system"]
end
+ end
if build.kind_of?(MRuby::CrossBuild) && %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
spec.linker.libraries += ['ws2_32']
end

MODIFY
mrbgems/mruby-socket/mrbgem.rake
mrbgems/mruby-socket/mrbgem.rake
@@ -8,9 +8,21 @@ MRuby::Gem::Specification.new('mruby-socket') do |spec|
# If Windows, use winsock
if ( /mswin|mingw|win32/ =~ RUBY_PLATFORM ) then
+ really_for_window = true
+
+ if build.kind_of?(MRuby::CrossBuild)
+ if %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
+ really_for_window = true
+ else
+ really_for_window = false
+ end
+ end
+
+ if really_for_window
spec.linker.libraries << "wsock32"
spec.linker.libraries << "ws2_32"
end
+ end
spec.add_dependency('mruby-io', :core => 'mruby-io')
spec.add_dependency('mruby-pack', :core => 'mruby-pack')

MODIFY
tasks/toolchains/android.rake
tasks/toolchains/android.rake
@@ -10,6 +10,7 @@ class MRuby::Toolchain::Android
~/Android/Sdk/ndk-bundle
%LOCALAPPDATA%/Android/android-sdk/ndk-bundle
%LOCALAPPDATA%/Android/android-ndk
+ %LOCALAPPDATA%/Android/Sdk/ndk/*
~/Library/Android/sdk/ndk-bundle
~/Library/Android/ndk
}
@@ -40,6 +41,19 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
end
end
+ class SysrootNotReady < StandardError
+ def message
+ <<-EOM
+Couldn't find standard header files
+Please Move/Copy important file inside
+ <NDK_HOME>/sysroot/usr/include/
+to
+ <NDK_HOME>/platforms/<ANDROID_VERSION>/<ARCH>/usr/include/
+Higher NDK version will be use.
+ EOM
+ end
+ end
+
attr_reader :params
def initialize(params)
@@ -74,6 +88,25 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
path.gsub! '%LOCALAPPDATA%', ENV['LOCALAPPDATA'] || '%LOCALAPPDATA%'
path.gsub! '\\', '/'
path.gsub! '~', Dir.home || '~'
+ path.gsub!('*') do
+ next nil unless path[-1] == "*"
+ dirs = Dir.glob(path).collect do |d|
+ m = d.match(/(\d+)\.(\d+)\.(\d+)$/)
+ m ? [m[1], m[2], m[3]].collect { |v| v.to_i } : nil
+ end
+ dirs.compact!
+ dirs.sort! do |before, after|
+ f = 0
+ if (f = (after.first <=> before.first)) != 0
+ next f
+ elsif (f = (after[1] <=> before[1])) != 0
+ next f
+ else
+ next after.last <=> before.last
+ end
+ end
+ dirs.empty? ? nil.to_s : dirs.first.join(".")
+ end
File.directory?(path)
} || raise(AndroidNDKHomeNotFound)
)
@@ -146,7 +179,8 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
end
def sysroot
- @sysroot ||= home_path.join('platforms', platform,
+ return @sysroot if @sysroot
+ sysroot_path = home_path.join('platforms', platform,
case arch
when /armeabi/ then 'arch-arm'
when /arm64-v8a/ then 'arch-arm64'
@@ -156,6 +190,11 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
when /mips/ then 'arch-mips'
end
).to_s
+ if Dir.exist?(File.join(sysroot_path, "usr", "include"))
+ return @sysroot = sysroot_path
+ else
+ raise(SysrootNotReady)
+ end
end
def platform
@@ -259,6 +298,12 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
def cflags
flags = []
+ case RUBY_PLATFORM
+ when /mswin|mingw|win32/
+ # Build for Android dont need window flag
+ flags += %W(-U_WIN32 -U_WIN64)
+ end
+
flags += %W(-MMD -MP -D__android__ -DANDROID --sysroot="#{sysroot}")
flags += ctarget
case toolchain

Increase flexibility of CrossBuild