summaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
authorcrimsonwoods <[email protected]>2013-03-09 19:34:22 +0900
committercrimsonwoods <[email protected]>2013-03-09 19:34:22 +0900
commite63425a8f923accabd156861e5b8a05307c44436 (patch)
tree2cde887bfb65b414239075e7bd93f7305be18857 /tasks
parent572acc0beae3ee849ff894eac139c00aae9ae659 (diff)
downloadmruby-e63425a8f923accabd156861e5b8a05307c44436.tar.gz
mruby-e63425a8f923accabd156861e5b8a05307c44436.zip
add a new feature to select the target Android platform.
Diffstat (limited to 'tasks')
-rw-r--r--tasks/toolchains/androideabi.rake53
1 files changed, 48 insertions, 5 deletions
diff --git a/tasks/toolchains/androideabi.rake b/tasks/toolchains/androideabi.rake
index 641214be8..34a25151d 100644
--- a/tasks/toolchains/androideabi.rake
+++ b/tasks/toolchains/androideabi.rake
@@ -14,12 +14,15 @@ MRuby::Toolchain.new(:androideabi) do |conf|
DEFAULT_ANDROID_TOOLCHAIN = 'gcc'
DEFAULT_ANDROID_TARGET_ARCH = 'arm'
DEFAULT_ANDROID_TARGET_ARCH_ABI = 'armeabi'
+ DEFAULT_ANDROID_TARGET_PLATFORM = 'android-14'
+ DEFAULT_GCC_VERSION = '4.6'
+ DEFAULT_CLANG_VERSION = '3.1'
GCC_COMMON_CFLAGS = %W(-ffunction-sections -funwind-tables -fstack-protector)
GCC_COMMON_LDFLAGS = %W()
- # An environment variable 'ANDROID_STANDALONE_TOOLCHAIN' must be set a path to toolchains.
+ # 'ANDROID_STANDALONE_TOOLCHAIN' or 'ANDROID_NDK_HOME' must be set.
ANDROID_STANDALONE_TOOLCHAIN = ENV['ANDROID_STANDALONE_TOOLCHAIN']
- SYSROOT = ENV['ANDROID_STANDALONE_TOOLCHAIN'] + '/sysroot'
+ ANDROID_NDK_HOME = ENV['ANDROID_NDK_HOME']
ANDROID_TARGET_ARCH = ENV['ANDROID_TARGET_ARCH'] || DEFAULT_ANDROID_TARGET_ARCH
ANDROID_TOOLCHAIN = ENV['ANDROID_TOOLCHAIN'] || DEFAULT_ANDROID_TOOLCHAIN
@@ -36,11 +39,51 @@ MRuby::Toolchain.new(:androideabi) do |conf|
# Notify error.
end
+ if ANDROID_STANDALONE_TOOLCHAIN == nil then
+ if RUBY_PLATFORM.include?('darwin') then
+ HOST_PLATFORM = 'darwin-x86'
+ elsif RUBY_PLATFORM.include('linux') then
+ HOST_PLATFORM = 'linux-x86'
+ elsif RUBY_PLATFORM.include('win') then
+ HOST_PLATFORM = 'windows'
+ else
+ # Unknown host platform.
+ end
+
+ ANDROID_TARGET_PLATFORM = ENV['ANDROID_TARGET_PLATFORM'] || DEFAULT_ANDROID_TARGET_PLATFORM
+
+ path_to_toolchain = ANDROID_NDK_HOME + '/toolchains/'
+ path_to_sysroot = ANDROID_NDK_HOME + '/platforms/' + ANDROID_TARGET_PLATFORM
+ if ANDROID_TOOLCHAIN.downcase == 'gcc' then
+ case ANDROID_TARGET_ARCH.downcase
+ when 'arch-arm', 'arm' then
+ path_to_toolchain += 'arm-linux-androideabi-'
+ path_to_sysroot += '/arch-arm'
+ when 'arch-x86', 'x86' then
+ path_to_toolchain += 'x86-'
+ path_to_sysroot += '/arch-x86'
+ when 'arch-mips', 'mips' then
+ path_to_toolchain += 'mipsel-linux-android-'
+ path_to_sysroot += '/arch-mips'
+ else
+ # Any other architecture are not supported by Android NDK.
+ end
+ path_to_toolchain += DEFAULT_GCC_VERSION + '/prebuilt/' + HOST_PLATFORM
+ else
+ path_to_toolchain += 'llvm-' + DEFAULT_CLANG_VERSION + '/prebuilt/' + HOST_PLATFORM
+ end
+ else
+ path_to_toolchain = ANDROID_STANDALONE_TOOLCHAIN
+ path_to_sysroot = ANDROID_STANDALONE_TOOLCHAIN + '/sysroot'
+ end
+
+ SYSROOT = path_to_sysroot
+
case ANDROID_TOOLCHAIN.downcase
when 'gcc' then
- ANDROID_CC = ANDROID_STANDALONE_TOOLCHAIN + '/bin/' + toolchain_prefix + 'gcc'
- ANDROID_LD = ANDROID_STANDALONE_TOOLCHAIN + '/bin/' + toolchain_prefix + 'gcc'
- ANDROID_AR = ANDROID_STANDALONE_TOOLCHAIN + '/bin/' + toolchain_prefix + 'ar'
+ ANDROID_CC = path_to_toolchain + '/bin/' + toolchain_prefix + 'gcc'
+ ANDROID_LD = path_to_toolchain + '/bin/' + toolchain_prefix + 'gcc'
+ ANDROID_AR = path_to_toolchain + '/bin/' + toolchain_prefix + 'ar'
ANDROID_CFLAGS = GCC_COMMON_CFLAGS + %W(-mandroid --sysroot=#{SYSROOT})
ANDROID_LDFLAGS = GCC_COMMON_LDFLAGS + %W(-mandroid --sysroot=#{SYSROOT})
when 'clang' then