This is an archive of the discontinued LLVM Phabricator instance.

[Bazel] Make td_library usable as data
ClosedPublic

Authored by GMNGeoffrey on Jul 27 2021, 3:42 PM.

Details

Summary

This patch makes it possible to list a td_library as a rule's data
attribute and get its source files and all its transitive dependencies
at runtime. This is useful for, e.g. shell tests running tblgen.

Note that this is a bit different from how a "normal" (e.g. C++) library
rule would work because those have actual library outputs and the
td_library rule just bundles some source files and includes. If someone
wanted to make use of the includes, they would have to access the TdInfo
provider, but this keeps simple things simple.

Diff Detail

Event Timeline

GMNGeoffrey created this revision.Jul 27 2021, 3:42 PM
GMNGeoffrey requested review of this revision.Jul 27 2021, 3:42 PM
GMNGeoffrey edited the summary of this revision. (Show Details)Jul 27 2021, 4:23 PM
jpienaar added inline comments.Jul 27 2021, 4:55 PM
utils/bazel/llvm-project-overlay/mlir/tblgen.bzl
105

"to produce on the output" is difficult to parse for me

267

High-level comment here too?

  • Fix typo
utils/bazel/llvm-project-overlay/mlir/tblgen.bzl
105

That's because it makes no sense :-D Fixed

267

I was less sure on this one since here we're gathering the files that gentbl_test itself needs to execute, which is much more normal. The gathering of runfiles from dependencies is just following the advice at https://docs.bazel.build/versions/main/skylark/rules.html#runfiles.

Rebase on main

Ping on this? Any concerns? I'm happy to add a comment if you'd like Jacques :-D

jpienaar accepted this revision.Jul 29 2021, 6:09 PM

Works for me, thanks!

This revision is now accepted and ready to land.Jul 29 2021, 6:09 PM
This revision was automatically updated to reflect the committed changes.