Fix android build compatibility problems
authorCaiwen Zhang <caiwen.zhang@intel.com>
Thu, 25 Dec 2014 10:37:00 +0000 (18:37 +0800)
committerSudarshan Prasad <sudarshan.prasad@intel.com>
Wed, 21 Jan 2015 01:45:30 +0000 (01:45 +0000)
commitd85438f2853541201ab8e6ff0c47a7e51917b042
treeed9269a8cb63288320c9ea5a80817bdf90657578
parentece439f7727bd7de66f850726f8ce9d4856d39c2
Fix android build compatibility problems

1. Some C++11 features are used in IoTivity. Old Android NDK may doesn't
support a part of these features directly. Implement and include it if
it is required.

2. Fix libc function missing problem. Some functions, e.g. rand, srand.
strtof ... are static inline prior to android-L(it is defined and
implemented in the header file). So before android-L libc.so doesn't
include them. If build on android-L and run on an old platform(earlier
than android-L), there will be 'can't locate xxx' problem.

e.g.:
rand, it is defined in stdlib.h as "static __inline__ int rand() { ....} in
the ndk < 10. it's defined as 'extern int rand();' from ndk-10x. With old
ndk, if a file (x.c) used 'rand' function, when build x.c, 'rand' is compiled
into x.o. 'rand' won't exit in neither libc.so nor libc.a. If build an
application with ndk-10x and run it on emulator or device(developed with
NDK < 10), it requires implement 'rand' function by owerself or there
will be be 'can't locate rand' problem.

For convenience, add these functions in a file, if necessary, build it as
library and auto link into binary.

Change-Id: If47da94db7d06fde9887eba335bc0c67762514a9
Signed-off-by: Caiwen Zhang<caiwen.zhang@intel.com>
(cherry picked from commit f56a9ad5a7c86609cf8895e8a579fb192f0ebfdb)
Reviewed-on: https://gerrit.iotivity.org/gerrit/175
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
17 files changed:
build_common/android/SConscript
build_common/android/compatibility/android_cpp11_compat.cpp [new file with mode: 0644]
build_common/android/compatibility/android_cpp11_compat.h [new file with mode: 0644]
build_common/android/compatibility/c_compat.c [new file with mode: 0644]
build_common/android/compatibility/c_compat.scons [new file with mode: 0644]
build_common/android/compatibility/cpp11_compat.scons [new file with mode: 0644]
build_common/android/jni/Android.mk
resource/examples/SConscript
resource/examples/ocicuc/SConscript
resource/include/OCRepresentation.h
resource/oc_logger/SConscript
resource/oc_logger/examples/SConscript
resource/src/SConscript
service/SConscript
service/notification-manager/SConscript
service/protocol-plugin/plugins/SConscript
service/things-manager/SConscript