diff options
author | Vinh Tran <vinhdaitran@google.com> | 2023-07-21 19:38:23 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-07-21 19:38:23 +0000 |
commit | f0df148dbeb9b9ed3816aad328ebe7c65efaaa24 (patch) | |
tree | c75dabb560288e11786211bdc61ba40dde4b8674 /examples/custom_toolchain/toolchain_config.bzl | |
parent | 3544b5a539d9e51161befd2ac3fdc04525bced91 (diff) | |
parent | 9a4853f0327e0266818c8d6b4967e2e8f36b1a88 (diff) | |
download | bazelbuild-rules_cc-f0df148dbeb9b9ed3816aad328ebe7c65efaaa24.tar.gz |
Merge remote-tracking branch 'aosp/upstream-main' into main am: 755aefef35 am: d7bf0d569f am: 59148a708a am: 13ca54997b am: 9a4853f032android-14.0.0_r51android-14.0.0_r50android-14.0.0_r37android-14.0.0_r36android-14.0.0_r35android-14.0.0_r34android-14.0.0_r33android-14.0.0_r32android-14.0.0_r31android-14.0.0_r30android-14.0.0_r29android-14.0.0_r28android14-qpr3-releaseandroid14-qpr2-s5-releaseandroid14-qpr2-s4-releaseandroid14-qpr2-s3-releaseandroid14-qpr2-s2-releaseandroid14-qpr2-s1-releaseandroid14-qpr2-release
Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-rules_cc/+/2663436
Change-Id: I450b9f32024fa1b0844cc21a825c26589feb3977
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'examples/custom_toolchain/toolchain_config.bzl')
-rw-r--r-- | examples/custom_toolchain/toolchain_config.bzl | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/examples/custom_toolchain/toolchain_config.bzl b/examples/custom_toolchain/toolchain_config.bzl new file mode 100644 index 0000000..e83162b --- /dev/null +++ b/examples/custom_toolchain/toolchain_config.bzl @@ -0,0 +1,77 @@ +"""Sample Starlark definition defining a C++ toolchain's behavior. + +When you build a cc_* rule, this logic defines what programs run for what +build steps (e.g. compile / link / archive) and how their command lines are +structured. + +This is a proof-of-concept simple implementation. It doesn't construct fancy +command lines and uses mock shell scripts to compile and link +("sample_compiler" and "sample_linker"). See +https://docs.bazel.build/versions/main/cc-toolchain-config-reference.html and +https://docs.bazel.build/versions/main/tutorial/cc-toolchain-config.html for +advanced usage. +""" + +load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "tool_path") + +def _impl(ctx): + tool_paths = [ + tool_path( + name = "ar", + path = "sample_linker", + ), + tool_path( + name = "cpp", + path = "not_used_in_this_example", + ), + tool_path( + name = "gcc", + path = "sample_compiler", + ), + tool_path( + name = "gcov", + path = "not_used_in_this_example", + ), + tool_path( + name = "ld", + path = "sample_linker", + ), + tool_path( + name = "nm", + path = "not_used_in_this_example", + ), + tool_path( + name = "objdump", + path = "not_used_in_this_example", + ), + tool_path( + name = "strip", + path = "not_used_in_this_example", + ), + ] + + # Documented at + # https://docs.bazel.build/versions/main/skylark/lib/cc_common.html#create_cc_toolchain_config_info. + # + # create_cc_toolchain_config_info is the public interface for registering + # C++ toolchain behavior. + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + toolchain_identifier = "custom-toolchain-identifier", + host_system_name = "local", + target_system_name = "local", + target_cpu = "sample_cpu", + target_libc = "unknown", + compiler = "gcc", + abi_version = "unknown", + abi_libc_version = "unknown", + tool_paths = tool_paths, + ) + +cc_toolchain_config = rule( + implementation = _impl, + # You can alternatively define attributes here that make it possible to + # instantiate different cc_toolchain_config targets with different behavior. + attrs = {}, + provides = [CcToolchainConfigInfo], +) |