Release rules_gomobile v0.1.1.
Usage
Apply to workspace and project
In WORKSPACE
file, defines
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bolitt_rules_gomobile",
sha256 = "b2a7c1c47dc98e945a384455ac1774de81707170e810c67dbd69b97dfb01fa1a",
strip_prefix = "rules_gomobile-0.1.1",
url = "https://github.com/bolitt/rules_gomobile/archive/refs/tags/v0.1.1.tar.gz",
)
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
android_sdk_repository(
name = "androidsdk",
api_level = 29, # Optional: your API level.
)
android_ndk_repository(
name = "androidndk",
api_level = 21, # Optional: your API level.
)
Patch org_golang_x_mobile
with @bolitt_rules_gomobile//third_party/org_golang_x_mobile:all.patch
.
go_repository(
name = "org_golang_x_mobile",
importpath = "golang.org/x/mobile",
sum = "h1:CyFUjc175y/mbMjxe+WdqI72jguLyjQChKCDe9mfTvg=",
version = "v0.0.0-20210924032853-1c027f395ef7",
patches = [
"@bolitt_rules_gomobile//third_party/org_golang_x_mobile:all.patch", # Apply patch.
],
)
Apply to BUILD in the package
In BUILD.bazel
/BUILD
of target package,
gobind(
name = "HelloLib",
java_package = "your.java.package.namespace",
deps = [":helloworld"], # Depends on go_library.
)
Before building, it is needed to have ANDROID_HOME
and ANDROID_NDK_HOME
set in the system environment.
# Optional: Set as per your own paths.
export ANDROID_HOME="$HOME/Android/Sdk"
export ANDROID_NDK_HOME="$HOME/Android/Sdk/ndk-bundle/android-ndk-r21e"
Build
Run bazel
to build
bazel build :HelloLib@java