• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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 FreeBSD and OpenBSD.
16
17load("@rules_cc//cc:cc_library.bzl", "cc_library")
18load("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain")
19load("@rules_cc//cc/toolchains:cc_toolchain_suite.bzl", "cc_toolchain_suite")
20load(":cc_toolchain_config.bzl", "cc_toolchain_config")
21
22package(default_visibility = ["//visibility:public"])
23
24cc_library(name = "empty_lib")
25
26# Label flag for extra libraries to be linked into every binary.
27# TODO(bazel-team): Support passing flag multiple times to build a list.
28label_flag(
29    name = "link_extra_libs",
30    build_setting_default = ":empty_lib",
31)
32
33# The final extra library to be linked into every binary target. This collects
34# the above flag, but may also include more libraries depending on config.
35cc_library(
36    name = "link_extra_lib",
37    deps = [
38        ":link_extra_libs",
39    ],
40)
41
42cc_library(
43    name = "malloc",
44)
45
46filegroup(
47    name = "empty",
48    srcs = [],
49)
50
51# Hardcoded toolchain, legacy behaviour.
52cc_toolchain_suite(
53    name = "toolchain",
54    toolchains = {
55        "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
56        "freebsd|compiler": ":cc-compiler-freebsd",
57        "openbsd|compiler": ":cc-compiler-openbsd",
58        "armeabi-v7a": ":cc-compiler-armeabi-v7a",
59        "freebsd": ":cc-compiler-freebsd",
60        "openbsd": ":cc-compiler-openbsd",
61    },
62)
63
64cc_toolchain(
65    name = "cc-compiler-freebsd",
66    all_files = ":empty",
67    ar_files = ":empty",
68    as_files = ":empty",
69    compiler_files = ":empty",
70    dwp_files = ":empty",
71    linker_files = ":empty",
72    objcopy_files = ":empty",
73    strip_files = ":empty",
74    supports_param_files = 0,
75    toolchain_config = ":local_freebsd",
76    toolchain_identifier = "local_freebsd",
77)
78
79cc_toolchain_config(
80    name = "local_freebsd",
81    cpu = "freebsd",
82)
83
84toolchain(
85    name = "cc-toolchain-freebsd",
86    exec_compatible_with = [
87        "@platforms//cpu:x86_64",
88        "@platforms//os:freebsd",
89    ],
90    target_compatible_with = [
91        "@platforms//cpu:x86_64",
92        "@platforms//os:freebsd",
93    ],
94    toolchain = ":cc-compiler-freebsd",
95    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
96)
97
98cc_toolchain(
99    name = "cc-compiler-openbsd",
100    all_files = ":empty",
101    ar_files = ":empty",
102    as_files = ":empty",
103    compiler_files = ":empty",
104    dwp_files = ":empty",
105    linker_files = ":empty",
106    objcopy_files = ":empty",
107    strip_files = ":empty",
108    supports_param_files = 0,
109    toolchain_config = ":local_openbsd",
110    toolchain_identifier = "local_openbsd",
111)
112
113cc_toolchain_config(
114    name = "local_openbsd",
115    cpu = "openbsd",
116)
117
118toolchain(
119    name = "cc-toolchain-openbsd",
120    exec_compatible_with = [
121        "@platforms//cpu:x86_64",
122        "@platforms//os:openbsd",
123    ],
124    target_compatible_with = [
125        "@platforms//cpu:x86_64",
126        "@platforms//os:openbsd",
127    ],
128    toolchain = ":cc-compiler-openbsd",
129    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
130)
131
132cc_toolchain(
133    name = "cc-compiler-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 = 0,
143    toolchain_config = ":stub_armeabi-v7a",
144    toolchain_identifier = "stub_armeabi-v7a",
145)
146
147cc_toolchain_config(
148    name = "stub_armeabi-v7a",
149    cpu = "armeabi-v7a",
150)
151
152toolchain(
153    name = "cc-toolchain-armeabi-v7a",
154    exec_compatible_with = [
155        "@platforms//cpu:arm",
156    ],
157    target_compatible_with = [
158        "@platforms//cpu:armv7",
159        "@platforms//os:android",
160    ],
161    toolchain = ":cc-compiler-armeabi-v7a",
162    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
163)
164
165filegroup(
166    name = "link_dynamic_library",
167    srcs = ["link_dynamic_library.sh"],
168)
169