forked from hermeticbuild/hermetic-llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirectory.bzl
More file actions
54 lines (47 loc) · 1.48 KB
/
directory.bzl
File metadata and controls
54 lines (47 loc) · 1.48 KB
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
load("@bazel_skylib//rules/directory:directory.bzl", "directory")
load("@bazel_skylib//rules/directory:providers.bzl", "DirectoryInfo")
load("@bazel_skylib//rules/directory:subdirectory.bzl", "subdirectory")
# We want to put a source directory into the DefaultInfo but still propagate
# the DirectoryInfo for header inclusion checking.
def headers_directory(name, path, visibility = None):
if path == ".":
directory(
name = name + "_directory",
srcs = native.glob(["**"]),
)
else:
directory(
name = name + "_files",
srcs = native.glob([path + "/**"]),
)
subdirectory(
name = name + "_directory",
path = path,
parent = name + "_files",
)
native.filegroup(
name = name + "_source_directory",
srcs = [path],
)
_headers_directory(
name = name,
directory = name + "_directory",
source_directory = name + "_source_directory",
visibility = visibility,
)
SourceDirectoryInfo = provider("Marker Provider", fields = [])
def _headers_directory_impl(ctx):
return [
ctx.attr.directory[DirectoryInfo],
SourceDirectoryInfo(),
DefaultInfo(
files = ctx.attr.source_directory[DefaultInfo].files,
),
]
_headers_directory = rule(
implementation = _headers_directory_impl,
attrs = {
"directory": attr.label(),
"source_directory": attr.label(),
},
)