@@ -28,6 +28,8 @@ PACKAGES_PATH="$ROOT_PATH/.packages"
2828SRC_PATH=" $ROOT_PATH /src"
2929JNI_PATH=" $SRC_PATH /jni"
3030DIST_PATH=" $ROOT_PATH /dist/default"
31+ SITEPACKAGES_PATH=" $BUILD_PATH /python-install/lib/python2.7/site-packages/"
32+ HOSTPYTHON=" $BUILD_PATH /python-install/bin/python.host"
3133
3234# Tools
3335export LIBLINK_PATH=" $BUILD_PATH /objects"
@@ -213,19 +215,18 @@ function pop_arm() {
213215
214216function usage() {
215217 echo " Python for android - distribute.sh"
216- echo " This script create a directory will all the libraries wanted"
217218 echo
218- echo " Usage: ./distribute.sh [options] directory"
219- echo " Example: ./distribute.sh -m 'pil kivy' dist"
220- echo
221- echo " Options:"
219+ echo " Usage: ./distribute.sh [options]"
222220 echo
223221 echo " -d directory Name of the distribution directory"
224222 echo " -h Show this help"
225223 echo " -l Show a list of available modules"
226224 echo " -m 'mod1 mod2' Modules to include"
227225 echo " -f Restart from scratch (remove the current build)"
228- echo " -x display expanded values (execute 'set -x')"
226+ echo " -x display expanded values (execute 'set -x')"
227+ echo
228+ echo " For developers:"
229+ echo " -u 'mod1 mod2' Modules to update (if already compiled)"
229230 echo
230231 exit 0
231232}
@@ -330,6 +331,11 @@ function run_prepare() {
330331 try rm -rf $BUILD_PATH
331332 try rm -rf $SRC_PATH /obj
332333 try rm -rf $SRC_PATH /libs
334+ pushd $JNI_PATH
335+ push_arm
336+ try ndk-build clean
337+ pop_arm
338+ popd
333339 fi
334340
335341 # create build directory if not found
@@ -585,11 +591,40 @@ function run_prebuild() {
585591
586592function run_build() {
587593 info " Run build"
594+
595+ modules_update=($MODULES_UPDATE )
596+
588597 cd $BUILD_PATH
598+
589599 for module in $MODULES ; do
590- fn=$( echo build_$module )
591- debug " Call $fn "
592- $fn
600+ fn=" build_$module "
601+ shouldbuildfn=" shouldbuild_$module "
602+ MARKER_FN=" $BUILD_PATH /.mark-$module "
603+
604+ # if the module should be updated, then remove the marker.
605+ in_array $module " ${modules_update[@]} "
606+ if [ $? -ne 255 ]; then
607+ debug " $module detected to be updated"
608+ rm -f " $MARKER_FN "
609+ fi
610+
611+ # if shouldbuild_$module exist, call it to see if the module want to be
612+ # built again
613+ DO_BUILD=1
614+ if [ " $( type -t $shouldbuildfn ) " == " function" ]; then
615+ $shouldbuildfn
616+ fi
617+
618+ # if the module should be build, or if the marker is not present,
619+ # do the build
620+ if [ " X$DO_BUILD " == " X1" ] || [ ! -f " $MARKER_FN " ]; then
621+ debug " Call $fn "
622+ rm -f " $MARKER_FN "
623+ $fn
624+ touch " $MARKER_FN "
625+ else
626+ debug " Skipped $fn "
627+ fi
593628 done
594629}
595630
@@ -633,7 +668,7 @@ function run_pymodules_install() {
633668 try echo " $PYMODULES " | try sed ' s/\ /\n/g' > requirements.txt
634669
635670 debug " Install pure-python modules via pip in venv"
636- try bash -c " source venv/bin/activate && env CC=/bin/false CXX=/bin/false $PIP install --target '$BUILD_PATH /python-install/lib/python2.7/site-packages ' --download-cache '$PACKAGES_PATH ' -r requirements.txt"
671+ try bash -c " source venv/bin/activate && env CC=/bin/false CXX=/bin/false $PIP install --target '$SITEPACKAGES_PATH ' --download-cache '$PACKAGES_PATH ' -r requirements.txt"
637672
638673}
639674
@@ -656,7 +691,7 @@ function run_distribute() {
656691 try cp -a $BUILD_PATH /blacklist.txt .
657692
658693 debug " Copy python distribution"
659- $BUILD_PATH /python-install/bin/python.host -OO -m compileall $BUILD_PATH /python-install
694+ $HOSTPYTHON -OO -m compileall $BUILD_PATH /python-install
660695 try cp -a $BUILD_PATH /python-install .
661696
662697 debug " Copy libs"
@@ -679,19 +714,11 @@ function run_distribute() {
679714 try find . | grep -E ' *\.(py|pyc|so\.o|so\.a|so\.libs)$' | xargs rm
680715
681716 # we are sure that all of theses will be never used on android (well...)
682- try rm -rf test
683717 try rm -rf ctypes
684718 try rm -rf lib2to3
685- try rm -rf lib-tk
686719 try rm -rf idlelib
687- try rm -rf unittest/test
688- try rm -rf json/tests
689- try rm -rf distutils/tests
690- try rm -rf email/test
691- try rm -rf bsddb/test
692720 try rm -rf config/libpython* .a
693721 try rm -rf config/python.o
694- try rm -rf curses
695722 try rm -rf lib-dynload/_ctypes_test.so
696723 try rm -rf lib-dynload/_testcapi.so
697724
@@ -746,7 +773,7 @@ function arm_deduplicate() {
746773
747774
748775# Do the build
749- while getopts " :hvlfxm:d:s" opt; do
776+ while getopts " :hvlfxm:u: d:s" opt; do
750777 case $opt in
751778 h)
752779 usage
@@ -765,6 +792,9 @@ while getopts ":hvlfxm:d:s" opt; do
765792 m)
766793 MODULES=" $OPTARG "
767794 ;;
795+ u)
796+ MODULES_UPDATE=" $OPTARG "
797+ ;;
768798 d)
769799 DIST_PATH=" $ROOT_PATH /dist/$OPTARG "
770800 ;;
0 commit comments