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