bazelbuild/bazel

Document providers in C/C++ rules and return values in cc_common

Open

#9.147 geöffnet am 12. Aug. 2019

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Java (4.465 Forks)batch import
P3help wantedteam-Documentationteam-Rules-CPPtype: documentation (cleanup)

Repository-Metriken

Stars
 (25.384 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 22T 20h) (77 gemergte PRs in 30 T)

Beschreibung

Description of the request:

Need to document providers exposed from native rules cc_library, cc_binary (and others) and returned values from cc_common functions.

Feature requests: what underlying problem are you trying to solve with this feature?

I want to write my own rules in C++ project, which uses cc_library, cc_binary as an input, and there is no documentation about how I can use output of those rules. Also my rules are trying to use cc_common utilities and there is a lack of documentation too.

As an example: BUILD

package(default_visibility = ["//visibility:public"])
load("//:my_rule.bzl", "my_rule")

cc_library(
    name = "bar",
    srcs = ["main.cc"],
)

my_rule(
	name = "dump",
	input = ":bar",
)

my_rule.bzl

def _my_rule(ctx):
    input = ctx.attr.input
    print(input.output_groups.dynamic_library)

my_rule = rule(
    implementation = _my_rule,
    attrs = {
        "input": attr.label(),
    },
)

There is no information in documentation that shared library is stored in .output_groups.dynamic_library.

About cc_common: there are many places which not properly documented in https://docs.bazel.build/versions/0.28.0/skylark/lib/cc_common.html , for example

  1. Return value of cc_common.link (CcLinkingOutputs) is not documented
  2. Return value of cc_common.compile (tuple) is not documented (there is no information about content of the tuple)

I think documentation need to be more detailed.

Contributor Guide