1# Copyright 2016 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://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, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# This becomes the BUILD file for @local_config_cc// under non-BSD unixes. 16 17load(":cc_toolchain_config.bzl", "cc_toolchain_config") 18load(":armeabi_cc_toolchain_config.bzl", "armeabi_cc_toolchain_config") 19load("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain") 20load("@rules_cc//cc/toolchains:cc_toolchain_suite.bzl", "cc_toolchain_suite") 21 22package(default_visibility = ["//visibility:public"]) 23 24licenses(["notice"]) # Apache 2.0 25 26cc_library(name = "empty_lib") 27 28# Label flag for extra libraries to be linked into every binary. 29# TODO(bazel-team): Support passing flag multiple times to build a list. 30label_flag( 31 name = "link_extra_libs", 32 build_setting_default = ":empty_lib", 33) 34 35# The final extra library to be linked into every binary target. This collects 36# the above flag, but may also include more libraries depending on config. 37cc_library( 38 name = "link_extra_lib", 39 deps = [ 40 ":link_extra_libs", 41 ], 42) 43 44cc_library( 45 name = "malloc", 46) 47 48filegroup( 49 name = "empty", 50 srcs = [], 51) 52 53filegroup( 54 name = "cc_wrapper", 55 srcs = ["cc_wrapper.sh"], 56) 57 58filegroup( 59 name = "validate_static_library", 60 srcs = ["validate_static_library.sh"], 61) 62 63filegroup( 64 name = "deps_scanner_wrapper", 65 srcs = ["deps_scanner_wrapper.sh"], 66) 67filegroup( 68 name = "compiler_deps", 69 srcs = glob(["extra_tools/**"], allow_empty = True) + [%{cc_compiler_deps}], 70) 71 72# This is the entry point for --crosstool_top. Toolchains are found 73# by lopping off the name of --crosstool_top and searching for 74# the "${CPU}" entry in the toolchains attribute. 75cc_toolchain_suite( 76 name = "toolchain", 77 toolchains = { 78 "%{name}|%{compiler}": ":cc-compiler-%{name}", 79 "%{name}": ":cc-compiler-%{name}", 80 "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a", 81 "armeabi-v7a": ":cc-compiler-armeabi-v7a", 82 }, 83) 84 85cc_toolchain( 86 name = "cc-compiler-%{name}", 87 toolchain_identifier = "%{cc_toolchain_identifier}", 88 toolchain_config = ":%{cc_toolchain_identifier}", 89 all_files = ":compiler_deps", 90 ar_files = ":compiler_deps", 91 as_files = ":compiler_deps", 92 compiler_files = ":compiler_deps", 93 dwp_files = ":empty", 94 linker_files = ":compiler_deps", 95 objcopy_files = ":empty", 96 strip_files = ":empty", 97 supports_header_parsing = 1, 98 supports_param_files = 1, 99 module_map = %{modulemap}, 100) 101 102cc_toolchain_config( 103 name = "%{cc_toolchain_identifier}", 104 cpu = "%{target_cpu}", 105 compiler = "%{compiler}", 106 toolchain_identifier = "%{cc_toolchain_identifier}", 107 host_system_name = "%{host_system_name}", 108 target_system_name = "%{target_system_name}", 109 target_libc = "%{target_libc}", 110 abi_version = "%{abi_version}", 111 abi_libc_version = "%{abi_libc_version}", 112 cxx_builtin_include_directories = [%{cxx_builtin_include_directories}], 113 tool_paths = {%{tool_paths}}, 114 compile_flags = [%{compile_flags}], 115 opt_compile_flags = [%{opt_compile_flags}], 116 dbg_compile_flags = [%{dbg_compile_flags}], 117 conly_flags = [%{conly_flags}], 118 cxx_flags = [%{cxx_flags}], 119 link_flags = [%{link_flags}], 120 link_libs = [%{link_libs}], 121 opt_link_flags = [%{opt_link_flags}], 122 unfiltered_compile_flags = [%{unfiltered_compile_flags}], 123 coverage_compile_flags = [%{coverage_compile_flags}], 124 coverage_link_flags = [%{coverage_link_flags}], 125 supports_start_end_lib = %{supports_start_end_lib}, 126 extra_flags_per_feature = %{extra_flags_per_feature}, 127) 128 129# Android tooling requires a default toolchain for the armeabi-v7a cpu. 130cc_toolchain( 131 name = "cc-compiler-armeabi-v7a", 132 toolchain_identifier = "stub_armeabi-v7a", 133 toolchain_config = ":stub_armeabi-v7a", 134 all_files = ":empty", 135 ar_files = ":empty", 136 as_files = ":empty", 137 compiler_files = ":empty", 138 dwp_files = ":empty", 139 linker_files = ":empty", 140 objcopy_files = ":empty", 141 strip_files = ":empty", 142 supports_param_files = 1, 143) 144 145armeabi_cc_toolchain_config(name = "stub_armeabi-v7a") 146