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

fix bazel incompatibilities in proto #454

Merged
merged 1 commit into from
Mar 27, 2018

Conversation

johnynek
Copy link
Member

just the proto part of #452 to address #430

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, couple of questions inside.
Probably need to run some of the Travis configurations

#inline this if after 0.12.0 is the oldest supported version
if hasattr(target.proto, 'transitive_proto_path'):
transitive_proto_paths += target.proto.transitive_proto_path
else:
jvm_deps.append(target)

acc_imports = depset(transitive = acc_imports)
Copy link
Member

Choose a reason for hiding this comment

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

Can we move changing acc_imports to a depset after 44?
In it you’re changing it back to a list which seems redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

so, note that acc_imports as the arg to transitive is a List[Depset] not a List[File] or something, so when we do depset(transitive = acc_imports).to_list() converts a List[Depset] to a List[File].

Copy link
Member

Choose a reason for hiding this comment

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

😱 that's so implicit JavaConversions feels explicit 😉

transitive_proto_paths = depset()

proto_deps, jvm_deps = [], []
for target in ctx.attr.deps:
if hasattr(target, 'proto'):
proto_deps.append(target)
acc_imports += target.proto.transitive_sources
acc_imports.append(target.proto.transitive_sources)
Copy link
Member

Choose a reason for hiding this comment

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

Isn’t transitive_sources a depset? If so isn’t it better to accumulate them in depsets?

Copy link
Member Author

Choose a reason for hiding this comment

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

there is no way to accumulate depsets that is not deprecated. You accumulate a list and then make a depset(transitive = your_list_here)

Copy link
Member

Choose a reason for hiding this comment

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

@laurentlb is this correct? Why can’t we accumulate depsets? Turning depsets to lists so we accumulate them as depsets sounds counter intuitive

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it's correct (https://docs.bazel.build/versions/master/skylark/depsets.html).

  • depset is immutable, so the += operator was misleading
  • we can create only one depset, with the correct structure, and it's much better for performance (adding depset inside a loop could lead to O(n^2) complexity
  • it's more explicit: you see that the depset has n transitive depsets at the same level (which corresponds to the internal representation)

Depsets are not turned into lists. We just collect all the depsets first, and then merge them all at the same time.

Copy link
Member

Choose a reason for hiding this comment

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

Can we pass a depset to the “transitive” argument of the constructor?
What Oscar did is convert them to lists for this ctor which sounds wrong

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 didn’t convert them to lists. I added them to a list. The argument to transitive is a list of Depsets. I constructed that list so I could pass the list of depsets to transitive.

Copy link
Member

Choose a reason for hiding this comment

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

I see, my bad.
Thanks for the clarification

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.

I'm approving though the code seems strange (with respect to depset accumulation).
Let's hope @laurentlb can shed some light

@ittaiz ittaiz merged commit e0d4b14 into master Mar 27, 2018
@ittaiz ittaiz deleted the oscar/fix_incompatibilities_proto 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