2
0
Fork 0
mirror of https://github.com/bazelbuild/rules_cc synced 2024-12-04 05:03:18 +00:00
rules_cc/cc/toolchains/args/archiver_flags/BUILD
Googler 0d5561bcba Consolidate action labels in toolchain args
BEGIN_PUBLIC

Consolidate action labels in toolchain args

Consolidates action labels used by re-implementation of legacy features to use logical groups rather than individually listing every action. This simplifies the rule definitions slightly.

END_PUBLIC

PiperOrigin-RevId: 673920103
Change-Id: If5453dd5b45d5549ff75d656da8a2873232117ae
2024-09-12 11:05:19 -07:00

69 lines
2 KiB
Python

load("//cc/toolchains:args.bzl", "cc_args")
load("//cc/toolchains:args_list.bzl", "cc_args_list")
load("//cc/toolchains:nested_args.bzl", "cc_nested_args")
package(default_visibility = ["//visibility:private"])
cc_args_list(
name = "archiver_flags",
args = [
":create_static_archive",
":output_execpath",
":libraries_to_link",
],
visibility = ["//visibility:public"],
)
cc_args(
name = "create_static_archive",
actions = ["//cc/toolchains/actions:ar_actions"],
args = select({
"@platforms//os:macos": ["-static"],
"//conditions:default": ["rcsD"],
}),
)
cc_args(
name = "output_execpath",
actions = ["//cc/toolchains/actions:ar_actions"],
args = select({
"@platforms//os:macos": ["-o"],
"//conditions:default": [],
}) + ["{output_execpath}"],
format = {"output_execpath": "//cc/toolchains/variables:output_execpath"},
requires_not_none = "//cc/toolchains/variables:output_execpath",
)
cc_args(
name = "libraries_to_link",
actions = ["//cc/toolchains/actions:ar_actions"],
nested = ["libraries_to_link_expansion"],
requires_not_none = "//cc/toolchains/variables:libraries_to_link",
)
cc_nested_args(
name = "libraries_to_link_expansion",
iterate_over = "//cc/toolchains/variables:libraries_to_link",
nested = [
":link_obj_file",
":link_object_file_group",
],
)
cc_nested_args(
name = "link_obj_file",
args = ["{object_file}"],
format = {"object_file": "//cc/toolchains/variables:libraries_to_link.name"},
requires_equal = "//cc/toolchains/variables:libraries_to_link.type",
requires_equal_value = "object_file",
)
cc_nested_args(
name = "link_object_file_group",
args = ["{object_files}"],
format = {"object_files": "//cc/toolchains/variables:libraries_to_link.object_files"},
iterate_over = "//cc/toolchains/variables:libraries_to_link.object_files",
requires_equal = "//cc/toolchains/variables:libraries_to_link.type",
requires_equal_value = "object_file_group",
)