-1

基本上我想要的只是cp -r src/ dist/,但由于某种原因,我根本无法让它工作。

目前我正在尝试:

filegroup(
    name = "src_files",
    srcs = glob([
        "src/**",
    ]),
)
filegroup(
    name = "dist_files",
    srcs = glob([
        "dist/**"
    ]),
)
genrule(
    name = "copy",
    srcs = ["//packages/variables:src_files"],
    outs = ["//packages/variables:dist_files"],
    cmd = "cp -R $(locations //packages/variables:src_files) $(locations //packages/variables:dist_files)"
)

我已经浏览了至少 4 页的 google 和文档,但似乎除非我创建一个 genrule 并在规则中手动指定所有 100 个文件,否则它不会起作用?

4

1 回答 1

0

@JamesSharpe 有我所缺少的,将 BUILD 文件更新为:

filegroup(
    name = "src_files",
    srcs = glob([
        "src/**",
    ]),
)
pkg_tar(
    name = "pack_srcs",
    extension = "tar.gz",
    srcs = [":src_files"],
)
genrule(
    name = "unpack_to_dist",
    srcs = [":pack_srcs"],
    outs = ["dist"],
    cmd = "mkdir $(RULEDIR)/dist && tar -C $(RULEDIR)/dist -zxvf $(SRCS)"
)

并且能够成功地将其传递给下游规则。

于 2020-09-14T22:35:28.863 回答