简体   繁体   English

有没有办法为特定规则生成deps列表?

[英]Is there any way to generate the deps list for particular rules?

I have a program that can look at my language's source file, and derive the correct value for the deps=[] value of its build rule. 我有一个程序可以查看我的语言的源文件,并为其构建规则的deps=[]值派生正确的值。

I'm looking for a way to replace all my existing rules (that look like this): 我正在寻找一种方法来替换我现有的所有规则(看起来像这样):

build_lib(name = "foo", deps = [...])
build_lib(name = "bar", deps = [...])
build_lib(name = "baz", deps = [...])

To instead be: 相反是:

build_lib_new(name = "foo")
build_lib_new(name = "bar")
build_lib_new(name = "baz")

with the same specified deps resolved internally in the rule by calling my program. 通过调用我的程序在规则内部解析相同的指定deps。

Ideally, build_lib_new would just be a wrapper rule around build_lib : 理想情况下, build_lib_new也只是围绕一个包装规则build_lib

def derive_deps(name):
    deps = []
    # call my tool somehow?
    return deps

def build_lib_new(name):
    deps = derive_deps(name)
    build_lib(name,deps)

Now I'm stuck. 现在我被卡住了。 Unfortunately, I think bazel wants to know all the dependencies up front as part of the analysis phase. 不幸的是,我认为bazel希望在分析阶段预先了解所有依赖关系。 I see that their are actions to run shell commands, but I believe those happen after the dependency graph is made. 我看到他们是运行shell命令的动作,但我相信这些是在创建依赖图之后发生的。

Do I have to run the external tool outside of bazel to rewrite BUILD files? 我是否必须在bazel之外运行外部工具来重写BUILD文件?

Do I have to run the external tool outside of bazel to rewrite BUILD files? 我是否必须在bazel之外运行外部工具来重写BUILD文件?

In short, yes. 简而言之,是的。 This is why tools like Gazelle and Jadep exist. 这就是为什么像Gazelle和Jadep这样的工具存在的原因。

If your tool runs as actions during execution phase, then the deps would be non-existent during loading and analysis phase. 如果您的工具执行阶段作为操作运行,那么在加载和分析阶段,deps将不存在。 You'll need to run the tool before loading/analysis, maybe as a repository rule ? 您需要加载/分析之前运行该工具,可能作为存储库规则

I see that their are actions to run shell commands, but I believe those happen after the dependency graph is made. 我看到他们是运行shell命令的动作,但我相信这些是在创建依赖图之后发生的。

Correct. 正确。 The analysis phase creates the configured target graph, and reifies it into the action (shell commands, artifacts, etc) graph for the execution phase. 分析阶段创建配置的目标图,并将其强制执行到执行阶段的操作(shell命令,工件等)图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails:特定应用程序使用的Gems列表 - Rails: List of Gems being used by a particular application 是否有任何工具或技术可以让php发现特定类所依赖的所有类? - Are there any tools or techniques for php to discover all classes particular class depends on? 有什么方法可以下载旧版本的Appcompat库? - Is there any way to download old versions of appcompat libraries? 在pom.xml中生成Maven依赖关系的简单方法? - Easy way to generate Maven dependencies in pom.xml? 有没有一种方法可以在build.gradle中自动生成gradle依赖声明? - Is there a way to automatically generate the gradle dependencies declaration in build.gradle? 哪种工具(或工具链)将生成.NET程序集所需的DLL的完整列表? - What tool (or toolchain) will generate a complete list of DLLs required by a .NET assembly? 有没有办法从yum中检索依赖树? - Is there any way to retrieve a dependency tree from yum? 有没有办法根据任何属性搜索/查询 NPM? - Is there a way to search/query NPM based on any of the attributes? docker-是否可以查看所有先前的Dockerfile? - docker - Any way to view all preceding Dockerfiles? 如何在下载前告诉钢筋在另一个目录中检查dep? - How to tell rebar to check for deps in another directory prior to downloading them?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM