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

Add a ThriftInfo provider #464

Merged
merged 3 commits into from
Apr 2, 2018
Merged

Add a ThriftInfo provider #464

merged 3 commits into from
Apr 2, 2018

Conversation

johnynek
Copy link
Member

This updates thrift to use a modern provider instead of an anonymous struct.

This is part of #450

ptal @andyscott @ittaiz

@@ -2,6 +2,8 @@

_thrift_filetype = FileType([".thrift"])

ThriftInfo = provider(fields=["srcs", "transitive_srcs", "external_jars", "transitive_external_jars"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: format this with each field on a new line
also consider adding a one line comment to each provider field to document what it's for

for jar in thrift.external_jars:
r.extend(_jar_filetype.filter(jar.files))
r.extend(_jar_filetype.filter(thrift.transitive_external_jars))
return depset(r)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using the transitive parameter on the depset constructor. Something like this might work:

depset(transitive =
  [_jar_filetype.filter(jar.files) for jar in thrift.external_jars] +
  [_jar_filetype.filter(thrift.transitive_external_jars)]
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note that FileType is deprecated and we should move away from it (maybe in another PR).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that works because transitive is a list of depsets while the arg to depset is a list of items (non-depset). I could make singleton depsets, but I assume that is slower than just putting it in the first arg since it is adding more nesting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 makes sense. I'm not terribly familiar with the thrift code so it wasn't immediately apparent what's a depset and what's not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, me neither. Especially due to the lack of types... :(

@andyscott
Copy link
Contributor

LGTM

Copy link
Member

@ittaiz ittaiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ittaiz ittaiz merged commit 06e9fc1 into master Apr 2, 2018
ianoc-stripe pushed a commit to ianoc-stripe/rules_scala that referenced this pull request Jun 12, 2018
* Add a ThriftInfo provider

* minor cleanup

* address review comments
@ittaiz ittaiz deleted the oscar/thrift_provider branch July 1, 2018 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants