1# Copyright 2023 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load( 16 "@pw_toolchain//cc_toolchain:defs.bzl", 17 "pw_cc_action_config", 18 "pw_cc_tool", 19) 20 21package(default_visibility = ["//visibility:public"]) 22 23licenses(["notice"]) 24 25# This build file defines a complete set of tools for a LLVM-based toolchain. 26 27exports_files(glob(["**"])) 28 29filegroup( 30 name = "all", 31 srcs = glob(["**"]), 32 visibility = ["//visibility:public"], 33) 34 35pw_cc_tool( 36 name = "ar_tool", 37 tool = select({ 38 "@platforms//os:windows": "//:bin/llvm-ar.exe", 39 "//conditions:default": "//:bin/llvm-ar", 40 }), 41) 42 43pw_cc_tool( 44 name = "llvm_libtool_darwin_tool", 45 tool = "//:bin/llvm-libtool-darwin", 46) 47 48pw_cc_action_config( 49 name = "ar", 50 action_names = ["@pw_toolchain//actions:all_ar_actions"], 51 # Unlike most legacy features required to compile code, these features 52 # aren't enabled by default, and are instead only implied by the built-in 53 # action configs. We imply the features here to match the behavior of the 54 # built-in action configs so flags are actually passed to `ar`. 55 implies = [ 56 "@pw_toolchain//features/legacy:archiver_flags", 57 "@pw_toolchain//features/legacy:linker_param_file", 58 ], 59 tools = select({ 60 "@platforms//os:macos": [":llvm_libtool_darwin_tool"], 61 "//conditions:default": [":ar_tool"], 62 }), 63) 64 65pw_cc_tool( 66 name = "clang++_tool", 67 tool = select({ 68 "@platforms//os:windows": "//:bin/clang++.exe", 69 "//conditions:default": "//:bin/clang++", 70 }), 71 additional_files = glob([ 72 "include/**", 73 "lib/clang/**/include/**", 74 ]), 75) 76 77pw_cc_action_config( 78 name = "clang++", 79 action_names = ["@pw_toolchain//actions:all_cpp_compiler_actions"], 80 tools = [":clang++_tool"], 81) 82 83pw_cc_tool( 84 name = "clang_tool", 85 tool = select({ 86 "@platforms//os:windows": "//:bin/clang.exe", 87 "//conditions:default": "//:bin/clang", 88 }), 89 additional_files = glob([ 90 "include/**", 91 "lib/clang/**/include/**", 92 ]), 93) 94 95pw_cc_action_config( 96 name = "clang", 97 action_names = [ 98 "@pw_toolchain//actions:all_asm_actions", 99 "@pw_toolchain//actions:all_c_compiler_actions", 100 ], 101 tools = [":clang_tool"], 102) 103 104# This tool is actually just clang++ under the hood, we just enumerate this 105# tool differently to specify a different set of additional files. 106pw_cc_tool( 107 name = "lld_tool", 108 tool = select({ 109 "@platforms//os:windows": "//:bin/clang++.exe", 110 "//conditions:default": "//:bin/clang++", 111 }), 112 additional_files = glob([ 113 "lib/**/*.a", 114 "lib/**/*.so*", 115 ]), 116) 117 118pw_cc_action_config( 119 name = "lld", 120 action_names = ["@pw_toolchain//actions:all_link_actions"], 121 tools = [":lld_tool"], 122) 123 124pw_cc_tool( 125 name = "llvm_cov_tool", 126 tool = select({ 127 "@platforms//os:windows": "//:bin/llvm-cov.exe", 128 "//conditions:default": "//:bin/llvm-cov", 129 }), 130) 131 132pw_cc_action_config( 133 name = "llvm-cov", 134 action_names = ["@pw_toolchain//actions:all_coverage_actions"], 135 tools = [":llvm_cov_tool"], 136) 137 138pw_cc_tool( 139 name = "llvm_objcopy_tool", 140 tool = select({ 141 "@platforms//os:windows": "//:bin/llvm-objcopy.exe", 142 "//conditions:default": "//:bin/llvm-objcopy", 143 }), 144) 145 146pw_cc_action_config( 147 name = "llvm-objcopy", 148 action_names = ["@pw_toolchain//actions:all_objcopy_actions"], 149 tools = [":llvm_objcopy_tool"], 150) 151 152pw_cc_tool( 153 name = "llvm_objdump_tool", 154 tool = select({ 155 "@platforms//os:windows": "//:bin/llvm-objdump.exe", 156 "//conditions:default": "//:bin/llvm-objdump", 157 }), 158) 159 160pw_cc_action_config( 161 name = "llvm-objdump", 162 action_names = ["@pw_toolchain//actions:all_objdump_actions"], 163 tools = [":llvm_objdump_tool"], 164) 165 166pw_cc_tool( 167 name = "llvm_strip_tool", 168 tool = select({ 169 "@platforms//os:windows": "//:bin/llvm-strip.exe", 170 "//conditions:default": "//:bin/llvm-strip", 171 }), 172) 173 174pw_cc_action_config( 175 name = "llvm-strip", 176 action_names = ["@pw_toolchain//actions:all_strip_actions"], 177 tools = [":llvm_strip_tool"], 178) 179