https://github.com/bazelbuild/rules_android_ndk
https://github.com/bazelbuild/rules_android_ndk
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bazelbuild/rules_android_ndk
- Owner: bazelbuild
- License: apache-2.0
- Created: 2022-08-29T18:28:27.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-23T21:44:27.000Z (over 1 year ago)
- Last Synced: 2025-01-23T22:29:15.486Z (over 1 year ago)
- Language: Starlark
- Size: 91.8 KB
- Stars: 34
- Watchers: 8
- Forks: 15
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Android NDK Bazel Rules
## Overview
This repository contains Starlark rules for integrating Bazel with the
Android NDK. These rules currently work with Android NDK version 25b.
NOTE: This is a development preview of the Starlark Android NDK Bazel
rules. These rules are not guaranteed to be complete or work for every
NDK use case. Bazel versions up to and including 7.0.0 contain a
built-in ("native") version of `android_ndk_repository` described at
https://bazel.build/reference/be/android#android_ndk_repository. Over
time, these Starlark rules will replace the native version of
`android_ndk_repository`.
## Getting Started
To use the Android NDK rules, add the following to your `WORKSPACE` file:
# Or a later commit
RULES_ANDROID_NDK_COMMIT= "81ec8b79dc50ee97e336a25724fdbb28e33b8d41"
RULES_ANDROID_NDK_SHA = "b29409496439cdcdb50a8e161c4953ca78a548e16d3ee729a1b5cd719ffdacbf"
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_android_ndk",
url = "https://github.com/bazelbuild/rules_android_ndk/archive/%s.zip" % RULES_ANDROID_NDK_COMMIT,
sha256 = RULES_ANDROID_NDK_SHA,
strip_prefix = "rules_android_ndk-%s" % RULES_ANDROID_NDK_COMMIT,
)
load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")
android_ndk_repository(name = "androidndk")
register_toolchains("@androidndk//:all")
Then, set the `ANDROID_NDK_HOME` environment variable or the `path` attribute of
`android_ndk_repository` to the path of the local Android NDK installation
directory. If the path starts with `$WORKSPACE_ROOT`, then this string is
replaced with the root path of the Bazel workspace.
The `api_level` attribute can also be used to set the Android API level to build
against.
Finally, when building an Android app with native dependencies (e.g.
`cc_library` targets), add
--fat_apk_cpu= --android_crosstool_top=@androidndk//:toolchain
to your Bazel invocation. `` is a comma-separated list of the available
CPUs:
armeabi-v7a
arm64-v8a
x86
x86_64
e.g. `--fat_apk_cpu=arm64-v8a` or `--fat_apk_cpu=arm64-v8a,x86`.
These flags may also be added to the your project's `.bazelrc` file so that they
don't have to be specified on the command line.
See the example in https://github.com/bazelbuild/rules_android_ndk/tree/main/examples/basic.