GN 代表生成忍者。它生成构建事物的忍者文件。主文件是BUILD.GN在fuchsia源码树的根目录
它包含很多 build_api_module
调用:
build_api_module("images") {
testonly = true
data_keys = [ "images" ]
deps = [
# XXX(46415): as the build is specialized by board (bootfs_only)
# for bringup, it is not possible for this to be complete. As this
# is used in the formation of the build API with infrastructure,
# and infrastructure assumes that the board configuration modulates
# the definition of `zircon-a` between bringup/non-bringup, we can
# not in fact have a complete description. See the associated
# conditional at this group also.
"build/images",
# This has the images referred to by $qemu_kernel_label entries.
"//build/zircon/zbi_tests",
]
}
但是,我不清楚这到底是做什么的。例如查看它在 build/config/build_api_module.gn 上的定义:
template("build_api_module") {
if (current_toolchain == default_toolchain) {
generated_file(target_name) {
outputs = [ "$root_build_dir/$target_name.json" ]
forward_variables_from(invoker,
[
"contents",
"data_keys",
"deps",
"metadata",
"testonly",
"visibility",
"walk_keys",
"rebase",
])
output_conversion = "json"
metadata = {
build_api_modules = [ target_name ]
if (defined(invoker.metadata)) {
forward_variables_from(invoker.metadata, "*", [ "build_api_modules" ])
}
}
}
} else {
not_needed([ "target_name" ])
not_needed(invoker, "*")
}
}
看起来它只是生成了一个文件。
有人可以向我解释一下 build_api_module("images")
是如何构建所有锆石内核映像的吗?
答案 0 :(得分:0)
build_api_module()
目标生成 JSON 文件,描述有关当前构建系统配置的一些信息。这些文件通常由需要了解当前构建的其他工具(在某些情况下依赖于其他构建规则)使用。
一个例子是生成 tests.json
文件的 tests target。 fx test
使用此文件来确定哪些测试可用,并将您提供的测试名称与要调用的组件 URL 相匹配。
有人可以向我解释一下 build_api_module("images")
是如何构建所有锆石内核映像的吗?
它没有。这些目标是对当前构建配置的描述性,而不是对构建生成的工件的描述性。在这种特定情况下,FEMU 和 images.json
等工具通常使用 ffx
文件来确定要在目标设备上使用的系统映像。