99# Modules
1010MODULES=$MODULES
1111
12+ # Resolve Python path
13+ PYTHON=" $( which python2.7) "
14+ if [ " X$PYTHON " == " X" ]; then
15+ PYTHON=" $( which python2) "
16+ fi
17+ if [ " X$PYTHON " == " X" ]; then
18+ PYTHON=" $( which python) "
19+ fi
20+
1221# Paths
13- ROOT_PATH=" $( dirname $( python -c ' import os,sys;print os.path.realpath(sys.argv[1])' $0 ) ) "
22+ ROOT_PATH=" $( dirname $( $PYTHON -c ' from __future__ import print_function; import os,sys;print( os.path.realpath(sys.argv[1]) )' $0 ) ) "
1423RECIPES_PATH=" $ROOT_PATH /recipes"
1524BUILD_PATH=" $ROOT_PATH /build"
1625LIBS_PATH=" $ROOT_PATH /build/libs"
26+ JAVACLASS_PATH=" $ROOT_PATH /build/java"
1727PACKAGES_PATH=" $ROOT_PATH /.packages"
1828SRC_PATH=" $ROOT_PATH /src"
1929JNI_PATH=" $SRC_PATH /jni"
@@ -42,8 +52,10 @@ if [ "X$WGET" == "X" ]; then
4252 echo " Error: you need at least wget or curl installed."
4353 exit 1
4454 else
45- WGET=" $WGET -L -O"
55+ WGET=" $WGET -L -O -o "
4656 fi
57+ else
58+ WGET=" $WGET -O"
4759fi
4860
4961case $OSTYPE in
@@ -123,7 +135,7 @@ function push_arm() {
123135 # export OFLAG="-Os"
124136 # export OFLAG="-O2"
125137
126- export CFLAGS=" -mandroid $OFLAG -fomit-frame-pointer --sysroot $NDKPLATFORM "
138+ export CFLAGS=" -DANDROID - mandroid $OFLAG -fomit-frame-pointer --sysroot $NDKPLATFORM "
127139 if [ " X$ARCH " == " Xarmeabi-v7a" ]; then
128140 CFLAGS+=" -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb"
129141 fi
@@ -133,7 +145,7 @@ function push_arm() {
133145 export LDFLAGS=" -lm"
134146
135147 # this must be something depending of the API level of Android
136- PYPLATFORM=$( python -c ' import sys; print sys.platform' )
148+ PYPLATFORM=$( $PYTHON -c ' from __future__ import print_function; import sys; print( sys.platform) ' )
137149 if [ " $PYPLATFORM " == " linux2" ]; then
138150 PYPLATFORM=" linux"
139151 elif [ " $PYPLATFORM " == " linux3" ]; then
@@ -150,7 +162,7 @@ function push_arm() {
150162 export TOOLCHAIN_VERSION=4.4.3
151163 fi
152164
153- export PATH=" $ANDROIDNDK /toolchains/$TOOLCHAIN_PREFIX -$TOOLCHAIN_VERSION /prebuilt/$PYPLATFORM -x86/bin/:$ANDROIDNDK :$ANDROIDSDK /tools:$PATH "
165+ export PATH=" $ANDROIDNDK /toolchains/$TOOLCHAIN_PREFIX -$TOOLCHAIN_VERSION /prebuilt/$PYPLATFORM -x86/bin/:$ANDROIDNDK /toolchains/ $TOOLCHAIN_PREFIX - $TOOLCHAIN_VERSION /prebuilt/ $PYPLATFORM -x86_64/bin/: $ANDROIDNDK :$ANDROIDSDK /tools:$PATH "
154166
155167 # search compiler in the path, to fail now instead of later.
156168 CC=$( which $TOOLCHAIN_PREFIX -gcc)
@@ -213,6 +225,36 @@ function usage() {
213225 exit 0
214226}
215227
228+ # Check installation state of a debian package list.
229+ # Return all missing packages.
230+ function check_pkg_deb_installed() {
231+ PKGS=$1
232+ MISSING_PKGS=" "
233+ for PKG in $PKGS ; do
234+ CHECK=$( dpkg -s $PKG 2>&1 )
235+ if [ $? -eq 1 ]; then
236+ MISSING_PKGS=" $PKG $MISSING_PKGS "
237+ fi
238+ done
239+ if [ " X$MISSING_PKGS " != " X" ]; then
240+ error " Packages missing: $MISSING_PKGS "
241+ error " It might break the compilation, except if you installed thoses packages manually."
242+ fi
243+ }
244+
245+ function check_build_deps() {
246+ DIST=$( lsb_release -is)
247+ info " Check build dependencies for $DIST "
248+ case $DIST in
249+ Debian|Ubuntu)
250+ check_pkg_deb_installed " build-essential zlib1g-dev cython"
251+ ;;
252+ * )
253+ debug " Avoid check build dependencies, unknow platform $DIST "
254+ ;;
255+ esac
256+ }
257+
216258function run_prepare() {
217259 info " Check enviromnent"
218260 if [ " X$ANDROIDSDK " == " X" ]; then
@@ -289,6 +331,7 @@ function run_prepare() {
289331 test -d $PACKAGES_PATH || mkdir -p $PACKAGES_PATH
290332 test -d $BUILD_PATH || mkdir -p $BUILD_PATH
291333 test -d $LIBS_PATH || mkdir -p $LIBS_PATH
334+ test -d $JAVACLASS_PATH || mkdir -p $JAVACLASS_PATH
292335 test -d $LIBLINK_PATH || mkdir -p $LIBLINK_PATH
293336
294337 # create initial files
@@ -346,7 +389,7 @@ function run_source_modules() {
346389 debug " Read $module recipe"
347390 recipe=$RECIPES_PATH /$module /recipe.sh
348391 if [ ! -f $recipe ]; then
349- error " Recipe $module does not exit "
392+ error " Recipe $module does not exist "
350393 exit -1
351394 fi
352395 source $RECIPES_PATH /$module /recipe.sh
@@ -388,6 +431,20 @@ function run_get_packages() {
388431
389432 for module in $MODULES ; do
390433 # download dependencies for this module
434+ # check if there is not an overload from environment
435+ module_dir=$( eval " echo \$ P4A_${module} _DIR" )
436+ if [ " $module_dir " ]
437+ then
438+ debug " \$ P4A_${module} _DIR is not empty, linking $module_dir dir instead of downloading"
439+ directory=$( eval " echo \$ BUILD_${module} " )
440+ if [ -e $directory ]; then
441+ try rm -rf " $directory "
442+ fi
443+ try mkdir -p " $directory "
444+ try rmdir " $directory "
445+ try ln -s " $module_dir " " $directory "
446+ continue
447+ fi
391448 debug " Download package for $module "
392449
393450 url=" URL_$module "
@@ -429,7 +486,7 @@ function run_get_packages() {
429486 # download if needed
430487 if [ $do_download -eq 1 ]; then
431488 info " Downloading $url "
432- try $WGET $url
489+ try $WGET $filename $ url
433490 else
434491 debug " Module $module already downloaded"
435492 fi
@@ -536,6 +593,9 @@ function run_distribute() {
536593 try mkdir -p libs/$ARCH
537594 try cp -a $BUILD_PATH /libs/* libs/$ARCH /
538595
596+ debug " Copy java files from various libs"
597+ cp -a $BUILD_PATH /java/* src
598+
539599 debug " Fill private directory"
540600 try cp -a python-install/lib private/
541601 try mkdir -p private/include/python2.7
@@ -579,6 +639,7 @@ function run_biglink() {
579639}
580640
581641function run() {
642+ check_build_deps
582643 run_prepare
583644 run_source_modules
584645 run_get_packages
@@ -639,9 +700,9 @@ while getopts ":hvlfxm:d:s" opt; do
639700 f)
640701 DO_CLEAN_BUILD=1
641702 ;;
642- x)
643- DO_SET_X=1
644- ;;
703+ x)
704+ DO_SET_X=1
705+ ;;
645706 \? )
646707 echo " Invalid option: -$OPTARG " >&2
647708 exit 1
0 commit comments