1""" CC Strip ActionConfigs for llvm-strip """
2
3load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
4load(
5    "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
6    "action_config",
7    "flag_group",
8    "flag_set",
9    "tool",
10)
11
12def strip_action_configs(llvm):
13    """
14    Generates CC Strip ActionConfigs
15
16    Args:
17        llvm (string): Path to LLVM binaries.
18
19    Returns:
20        List of CC Strip ActionConfigs
21    """
22
23    return [action_config(
24        action_name = ACTION_NAMES.strip,
25        tools = [tool(path = "{}/bin/llvm-strip".format(llvm))],
26        flag_sets = [
27            flag_set(
28                flag_groups = [
29                    flag_group(
30                        flags = ["-S", "-p", "-o", "%{output_file}"],
31                    ),
32                    flag_group(
33                        iterate_over = "stripopts",
34                        flags = ["%{stripopts}"],
35                    ),
36                    flag_group(
37                        flags = ["%{input_file}"],
38                    ),
39                ],
40            ),
41        ],
42    )]
43