From 69033ad532a32fc7e13192a2b8d492d5e19e1088 Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Fri, 26 Jan 2024 16:24:17 +0100 Subject: [PATCH] [docs] Update README.md Also, scripts/build.sh can be called without specifying the CMAKE_TOOLCHAIN_FILE environment variable. --- README.md | 51 +++++++++++++++++++++++++++++++++--------------- scripts/build.sh | 11 +++++++++-- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 18174c8c6..09ca99760 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ @@ -30,21 +30,30 @@ Integration with other projects are stored in `adapters` folder. `test` contains API and unit tests for the library. All supporting scripts are located in `scripts`. -# Standalone build +# Standalone build using CMake The library can be built using CMake: ``` cmake \ -S /path/to/intrinsiccv \ -B build-intrinsiccv \ +cmake --build build-intrinsiccv --parallel +``` + +To target Android devices the following CMake flags are also required: +``` -DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake \ -DANDROID_ABI=arm64-v8a -cmake --build build-intrinsiccv --parallel ``` -Builds scripts for Linux/macOS are also provided for convenience. To target -Android devices the following command should work: +# Standalone build using the provided script +Build scripts for Linux/macOS are provided for convenience. To build the library run: +``` +scripts/build.sh +``` + +To target Android devices the following command can be used: ``` BUILD_ID=android \ CMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake \ @@ -52,14 +61,14 @@ EXTRA_CMAKE_ARGS="-DANDROID_ABI=arm64-v8a" \ scripts/build.sh ``` -For further options please refer to the documentation in `./scripts/build.sh`. +The build artifacts are placed in the `build` directory. -# Build and run tests +## Build and run tests for Android -To build all the tests target `intrinsiccv-test`, to also run them use +To build all the tests use the target `intrinsiccv-test`, to also run them use `check-intrinsiccv` and set a proper `CMAKE_CROSSCOMPILING_EMULATOR`. -To build all tests for Android: +To build all tests: ``` BUILD_ID=android \ CMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake \ @@ -67,8 +76,7 @@ EXTRA_CMAKE_ARGS="-DANDROID_ABI=arm64-v8a" \ scripts/build.sh intrinsiccv-test ``` -To build and run all tests for Android with a single command: - +To run the tests: ``` BUILD_ID=android \ CMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake \ @@ -78,6 +86,9 @@ EXTRA_CMAKE_ARGS="-DANDROID_ABI=arm64-v8a" \ scripts/build.sh check-intrinsiccv ``` +For further options please refer to the documentation in `./scripts/build.sh` +and `./scripts/test_android.sh`. + # Building with OpenCV ## Install @@ -98,17 +109,14 @@ git apply /path/to/intrinsiccv/adapters/opencv/opencv-5.x.patch ## Build Library -The project can be built using standard cmake and ninja. +The project can be built using standard cmake. ``` cmake \ -S /path/to/opencv \ -B build-opencv \ --G Ninja \ -DWITH_INTRINSICCV=ON \ -DINTRINSICCV_SOURCE_PATH=/path/to/intrinsiccv \ --DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake \ --DANDROID_ABI=arm64-v8a \ -DCMAKE_CXX_STANDARD=14 \ -DBUILD_ANDROID_EXAMPLE=OFF \ -DBUILD_ANDROID_PROJECTS=OFF \ @@ -118,7 +126,13 @@ cmake \ cmake --build build-opencv --parallel ``` -### Build Prerequisites +To target Android devices the following CMake flags are required here as well: +``` +-DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake \ +-DANDROID_ABI=arm64-v8a +``` + +# Build Prerequisites While the core functionality of the library does not rely on any third-party libraries, there are build prerequisites that are essential for compiling the source code and generating the executable. Please ensure that these tools are installed on your system before proceeding with the build @@ -131,5 +145,10 @@ To successfully build and compile this project, you'll need the following tools: - [rsync](https://linux.die.net/man/1/rsync) for coverage reports, - recent version of [llvm](https://llvm.org), preferably 17 or newer. +Building for Android requires the [Android NDK](https://developer.android.com/ndk/). + +Running tests on Android devices requires [ADB](https://developer.android.com/tools/adb). +Can be installed standalone by installing [Android SDK Platform-Tools](https://developer.android.com/tools/releases/platform-tools). + OpenCV has its own [dependencies](https://docs.opencv.org/5.x/d7/d9f/tutorial_linux_install.html). diff --git a/scripts/build.sh b/scripts/build.sh index 8df09dddc..9f7384c43 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# SPDX-FileCopyrightText: 2023 Arm Limited and/or its affiliates +# SPDX-FileCopyrightText: 2023 - 2024 Arm Limited and/or its affiliates # # SPDX-License-Identifier: Apache-2.0 # @@ -20,6 +20,7 @@ # CMAKE_EXE_LINKER_FLAGS: General flags for all linker commands for executables. # CMAKE_GENERATOR: Generator to use, see cmake documentation for details. Defaults to 'Ninja'. # CMAKE_SHARED_LINKER_FLAGS: General flags for all linker commands for shared libraries. +# CMAKE_TOOLCHAIN_FILE: If set, it is the full path to the CMake toolchain file. # CMAKE_VERBOSE_MAKEFILE: Enables verbose logs during builds. Defaults to 'OFF'. # COVERAGE: Enables collection of coverage metrics if set to 'ON'. Defaults to 'OFF'. # EXTRA_CMAKE_ARGS: Any additional args to pass to CMake. @@ -44,6 +45,7 @@ SCRIPT_PATH="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" : "${CMAKE_EXE_LINKER_FLAGS:=}" : "${CMAKE_GENERATOR:=Ninja}" : "${CMAKE_SHARED_LINKER_FLAGS:=}" +: "${CMAKE_TOOLCHAIN_FILE:=}" : "${CMAKE_VERBOSE_MAKEFILE:=OFF}" : "${COVERAGE:=OFF}" : "${EXTRA_CMAKE_ARGS:=}" @@ -80,7 +82,6 @@ cmake_config_args=( -G "${CMAKE_GENERATOR}" "-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" - "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" "-DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}" @@ -92,6 +93,12 @@ if [[ -n "${CMAKE_CROSSCOMPILING_EMULATOR}" ]]; then ) fi +if [[ -n "${CMAKE_TOOLCHAIN_FILE}" ]]; then + cmake_config_args+=( + "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" + ) +fi + cmake_config_args+=("${EXTRA_CMAKE_ARGS_ARRAY[@]}") "${CMAKE}" "${cmake_config_args[@]}" -- GitLab