Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ xcuserdata
*.pyc
.scons*
.DS_Store
Build/Targets/arm64-android-linux/Debug
Build/Targets/arm64-android-linux/Release

8 changes: 4 additions & 4 deletions Build/Targets/arm-android-linux/Config.scons
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ if env.has_key('android_host_system') and env['android_host_system']:
ANDROID_HOST_SYSTEM = env['android_host_system']
else:
PLATFORM_TO_TARGET_MAP = {
'linux-i386' : 'linux-x86',
'linux2' : 'linux-x86',
'linux-i386' : 'linux-x86_64',
'linux2' : 'linux-x86_64',
'win32' : 'windows',
'cygwin' : 'windows',
'darwin' : 'darwin-x86'
Expand All @@ -32,8 +32,8 @@ else:

# set defaults
ANDROID_ARCH = 'arm'
ANDROID_PLATFORM = 'android-9'
ANDROID_TOOLCHAIN = 'arm-linux-androideabi-4.4.3'
ANDROID_PLATFORM = 'android-14'
ANDROID_TOOLCHAIN = 'arm-linux-androideabi-4.9'
ANDROID_CROSS_PREFIX = 'arm-linux-androideabi'

if not os.path.exists(os.path.join(ANDROID_NDK_ROOT, 'toolchains', ANDROID_TOOLCHAIN)):
Expand Down
107 changes: 107 additions & 0 deletions Build/Targets/arm64-android-linux/Config.scons
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#################################################################
# Important: this build file has been tested with Android NDK r6, r7 and r8
# It may or may not work with other releases of the NDK. Please notify
# us if you find a newer NDK for which this does not work.
#################################################################

import os
import re
import sys
import platform

# we need to know when the NDK is
ANDROID_NDK_ROOT=os.getenv('ANDROID_NDK_ROOT')
if not ANDROID_NDK_ROOT:
raise Exception('ANDROID_NDK_ROOT environment variable not set')

# detect the host system on which we're running
if env.has_key('android_host_system') and env['android_host_system']:
ANDROID_HOST_SYSTEM = env['android_host_system']
else:
PLATFORM_TO_TARGET_MAP = {
'linux-i386' : 'linux-x86_64',
'linux2' : 'linux-x86_64',
'win32' : 'windows',
'cygwin' : 'windows',
'darwin' : 'darwin-x86'
}
if sys.platform in PLATFORM_TO_TARGET_MAP:
ANDROID_HOST_SYSTEM = PLATFORM_TO_TARGET_MAP[sys.platform]
else:
raise Exception('Android Host Platform cannot be determined')

# set defaults
ANDROID_ARCH = 'arm64'
ANDROID_PLATFORM = 'android-21'
ANDROID_TOOLCHAIN = 'aarch64-linux-android-4.9'
ANDROID_CROSS_PREFIX = 'aarch64-linux-android'

if not os.path.exists(os.path.join(ANDROID_NDK_ROOT, 'toolchains', ANDROID_TOOLCHAIN)):
toolchain_dirs = os.listdir(ANDROID_NDK_ROOT+'/toolchains')
for toolchain_dir in toolchain_dirs:
if os.path.exists(os.path.join(ANDROID_NDK_ROOT, 'toolchains', toolchain_dir, 'prebuilt', ANDROID_HOST_SYSTEM)):
ANDROID_TOOLCHAIN=toolchain_dir
suffix_pos = toolchain_dir.rfind('-')
if (suffix_pos >= 0):
ANDROID_CROSS_PREFIX = ANDROID_TOOLCHAIN[:suffix_pos]
print "Auto-selecting toolchain:", ANDROID_TOOLCHAIN
break

# override defaults from command line args
if ARGUMENTS.get('android_toolchain'):
ANDROID_TOOLCHAIN=ARGUMENTS.get('android_toolchain')

if ARGUMENTS.get('android_cross_prefix'):
ANDROID_CROSS_PREFIX=ARGUMENTS.get('android_cross_prefix')

if ARGUMENTS.get('android_platform'):
ANDROID_PLATFORM=ARGUMENTS.get('android_platform')

if ARGUMENTS.get('android_arch'):
ANDROID_ARCH=ARGUMENTS.get('android_arch')

print 'Building for Android: '
print 'ANDROID_HOST_SYSTEM =', ANDROID_HOST_SYSTEM
print 'ANDROID_TOOLCHAIN =', ANDROID_TOOLCHAIN
print 'ANDROID_PLATFORM =', ANDROID_PLATFORM
print 'ANDROID_ARCH =', ANDROID_ARCH

ANDROID_TOOLCHAIN_BIN = ANDROID_NDK_ROOT+'/toolchains/'+ANDROID_TOOLCHAIN+'/prebuilt/'+ANDROID_HOST_SYSTEM+'/bin'
ANDROID_SYSROOT = ANDROID_NDK_ROOT+'/platforms/'+ANDROID_PLATFORM+'/arch-'+ANDROID_ARCH

### add the tools to the path
env.PrependENVPath('PATH', ANDROID_TOOLCHAIN_BIN)

### special C Runtime startup for executables
env['NPT_EXTRA_EXECUTABLE_OBJECTS'] = []
env['NPT_EXTRA_LIBS'] = ['gcc']

### Load the tools
LoadTool('gcc-generic', env, gcc_cross_prefix=ANDROID_CROSS_PREFIX, gcc_strict=False)
env.AppendUnique(CCFLAGS = ['-I'+ANDROID_NDK_ROOT+'/sources/cxx-stl/system/include' ,
'--sysroot', ANDROID_SYSROOT,
# '-msoft-float',
'-fpic',
# '-mthumb-interwork',
'-ffunction-sections',
'-funwind-tables',
'-fstack-protector',
'-fno-short-enums'])
env.AppendUnique(CXXFLAGS = ['-fno-exceptions', '-fno-rtti'])
env.AppendUnique(CPPDEFINES = ['ANDROID', 'NPT_CONFIG_HAVE_SYSTEM_LOG_CONFIG'])
env.AppendUnique(LINKFLAGS = ['--sysroot', ANDROID_SYSROOT,
'-Wl,--no-undefined',
'-Wl,-z,noexecstack',
'-L'+ANDROID_SYSROOT+'/usr/lib',
'-lc',
'-lstdc++',
'-lm',
'-llog',
'-ldl'])

### Specific System choices
env['NPT_SYSTEM_SOURCES']={'System/StdC':'NptStdc[!D]*.cpp',
'System/Bsd':'*.cpp',
'System/Posix':'*.cpp',
'System/Null':['NptNullSerialPort.cpp', 'NptNullAutoreleasePool.cpp'],
'System/Android':'*.cpp'}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ Under Source/Extras/Managed

## Android Java/JNI
To build the JNI shared library, you will need to install the Android NDK and set up the proper environment variables such as ANDROID_NDK_ROOT.
(android-ndk-r15c recommended;If a path error occurs, use the absolute path.)
```
> scons -c target=arm-android-linux build_config=Release
> scons target=arm-android-linux build_config=Release
> scons -c target=arm64-android-linux build_config=Release
> scons target=arm64-android-linux build_config=Release
> cd Source/Platform/Android/module/platinum
> ndk-build NDK_DEBUG=0
```
Expand Down
4 changes: 2 additions & 2 deletions Source/Platform/Android/module/platinum/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="10" />
<uses-sdk android:minSdkVersion="14" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
</application>

</manifest>
</manifest>
17 changes: 14 additions & 3 deletions Source/Platform/Android/module/platinum/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ LOCAL_PATH := $(call my-dir)

PLT_ROOT := $(LOCAL_PATH)/../../../../../..
PLT_SRC_ROOT := $(PLT_ROOT)/Source

$(warning "TARGET_ARCH_ABI:$(TARGET_ARCH_ABI)")
ifeq ($(NDK_DEBUG),1)
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
$(warning "build arm64")
PLT_PREBUILT_PATH := ../../../../../../Build/Targets/arm64-android-linux/Debug
else
PLT_PREBUILT_PATH := ../../../../../../Build/Targets/arm-android-linux/Debug
endif
else
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
$(warning "build arm64")
PLT_PREBUILT_PATH := ../../../../../../Build/Targets/arm64-android-linux/Release
else
PLT_PREBUILT_PATH := ../../../../../../Build/Targets/arm-android-linux/Release
endif
endif


include $(CLEAR_VARS)
LOCAL_MODULE := Platinum
Expand All @@ -18,13 +29,13 @@ LOCAL_EXPORT_C_INCLUDES += $(PLT_SRC_ROOT)/Devices/MediaConnect
LOCAL_EXPORT_C_INCLUDES += $(PLT_SRC_ROOT)/Devices/MediaServer
LOCAL_EXPORT_C_INCLUDES += $(PLT_SRC_ROOT)/Devices/MediaRenderer
LOCAL_EXPORT_C_INCLUDES += $(PLT_SRC_ROOT)/Extras
LOCAL_C_INCLUDES += $(PLT_ROOT)/../Neptune/Source/Core
LOCAL_C_INCLUDES += $(PLT_ROOT)/ThirdParty/Neptune/Source/Core
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := Neptune
LOCAL_SRC_FILES := $(PLT_PREBUILT_PATH)/libNeptune.a
LOCAL_EXPORT_C_INCLUDES += $(PLT_ROOT)/../Neptune/Source/Core
LOCAL_EXPORT_C_INCLUDES += $(PLT_ROOT)/ThirdParty/Neptune/Source/Core
include $(PREBUILT_STATIC_LIBRARY)

ifneq ($(NPT_CONFIG_NO_SSL),1)
Expand Down
2 changes: 1 addition & 1 deletion Source/Platform/Android/module/platinum/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1 +1 @@
APP_ABI := armeabi armeabi-v7a
APP_ABI := armeabi armeabi-v7a arm64-v8a
2 changes: 1 addition & 1 deletion Source/Platform/Android/module/platinum/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-10
target=android-14
android.library=true