mirror of https://github.com/FreeRDP/FreeRDP
Merge pull request #1599 from akallabeth/helper_script
[ANDROID] Added script to automate gprof reporting.
This commit is contained in:
commit
fcea789a77
|
@ -29,14 +29,15 @@ FreeRDP requires openssl libraries for building but they are not part of the
|
|||
Android NDK and therefore they need to be prebuild manually.
|
||||
Multiple source versions and builds of static openssl libraries are floating around.
|
||||
At the time of writing we have tested and used:
|
||||
https://github.com/bmiklautz/Android-external-openssl-ndk-static.
|
||||
https://github.com/bmiklautz/Android-external-openssl-ndk-static
|
||||
https://github.com/akallabeth/openssl-android
|
||||
However, any other static build should work as well.
|
||||
|
||||
To build openssl:
|
||||
|
||||
git clone git@github.com:bmiklautz/android-external-openssl-ndk-static.git
|
||||
cd android-external-openssl-ndk-static
|
||||
ndk-build # found in the Android NDK
|
||||
Set up ANDROID_NDK and ANDROID_SDK to the absolute paths on your machine.
|
||||
From the project root folder run './scripts/android_setup_build_env.sh'
|
||||
This will set up openssl and gprof helper libraries as required for FreeRDP.
|
||||
|
||||
|
||||
Building
|
||||
|
|
|
@ -10,28 +10,26 @@
|
|||
# Usage:
|
||||
# android_setup_build_env.sh <source root>
|
||||
|
||||
OPENSSL_SCM=https://github.com/bmiklautz/android-external-openssl-ndk-static
|
||||
OPENSSL_SCM=https://github.com/akallabeth/openssl-android
|
||||
NDK_PROFILER_SCM=https://github.com/richq/android-ndk-profiler
|
||||
|
||||
SCRIPT_NAME=`basename $0`
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
|
||||
echo "Missing command line argument."
|
||||
echo "$SCRIPT_NAME <FreeRDP source>"
|
||||
exit -1
|
||||
echo "Missing command line argument, current directory as root."
|
||||
ROOT=`pwd`
|
||||
ROOT=$ROOT/external
|
||||
else
|
||||
ROOT=`readlink -f $1`
|
||||
fi
|
||||
|
||||
if [ ! -d $1 ]; then
|
||||
echo "Argument '$1' is not a directory."
|
||||
if [ ! -d $ROOT ]; then
|
||||
echo "Argument '$ROOT' is not a directory."
|
||||
exit -2
|
||||
fi
|
||||
SRC=`realpath $1`
|
||||
|
||||
echo "Using '$SRC' as root."
|
||||
echo "Using '$ROOT' as root."
|
||||
|
||||
echo "Preparing OpenSSL..."
|
||||
OPENSSL_SRC=$SRC/external/openssl
|
||||
OPENSSL_SRC=$ROOT/openssl-build
|
||||
if [ -d $OPENSSL_SRC ]; then
|
||||
cd $OPENSSL_SRC
|
||||
git pull
|
||||
|
@ -39,21 +37,35 @@ if [ -d $OPENSSL_SRC ]; then
|
|||
else
|
||||
git clone $OPENSSL_SCM $OPENSSL_SRC
|
||||
RETVAL=$?
|
||||
cd $OPENSSL_SRC
|
||||
fi
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo "Failed to execute git command [$RETVAL]"
|
||||
exit -3
|
||||
fi
|
||||
ndk-build
|
||||
RETVAL=$?
|
||||
|
||||
cd $OPENSSL_SRC
|
||||
make clean
|
||||
# The makefile has a bug, which aborts during
|
||||
# first compilation. Rerun make to build the whole lib.
|
||||
make
|
||||
make
|
||||
RETVAL=0 # TODO: Check, why 2 is returned.
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo "Failed to execute ndk-build command [$RETVAL]"
|
||||
echo "Failed to execute make command [$RETVAL]"
|
||||
exit -4
|
||||
fi
|
||||
|
||||
# Copy the created library to the default openssl directory,
|
||||
# so that CMake will detect it automatically.
|
||||
SSL_ROOT=`find $OPENSSL_SRC -type d -name "openssl-?.?.*"`
|
||||
rm -f $ROOT/openssl
|
||||
ln -s $SSL_ROOT $ROOT/openssl
|
||||
mkdir -p $ROOT/openssl/obj/local/armeabi/
|
||||
cp $ROOT/openssl/libssl.a $ROOT/openssl/obj/local/armeabi/
|
||||
cp $ROOT/openssl/libcrypto.a $ROOT/openssl/obj/local/armeabi/
|
||||
|
||||
echo "Preparing NDK profiler..."
|
||||
NDK_PROFILER_SRC=$SRC/external/android-ndk-profiler
|
||||
NDK_PROFILER_SRC=$ROOT/android-ndk-profiler
|
||||
if [ -d $NDK_PROFILER_SRC ]; then
|
||||
cd $NDK_PROFILER_SRC
|
||||
git pull
|
||||
|
@ -61,13 +73,14 @@ if [ -d $NDK_PROFILER_SRC ]; then
|
|||
else
|
||||
git clone $NDK_PROFILER_SCM $NDK_PROFILER_SRC
|
||||
RETVAL=$?
|
||||
cd $NDK_PROFILER_SRC
|
||||
fi
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo "Failed to execute git command [$RETVAL]"
|
||||
exit -5
|
||||
fi
|
||||
ndk-build
|
||||
cd $NDK_PROFILER_SRC
|
||||
ndk-build V=1 APP_ABI=armeabi-v7a clean
|
||||
ndk-build V=1 APP_ABI=armeabi-v7a
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo "Failed to execute ndk-build command [$RETVAL]"
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# This script tries to pull gprof profiling information generated by aFreeRDP
|
||||
# from the target using adb and generating human readable profiling data from
|
||||
# it.
|
||||
#
|
||||
# Any arguments supplied to the script will be appended to adb.
|
||||
#
|
||||
# Requirements:
|
||||
# - ANDROID_SDK is set to the android SDK directory or adb is in path.
|
||||
#
|
||||
|
||||
if [ -d $ANDROID_SDK ]; then
|
||||
ADB=$ANDROID_SDK/platform-tools/adb
|
||||
else
|
||||
ADB=`which adb`
|
||||
fi
|
||||
|
||||
GCC=@CMAKE_C_COMPILER@
|
||||
GPROF=${GCC/gcc/gprof}
|
||||
LIB=@CMAKE_BINARY_DIR@/client/Android/FreeRDPCore/jni/armeabi-v7a/libfreerdp-android.so
|
||||
|
||||
if [ ! -f $LIB ]; then
|
||||
echo "Missing libfreerdp-android.so"
|
||||
echo "Please build the project first."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ ! -f $GPROF ]; then
|
||||
echo "gprof could not be found at $GPROF."
|
||||
echo "Please assure, that you are using a GCC based android toolchain."
|
||||
exit -2
|
||||
fi
|
||||
|
||||
if [ ! -f $ADB ] || [ ! -x $ADB ]; then
|
||||
echo "adb could not be found."
|
||||
echo "assure, that either ANDROID_SDK is set to the path of your android SDK"
|
||||
echo "or that adb is in path."
|
||||
exit -3
|
||||
fi
|
||||
|
||||
# Do the acutal work in a temporary directory.
|
||||
SRC=`mktemp -d`
|
||||
cd $SRC
|
||||
$ADB $@ pull /sdcard/gmon.out
|
||||
if [ ! -f gmon.out ]; then
|
||||
echo "Could not pull profiling information from device!"
|
||||
RC=-4
|
||||
else
|
||||
echo "Pulled profiling information from device, starting conversion..."
|
||||
$GPROF $LIB -PprofCount -QprofCount -P__gnu_mcount_nc -Q__gnu_mcount_nc
|
||||
RC=0
|
||||
fi
|
||||
rm -rf $SRC
|
||||
|
||||
exit $RC
|
Loading…
Reference in New Issue