Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / lib / libUPnP / Neptune / Build / Targets / arm-android-linux / Config.scons
blob40fe8211610e4dfc3351cc4db9091f4c5a0c2c72
1 #################################################################
2 # Important: this build file has been tested with Android NDK 11
3 # It may or may not work with other releases of the NDK. Please notify
4 # us if you find a newer NDK for which this does not work.
5 #################################################################
7 import os
8 import re
9 import sys
10 import platform
12 # we need to know when the NDK is
13 ANDROID_NDK_ROOT=os.getenv('ANDROID_NDK_ROOT')
14 if not ANDROID_NDK_ROOT:
15     raise Exception('ANDROID_NDK_ROOT environment variable not set')
17 # detect the host system on which we're running
18 if env.has_key('android_host_system') and env['android_host_system']:
19         ANDROID_HOST_SYSTEM = env['android_host_system']
20 else:
21         PLATFORM_TO_TARGET_MAP = {
22         'linux-i386' : 'linux-x86',
23         'linux2'     : 'linux-x86',
24         'win32'      : 'windows',
25         'cygwin'     : 'windows',
26         'darwin'     : 'darwin-x86_64'
27         }
28         if sys.platform in PLATFORM_TO_TARGET_MAP:
29                 ANDROID_HOST_SYSTEM = PLATFORM_TO_TARGET_MAP[sys.platform]
30         else:
31                 raise Exception('Android Host Platform cannot be determined')
33 # set defaults
34 ANDROID_ARCH         = 'arm'
35 ANDROID_PLATFORM     = 'android-9'
36 ANDROID_TOOLCHAIN    = 'arm-linux-androideabi-4.9'
37 ANDROID_CROSS_PREFIX = 'arm-linux-androideabi'
39 if not os.path.exists(os.path.join(ANDROID_NDK_ROOT, 'toolchains', ANDROID_TOOLCHAIN)):
40     toolchain_dirs = os.listdir(ANDROID_NDK_ROOT+'/toolchains')
41     for toolchain_dir in toolchain_dirs:
42         if os.path.exists(os.path.join(ANDROID_NDK_ROOT, 'toolchains', toolchain_dir, 'prebuilt', ANDROID_HOST_SYSTEM)):
43             ANDROID_TOOLCHAIN=toolchain_dir
44             suffix_pos = toolchain_dir.rfind('-')
45             if (suffix_pos >= 0):
46                 ANDROID_CROSS_PREFIX = ANDROID_TOOLCHAIN[:suffix_pos]
47             print "Auto-selecting toolchain:", ANDROID_TOOLCHAIN
48             break
50 # override defaults from command line args
51 if ARGUMENTS.get('android_toolchain'):
52     ANDROID_TOOLCHAIN=ARGUMENTS.get('android_toolchain')
54 if ARGUMENTS.get('android_cross_prefix'):
55     ANDROID_CROSS_PREFIX=ARGUMENTS.get('android_cross_prefix')
57 if ARGUMENTS.get('android_platform'):
58     ANDROID_PLATFORM=ARGUMENTS.get('android_platform')
60 if ARGUMENTS.get('android_arch'):
61     ANDROID_ARCH=ARGUMENTS.get('android_arch')
63 print 'Building for Android: '
64 print 'ANDROID_HOST_SYSTEM =', ANDROID_HOST_SYSTEM
65 print 'ANDROID_TOOLCHAIN   =', ANDROID_TOOLCHAIN
66 print 'ANDROID_PLATFORM    =', ANDROID_PLATFORM
67 print 'ANDROID_ARCH        =', ANDROID_ARCH
69 ANDROID_TOOLCHAIN_BIN = ANDROID_NDK_ROOT+'/toolchains/'+ANDROID_TOOLCHAIN+'/prebuilt/'+ANDROID_HOST_SYSTEM+'/bin'
70 if not os.path.exists(ANDROID_TOOLCHAIN_BIN) and ANDROID_HOST_SYSTEM is 'darwin-x86':
71     ANDROID_HOST_SYSTEM = 'darwin-x86_64'
72     ANDROID_TOOLCHAIN_BIN = ANDROID_NDK_ROOT+'/toolchains/'+ANDROID_TOOLCHAIN+'/prebuilt/'+ANDROID_HOST_SYSTEM+'/bin'
73 ANDROID_SYSROOT = ANDROID_NDK_ROOT+'/platforms/'+ANDROID_PLATFORM+'/arch-'+ANDROID_ARCH
75 ### add the tools to the path
76 env.PrependENVPath('PATH', ANDROID_TOOLCHAIN_BIN)
78 ### special C Runtime startup for executables
79 env['NPT_EXTRA_EXECUTABLE_OBJECTS'] = []
80 env['NPT_EXTRA_LIBS'] = ['gcc']
82 ### Load the tools
83 LoadTool('gcc-generic', env, gcc_cross_prefix=ANDROID_CROSS_PREFIX, gcc_strict=False)
84 env.AppendUnique(CCFLAGS = ['-I'+ANDROID_NDK_ROOT+'/sources/cxx-stl/system/include' ,
85                             '--sysroot', ANDROID_SYSROOT,
86                             '-msoft-float',
87                             '-fpic',
88                             '-mthumb-interwork',
89                             '-ffunction-sections',
90                             '-funwind-tables',
91                             '-fstack-protector',
92                             '-fno-short-enums'])
93 env.AppendUnique(CXXFLAGS = ['-fno-exceptions', '-fno-rtti'])
94 env.AppendUnique(CPPDEFINES = ['ANDROID', 'NPT_CONFIG_HAVE_SYSTEM_LOG_CONFIG'])
95 env.AppendUnique(LINKFLAGS = ['--sysroot', ANDROID_SYSROOT,
96                                           '-Wl,--no-undefined',
97                               '-Wl,-z,noexecstack',
98                                           '-L'+ANDROID_SYSROOT+'/usr/lib',
99                                           '-lc',
100                                           '-lstdc++',
101                                           '-lm',
102                                           '-llog',
103                               '-ldl',
104                               '-pie'])
106 ### Specific System choices
107 env['NPT_SYSTEM_SOURCES']={'System/StdC':['NptStdcConsole.cpp', 'NptStdcEnvironment.cpp'],
108                            'System/Bsd':'*.cpp',
109                            'System/Posix':'*.cpp',
110                            'System/Null':['NptNullSerialPort.cpp', 'NptNullAutoreleasePool.cpp'],
111                            'System/Android':'*.cpp'}