Tensorflow的Bazel编程(六)

最后看的是Protocol Buffer Rules和shell Rules

proto_lang_toolchain(name, deps, data, blacklisted_protos, command_line, compatible_with, deprecation, distribs, features, licenses, plugin, restricted_to, runtime, tags, testonly, visibility)

例子:

proto_lang_toolchain(
    name = "javalite_toolchain",
    command_line = "--$(PLUGIN_OUT)=shared,immutable:$(OUT)",
    plugin = ":javalite_plugin",
    runtime = ":protobuf_lite",
)

Arguments

Attributes
name

Name; required

A unique name for this rule.

blacklisted_protos

List of labels; optional

No code will be generated for files in the srcs attribute of blacklisted_protos. This is used for .proto files that are already linked into proto runtimes, such as any.proto.
command_line

String; required

This value will be passed to proto-compiler to generate the code. Only include the parts specific to this code-generator/plugin (e.g., do not include -I parameters)
  • $(OUT) is LANG_proto_library-specific. The rules are expected to define how they interpret this variable. For Java, for example, $(OUT) will be replaced with the src-jar filename to create.
  • $(PLUGIN_out) will be substituted to work with a `--plugin=protoc-gen-PLUGIN` command line.
plugin

Label; optional

If provided, will be made available to the action that calls the proto-compiler, and will be passed to the proto-compiler: --plugin=protoc-gen-PLUGIN=.
runtime

Label; optional

A language-specific library that the generated code is compiled against. The exact behavior is LANG_proto_librar-specific. Java, for example, should compile against the runtime.

sh_binary

sh_binary(name, deps, srcs, data, args, compatible_with, deprecation, distribs, features, licenses, output_licenses, restricted_to, tags, testonly, visibility)
Example

For a simple shell script with no dependencies or data:

sh_binary(
    name = "foo",
    srcs = ["foo.sh"],
    data = glob(["datafiles/*.txt"]),
)

Arguments

Attributes
name

Name; required

A unique name for this rule.

deps

List of labels; optional

The list of "library" targets to be aggregated into this target. See general comments about deps at Attributes common to all build rules .

This attribute should be used to list other sh_library rules that provide interpreted program source code depended on by the code in srcs. The files provided by these rules will be present among the runfiles of this target.

srcs

List of labels; required

The file containing the shell script.

This attribute must be a singleton list, whose element is the shell script. This script must be executable, and may be a source file or a generated file. All other files required at runtime (whether scripts or data) belong in the data attribute.

sh_library

sh_library(name, deps, srcs, data, compatible_with, deprecation, distribs, features, licenses, restricted_to, tags, testonly, visibility)
Examples
sh_library(
    name = "foo",
    data = [
        ":foo_service_script",  # an sh_binary with srcs
        ":deploy_foo",  # another sh_binary with srcs
    ],
)

Arguments

Attributes
name

Name; required

A unique name for this rule.

deps

List of labels; optional

The list of "library" targets to be aggregated into this target. See general comments about deps at Attributes common to all build rules .

This attribute should be used to list other sh_library rules that provide interpreted program source code depended on by the code in srcs. The files provided by these rules will be present among the runfiles of this target.

srcs

List of labels; optional

The list of input files.

This attribute should be used to list shell script source files that belong to this library. Scripts can load other scripts using the shell's source or . command.

sh_test

sh_test(name, deps, srcs, data, args, compatible_with, deprecation, distribs, features, flaky, licenses, local, restricted_to, shard_count, size, tags, testonly, timeout, visibility)
Examples
sh_test(
    name = "foo_integration_test",
    size = "small",
    srcs = ["foo_integration_test.sh"],
    deps = [":foo_sh_lib"],
    data = glob(["testdata/*.txt"]),
)

Arguments

Attributes
name

Name; required

A unique name for this rule.

deps

List of labels; optional

The list of "library" targets to be aggregated into this target. See general comments about deps at Attributes common to all build rules .

This attribute should be used to list other sh_library rules that provide interpreted program source code depended on by the code in srcs. The files provided by these rules will be present among the runfiles of this target.

srcs

List of labels; required

The file containing the shell script.

This attribute must be a singleton list, whose element is the shell script. This script must be executable, and may be a source file or a generated file. All other files required at runtime (whether scripts or data) belong in the data attribute.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值