-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathforward_files.bzl
35 lines (32 loc) · 1009 Bytes
/
forward_files.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
# -*- python -*-
def forward_files(
srcs,
strip_prefix,
dest_prefix,
visibility = None,
tags = []):
"""Forwards files in `srcs` to be physically present in the current
packages.
Present implementation simply copies the files.
@param srcs
List of string, pointing *directly* to files. Does not handle filegroup
targets.
@param strip_prefix
String to be stripped from source files. Should include trailing slash.
@param dest_prefix
String to be prepended to target.
"""
outs = []
for src in srcs:
if not src.startswith(strip_prefix):
fail("'{}' not under '{}'".format(src, strip_prefix))
out = dest_prefix + src[len(strip_prefix):]
native.genrule(
name = out + ".forward",
srcs = [src],
outs = [out],
cmd = "cp $< $@",
tags = tags,
visibility = visibility,
)
outs.append(out)