【发布时间】:2019-08-26 17:28:06
【问题描述】:
我有两个宏/目标:组件和捆绑包(打包了几个组件)。我想扩展 bundle 宏以接受除了组件列表之外的捆绑列表,并将所有组件直接包含或包含在其中一个包含的捆绑包中。
例如,如果我有以下BUILD 文件:
component(name = 'a')
component(name = 'b')
component(name = 'c')
component(name = 'd')
bundle(name = 'x', components = ['a'])
bundle(name = 'y', components = ['b', 'c'], bundles = ['x'])
bundle(name = 'z', components = ['d'], bundles = ['y'])
Bundle z 应该包含组件 a、b、c 和 d
.bzl 文件现在是这样的:
def component(name):
# implementation (it uses other args but they aren't relevant)
def bundle(name, components = []):
# complex logic on components
我想要的是:
def bundle(name, components = [], bundles = []):
for bundle in bundles:
for component in TODO_get_components_in_bundle(bundle):
if component not in components:
components.append(component)
# complex logic on components
如何实现TODO_get_components_in_bundle或者达到同样的效果?
【问题讨论】:
-
components在bundle中是如何使用的?它们最终会出现在原生规则的领域吗?
标签: bazel