Commit 7c85a1ff authored by Reckordp's avatar Reckordp

Increase flexibility of CrossBuild

parent dd6f5e46
...@@ -7,9 +7,21 @@ MRuby::Gem::Specification.new('mruby-io') do |spec| ...@@ -7,9 +7,21 @@ MRuby::Gem::Specification.new('mruby-io') do |spec|
case RUBY_PLATFORM case RUBY_PLATFORM
when /mingw|mswin|msys/ when /mingw|mswin|msys/
spec.linker.libraries += ['Ws2_32'] really_for_window = true
#spec.cc.include_paths += ["C:/Windows/system/include"]
spec.linker.library_paths += ["C:/Windows/system"] 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 end
if build.kind_of?(MRuby::CrossBuild) && %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target) if build.kind_of?(MRuby::CrossBuild) && %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
spec.linker.libraries += ['ws2_32'] spec.linker.libraries += ['ws2_32']
......
...@@ -8,8 +8,20 @@ MRuby::Gem::Specification.new('mruby-socket') do |spec| ...@@ -8,8 +8,20 @@ MRuby::Gem::Specification.new('mruby-socket') do |spec|
# If Windows, use winsock # If Windows, use winsock
if ( /mswin|mingw|win32/ =~ RUBY_PLATFORM ) then if ( /mswin|mingw|win32/ =~ RUBY_PLATFORM ) then
spec.linker.libraries << "wsock32" really_for_window = true
spec.linker.libraries << "ws2_32"
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 end
spec.add_dependency('mruby-io', :core => 'mruby-io') spec.add_dependency('mruby-io', :core => 'mruby-io')
......
...@@ -10,6 +10,7 @@ class MRuby::Toolchain::Android ...@@ -10,6 +10,7 @@ class MRuby::Toolchain::Android
~/Android/Sdk/ndk-bundle ~/Android/Sdk/ndk-bundle
%LOCALAPPDATA%/Android/android-sdk/ndk-bundle %LOCALAPPDATA%/Android/android-sdk/ndk-bundle
%LOCALAPPDATA%/Android/android-ndk %LOCALAPPDATA%/Android/android-ndk
%LOCALAPPDATA%/Android/Sdk/ndk/*
~/Library/Android/sdk/ndk-bundle ~/Library/Android/sdk/ndk-bundle
~/Library/Android/ndk ~/Library/Android/ndk
} }
...@@ -40,6 +41,19 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter ...@@ -40,6 +41,19 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
end end
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 attr_reader :params
def initialize(params) def initialize(params)
...@@ -74,6 +88,25 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter ...@@ -74,6 +88,25 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
path.gsub! '%LOCALAPPDATA%', ENV['LOCALAPPDATA'] || '%LOCALAPPDATA%' path.gsub! '%LOCALAPPDATA%', ENV['LOCALAPPDATA'] || '%LOCALAPPDATA%'
path.gsub! '\\', '/' path.gsub! '\\', '/'
path.gsub! '~', Dir.home || '~' 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) File.directory?(path)
} || raise(AndroidNDKHomeNotFound) } || raise(AndroidNDKHomeNotFound)
) )
...@@ -146,7 +179,8 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter ...@@ -146,7 +179,8 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
end end
def sysroot def sysroot
@sysroot ||= home_path.join('platforms', platform, return @sysroot if @sysroot
sysroot_path = home_path.join('platforms', platform,
case arch case arch
when /armeabi/ then 'arch-arm' when /armeabi/ then 'arch-arm'
when /arm64-v8a/ then 'arch-arm64' when /arm64-v8a/ then 'arch-arm64'
...@@ -156,6 +190,11 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter ...@@ -156,6 +190,11 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
when /mips/ then 'arch-mips' when /mips/ then 'arch-mips'
end end
).to_s ).to_s
if Dir.exist?(File.join(sysroot_path, "usr", "include"))
return @sysroot = sysroot_path
else
raise(SysrootNotReady)
end
end end
def platform def platform
...@@ -259,6 +298,12 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter ...@@ -259,6 +298,12 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
def cflags def cflags
flags = [] 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 += %W(-MMD -MP -D__android__ -DANDROID --sysroot="#{sysroot}")
flags += ctarget flags += ctarget
case toolchain case toolchain
......
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