forked from google-coral/crosstool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.bzl
58 lines (54 loc) · 2.24 KB
/
configure.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Rules for configuring the C++ cross-toolchain."""
load(":windows_cc_configure.bzl", "configure_windows_toolchain")
def _impl(repository_ctx):
dir_labels = repository_ctx.attr.additional_system_include_directories
additional_include_dirs = ", ".join([
'"%s"' % repository_ctx.path(dir_label.relative("BUILD")).dirname
for dir_label in dir_labels
])
gcc_version = repository_ctx.execute(["/bin/bash", "-c", "gcc -dumpversion | cut -f1 -d."]).stdout or "0"
bcm2708_toolchain_root = repository_ctx.os.environ.get("BCM2708_TOOLCHAIN_ROOT", "/tools/arm-bcm2708")
repository_ctx.template(
"cc_toolchain_config.bzl",
Label("//:cc_toolchain_config.bzl.tpl"),
{
"%{gcc_version}%": gcc_version,
"%{c_version}%": repository_ctx.attr.c_version,
"%{cpp_version}%": repository_ctx.attr.cpp_version,
"%{bcm2708_toolchain_root}%": bcm2708_toolchain_root,
"%{additional_system_include_directories}%": additional_include_dirs,
},
)
template_vars = configure_windows_toolchain(repository_ctx)
repository_ctx.template(
"BUILD",
Label("//:BUILD.tpl"),
template_vars,
)
cc_crosstool = repository_rule(
environ = [
"BCM2708_TOOLCHAIN_ROOT",
],
attrs = {
# Consult https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html for
# valid c_version and cpp_version values (-std option).
"c_version": attr.string(default = "c99"),
"cpp_version": attr.string(default = "c++11"),
"additional_system_include_directories": attr.label_list(allow_files = True),
},
implementation = _impl,
local = True,
)