Commit 364761f4 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3222 from AltimitSystems/android.rake-ndk-clang

Android mips/mips64 support
parents 2d335dae 5d2795c0
......@@ -5,9 +5,12 @@ class MRuby::Toolchain::Android
DEFAULT_TOOLCHAIN = :clang
DEFAULT_NDK_HOMES = %w{
/usr/local/opt/android-ndk
/usr/local/opt/android-sdk/ndk-bundle
/usr/local/opt/android-ndk
%LOCALAPPDATA%/Android/android-sdk/ndk-bundle
%LOCALAPPDATA%/Android/android-ndk
~/Library/Android/sdk/ndk-bundle
~/Library/Android/ndk
}
TOOLCHAINS = [:clang] # TODO : Add gcc support
......@@ -15,7 +18,8 @@ class MRuby::Toolchain::Android
ARCHITECTURES = %w{
armeabi armeabi-v7a arm64-v8a
x86 x86_64
} # TODO : Add mips mips64 support
mips mips64
}
class AndroidNDKHomeNotFound < StandardError
def message
......@@ -56,26 +60,6 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
when /mips/ then 'mipsel-linux-android-'
end + command
prefix = case arch
when /armeabi/ then 'arm-linux-androideabi-'
when /arm64-v8a/ then 'aarch64-linux-android-'
when /x86_64/ then 'x86_64-'
when /x86/ then 'x86-'
when /mips64/ then 'mips64el-linux-android-'
when /mips/ then 'mipsel-linux-android-'
end
test = case arch
when /armeabi/ then 'arm-linux-androideabi-*'
when /arm64-v8a/ then 'aarch64-linux-android-*'
when /x86_64/ then 'x86_64-*'
when /x86/ then 'x86-*'
when /mips64/ then 'mips64el-linux-android-*'
when /mips/ then 'mipsel-linux-android-*'
end
gcc_toolchain_version = Dir[home_path.join('toolchains', test)].map{|t| t.match(/-(\d+\.\d+)$/); $1.to_f }.max
gcc_toolchain_path = home_path.join('toolchains', prefix + gcc_toolchain_version.to_s, 'prebuilt', host_platform)
gcc_toolchain_path.join('bin', command).to_s
end
end
......@@ -92,6 +76,7 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
DEFAULT_NDK_HOMES.find { |path|
path.gsub! '%LOCALAPPDATA%', ENV['LOCALAPPDATA'] || '%LOCALAPPDATA%'
path.gsub! '\\', '/'
path.gsub! '~', Dir.home || '~'
File.directory?(path)
} || raise(AndroidNDKHomeNotFound)
)
......@@ -108,6 +93,32 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
end
end
def gcc_toolchain_path
if @gcc_toolchain_path === nil then
prefix = case arch
when /armeabi/ then 'arm-linux-androideabi-'
when /arm64-v8a/ then 'aarch64-linux-android-'
when /x86_64/ then 'x86_64-'
when /x86/ then 'x86-'
when /mips64/ then 'mips64el-linux-android-'
when /mips/ then 'mipsel-linux-android-'
end
test = case arch
when /armeabi/ then 'arm-linux-androideabi-*'
when /arm64-v8a/ then 'aarch64-linux-android-*'
when /x86_64/ then 'x86_64-*'
when /x86/ then 'x86-*'
when /mips64/ then 'mips64el-linux-android-*'
when /mips/ then 'mipsel-linux-android-*'
end
gcc_toolchain_version = Dir[home_path.join('toolchains', test)].map{|t| t.match(/-(\d+\.\d+)$/); $1.to_f }.max
@gcc_toolchain_path = home_path.join('toolchains', prefix + gcc_toolchain_version.to_s, 'prebuilt', host_platform)
end
@gcc_toolchain_path
end
def host_platform
@host_platform ||= case RUBY_PLATFORM
when /cygwin|mswin|mingw|bccwin|wince|emx/i
......@@ -195,7 +206,7 @@ Set ANDROID_PLATFORM environment variable or set :platform parameter
flags += %W(-D__android__ --sysroot="#{sysroot}")
case toolchain
when :clang
flags += %W(-gcc-toolchain #{toolchain_path.to_s})
flags += %W(-gcc-toolchain "#{gcc_toolchain_path.to_s}")
case arch
when /armeabi-v7a/ then flags += %W(-target armv7-none-linux-androideabi)
when /armeabi/ then flags += %W(-target armv5te-none-linux-androideabi)
......
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