├── .gitattributes ├── .github └── workflows │ └── ci.yaml ├── .gitignore ├── License.md ├── README.md ├── __build.sh ├── bin ├── ar ├── base_clang++ ├── clang++ ├── hide │ ├── as │ └── strip └── ranlib ├── boost ├── down │ └── readme.md └── patch │ ├── 1.87.0.md │ └── readme.md ├── do.sh ├── docker ├── docker_readme.md ├── droid_base └── droid_full_auto ├── example_app ├── .gitignore ├── .idea │ ├── .name │ ├── compiler.xml │ ├── deploymentTargetSelector.xml │ ├── gradle.xml │ ├── kotlinc.xml │ ├── migrations.xml │ ├── misc.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── app │ ├── .gitignore │ ├── build.gradle.kts │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── boost_test │ │ │ └── ExampleInstrumentedTest.kt │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── cpp │ │ │ ├── CMakeLists.txt │ │ │ └── native-lib.cpp │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── boost_test │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable │ │ │ ├── ic_launcher_background.xml │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── values-night │ │ │ └── themes.xml │ │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── themes.xml │ │ │ └── xml │ │ │ ├── backup_rules.xml │ │ │ └── data_extraction_rules.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── boost_test │ │ └── ExampleUnitTest.kt ├── build.gradle.kts ├── gradle.properties ├── gradle │ ├── libs.versions.toml │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── local.properties ├── readme.md ├── screenshot.png └── settings.gradle.kts └── user-config.jam /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.{cmd,[cC][mM][dD]} text eol=crlf 4 | *.{bat,[bB][aA][tT]} text eol=crlf 5 | 6 | *.sh text eol=lf 7 | /bin/** text eol=lf -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: Release Asset Check 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | tagName: 7 | description: 'Tag Name to Process (leave empty for latest)' 8 | required: false 9 | default: '' 10 | release: 11 | types: [created, published] 12 | 13 | jobs: 14 | check-release: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout code 18 | uses: actions/checkout@v4 19 | 20 | - name: Install GitHub CLI 21 | run: | 22 | if ! command -v gh &> /dev/null 23 | then 24 | echo "GitHub CLI not found, installing..." 25 | sudo apt update 26 | sudo apt install -y gh 27 | else 28 | echo "GitHub CLI is already installed." 29 | fi 30 | gh --version 31 | 32 | - name: Determine the Tag Name 33 | id: get-tag-name 34 | env: 35 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | run: | 37 | if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.tagName }}" != "" ]]; then 38 | echo "Using manually provided tag name: ${{ github.event.inputs.tagName }}" 39 | echo "tag_name=${{ github.event.inputs.tagName }}" >> $GITHUB_ENV 40 | else 41 | echo "Determining the latest release tag..." 42 | release_info=$(gh release view --json tagName -q .tagName) 43 | echo "tag_name=$release_info" >> $GITHUB_ENV 44 | fi 45 | 46 | - name: Download the release asset 47 | env: 48 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 49 | run: | 50 | # Read the tag name from the environment variable 51 | asset_name="${{ env.tag_name }}.zip" 52 | echo "Looking for asset: $asset_name" 53 | 54 | # Ensure no stale asset file is present 55 | rm -f "$asset_name" 56 | 57 | # Use GitHub CLI to download the asset 58 | gh release download "${{ env.tag_name }}" \ 59 | --pattern "$asset_name" \ 60 | --dir . 61 | 62 | # List files to verify the correct asset is downloaded 63 | echo "Downloaded files:" 64 | ls -l 65 | 66 | - name: Extract the archive 67 | run: | 68 | asset_name="${{ env.tag_name }}.zip" 69 | unzip "$asset_name" -d extracted 70 | 71 | # List contents to ensure cache is not affecting the content 72 | echo "Contents of extracted directory:" 73 | ls -lR extracted/ 74 | 75 | - name: Check for the expected directory structure 76 | run: | 77 | # Expected root directory inside the extracted folder 78 | expected_dir="extracted/${{ env.tag_name }}" 79 | echo "Checking for directory: $expected_dir" 80 | 81 | # Check if the extracted root directory exists 82 | if [ ! -d "$expected_dir" ]; then 83 | echo "Directory $expected_dir does not exist." 84 | exit 1 85 | fi 86 | 87 | # Check for the 'include' directory with the 'boost' subdirectory 88 | if [ ! -d "$expected_dir/include/boost" ]; then 89 | echo "Directory $expected_dir/include/boost does not exist." 90 | exit 1 91 | fi 92 | 93 | # Check for the 'libs' directory with expected architecture subdirectories 94 | for arch in arm64-v8a armeabi-v7a x86 x86_64; do 95 | if [ ! -d "$expected_dir/libs/$arch" ]; then 96 | echo "Directory $expected_dir/libs/$arch does not exist." 97 | exit 1 98 | fi 99 | done 100 | 101 | echo "All specified directories exist." 102 | 103 | # extracted/{release_name} 104 | # include 105 | # boost/ 106 | # libs 107 | # arm64-v8a/ 108 | # armeabi-v7a/ 109 | # x86/ 110 | # x86_64/ 111 | 112 | 113 | 114 | # - name: Check for the specific file 115 | # run: | 116 | # # Update this path to the expected location of your file within the extracted directory 117 | # if [ -f "extracted/path/to/your/file" ]; then 118 | # echo "File exists." 119 | # else 120 | # echo "File does not exist." 121 | # exit 1 122 | # fi 123 | 124 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /build_ndk_*/ 3 | /build_ndk_15b_boost_1.64.0 4 | /build_out.txt 5 | /src/ 6 | /prebuilt/ 7 | /down/ 8 | 9 | /.gradle/ 10 | /boost/down/1.87.0 11 | /boost/down/1_87_0/ 12 | -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Declan Moran 4 | 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Build and/or simply download the Boost C++ Libraries for the Android platform, with Google's NDK. 3 | 4 | The [Boost C++ Libraries](http://www.boost.org/), are possibly *the* most popular and generally useful c++ libraries. It would be nice to be able to use them when developing (native c++ or hybrid java/c++ with Google's [NDK](https://developer.android.com/ndk/)) apps and/or libraries for Android devices. 5 | The Boost libraries are written to be cross platform, and are available in source code format. However, building the libraries for a given target platform like Android can be very difficult and time consuming. (In particular, building **arm64_v8a** shared libraries that an application can actually load). This project aims to lower the barrier by offering a simple customizable build script you can use to build Boost for Android (abstracting away all the details of the underlying custom boost build system, and target architecture differences), and even providing standard prebuilt binaries to get you started fast. 6 | 7 | Tested with **Boost 1.87.0** and **Google's NDK 27c** (LTS). 8 | 9 | You can build directly on a Linux or MacOS machine, or indirectly on any of Linux, Windows, MacOS via [docker](https://www.docker.com) (or of course virtual machines and wsl). _No matter what OS you use to build with, the resulting binaries can then be copied to any other, and used from then on as if you had built them there to start with (they're cross compiled *for* android and have no memory of *where* they were built_). 10 | 11 | 12 | Creates binaries (both shared and static) for multiple abis (**armeabi-v7a**, **arm64-v8a**, **x86**, **x86_64**). 13 | 14 | 15 | ## Prebuilt 16 | You can just download a current set of standard prebuilt binaries [here](https://github.com/dec1/Boost-for-Android/releases) if you don't need to customize the build, or don't have access to a suitable development machine. 17 | 18 | 19 | ## Build Yourself 20 | 21 | ### Build using Docker 22 | The easiest and most flexible way to build is to use [docker](./docker/docker_readme.md). 23 | This way you need not need to install any build tools or other prerequisites, and can use any host operating system you wish that has docker installed. 24 | 25 | 26 | ### Build directly on your Linux/WSL or MacOS machine 27 | 28 | - Prerequisites 29 | - Linux/WSL: see [Dockerflile](./docker/droid_base#L18) 30 | - MacOS: XCode ( Command Line Tools)) 31 | - NDK (eg in Android studio or downloaded separately) 32 | - Download the [boost source](https://www.boost.org) and [extract here](./boost/down/readme.md) 33 | - Boost doesn't always build out of the box, so you may need to patch the source code to make necessary fixes - see [patch](./boost/patch/readme.md) 34 | 35 | 36 | 37 | - Clone this repo: 38 | - `git clone https://github.com/dec1/Boost-for-Android.git` 39 | 40 | * Modify the paths (where the ndk is) and variables (which abis you want to build for) in _do.sh_ as you wish, and execute 41 | - `cd Boost-for-Android` 42 | - `./do.sh` 43 | 44 | If the build succeeded, then the boost binaries should now be in **`./build/install`** 45 | 46 | _Warning_: If you download the ndk directly do *not* extract it with [Ark](https://apps.kde.org/de/ark). It produces a corrupt extraction, that results in strange compiler errors. (use unzip instead) 47 | 48 | 49 | 50 | 51 | * *__Note__:* If for some reason the build fails you may want to manually clear the */tmp/ndk-your_username* dir (which gets cleared automatically after a successful build). 52 | 53 | 54 | 55 | ## Test App 56 | Also included is a [test app](./example_app/) which can be opened by Android Studio. If you build and run this app it should show the date and time as calculated by boost *chrono* (indicating that you have built, linked to and called the boost library correctly), as well as the ndk version used to build the boost library. 57 | To use the test app make sure to adjust the values in the [local.properties](./example_app/local.properties) file. 58 | 59 | *Note:* The test app uses [CMake for Android](https://developer.android.com/ndk/guides/cmake) and [Kotlin](https://developer.android.com/kotlin) 60 | 61 | 62 | ## *Header-only* Boost Libraries 63 | Many of the boost libraries (eg. *algorithm*) can be used as "header only" ie do not require compilation . So you may get away with not building boost if you only 64 | want to use these. To see which of the libraries do require building you can switch to the dir where you extracted the boost download and call: 65 | 66 | 67 | `./bootstrap.sh --show-libraries ` 68 | 69 | 70 | which for example with boost 1.87.0 produces the output: 71 | 72 | ``` 73 | The following Boost libraries have portions that require a separate build 74 | and installation step. Any library not listed here can be used by including 75 | the headers only. 76 | 77 | The Boost libraries requiring separate building and installation are: 78 | - contract 79 | - date_time 80 | - exception 81 | - graph 82 | - graph_parallel 83 | - headers 84 | - locale 85 | - log 86 | - nowide 87 | - program_options 88 | - regex 89 | - serialization 90 | - test 91 | - thread 92 | - type_erasure 93 | - winapi 94 | - wave 95 | - variant2 96 | - variant 97 | - uuid 98 | - url 99 | - unordered 100 | - type_index 101 | - tuple 102 | - timer 103 | - throw_exception 104 | - system 105 | - stl_interfaces 106 | - stacktrace 107 | - smart_ptr 108 | - signals2 109 | - scope 110 | - redis 111 | - ratio 112 | - random 113 | - python 114 | - process 115 | - predef 116 | - poly_collection 117 | - pfr 118 | - parameter 119 | - outcome 120 | - optional 121 | - mysql 122 | - multi_index 123 | - msm 124 | - mpi 125 | - mp11 126 | - move 127 | - math 128 | - lockfree 129 | - lexical_cast 130 | - lambda2 131 | - json 132 | - iterator 133 | - iostreams 134 | - intrusive 135 | - interprocess 136 | - integer 137 | - heap 138 | - hana 139 | - geometry 140 | - function_types 141 | - function 142 | - flyweight 143 | - filesystem 144 | - fiber 145 | - endian 146 | - dll 147 | - detail 148 | - describe 149 | - crc 150 | - coroutine2 151 | - coroutine 152 | - core 153 | - conversion 154 | - context 155 | - container_hash 156 | - container 157 | - compat 158 | - cobalt 159 | - chrono 160 | - charconv 161 | - bind 162 | - bimap 163 | - beast 164 | - atomic 165 | - assert 166 | - asio 167 | - any 168 | 169 | ``` 170 | 171 | 172 | ## Contributions 173 | - Many thanks to [crystax](https://github.com/crystax/android-platform-ndk/tree/master/build/tools) for their version of _build-boost.sh which I adapted to make it work with the google ndk. 174 | 175 | -------------------------------------------------------------------------------- /__build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # see here for info on "new paths for toolchains": 4 | # https://developer.android.com/ndk/guides/other_build_systems 5 | 6 | # also useful ndk details: 7 | # https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md 8 | 9 | SAVED_PATH=$PATH 10 | export PATH=$(pwd)/bin:$SAVED_PATH 11 | 12 | #---------------------------------------------------- 13 | 14 | 15 | BUILD_DIR=$(pwd)/build 16 | mkdir -p ${BUILD_DIR} 17 | 18 | 19 | BUILD_DIR_TMP=${BUILD_DIR}/tmp 20 | 21 | PREFIX_DIR=${BUILD_DIR}/install 22 | mkdir -p ${PREFIX_DIR} 23 | 24 | LIBS_DIR=${PREFIX_DIR}/libs 25 | INCLUDE_DIR=${PREFIX_DIR}/include 26 | 27 | WITHOUT_LIBRARIES="--without-python" 28 | WITHOUT_LIBRARIES+=" --without-process" # avoid: "libs/process/src/shell.cpp:23:10: fatal error: 'wordexp.h' file not found" 29 | # 'process' control very restriced in android sandboxes anyways 30 | 31 | # only build these libs 32 | # WITH_LIBRARIES="--with-chrono --with-system" 33 | 34 | #--------------------------------------------------- 35 | host_os_tag() { 36 | # are we building on linux or mac 37 | 38 | unameOut="$(uname -s)" 39 | case "${unameOut}" in 40 | Linux*) echo "linux-x86_64";; 41 | Darwin*) echo "darwin-x86_64";; 42 | *) echo "host_os_tag_unknown" 43 | esac 44 | 45 | } 46 | #------------------------------------- 47 | export HOST_OS_TAG=$(host_os_tag) 48 | 49 | #--------------------------------------------------- 50 | num_cpu_cores() { 51 | # are we building on linux or mac 52 | 53 | unameOut="$(uname -s)" 54 | case "${unameOut}" in 55 | Linux*) echo $(grep -c ^processor /proc/cpuinfo);; 56 | Darwin*) echo $(sysctl -n hw.ncpu);; 57 | *) echo "1" 58 | esac 59 | 60 | } 61 | #---------------------------------------------------------------------------------- 62 | # map abi to {NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/*-clang++ 63 | clang_triple_for_abi_name() { 64 | 65 | local abi_name=$1 66 | 67 | case "$abi_name" in 68 | arm64-v8a) echo "aarch64-linux-android21" 69 | ;; 70 | armeabi-v7a) echo "armv7a-linux-androideabi21" 71 | ;; 72 | x86) echo "i686-linux-android21" 73 | ;; 74 | x86_64) echo "x86_64-linux-android21" 75 | ;; 76 | 77 | esac 78 | 79 | } 80 | #---------------------------------------------------------------------------------- 81 | # map abi to {NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/*-ranlib etc 82 | tool_triple_for_abi_name() { 83 | 84 | local abi_name=$1 85 | 86 | case "$abi_name" in 87 | arm64-v8a) echo "aarch64-linux-android" 88 | ;; 89 | armeabi-v7a) echo "arm-linux-androideabi" 90 | ;; 91 | x86) echo "i686-linux-android" 92 | ;; 93 | x86_64) echo "x86_64-linux-android" 94 | ;; 95 | 96 | esac 97 | 98 | } 99 | #---------------------------------------------------------------------------------- 100 | abi_for_abi_name() { 101 | 102 | 103 | local abi_name=$1 104 | 105 | case "$abi_name" in 106 | arm64-v8a) echo "aapcs" 107 | ;; 108 | armeabi-v7a) echo "aapcs" 109 | ;; 110 | x86) echo "sysv" 111 | ;; 112 | x86_64) echo "sysv" 113 | ;; 114 | 115 | esac 116 | 117 | } 118 | #---------------------------------------------------------------------------------- 119 | arch_for_abi_name() { 120 | 121 | local abi_name=$1 122 | 123 | case "$abi_name" in 124 | arm64-v8a) echo "arm" 125 | ;; 126 | armeabi-v7a) echo "arm" 127 | ;; 128 | x86) echo "x86" 129 | ;; 130 | x86_64) echo "x86" 131 | ;; 132 | 133 | esac 134 | 135 | } 136 | 137 | #---------------------------------------------------------------------------------- 138 | address_model_for_abi_name() { 139 | 140 | local abi_name=$1 141 | 142 | case "$abi_name" in 143 | arm64-v8a) echo "64" 144 | ;; 145 | armeabi-v7a) echo "32" 146 | ;; 147 | x86) echo "32" 148 | ;; 149 | x86_64) echo "64" 150 | ;; 151 | 152 | esac 153 | 154 | } 155 | #---------------------------------------------- 156 | compiler_flags_for_abi_name() { 157 | 158 | local abi_name=$1 159 | 160 | COMMON_FLAGS="" #-fno-integrated-as -Wno-long-long" 161 | local ABI_FLAGS 162 | case "$abi_name" in 163 | armeabi-v7a) 164 | ABI_FLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp" 165 | ;; 166 | arm64-v8a|x86|x86_64) 167 | ;; 168 | *) 169 | echo "ERROR: Unknown ABI : $ABI" 1>&2 170 | exit 1 171 | esac 172 | 173 | echo "$COMMON_FLAGS $ABI_FLAGS" 174 | } 175 | #---------------------------------------------- 176 | linker_flags_for_abi_name() { 177 | 178 | local abi_name=$1 179 | 180 | COMMON_FLAGS="" 181 | local ABI_FLAGS 182 | case "$abi_name" in 183 | armeabi-v7a) 184 | ABI_FLAGS="-Wl,--fix-cortex-a8" 185 | ;; 186 | arm64-v8a|x86|x86_64) 187 | ;; 188 | *) 189 | echo "ERROR: Unknown ABI : $ABI" 1>&2 190 | exit 1 191 | esac 192 | 193 | echo "$COMMON_FLAGS $ABI_FLAGS" 194 | } 195 | 196 | #---------------------------------------------------------------------------------- 197 | #---------------------------------------------------------------------------------- 198 | persist_ndk_version() 199 | { 200 | # Define the path to the source properties file 201 | local source_properties="${NDK_DIR}/source.properties" 202 | 203 | # Read the file contents into a variable while stripping carriage returns 204 | local file_contents="$(cat "$source_properties" | tr -d '\r')" 205 | 206 | # Define the output directory and header file 207 | local dir_path="${PREFIX_DIR}/include/boost" 208 | mkdir -p "$dir_path" 209 | local headerFile="${dir_path}/version_ndk.hpp" 210 | 211 | # Check if source.properties file exists 212 | if [[ ! -f "$source_properties" ]]; then 213 | echo "Error: $source_properties does not exist!" 214 | return 1 215 | fi 216 | 217 | # echo "$source_properties contains:" 218 | # cat $source_properties 219 | # Read Pkg.ReleaseName (remove leading/trailing spaces, handle \r for carriage returns) 220 | local release_name="$(grep -m1 '^Pkg\.ReleaseName[[:space:]]*=' "$source_properties" \ 221 | | tr -d '\r' \ 222 | | cut -d= -f2 \ 223 | | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' 224 | )" 225 | 226 | 227 | # Read Pkg.BaseRevision (remove leading/trailing spaces, handle \r for carriage returns) 228 | local base_revision="$(grep -m1 '^Pkg\.BaseRevision[[:space:]]*=' "$source_properties" \ 229 | | tr -d '\r' \ 230 | | cut -d= -f2 \ 231 | | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' 232 | )" 233 | 234 | # Check if the variables are empty 235 | if [[ -z "$release_name" || -z "$base_revision" ]]; then 236 | echo "Error: Failed to read values from $source_properties" 237 | return 1 238 | fi 239 | 240 | # Concatenate ReleaseName and BaseRevision into ndk_ver 241 | local ndk_ver="${release_name} (${base_revision})" 242 | 243 | # Print the version to verify 244 | echo "NDK Version: $ndk_ver" 245 | 246 | # Write to the header file 247 | echo "writing NDK version $ndk_ver to $headerFile" 248 | 249 | # Create the header file with the NDK version information 250 | echo '#ifndef BOOST_VERSION_NDK_HPP' > "$headerFile" 251 | echo '#define BOOST_VERSION_NDK_HPP' >> "$headerFile" 252 | echo -e "\n// The version of the NDK used to build boost" >> "$headerFile" 253 | echo -e " #define BOOST_BUILT_WITH_NDK_VERSION \"$ndk_ver\" \\n" >> "$headerFile" 254 | echo '#endif' >> "$headerFile" 255 | } 256 | 257 | 258 | #---------------------------------------------------------------------------------- 259 | #---------------------------------------------------------------------------------- 260 | fix_version_suffices() { 261 | # 1) remove files that are symbolic links 262 | # 2) remove version suffix (remaining) in: 263 | # a) file names 264 | # b) "soname" of the elf header 265 | 266 | Re0="^libboost_(.*)\.so" 267 | Re1="(\.[[:digit:]]+){3}$" 268 | 269 | for DIR_NAME in $ABI_NAMES; do 270 | DIR_PATH="$LIBS_DIR/$DIR_NAME" 271 | FILE_NAMES=$(find "$DIR_PATH" -type f) 272 | 273 | # echo "$FILE_NAMES" 274 | # echo "" 275 | # echo "should delete:" 276 | # echo "--------------" 277 | for FILE_NAME in $FILE_NAMES; do 278 | File=$(echo "$FILE_NAME" | grep -Ev "${Re0}${Re1}") 279 | # echo "checking file " $File 280 | if [ ! -z "$File" ] && ! [[ $File == cmake* ]] && ! [[ $File == *.a ]]; then 281 | rm "$DIR_PATH/$File" 282 | fi 283 | done 284 | 285 | #echo "" 286 | #echo "should NOT delete:" 287 | for FILE_NAME in $FILE_NAMES; do 288 | File=$(echo "$FILE_NAME" | grep -E "${Re0}${Re1}") 289 | if [ ! -z "$File" ]; then 290 | NEW_NAME=$(echo "$FILE_NAME" | grep -Eo "^libboost_[^.]+\.so") 291 | # echo $File " ->" $NEW_NAME 292 | mv "$DIR_PATH/$File" "$DIR_PATH/$NEW_NAME" 293 | # patchelf --set-soname $NEW_NAME $DIR_PATH/$NEW_NAME 294 | fi 295 | done 296 | done 297 | } 298 | #---------------------------------------------------------------------------------- 299 | #---------------------------------------------------------------------------------- 300 | #---------------------------------------------------------------------------------- 301 | do_build() 302 | { 303 | 304 | USER_CONFIG_FILE=$(pwd)/user-config.jam 305 | 306 | cd $BOOST_DIR 307 | 308 | #------------------------------------------- 309 | # Bootstrap 310 | # --------- 311 | if [ ! -f ${BOOST_DIR}/b2 ] 312 | then 313 | echo "Performing boost bootstrap" 314 | 315 | ./bootstrap.sh # 2>&1 | tee -a bootstrap.log 316 | fi 317 | 318 | #------------------------------------------- 319 | 320 | # use as many cores as available (for build) 321 | num_cores=$(num_cpu_cores) 322 | echo " cores available = " $num_cores 323 | 324 | 325 | 326 | #------------------------------------------- 327 | for LINKAGE in $LINKAGES; do 328 | 329 | for ABI_NAME in $ABI_NAMES; do 330 | 331 | 332 | #------------------- 333 | LOG_FILE=${BUILD_DIR}/build_${ABI_NAME}_${LINKAGE}.log 334 | # clear any existing 335 | if [ -f "$LOG_FILE" ] 336 | then 337 | rm "$LOG_FILE" 338 | fi 339 | 340 | # ------------------ 341 | ABI_SPECIFIC_FLAGS="" 342 | if [ "$ABI_NAME" = "x86" ]; then 343 | # avoid possible memory leaks on x86 344 | ABI_SPECIFIC_FLAGS+=" boost.stacktrace.from_exception=off" 345 | fi 346 | 347 | # ------------------ 348 | 349 | # toolset_name="$(toolset_for_abi_name $ABI_NAME)" 350 | abi="$(abi_for_abi_name $ABI_NAME)" 351 | address_model="$(address_model_for_abi_name $ABI_NAME)" 352 | arch_for_abi="$(arch_for_abi_name $ABI_NAME)" 353 | 354 | # used by scripts in ./bin/ 355 | export BFA_CLANG_TRIPLE_FOR_ABI="$(clang_triple_for_abi_name $ABI_NAME)" 356 | export BFA_TOOL_TRIPLE_FOR_ABI="$(tool_triple_for_abi_name $ABI_NAME)" 357 | export BFA_COMPILER_FLAGS_FOR_ABI="$(compiler_flags_for_abi_name $ABI_NAME)" 358 | export BFA_LINKER_FLAGS_FOR_ABI="$(linker_flags_for_abi_name $ABI_NAME)" 359 | 360 | echo "------------------------------------------------------------"| tee -a ${LOG_FILE} 361 | echo "Building boost for: $ABI_NAME $LINKAGE on host ${HOST_OS_TAG}" | tee -a ${LOG_FILE} 362 | 363 | # echo "address-model=$address_model " | tee -a ${LOG_FILE} 364 | # echo "architecture=$arch_for_abi " | tee -a ${LOG_FILE} 365 | # echo "abi=$abi " | tee -a ${LOG_FILE} 366 | # echo "link=$LINKAGE " | tee -a ${LOG_FILE} 367 | # echo "--user-config=$USER_CONFIG_FILE" | tee -a ${LOG_FILE} 368 | 369 | # echo "WITH_LIBRARIES = $WITH_LIBRARIES" | tee -a ${LOG_FILE} 370 | # echo "WITHOUT_LIBRARIES = $WITHOUT_LIBRARIES" | tee -a ${LOG_FILE} 371 | # echo "ABI_SPECIFIC_FLAGS = $ABI_SPECIFIC_FLAGS" | tee -a ${LOG_FILE} 372 | 373 | # echo "--builddir=${BUILD_DIR_TMP}/$ABI_NAME " | tee -a ${LOG_FILE} 374 | # echo "--includedir=${INCLUDE_DIR}" | tee -a ${LOG_FILE} 375 | # echo "--libdir=${LIBS_DIR}/$ABI_NAME" | tee -a ${LOG_FILE} 376 | 377 | 378 | # echo "BFA_CLANG_TRIPLE_FOR_ABI=$(clang_triple_for_abi_name $ABI_NAME)" | tee -a ${LOG_FILE} 379 | # echo "BFA_TOOL_TRIPLE_FOR_ABI=$(tool_triple_for_abi_name $ABI_NAME)" | tee -a ${LOG_FILE} 380 | # echo "BFA_COMPILER_FLAGS_FOR_ABI=$(compiler_flags_for_abi_name $ABI_NAME)" | tee -a ${LOG_FILE} 381 | # echo "BFA_LINKER_FLAGS_FOR_ABI=$(linker_flags_for_abi_name $ABI_NAME)" | tee -a ${LOG_FILE} 382 | 383 | echo "------------------------------------------------------------"| tee -a ${LOG_FILE} 384 | # toolset=clang-$toolset_name \ 385 | 386 | { 387 | ./b2 -q -j$num_cores \ 388 | binary-format=elf \ 389 | address-model=$address_model \ 390 | architecture=$arch_for_abi \ 391 | abi=$abi \ 392 | link=$LINKAGE \ 393 | threading=multi \ 394 | target-os=android \ 395 | --user-config=$USER_CONFIG_FILE \ 396 | --ignore-site-config \ 397 | --layout=system \ 398 | $WITH_LIBRARIES \ 399 | $WITHOUT_LIBRARIES \ 400 | $ABI_SPECIFIC_FLAGS \ 401 | --build-dir=${BUILD_DIR_TMP}/$ABI_NAME/$LINKAGE \ 402 | --includedir=${INCLUDE_DIR} \ 403 | --libdir=${LIBS_DIR}/$ABI_NAME/$LINKAGE \ 404 | install 2>&1 \ 405 | || { echo "Error: Failed to build boost for $ABI_NAME!";} 406 | } | tee -a ${LOG_FILE} 407 | 408 | done # for ABI_NAME in $ABI_NAMES 409 | 410 | done # for LINKAGE in $LINKAGES 411 | } 412 | #------------------------------------------- 413 | 414 | # do_build 415 | 416 | persist_ndk_version 417 | 418 | # fix_version_suffices 419 | 420 | echo "built boost to " ${PREFIX_DIR} 421 | 422 | 423 | export PATH=$SAVED_PATH 424 | 425 | 426 | 427 | -------------------------------------------------------------------------------- /bin/ar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #echo "in ar....${BFA_TOOL_TRIPLE_FOR_ABI}" 4 | #exec ${NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/${BFA_TOOL_TRIPLE_FOR_ABI}-ar "$@" 5 | exec ${NDK_DIR}/toolchains/llvm/prebuilt/${HOST_OS_TAG}/bin/llvm-ar "$@" 6 | 7 | -------------------------------------------------------------------------------- /bin/base_clang++: -------------------------------------------------------------------------------- 1 | 2 | 3 | if echo "$@" | tr ' ' '\n' | grep -q -x -e -c; then 4 | LINKER=no 5 | elif echo "$@" | tr ' ' '\n' | grep -q -x -e -emit-pth; then 6 | LINKER=no 7 | else 8 | LINKER=yes 9 | fi 10 | 11 | #echo " .... LINKER = " $LINKER 12 | 13 | # Remove any -m32/-m64 from input parameters 14 | PARAMS=`echo "$@" | tr ' ' '\n' | grep -v -x -e -m32 | grep -v -x -e -m64 | tr '\n' ' '` 15 | 16 | 17 | 18 | #echo " .... PARMS (1) = " $PARAMS 19 | 20 | if [ "x$LINKER" = "xyes" ]; then 21 | # Fix SONAME for shared libraries 22 | NPARAMS="" 23 | NEXT_PARAM_IS_LIBNAME=no 24 | for p in $PARAMS; do 25 | if [ "x$NEXT_PARAM_IS_LIBNAME" = "xyes" ]; then 26 | LIBNAME=`expr "x$p" : "^x.*\(lib[^\.]*\.so\)"` 27 | p="-Wl,$LIBNAME" 28 | NEXT_PARAM_IS_LIBNAME=no 29 | else 30 | case $p in 31 | -Wl,-soname|-Wl,-h|-install_name) 32 | p="-Wl,-soname" 33 | NEXT_PARAM_IS_LIBNAME=yes 34 | ;; 35 | -Wl,-soname,lib*|-Wl,-h,lib*) 36 | LIBNAME=`expr "x$p" : "^x.*\(lib[^\.]*\.so\)"` 37 | p="-Wl,-soname,-l$LIBNAME" 38 | ;; 39 | -dynamiclib) 40 | p="-shared" 41 | ;; 42 | -undefined) 43 | p="-u" 44 | ;; 45 | -single_module) 46 | p="" 47 | ;; 48 | -lpthread|-lutil) 49 | p="" 50 | ;; 51 | esac 52 | fi 53 | NPARAMS="$NPARAMS $p" 54 | done 55 | PARAMS=$NPARAMS 56 | fi 57 | 58 | #echo " .... PARMS (2) = " $PARAMS 59 | 60 | # FLAGS=" -fno-integrated-as -fPIC" 61 | FLAGS=" -fPIC" 62 | if [ "x$LINKER" = "xyes" ]; then 63 | FLAGS="$FLAGS $BFA_LINKER_FLAGS_FOR_ABI" 64 | else 65 | FLAGS="$FLAGS $BFA_COMPILER_FLAGS_FOR_ABI -Wno-long-long" 66 | 67 | fi 68 | 69 | #echo " .... FLAGS = " $PARAMS 70 | 71 | PARAMS="$FLAGS $PARAMS" 72 | 73 | #echo " .... PARMS (3) = " $PARAMS 74 | 75 | run() 76 | { 77 | exec "$@" 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /bin/clang++: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | 5 | # include common base 6 | . `dirname $0`/base_clang++ 7 | 8 | #echo "pwd = $(pwd)" 9 | #echo "---------" 10 | #echo " .... calling clang: ${NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/${BFA_CLANG_TRIPLE_FOR_ABI}-clang++" 11 | #echo "---------" 12 | #echo ".... with PARAMS: $PARAMS" 13 | #echo "---------" 14 | 15 | run ${NDK_DIR}/toolchains/llvm/prebuilt/${HOST_OS_TAG}/bin/${BFA_CLANG_TRIPLE_FOR_ABI}-clang++ $PARAMS 16 | -------------------------------------------------------------------------------- /bin/hide/as: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "in as....${BFA_TOOL_TRIPLE_FOR_ABI}" 4 | exec ${NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/${BFA_TOOL_TRIPLE_FOR_ABI}-as "$@" 5 | echo "out as...." 6 | -------------------------------------------------------------------------------- /bin/hide/strip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "in strip....${BFA_TOOL_TRIPLE_FOR_ABI}" 4 | exec ${NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/${BFA_TOOL_TRIPLE_FOR_ABI}-strip "$@" 5 | 6 | -------------------------------------------------------------------------------- /bin/ranlib: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #echo "in ranlib ....${BFA_TOOL_TRIPLE_FOR_ABI}" 4 | #exec ${NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/${BFA_TOOL_TRIPLE_FOR_ABI}-ranlib "$@" 5 | exec ${NDK_DIR}/toolchains/llvm/prebuilt/${HOST_OS_TAG}/bin/llvm-ranlib "$@" 6 | 7 | -------------------------------------------------------------------------------- /boost/down/readme.md: -------------------------------------------------------------------------------- 1 | - [download](https://www.boost.org/users/download/) boost source code 2 | - Extract the archive into a subdir of this dir 3 | 4 | - You should then have something like: 5 | 6 | ```shell 7 | readme.md # ie this file 8 | boost_1_87_0/ # where the exact name of this dir reflects the version of boost you downloaded 9 | boostcpp.jam 10 | bootstrap.bat 11 | bootstrap.sh 12 | index.htm 13 | index.html 14 | ...... 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /boost/patch/1.87.0.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | replace: **`@`** with **`%`** 4 | in lines: 5 | `".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"` 6 | 7 | in the header files 8 | - [json](https://github.com/boostorg/json/pull/1064) 9 | - `include/boost/json/detail/gdb_printers.hpp` 10 | 11 | - [outcome](https://github.com/ned14/outcome/commit/83e5127dd20b15e3f59059e5862e9926283fee80#diff-670473b673eaa1bb860cf62ebc28f917731c53ad616bea0372e263ac91a8b0ab) 12 | - `boost/outcome/outcome_gdb.h` 13 | - `boost/outcome/experimental/status-code/status_code.hpp` 14 | 15 | - [unordered](https://github.com/boostorg/unordered/pull/295) 16 | - `boost/unordered/unordered_printers.hpp` 17 | 18 | - [interprocess](https://github.com/boostorg/interprocess/pull/246) 19 | - `boost/interprocess/interprocess_printers.hpp` 20 | 21 | 22 | to avoid build errors like 23 | 24 | ```yaml 25 | inline asm>:1:41: error: expected '%' or "" 26 | 1 | .pushsection ".debug_gdb_scripts", "MS",@progbits,1 27 | ``` 28 | 29 | ----- 30 | see also: 31 | 32 | [pushsection idiom for GDB scripts not supported by integrated as and llvm-mc for arm targets](https://github.com/llvm/llvm-project/issues/120871) 33 | -------------------------------------------------------------------------------- /boost/patch/readme.md: -------------------------------------------------------------------------------- 1 | Boost doesn't always build out of the box, so you may need to edit the boost source code after downloading, to make necessary fixes. 2 | This dir lists fixes I needed to make for specific boost versions. -------------------------------------------------------------------------------- /do.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #---------------------------------------------------------------- 4 | # Modify the variables below as appropriate for your local setup. 5 | #---------------------------------------------------------------- 6 | 7 | # Specify the path to boost (unzipped) source code dir 8 | export BOOST_DIR=$(pwd)/boost/down/1.87.0 9 | 10 | 11 | # Where the Android Ndk you want to build with is located 12 | export NDK_DIR=~/Library/Android/sdk/ndk/27.2.12479018 13 | 14 | # Which target abis (~ architecture + instruction set) you want to build for (separate by spaces) 15 | export ABI_NAMES="arm64-v8a armeabi-v7a x86 x86_64" 16 | # export ABI_NAMES="arm64-v8a" 17 | 18 | # Whether to build boost as dynamic or shared libraries (or both) 19 | export LINKAGES="shared static" # can be "shared" or "static" or "shared static" (both) 20 | #export LINKAGES="shared" # can be "shared" or "static" or "shared static" (both) 21 | 22 | #---------------------------------------------------------------- 23 | 24 | ./__build.sh 25 | 26 | -------------------------------------------------------------------------------- /docker/docker_readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Docker 4 | 5 | The easiest and most flexible way to build is to use [docker](https://www.docker.com). 6 | This way you need not need to install any build tools or other prerequisites, and can use any host operating system you wish that has docker installed. 7 | You only need to download and extract the two archives: [boost sources](https://www.boost.org) and [android ndk](https://developer.android.com/ndk) to your host machine. 8 | 9 | 10 | 11 | ## (1) Clone this repo: 12 | 13 | `> git clone https://github.com/dec1/Boost-for-Android.git ./boost_for_android` 14 | 15 | `> cd boost_for_android` 16 | 17 | ## (2) Download boost and ndk 18 | 19 | And extract then to the sub dir *down* (eg to *down/boost/1.71.1/bootstrap.sh...* and *down/ndk/20/source.properties....* etc). 20 | 21 | If necessary, modify the variables in *./do.sh*, to match these paths (and/or required build configuration). 22 | 23 | If necessary, fix any bugs in boost (eg for [1.71.0](https://github.com/boostorg/build/issues/385)). 24 | 25 | 26 | ## (3) Build docker image 27 | 28 | build docker image *my_img_droid_base* from the docker file *droid_base* (using the *docker* dir as the *build context*) 29 | 30 | `> docker build -t my_img_droid_base -f docker/droid_base ./docker` 31 | 32 | 33 | ## (4) Run docker container 34 | 35 | Run a docker container *my_ctr_droid_base* from this image, mounting the current dir as */home/bfa* 36 | 37 | If you have downloaded boost and ndk as suggested to this (host) dir then they will automatically be available in the */home/bfa/down* dir of the container too. 38 | (Otherwise you need to mount the respective paths additionally). 39 | 40 | _Note_: 41 | * Need to pass absolute host paths to mount volume hence _$(pwd)_. 42 | * We want the container to run with the same user id as you have on your host and not as root (the default). Hence the *$(id -u):$(id -g)* 43 | 44 | `> docker run -v $(pwd):/home/bfa -it --entrypoint=/bin/bash --user $(id -u):$(id -g) --workdir /home/bfa --name my_ctr_droid_base my_img_droid_base` 45 | 46 | If a container with this name already exists you must delete it first with 47 | 48 | `> docker rm my_ctr_droid_base` 49 | 50 | 51 | ## (5) Build boost inside docker container 52 | 53 | Now inside docker container, build boost. 54 | 55 | `$./do.sh` 56 | 57 | 58 | ## (6) Exit container 59 | Boost should be built in the dir */build/install* (by default) 60 | 61 | `$ exit` 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /docker/droid_base: -------------------------------------------------------------------------------- 1 | # Version: 1.4 2 | 3 | # Dockerfile with all tools, libraries and sources for building boost for android, interactively 4 | # https://github.com/dec1/Boost-for-Android 5 | 6 | 7 | # Author: Declan Moran 8 | 9 | 10 | 11 | 12 | 13 | 14 | FROM amd64/ubuntu:22.04 15 | #---------------------- 16 | 17 | 18 | # Install Prerequsiites 19 | # --------------------- 20 | RUN apt-get update 21 | RUN apt-get -y dist-upgrade 22 | 23 | 24 | # for downloading archives 25 | RUN apt-get -y install wget 26 | 27 | # for unzipping downloaded android archives 28 | RUN apt-get -y install zip 29 | 30 | RUN apt-get -y install openjdk-17-jdk 31 | RUN apt-get -y install lib32z1 32 | 33 | 34 | # need this this to install some (32 bit) prerequisites for android builds 35 | RUN dpkg --add-architecture i386 36 | RUN apt-get update 37 | RUN apt-get -y dist-upgrade 38 | RUN apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 libbz2-1.0:i386 39 | 40 | 41 | # need c compiler to set up create boost build system (before building boost with it and android toolchain) 42 | RUN apt-get -y install build-essential 43 | RUN apt-get -y install libc6-dev-i386 44 | RUN apt-get -y install clang 45 | 46 | # need this to change soname of boost libraries 47 | RUN apt-get install patchelf 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /docker/droid_full_auto: -------------------------------------------------------------------------------- 1 | # Version: 1.4 2 | 3 | # Dockerfile with all tools, libraries and sources for building boost for android, automatically. 4 | 5 | # NOT recommended as some things used here change often. 6 | # Prefer droid_base instead 7 | 8 | 9 | 10 | # https://github.com/dec1/Boost-for-Android 11 | # creates docker container 12 | 13 | # Author: Declan Moran 14 | 15 | 16 | # Usage: 17 | #------ 18 | # > git clone https://github.com/dec1/boost-for-android 19 | # > cd boost-for-android 20 | # 21 | 22 | # (1) Build Image 23 | #----------------- 24 | # build docker image "my_img_droid" from the dockerfile in "docker" dir 25 | # > docker build -t my_img_droid ./docker 26 | 27 | # Build arguemnts 28 | # ----------------- 29 | # override any default build arguments (ARGs) by passing via "-build-arg key=val" 30 | # eg 31 | # 32 | 33 | 34 | # Proxy (of host) 35 | # ----- 36 | # > docker build \ 37 | # --build-arg PROXY_HTTP_HOST=10.110.15.6 \ 38 | # --build-arg PROXY_HTTP_PORT=8080 \ 39 | # --build-arg PROXY_HTTPS_HOST=10.110.15.6 \ 40 | # --build-arg PROXY_HTTPS_PORT=8080 \ 41 | # -t my_img_droid ./docker 42 | 43 | 44 | # Note : In order for docker to access network when host is behind a proxy ~/.docker/config.json should contain the relevant proxy settings. eg 45 | # 46 | # {.... 47 | # "proxies": { 48 | # "default": { 49 | # "httpProxy": "http://10.110.15.6:8080", 50 | # "httpsProxy": "https://10.110.15.6:8080", 51 | # "noProxy": "localhost,127.0.0.1" 52 | # } 53 | # } 54 | # } 55 | 56 | # Sdk version (onyl needed to build sample app in docker) 57 | # the file path for the sdk tools download (from eg https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip) 58 | # --build-arg SDK_FILE=sdk-tools-linux-4333796.zip 59 | 60 | 61 | # the sdk plaform to use - should match that used in example_app (app/build.gradle) 62 | # https://developer.android.com/guide/topics/manifest/uses-sdk-element 63 | # --build-arg ANDROID_SDK_PLATFORM_VERS="platforms;android-28" 64 | 65 | 66 | # (3) Download boost src and ndk to current dir (so can share with docker container .. see below) 67 | #------------------------------- 68 | # eg 69 | # ./down/boost_src/1.69.0 70 | # ./down/ndk/19c 71 | 72 | # (2) Run Container 73 | #------------------- 74 | # run docker container "my_ctr_droid" from this image, mounting the current dir as /home/bfa (thus also boost src and ndk), 75 | # (Need to pass absolute host paths to mount volume- hence "pwd") 76 | # 77 | # > docker run -v $(pwd):/home/bfa -it --entrypoint=/bin/bash --name my_ctr_droid my_img_droid 78 | 79 | 80 | 81 | # (3) Build boost and app inside container 82 | # ---------------------------------------- 83 | # Now inside docker container 84 | # $ cd /home/bfa 85 | # 86 | # Modify ./do_docker.sh (on host), to match the boost and android ndk versions/paths in the "Configure here" section below 87 | # Build boost from running docker container. 88 | # $./do_docker.sh 89 | # 90 | 91 | 92 | # Exit container, when build is finsihed, 93 | # $ exit 94 | # 95 | # "./build" dir contains required build, but owned by root. chown to your username/group 96 | # > sudo chown -R : ./build 97 | # > sudo chown -R : ./build_tmp 98 | # 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | FROM amd64/ubuntu:18.04 107 | 108 | 109 | ## -------------------------------------------------------------------- 110 | ## Configure here 111 | # --------------------------------------------------------------------- 112 | # --------------------------------------------------------------------- 113 | # Here you can speciofy exactly what boost, android ndk (and sdk) version you want to use. 114 | 115 | 116 | # (1) Boost Src 117 | ARG BOOST_SRC_DIR=Boost-For-Android/boost_src/1.69.0 118 | 119 | 120 | # (2) Android Ndk 121 | ARG NDK_DIR=/home/android/ndk 122 | 123 | 124 | # (3) Proxy 125 | # --------- 126 | # Any proxy settings (necessary if host is behind a proxy) for sdk_manager and gradle. 127 | # Note : Aditionally ~/.docker/config.json on host must have relevant proxy settings, for a containre to access network 128 | 129 | ARG PROXY_HTTP_HOST="" 130 | ARG PROXY_HTTP_PORT="" 131 | ARG PROXY_HTTPS_HOST="" 132 | ARG PROXY_HTTPS_PORT="" 133 | 134 | 135 | #-------------------------------------------------- 136 | # Sdk 137 | 138 | ARG ANDROID_SDK_PLATFORM_VERS="platforms;android-28" 139 | 140 | # base path for sdk 141 | ARG ANDROID_HOME=/home/android 142 | 143 | # https://developer.android.com/studio#downloads 144 | ARG SDK_URL_BASE=https://dl.google.com/android/repository 145 | ARG SDK_FILE=sdk-tools-linux-4333796.zip 146 | # sdk will be instalkled to $ANDROID_HOME 147 | 148 | 149 | # --------------------------------------------------------------------- 150 | # -------------------------------------------------------------------- 151 | 152 | RUN apt-get update 153 | RUN apt-get -y dist-upgrade 154 | 155 | 156 | # for downloading archives 157 | RUN apt-get -y install wget 158 | 159 | # for unzipping downloaded android archives 160 | RUN apt-get -y install zip 161 | 162 | RUN apt-get -y install openjdk-8-jdk 163 | RUN apt-get -y install lib32z1 164 | 165 | 166 | # need this this to install some (32 bit) prerequisites for android builds 167 | RUN dpkg --add-architecture i386 168 | RUN apt-get update 169 | RUN apt-get -y dist-upgrade 170 | RUN apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 libbz2-1.0:i386 171 | 172 | 173 | # need c compiler to set up create boost build system (before building boost with it and android toolchain) 174 | RUN apt-get -y install build-essential 175 | RUN apt-get -y install libc6-dev-i386 176 | RUN apt-get -y install clang 177 | 178 | 179 | #-------------------------------------- 180 | 181 | 182 | WORKDIR ${ANDROID_HOME} 183 | 184 | 185 | # SDK 186 | # ---- 187 | # download android sdk command line tools 188 | RUN wget ${SDK_URL_BASE}/$SDK_FILE 189 | RUN unzip $SDK_FILE 190 | 191 | ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools 192 | 193 | 194 | # RUN yes | sdkmanager ${PROXY_CONFIG_STR} --licenses 195 | 196 | RUN if [ ! -z "$PROXY_HTTP_HOST" ] ;\ 197 | then PROXY_CONFIG_STR="--proxy=http --proxy_host="$PROXY_HTTP_HOST" --proxy_port="$PROXY_HTTP_PORT ;\ 198 | else PROXY_CONFIG_STR="" ;\ 199 | fi ;\ 200 | \ 201 | yes | sdkmanager ${PROXY_CONFIG_STR} $ANDROID_SDK_PLATFORM_VERS 202 | 203 | 204 | 205 | 206 | # ------------------------------------------- 207 | # enable gradle to get through proxy (when building example_app) 208 | 209 | 210 | 211 | # Gradle needs to know how to deal with any proxy 212 | RUN if [ ! -z "$PROXY_HTTP_HOST" ] ;\ 213 | then echo "systemProp.http.proxyHost="$PROXY_HTTP_HOST >> ~/gradle.properties ;\ 214 | fi 215 | 216 | RUN if [ ! -z "$PROXY_HTTP_PORT" ] ;\ 217 | then echo "systemProp.http.proxyPort="$PROXY_HTTP_PORT >> ~/gradle.properties ;\ 218 | fi 219 | 220 | 221 | RUN if [ ! -z "$PROXY_HTTPS_HOST" ] ;\ 222 | then echo "systemProp.https.proxyHost="$PROXY_HTTPS_HOST >> ~/gradle.properties ;\ 223 | fi 224 | 225 | RUN if [ ! -z "$PROXY_HTTPS_PORT" ] ;\ 226 | then echo "systemProp.https.proxyPort="$PROXY_HTTPS_PORT >> ~/gradle.properties ;\ 227 | fi 228 | 229 | 230 | 231 | 232 | -------------------------------------------------------------------------------- /example_app/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /example_app/.idea/.name: -------------------------------------------------------------------------------- 1 | boost_test -------------------------------------------------------------------------------- /example_app/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example_app/.idea/deploymentTargetSelector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example_app/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /example_app/.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /example_app/.idea/migrations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /example_app/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | -------------------------------------------------------------------------------- /example_app/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | -------------------------------------------------------------------------------- /example_app/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example_app/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /example_app/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import java.util.Properties 2 | 3 | // Load the local.properties file 4 | val localPropertiesFile = rootProject.file("local.properties") 5 | println("Path to local.properties: ${localPropertiesFile.absolutePath}") 6 | val localProps = Properties() 7 | localPropertiesFile.inputStream().use { localProps.load(it) } 8 | 9 | val my_boost_dir = localProps.getProperty("boost.dir") 10 | val my_boost_dir_libs = "$my_boost_dir/libs" 11 | val my_boost_dir_inc = "$my_boost_dir/include" 12 | 13 | println("boost.dir: $my_boost_dir") 14 | println("my_boost_dir_libs: $my_boost_dir_libs") 15 | println("my_boost_dir_inc: $my_boost_dir_inc") 16 | 17 | //---------- 18 | 19 | 20 | plugins { 21 | alias(libs.plugins.android.application) 22 | alias(libs.plugins.kotlin.android) 23 | } 24 | 25 | android { 26 | namespace = "com.example.boost_test" 27 | compileSdk = 34 28 | 29 | defaultConfig { 30 | applicationId = "com.example.boost_test" 31 | minSdk = 24 32 | targetSdk = 34 33 | versionCode = 1 34 | versionName = "1.0" 35 | 36 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 37 | 38 | externalNativeBuild { 39 | cmake { 40 | // flags for the c++ compiler eg "-std=c++14 -frtti -fexceptions" 41 | // If you set cppFlags to "-std=c++14", you may need to build your boost libraries 42 | // with the same flags, depending on your compiler defaults. 43 | // cppFlags "-std=c++14" 44 | 45 | // This causes libc++_shared.so to get packaged into the APK 46 | arguments += "-DANDROID_STL=c++_shared" 47 | 48 | // This is used in CMakeLists.txt so our native code can find/use (prebuilt) boost 49 | arguments += "-DMY_BOOST_LIBS_DIR=${my_boost_dir_libs}" 50 | arguments += "-DMY_BOOST_INC_DIR=${my_boost_dir_inc}" 51 | 52 | } 53 | } 54 | 55 | ndk { 56 | // Specifies the ABI configurations of your native 57 | // libraries Gradle should build and package with your APK. 58 | // need to also have ~ boost binaries built for each abi specified here 59 | abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64") 60 | } 61 | } 62 | 63 | buildTypes { 64 | release { 65 | isMinifyEnabled = false 66 | proguardFiles( 67 | getDefaultProguardFile("proguard-android-optimize.txt"), 68 | "proguard-rules.pro" 69 | ) 70 | } 71 | } 72 | compileOptions { 73 | sourceCompatibility = JavaVersion.VERSION_11 74 | targetCompatibility = JavaVersion.VERSION_11 75 | } 76 | kotlinOptions { 77 | jvmTarget = "11" 78 | } 79 | externalNativeBuild { 80 | cmake { 81 | path = file("src/main/cpp/CMakeLists.txt") 82 | version = "3.22.1" 83 | } 84 | } 85 | buildFeatures { 86 | viewBinding = true 87 | } 88 | } 89 | 90 | dependencies { 91 | 92 | implementation(libs.androidx.core.ktx) 93 | implementation(libs.androidx.appcompat) 94 | implementation(libs.material) 95 | implementation(libs.androidx.constraintlayout) 96 | testImplementation(libs.junit) 97 | androidTestImplementation(libs.androidx.junit) 98 | androidTestImplementation(libs.androidx.espresso.core) 99 | } 100 | 101 | -------------------------------------------------------------------------------- /example_app/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /example_app/app/src/androidTest/java/com/example/boost_test/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.boost_test 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.example.boost_test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /example_app/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /example_app/app/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about using CMake with Android Studio, read the 2 | # documentation: https://d.android.com/studio/projects/add-native-code.html. 3 | # For more examples on how to use CMake, see https://github.com/android/ndk-samples. 4 | 5 | # Sets the minimum CMake version required for this project. 6 | cmake_minimum_required(VERSION 3.22.1) 7 | 8 | # Declares the project name. The project name can be accessed via ${ PROJECT_NAME}, 9 | # Since this is the top level CMakeLists.txt, the project name is also accessible 10 | # with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level 11 | # build script scope). 12 | project("boost_test") 13 | 14 | # Creates and names a library, sets it as either STATIC 15 | # or SHARED, and provides the relative paths to its source code. 16 | # You can define multiple libraries, and CMake builds them for you. 17 | # Gradle automatically packages shared libraries with your APK. 18 | # 19 | # In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define 20 | # the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME} 21 | # is preferred for the same purpose. 22 | # 23 | # In order to load a library into your app from Java/Kotlin, you must call 24 | # System.loadLibrary() and pass the name of the library defined here; 25 | # for GameActivity/NativeActivity derived applications, the same library name must be 26 | # used in the AndroidManifest.xml file. 27 | add_library(${CMAKE_PROJECT_NAME} SHARED 28 | # List C/C++ source files with relative paths to this CMakeLists.txt. 29 | native-lib.cpp) 30 | 31 | # Specifies libraries CMake should link to your target library. You 32 | # can link libraries from various origins, such as libraries defined in this 33 | # build script, prebuilt third-party libraries, or Android system libraries. 34 | target_link_libraries(${CMAKE_PROJECT_NAME} 35 | # List libraries link to the target library 36 | android 37 | log 38 | 39 | boost_system 40 | boost_chrono 41 | ) 42 | 43 | 44 | #----------------------------------------- 45 | add_library (boost_system SHARED IMPORTED) 46 | 47 | set_target_properties( boost_system PROPERTIES IMPORTED_LOCATION 48 | ${MY_BOOST_LIBS_DIR}/${ANDROID_ABI}/shared/libboost_system.so 49 | ) 50 | #----------------------------------------- 51 | add_library( boost_chrono SHARED IMPORTED) 52 | 53 | set_target_properties(boost_chrono PROPERTIES IMPORTED_LOCATION 54 | ${MY_BOOST_LIBS_DIR}/${ANDROID_ABI}/shared/libboost_chrono.so 55 | ) 56 | #----------------------------------------- 57 | 58 | include_directories( ${MY_BOOST_INC_DIR} 59 | ) 60 | 61 | #----------------------------------------- 62 | find_library (log-lib log) 63 | 64 | #----------------------------------------- 65 | -------------------------------------------------------------------------------- /example_app/app/src/main/cpp/native-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | // when building boost we persisted the NDK version used (BOOST_BUILT_WITH_NDK_VERSION) in this custom header file 8 | #include 9 | using std::string; 10 | 11 | 12 | extern "C" JNIEXPORT jstring JNICALL 13 | Java_com_example_boost_1test_MainActivity_stringFromJNI( 14 | JNIEnv* env, 15 | jobject /* this */) { 16 | 17 | string Str = "Hello from C++\n"; 18 | //------------------------------------- 19 | boost::chrono::system_clock::time_point p = boost::chrono::system_clock::now(); 20 | std::time_t t = boost::chrono::system_clock::to_time_t(p); 21 | 22 | char buffer[26]; 23 | ctime_r(&t, buffer); 24 | 25 | // std::string tst = std::to_string(3); 26 | 27 | int ver = BOOST_VERSION; 28 | int ver_maj = ver/100000; 29 | int ver_min = ver / 100 %1000; 30 | int ver_pat = ver %100; 31 | 32 | string Ver_Maj = boost::lexical_cast(ver_maj); 33 | string Ver_Min = boost::lexical_cast(ver_min); 34 | string Ver_Pat = boost::lexical_cast(ver_pat); 35 | 36 | Str += "Boost version: " + Ver_Maj + "." + Ver_Min + "." + Ver_Pat + "\n"; 37 | 38 | Str += "built with NDK version: " + string(BOOST_BUILT_WITH_NDK_VERSION) + "\n"; 39 | 40 | #if defined(__ANDROID_API__) 41 | Str += "native Api level: " + std::to_string(__ANDROID_API__) + "\n " ; 42 | #endif 43 | 44 | Str += "\n"; 45 | Str += "Boost chrono says time is \n" + std::string(buffer) + "\n\n"; 46 | //-------------------------------------------- 47 | return env->NewStringUTF(Str.c_str()); 48 | } -------------------------------------------------------------------------------- /example_app/app/src/main/java/com/example/boost_test/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.boost_test 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import android.widget.TextView 6 | import com.example.boost_test.databinding.ActivityMainBinding 7 | 8 | class MainActivity : AppCompatActivity() { 9 | 10 | private lateinit var binding: ActivityMainBinding 11 | 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | 15 | binding = ActivityMainBinding.inflate(layoutInflater) 16 | setContentView(binding.root) 17 | 18 | // Example of a call to a native method 19 | binding.sampleText.text = stringFromJNI() 20 | } 21 | 22 | /** 23 | * A native method that is implemented by the 'boost_test' native library, 24 | * which is packaged with this application. 25 | */ 26 | external fun stringFromJNI(): String 27 | 28 | companion object { 29 | // Used to load the 'boost_test' library on application startup. 30 | init { 31 | System.loadLibrary("boost_test") 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /example_app/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example_app/app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | boost_test 3 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /example_app/app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /example_app/app/src/test/java/com/example/boost_test/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.boost_test 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /example_app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | alias(libs.plugins.android.application) apply false 4 | alias(libs.plugins.kotlin.android) apply false 5 | } -------------------------------------------------------------------------------- /example_app/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. For more details, visit 12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /example_app/gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | agp = "8.7.3" 3 | kotlin = "1.9.24" 4 | coreKtx = "1.10.1" 5 | junit = "4.13.2" 6 | junitVersion = "1.2.1" 7 | espressoCore = "3.6.1" 8 | appcompat = "1.7.0" 9 | material = "1.12.0" 10 | constraintlayout = "2.2.0" 11 | 12 | [libraries] 13 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } 14 | junit = { group = "junit", name = "junit", version.ref = "junit" } 15 | androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } 16 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } 17 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } 18 | material = { group = "com.google.android.material", name = "material", version.ref = "material" } 19 | androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } 20 | 21 | [plugins] 22 | android-application = { id = "com.android.application", version.ref = "agp" } 23 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } 24 | 25 | -------------------------------------------------------------------------------- /example_app/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example_app/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jan 08 08:34:42 CET 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /example_app/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /example_app/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /example_app/local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file should *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=/Users/declan/Library/Android/sdk 11 | boost.dir=/Users/declan/Documents/zone/low/Boost-for-Android/build/install -------------------------------------------------------------------------------- /example_app/readme.md: -------------------------------------------------------------------------------- 1 | If you build and run this example app it should show the date and time as calculated by boost *chrono* (indicating that you have built, linked to and called the boost library correctly). 2 | Make sure to adjust the values in the [local.properties](./local.properties) file. 3 | 4 | 5 | ![Image description](screenshot.png) -------------------------------------------------------------------------------- /example_app/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dec1/Boost-for-Android/251fd8044c4467af8662cd8e237e7617add81164/example_app/screenshot.png -------------------------------------------------------------------------------- /example_app/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google { 4 | content { 5 | includeGroupByRegex("com\\.android.*") 6 | includeGroupByRegex("com\\.google.*") 7 | includeGroupByRegex("androidx.*") 8 | } 9 | } 10 | mavenCentral() 11 | gradlePluginPortal() 12 | } 13 | } 14 | dependencyResolutionManagement { 15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | rootProject.name = "boost_test" 23 | include(":app") 24 | -------------------------------------------------------------------------------- /user-config.jam: -------------------------------------------------------------------------------- 1 | 2 | 3 | import os ; 4 | local ndk_dir_env = [ os.environ NDK_DIR ] ; 5 | local host_os_tag_env = [ os.environ HOST_OS_TAG ] ; 6 | 7 | local ndk_bin_dir = $(ndk_dir_env)/toolchains/llvm/prebuilt/$(host_os_tag_env)/bin ; 8 | 9 | 10 | # -------------------------------------------------------------------- 11 | 12 | using clang : arm64v8a 13 | : 14 | clang++ 15 | : 16 | 17 | ; 18 | 19 | # -------------------------------------------------------------------- 20 | 21 | using clang : armeabiv7a 22 | : 23 | clang++ 24 | : 25 | 26 | ; 27 | # -------------------------------------------------------------------- 28 | 29 | using clang : x86 30 | : 31 | clang++ 32 | : 33 | 34 | ; 35 | 36 | # -------------------------------------------------------------------- 37 | 38 | using clang : x8664 39 | : 40 | clang++ 41 | : 42 | 43 | ; 44 | --------------------------------------------------------------------------------