有哪些不同类型的runfiles

时间:2017-05-12 11:27:57

标签: bazel

DefaultInfo的文档中,我们现在可以返回3种不同的"类型"运行文件:

runfiles
data_runfiles
default_runfiles

我找不到任何文档,这些文档之间的分离和何时使用哪个。任何人都可以详细说明吗?

1 个答案:

答案 0 :(得分:6)

data_runfiles是添加到二进制文件的运行文件中的文件,它依赖于data属性的规则。 default_runfiles是添加到二进制文件的运行文件中的文件,它依赖于除data属性之外的任何内容的规则。 runfiles是创建DefaultInfo的简写,data_runfiles具有与default_runfilesfilegroup相同的文件集。

请考虑以下涉及filegroup规则的示例。 (我不完全确定为什么data关心它是否通过# BUILD filegroup( name = "a", srcs = ["b"], data = ["c"], ) sh_binary( name = "bin1", srcs = ["bin.sh"], deps = [":a"], ) sh_binary( name = "bin2", srcs = ["bin.sh"], data = [":a"], ) # bin.sh ls 属性引用,但确实如此,它就是一个简单的例子。)

b

我们发现文件:bin2位于:bin1的运行文件中,而不是$ bazel run //:bin1 bin1 bin.sh c $ bazel run //:bin2 b bin2 bin.sh c

default_runfiles

现在让我们直接查看data_runfiles# my_rule.bzl def _impl(ctx): print(ctx.attr.dep.default_runfiles.files) print(ctx.attr.dep.data_runfiles.files) my_rule = rule( implementation = _impl, attrs = {"dep": attr.label()}, ) # BUILD load("//:my_rule.bzl", "my_rule") my_rule(name = "foo", dep = ":a") $ bazel build //:foo WARNING: /usr/local/google/home/ajmichael/playgrounds/runfiles/my_rule.bzl:2:3: depset([File:[/usr/local/google/home/ajmichael/playgrounds/runfiles[source]]c]). WARNING: /usr/local/google/home/ajmichael/playgrounds/runfiles/my_rule.bzl:3:3: depset([File:[/usr/local/google/home/ajmichael/playgrounds/runfiles[source]]b, File:[/usr/local/google/home/ajmichael/playgrounds/runfiles[source]]c]). INFO: Found 1 target... Target //:foo up-to-date (nothing to build) INFO: Elapsed time: 0.194s, Critical Path: 0.00s

default_runfiles

如您所见,c仅包含data_runfilesb包含cangular.module('TrackerApp').factory('TrackerFactory', function ($resource, CacheFactory) { if (!CacheFactory.get('CenterCache')) { console.log('cache does not exists'); CacheFactory.createCache('CenterCache', { maxAge: 5 * 60 * 1000, deleteOnExpire: 'aggressive' }); } var centerCache = CacheFactory.get('CenterCache'); var CenterClass = $resource(_ServiceBaseURL + 'api/Center/:id',{},{ query: { method: 'GET', cache: centerCache, isArray:true } }); CenterClass.GetMultipleAsObject = function () { return this.query(); }; return { CenterClass: CenterClass }; });