-
Notifications
You must be signed in to change notification settings - Fork 3
/
BUILD
140 lines (125 loc) · 3.84 KB
/
BUILD
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
load("@llvm-project//:vars.bzl", "LLVM_VERSION_MAJOR")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files")
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
pkg_files(
name = "builtin_headers_pkg_files",
srcs = [
"@llvm-project//clang:builtin_headers_files",
],
prefix = "lib/clang/%s/include" % LLVM_VERSION_MAJOR,
strip_prefix = "lib/Headers",
)
TIER2_BINS = [
"llvm-cov",
"llvm-dwp",
"llvm-objdump",
"llvm-profdata",
]
DIST_FLAVORS = {
"_minimal": {
"extra_empty_files": ["bin/" + bin for bin in TIER2_BINS],
},
"": {
"extra_bins": ["@llvm-project//llvm:" + bin for bin in TIER2_BINS],
},
}
[
pkg_files(
name = "bins" + suffix,
srcs = [
"@llvm-project//clang",
"@llvm-project//lld",
"@llvm-project//llvm:llvm-ar",
"@llvm-project//llvm:llvm-as",
"@llvm-project//llvm:llvm-libtool-darwin",
"@llvm-project//llvm:llvm-nm",
"@llvm-project//llvm:llvm-objcopy",
] + props.get("extra_bins", []),
attributes = pkg_attributes(
mode = "0755",
),
prefix = "bin",
)
for (suffix, props) in DIST_FLAVORS.items()
]
# Note, there are some inconsistencies in naming so expanding the templates.
LIB_PREFIX = "lib/clang/%s/lib/" % LLVM_VERSION_MAJOR
copy_file(
name = "copy_libclang_rt.profile_osx",
src = "@llvm-project//compiler-rt:profile",
out = "libclang_rt.profile_osx.a",
)
pkg_files(
name = "libclang_rt.profile_osx",
srcs = ["libclang_rt.profile_osx.a"],
prefix = LIB_PREFIX + "darwin",
)
copy_file(
name = "copy_libclang_rt.profile_linux_aarch64",
src = "@llvm-project//compiler-rt:profile",
out = "libclang_rt.profile_linux-aarch64.a",
)
pkg_files(
name = "libclang_rt.profile_linux_aarch64",
srcs = ["libclang_rt.profile_linux-aarch64.a"],
prefix = LIB_PREFIX + "linux",
)
# TODO(zbarsky): Not sure if this is the right name.
# Hopefully someone yells at me if it's wrong.
copy_file(
name = "copy_libclang_rt.profile_linux_x84_64",
src = "@llvm-project//compiler-rt:profile",
out = "libclang_rt.profile_linux-x86_64.a",
)
pkg_files(
name = "libclang_rt.profile_linux_x86_64",
srcs = ["libclang_rt.profile_linux-x86_64.a"],
prefix = LIB_PREFIX + "linux",
)
[
pkg_tar(
name = "dist" + suffix,
srcs = [
":bins" + suffix,
"//:builtin_headers_pkg_files",
"@llvm-raw//:libcxx_include",
] + select({
"@bazel_tools//src/conditions:darwin": [":libclang_rt.profile_osx"],
"@bazel_tools//src/conditions:linux_aarch64": [":libclang_rt.profile_linux_aarch64"],
"@bazel_tools//src/conditions:linux_x86_64": [":libclang_rt.profile_linux_x86_64"],
}),
empty_files = props.get("extra_empty_files", []),
extension = ".tar.xz",
symlinks = {
"bin/clang++": "./clang",
"bin/clang-cpp": "./clang",
"bin/ld.lld": "./lld",
"bin/ld64.lld": "./lld",
"bin/llvm-strip": "./llvm-objcopy",
},
)
for (suffix, props) in DIST_FLAVORS.items()
]
PLATFORMS = [
"@zig_sdk//platform:darwin_amd64",
"@zig_sdk//platform:darwin_arm64",
"@zig_sdk//libc_aware/platform:linux_arm64_musl",
"@zig_sdk//libc_aware/platform:linux_amd64_musl",
]
[
platform_transition_filegroup(
name = "for_" + platform.split(":")[1],
srcs = [
":dist",
":dist_minimal",
],
target_platform = platform,
)
for platform in PLATFORMS
]
filegroup(
name = "for_all_platforms",
srcs = ["for_" + platform.split(":")[1] for platform in PLATFORMS],
)