@@ -42,6 +42,9 @@ CMakeLists.txt file.
4242| ` TAGLIB_INSTALL_SUFFIX ` | Suffix added to installed libraries, includes, ... |
4343| ` ENABLE_STATIC_RUNTIME ` | Link with MSVC runtime statically |
4444| ` BUILD_FRAMEWORK ` | Build a macOS framework |
45+ | ` TESTS_DIR ` | Where to find unit test data (with data appended) |
46+ | ` TESTS_TMPDIR ` | Where to create temporary files in unit tests |
47+
4548
4649If you want to install TagLib 2 alongside TagLib 1, you can use
4750` -DTAGLIB_INSTALL_SUFFIX=-2 ` and make sure that ` BUILD_EXAMPLES ` is not ` ON `
@@ -462,3 +465,54 @@ cmake --build build_mingw --config Release
462465PATH=$PATH:$TAGLIB_PREFIX/bin
463466 build_mingw/tagreader /path/to/audio-file
464467```
468+
469+ ## Android
470+
471+ ### Using vcpkg
472+
473+ The bash script below can be used to build TagLib for Android using vcpkg.
474+ It must be started in the parent folder of the taglib source folder and will
475+ build in a folder _ android_build_ and install into _ android_pkg_ .
476+ The package and the unit tests are then transferred to an Android device
477+ and the unit tests are run on the device.
478+
479+ Note that ` TESTS_TMPDIR ` is set because there is no system-wide temporary folder
480+ on Android. ` TESTS_DIR ` is set to run the tests on the target.
481+
482+ ```
483+ # You may have to adapt the NDK and vcpkg paths and the ABI/triplet.
484+
485+ export ANDROID_NDK_HOME=$HOME/Development/android-sdk/ndk/23.1.7779620
486+ export VCPKG_ROOT=$HOME/Development/vcpkg
487+ PATH=$PATH:$VCPKG_ROOT
488+
489+ # armeabi-v7a/arm-android or arm64-v8a/arm64-android or x86/x86-android or x86_64/x64-android
490+ android_abi=armeabi-v7a
491+ vcpkg_target_triplet=arm-android
492+
493+ vcpkg_toolchain_file=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
494+ android_toolchain_file=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake
495+
496+ vcpkg install --triplet $vcpkg_target_triplet utfcpp zlib cppunit
497+
498+ cmake -B android_build -S taglib \
499+ -DCMAKE_TOOLCHAIN_FILE=$vcpkg_toolchain_file \
500+ -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$android_toolchain_file \
501+ -DVCPKG_TARGET_TRIPLET=$vcpkg_target_triplet \
502+ -DANDROID_ABI=$android_abi \
503+ -GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release \
504+ -DVISIBILITY_HIDDEN=ON -DENABLE_CCACHE=ON -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON \
505+ -DTESTS_DIR=/data/local/tmp/tests/ -DTESTS_TMPDIR=/data/local/tmp
506+ cmake --build android_build --config Release
507+ cmake --install android_build --config Release --prefix android_pkg --strip
508+ cp -a android_build/tests/test_runner android_pkg/bin/
509+
510+ if hash adb 2>/dev/null; then
511+ adb push android_pkg /data/local/tmp/
512+ adb push android_build/tests/test_runner /data/local/tmp/tests/test_runner
513+ adb push taglib/tests/data /data/local/tmp/tests/
514+ adb shell "env LD_LIBRARY_PATH=/data/local/tmp/android_pkg/lib /data/local/tmp/tests/test_runner"
515+ # You could also try an example binary:
516+ # adb shell "env LD_LIBRARY_PATH=/data/local/tmp/android_pkg/lib /data/local/tmp/android_pkg/bin/tagreader '/sdcard/Music/Some Album/A Track.mp3'"
517+ fi
518+ ```
0 commit comments