Skip to content

Commit

Permalink
Fix: Fix pkgconfig detection, and multiple subsequent build for Andro…
Browse files Browse the repository at this point in the history
…id (#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)
  • Loading branch information
lains authored and pgrandin committed Aug 20, 2019
1 parent c2f9838 commit e7a70e9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
52 changes: 29 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions scripts/build_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit e7a70e9

Please sign in to comment.