-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89aec55
commit a98b1d6
Showing
4 changed files
with
172 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,83 @@ | ||
# Required on windows | ||
############################################################################### | ||
## Bazel Configuration Flags | ||
## | ||
## `.bazelrc` is a Bazel configuration file. | ||
## https://bazel.build/docs/best-practices#bazelrc-file | ||
############################################################################### | ||
|
||
# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config | ||
common --enable_platform_specific_config | ||
startup --windows_enable_symlinks | ||
build:windows --enable_runfiles | ||
|
||
build --fat_apk_cpu=arm64-v8a --android_crosstool_top=@androidndk//:toolchain | ||
# Enable the only currently supported report type | ||
# https://bazel.build/reference/command-line-reference#flag--combined_report | ||
coverage --combined_report=lcov | ||
|
||
# Avoid fully cached builds reporting no coverage and failing CI | ||
# https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs | ||
coverage --experimental_fetch_all_coverage_outputs | ||
|
||
# Required for some of the tests | ||
# https://bazel.build/reference/command-line-reference#flag--experimental_cc_shared_library | ||
common --experimental_cc_shared_library | ||
|
||
############################################################################### | ||
## Unique configuration groups | ||
############################################################################### | ||
|
||
# Enable use of the nightly toolchains. | ||
build:nightly --@rules_rust//rust/toolchain/channel=nightly | ||
|
||
# Enable rustfmt for all targets in the workspace | ||
build:rustfmt --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect | ||
build:rustfmt --output_groups=+rustfmt_checks | ||
|
||
# Enable clippy for all targets in the workspace | ||
build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect | ||
build:clippy --output_groups=+clippy_checks | ||
|
||
# Enable unpretty for all targets in the workspace | ||
build:unpretty --aspects=@rules_rust//rust:defs.bzl%rust_unpretty_aspect | ||
build:unpretty --output_groups=+rust_unpretty | ||
|
||
# `unpretty` requires the nightly toolchain. See tracking issue: | ||
# https://github.com/rust-lang/rust/issues/43364 | ||
build:unpretty --config=nightly | ||
|
||
############################################################################### | ||
## Java configuration | ||
############################################################################### | ||
|
||
common --java_runtime_version=remotejdk_21 | ||
|
||
############################################################################### | ||
## Incompatibility flags | ||
############################################################################### | ||
|
||
# https://github.com/bazelbuild/bazel/issues/8195 | ||
build --incompatible_disallow_empty_glob=true | ||
|
||
# https://github.com/bazelbuild/bazel/issues/12821 | ||
build --nolegacy_external_runfiles | ||
|
||
# Required for cargo_build_script support before Bazel 7 | ||
build --incompatible_merge_fixed_and_default_shell_env | ||
|
||
############################################################################### | ||
## Bzlmod | ||
############################################################################### | ||
|
||
# A configuration for disabling bzlmod. | ||
common:no-bzlmod --noenable_bzlmod --enable_workspace | ||
|
||
# Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock | ||
common --lockfile_mode=off | ||
|
||
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel | ||
# https://github.com/bazelbuild/rules_rust/issues/2181 | ||
common --noenable_bzlmod | ||
############################################################################### | ||
## Custom user flags | ||
## | ||
## This should always be the last thing in the `.bazelrc` file to ensure | ||
## consistent behavior when setting flags in that file as `.bazelrc` files are | ||
## evaluated top to bottom. | ||
############################################################################### | ||
|
||
# This isn't currently the defaut in Bazel, but we enable it to test we'll be ready if/when it flips. | ||
build --incompatible_disallow_empty_glob | ||
try-import %workspace%/user.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/bazel-* | ||
user.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
module( | ||
name = "rules_rust_example_android", | ||
version = "0.0.0", | ||
) | ||
|
||
############################################################################### | ||
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/ | ||
############################################################################### | ||
# https://github.com/bazelbuild/rules_rust/releases | ||
bazel_dep(name = "rules_rust", version = "0.46.0") | ||
local_path_override( | ||
module_name = "rules_rust", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep( | ||
name = "rules_cc", | ||
version = "0.0.17", | ||
) | ||
bazel_dep( | ||
name = "rules_java", | ||
version = "8.6.3", | ||
) | ||
bazel_dep( | ||
name = "rules_jvm_external", | ||
version = "6.6", | ||
) | ||
|
||
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") | ||
use_repo(maven, "maven") | ||
|
||
bazel_dep( | ||
name = "rules_android", | ||
version = "0.6.0", | ||
repo_name = "build_bazel_rules_android", | ||
) | ||
|
||
############################################################################### | ||
# T O O L C H A I N S | ||
############################################################################### | ||
|
||
# Rust toolchain | ||
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") | ||
rust.toolchain( | ||
extra_target_triples = [ | ||
"aarch64-linux-android", | ||
], | ||
) | ||
use_repo(rust, "rust_toolchains") | ||
|
||
register_toolchains("@rust_toolchains//:all") | ||
|
||
java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") | ||
use_repo(java_toolchains, "remote_java_tools") | ||
use_repo(java_toolchains, "remote_java_tools_linux") | ||
use_repo(java_toolchains, "remote_java_tools_windows") | ||
use_repo(java_toolchains, "remote_java_tools_darwin_x86_64") | ||
use_repo(java_toolchains, "remote_java_tools_darwin_arm64") | ||
|
||
JDKS = { | ||
# Must match JDK repos defined in remote_jdk21_repos() | ||
"21": [ | ||
"linux", | ||
"linux_aarch64", | ||
"linux_ppc64le", | ||
"linux_s390x", | ||
"macos", | ||
"macos_aarch64", | ||
"win", | ||
"win_arm64", | ||
], | ||
} | ||
|
||
REMOTE_JDK_REPOS = [ | ||
(("remote_jdk" if version == "8" else "remotejdk") + version + "_" + platform) | ||
for version in JDKS | ||
for platform in JDKS[version] | ||
] | ||
|
||
[ | ||
use_repo( | ||
java_toolchains, | ||
repo + "_toolchain_config_repo", | ||
) | ||
for repo in REMOTE_JDK_REPOS | ||
] | ||
|
||
[ | ||
register_toolchains("@" + name + "_toolchain_config_repo//:all") | ||
for name in REMOTE_JDK_REPOS | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1 @@ | ||
workspace(name = "android_examples") | ||
|
||
# Users of `rules_rust` will commonly be unable to load it | ||
# using a `local_repository`. Instead, to setup the rules, | ||
# please see https://bazelbuild.github.io/rules_rust/#setup | ||
local_repository( | ||
name = "rules_rust", | ||
path = "../..", | ||
) | ||
|
||
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains") | ||
|
||
rules_rust_dependencies() | ||
|
||
rust_register_toolchains( | ||
edition = "2018", | ||
extra_target_triples = [ | ||
"aarch64-linux-android", | ||
], | ||
) | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "build_bazel_rules_android", | ||
sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", | ||
strip_prefix = "rules_android-0.1.1", | ||
urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"], | ||
) | ||
|
||
http_archive( | ||
name = "bazelci_rules", | ||
sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e", | ||
strip_prefix = "bazelci_rules-1.0.0", | ||
url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz", | ||
) | ||
|
||
load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig") | ||
|
||
# Creates a default toolchain config for RBE. | ||
# Use this as is if you are using the rbe_ubuntu16_04 container, | ||
# otherwise refer to RBE docs. | ||
rbe_preconfig( | ||
name = "buildkite_config", | ||
toolchain = "ubuntu1804-bazel-java11", | ||
) | ||
|
||
android_sdk_repository( | ||
name = "androidsdk", | ||
) | ||
|
||
http_archive( | ||
name = "rules_android_ndk", | ||
sha256 = "b1a5ddd784e6ed915c2035c0db536a278b5f50c64412128c06877115991391ef", | ||
strip_prefix = "rules_android_ndk-877c68ef34c9f3353028bf490d269230c1990483", | ||
url = "https://github.com/bazelbuild/rules_android_ndk/archive/877c68ef34c9f3353028bf490d269230c1990483.zip", | ||
) | ||
|
||
load("@rules_android_ndk//:rules.bzl", "android_ndk_repository") | ||
|
||
android_ndk_repository( | ||
name = "androidndk", | ||
) | ||
workspace(name = "rules_rust_example_android") |