Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify how to vary out filename based on configuration #87

Open
mobileink opened this issue Jan 8, 2021 · 2 comments
Open

Clarify how to vary out filename based on configuration #87

mobileink opened this issue Jan 8, 2021 · 2 comments

Comments

@mobileink
Copy link

Custom output requires that the out attribute be configurable. E.g.

    out = select({
        "//:xml": "ocaml_archive.xml",
        "//conditions:default": "ocaml_archive.md"
    }),
@brandjon
Copy link
Member

You're talking about the stardoc rule? The attr/documentation says:

    "out": attr.output(
        doc = "The (markdown) file to which documentation will be output.",
        mandatory = True,
    ),

This suggests a .xml file doesn't make sense (though maybe it works fine with the right template).

But more importantly, I don't believe the attr.output attribute type can be configurable, or that there's anything a Starlark rule can do to change that. This is because outputs declared by attributes are determined to exist during the loading phase, before configuration information is known.

As for the general issue of how to produce one output file or another depending on configuration: I don't know offhand, but it might be possible using a custom rule that sits on top of the stardoc rule. Perhaps the rule would just copy the desired file to have the appropriate name, and return it in the files of DefaultInfo. Or maybe it would use output groups to allow you to choose between files on the command line.

@mobileink
Copy link
Author

mobileink commented Jan 12, 2021 via email

@brandjon brandjon changed the title make 'out' attribute configurable Clarify how to vary out filename based on configuration Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants