From e7a70e9dc04b94b47fb7786aab4edfd25132c70f Mon Sep 17 00:00:00 2001 From: lains Date: Tue, 20 Aug 2019 17:06:27 +0200 Subject: Fix: Fix pkgconfig detection, and multiple subsequent build for Android (#833) * Fixing lib detection based on build host for Android builds * Fixing workaround according to jandegr's proposal * Fixing subsequent Android builds (where rename fails because of pre-existing renamed files) --- CMakeLists.txt | 52 +++++++++++++++++++++++++++--------------------- scripts/build_android.sh | 9 +++++++-- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4890afa04..1ce8d4b41 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,31 +154,35 @@ INCLUDE (CheckSymbolExists) find_package(PkgConfig) if(PKG_CONFIG_FOUND) - pkg_check_modules ( GMODULE gmodule-2.0 ) - if (GMODULE_FOUND) - set(HAVE_GMODULE 1) - include_directories(${GMODULE_INCLUDE_DIRS}) - list(APPEND NAVIT_LIBS ${GMODULE_LIBRARIES}) - endif(GMODULE_FOUND) - - pkg_check_modules (GLIB2 glib-2.0>=2.10) - if (GLIB2_FOUND) - set(HAVE_GLIB 1) - include_directories(${GLIB2_INCLUDE_DIRS}) - list(APPEND NAVIT_LIBS ${GLIB2_LIBRARIES}) - else(GLIB2_FOUND) - set_with_reason(support/glib "Glib not found" TRUE ${INTL_LIBS}) - endif(GLIB2_FOUND) + if (NOT ANDROID) + pkg_check_modules ( GMODULE gmodule-2.0 ) + if (GMODULE_FOUND) + set(HAVE_GMODULE 1) + include_directories(${GMODULE_INCLUDE_DIRS}) + list(APPEND NAVIT_LIBS ${GMODULE_LIBRARIES}) + endif(GMODULE_FOUND) + + pkg_check_modules (GLIB2 glib-2.0>=2.10) + if (GLIB2_FOUND) + set(HAVE_GLIB 1) + include_directories(${GLIB2_INCLUDE_DIRS}) + list(APPEND NAVIT_LIBS ${GLIB2_LIBRARIES}) + else(GLIB2_FOUND) + set_with_reason(support/glib "Glib not found" TRUE ${INTL_LIBS}) + endif(GLIB2_FOUND) + endif(NOT ANDROID) pkg_check_modules(FONTCONFIG "fontconfig >= 2.2.0") - pkg_check_modules(DBUS "dbus-1 >= 1.4") - pkg_check_modules(DBUSGLIB dbus-glib-1) - if(DBUSGLIB_FOUND) - include_directories(${DBUSGLIB_INCLUDE_DIRS}) - set_with_reason(binding/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES}) - set_with_reason(speech/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES}) - set_with_reason(vehicle/gpsd_dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES}) - endif() + if (NOT ANDROID) + pkg_check_modules(DBUS "dbus-1 >= 1.4") + pkg_check_modules(DBUSGLIB dbus-glib-1) + if(DBUSGLIB_FOUND) + include_directories(${DBUSGLIB_INCLUDE_DIRS}) + set_with_reason(binding/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES}) + set_with_reason(speech/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES}) + set_with_reason(vehicle/gpsd_dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES}) + endif(DBUSGLIB_FOUND) + endif(NOT ANDROID) pkg_check_modules(LIBLOCATION liblocation) pkg_check_modules(LIBOSSO libosso) @@ -740,6 +744,8 @@ if(ANDROID) set_with_reason(graphics/null "Android detected" FALSE) set_with_reason(graphics/android "Android detected" TRUE) set_with_reason(speech/android "Android detected" TRUE) + set_with_reason(support/ezxml "Android detected" TRUE) + set_with_reason(support/glib "Android detected" TRUE) set_with_reason(traffic/traff_android "Android detected" TRUE) set_with_reason(vehicle/android "Android detected" TRUE) set_with_reason(vehicle/file "Android detected" FALSE) diff --git a/scripts/build_android.sh b/scripts/build_android.sh index 3f2738451..f30c7d76c 100755 --- a/scripts/build_android.sh +++ b/scripts/build_android.sh @@ -28,25 +28,29 @@ export GRADLE_OPTS='-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryEr sudo apt-get install -y ant echo Run CMake +test -z "$PKG_CONFIG_LIBDIR" && export PKG_CONFIG_LIBDIR="" # Force cmake below to run ignore build host libraries when using pkgconfig. +# Note: If you want to compile against specific target libraries that are searched using pkgconfig, please run this script with variable PKG_CONFIG_LIBDIR set to the appropriate path cmake ./ -Dvehicle/gpsd_dbus:BOOL=FALSE -Dsvg2png_scaling:STRING=-1,24,32,48,64,96,128,192,256 -Dsvg2png_scaling_nav:STRING=-1,24,32,48,64,96,128,192,256 -Dsvg2png_scaling_flag:STRING=-1,24,32,64,96 -DXSL_PROCESSING=y -DXSLTS=android -DANDROID=y || exit 1 echo Process icons pushd navit/icons make || exit 32 +rm -rf ../android/res/drawable-nodpi mkdir ../android/res/drawable-nodpi cp ./*.png ../android/res/drawable-nodpi pushd ../android/res/drawable-nodpi -rename 'y/A-Z/a-z/' ./*.png +rename -f 'y/A-Z/a-z/' ./*.png popd popd echo Process translations pushd po make || exit 64 +rm -rf ../navit/android/res/raw mkdir ../navit/android/res/raw cp ./*.mo ../navit/android/res/raw pushd ../navit/android/res/raw -rename 'y/A-Z/a-z/' ./*.mo +rename -f 'y/A-Z/a-z/' ./*.mo popd popd @@ -55,6 +59,7 @@ popd echo Process xml config files make navit_config_xml || exit 96 pushd navit +rm -rf ./android/assets mkdir -p ./android/assets cp -R config ./android/assets/ popd -- cgit v1.2.1