This document is a Markdown export of the Skycache Bazel Unconference presentation, formatted for GitHub Discussions and Gists.
- Gather requirements and use cases from the Bazel community.
| # https://cs.opensource.google/bazel/bazel/+/master:tools/cpp/toolchain_utils.bzl;l=23 | |
| load("@rules_cc///tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") | |
| def _crosstool_feature_flag_impl(ctx): | |
| """Rule that allows select-ing based on if a crosstool feature is enabled.""" | |
| toolchain = find_cpp_toolchain(ctx) | |
| feature_configuration = cc_common.configure_features( | |
| ctx = ctx, | |
| cc_toolchain = toolchain, | |
| requested_features = ctx.features, |
| $ bazel cquery //src/main/... --output=providers | |
| INFO: Analyzed 1014 targets (0 packages loaded, 0 targets configured). | |
| INFO: Found 1014 targets... | |
| //src/main/protobuf:_command_server_cc_grpc_grpc_codegen [OutputGroupInfo] | |
| //src/main/protobuf:action_cache_java_proto [JavaInfo, OutputGroupInfo] | |
| //src/main/protobuf:action_cache_java_proto [JavaInfo, OutputGroupInfo] | |
| //src/main/protobuf:action_cache_java_proto_srcs [OutputGroupInfo] | |
| //src/main/protobuf:action_cache_proto [ProtoInfo, OutputGroupInfo] | |
| //src/main/protobuf:action_cache_proto [ProtoInfo, OutputGroupInfo] | |
| //src/main/protobuf:analysis_java_proto [JavaInfo, OutputGroupInfo] |
| $ cat WORKSPACE | |
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | |
| http_archive( | |
| name = "io_tweag_rules_nixpkgs", | |
| urls = ["https://github.com/tweag/rules_nixpkgs/archive/v0.5.2.tar.gz"], | |
| strip_prefix = "rules_nixpkgs-0.5.2", | |
| sha256 = "5a384daa57b49abf9f0b672852f1a66a3c52aecf9d4d2ac64f6de0fd307690c8", | |
| ) |
| $ docker pull docker.bintray.io/jfrog/artifactory-oss:latest | |
| $ docker run --name artifactory -d -p 8081:8081 docker.bintray.io/jfrog/artifactory-oss:latest | |
| # Go to http://localhost:8081, set up admin password, skip proxy setup. | |
| # Add a new remote Maven repo for Google Maven. URL: https://maven.google.com | |
| # In rules_jvm_external, | |
| maven_install( | |
| artifacts = [ |
| package(default_visibility = ["//visibility:public"]) | |
| java_import( | |
| name = "android_arch_core_common_1_1_1", | |
| jars = ["https/maven.google.com/android/arch/core/common/1.1.1/common-1.1.1.jar"], | |
| deps = [ | |
| ":com_android_support_support_annotations_28_0_0", | |
| ], | |
| ) | |
| aar_import( | |
| name = "android_arch_core_runtime_aar_1_1_1", |
| # Requires Bazel built from HEAD (after https://github.com/bazelbuild/bazel/commit/b6f2ff19727c150cd745cff3d6365eb40935253e) | |
| # ... import /path/to/bazel-toolchains/bazelrc/bazel-0.19.2.bazelrc | |
| ## Configuration to build Android apps remotely | |
| # bazel build //android:app --config=remote_android | |
| build:remote_android --config=remote # Reuse remote config from RBE bazelrc | |
| build:remote_android --strategy=CppCompile=remote # RBE C++ toolchain is built for RBE container | |
| build:remote_android --strategy=CppLink=remote # RBE C++ toolchain is built for RBE container | |
| build:remote_android --strategy=DexBuilder=remote # RBE C++ toolchain is built for RBE container | |
| build:remote_android --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0 |
| command_args: "bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox" | |
| command_args: "--tool" | |
| command_args: "COMPILE_LIBRARY_RESOURCES" | |
| command_args: "--" | |
| command_args: "--aapt2" | |
| command_args: "bazel-out/host/bin/external/androidsdk/aapt2_binary" | |
| command_args: "--resources" | |
| command_args: "bazel-out/android-armeabi-v7a-fastbuild/bin/external/com_android_support_support_compat_28_0_0/_aar/unzipped/resources/com_android_support_support_compat_28_0_0/res:" | |
| command_args: "--output" | |
| command_args: "bazel-out/android-armeabi-v7a-fastbuild/bin/external/com_android_support_support_compat_28_0_0/com_android_support_support_compat_28_0_0_symbols/symbols.zip" |
| action 'Compiling main/hello-world.cc' | |
| Mnemonic: CppCompile | |
| Owner: //main:hello-world | |
| Configuration: darwin-fastbuild | |
| ActionKey: 3ffd28bdc51685c24941885b8ac01f22 | |
| Inputs: [external/bazel_tools/tools/cpp/grep-includes.sh, external/local_config_cc/cc_wrapper.sh, external/local_config_cc/libtool, external/local_config_cc/make_hashed_objlist.py, external/local_config_cc/wrapped_ar, external/local_config_cc/wrapped_clang, external/local_config_cc/wrapped_clang_pp, external/local_config_cc/xcrunwrapper.sh, main/hello-world.cc] | |
| Outputs: [bazel-out/darwin-fastbuild/bin/main/_objs/hello-world/hello-world.d, bazel-out/darwin-fastbuild/bin/main/_objs/hello-world/hello-world.o] | |
| action 'Linking main/hello-world' | |
| Mnemonic: CppLink |
| # Run with Bazel with 88a20ee08c0af7cf187893bcafe0771e5a19ff9d reverted | |
| # This commit adds a JDK9+ opt into desugar.sh to silence warnings | |
| # $ git revert 88a20ee08c0af7cf187893bcafe0771e5a19ff9d | |
| # After that, run bazel build --config=jdk8 //... | |
| build:jdk8 --javabase=@local_jdk//:jdk | |
| build:jdk8 --host_javabase=@local_jdk//:jdk | |
| build:jdk8 --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 | |
| build:jdk8 --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 |