forked from bazelbuild/rules_kotlin
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support friend-declarations for access to internal members of upstream deps #37
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…on another compilation unit, causing it to (a) share a module definition, and (b) have access to the internal members of that library. This expands the current feature which exposes this to test only, and generalizes it. It also addresses an issue in kotlinc (https://youtrack.jetbrains.com/issue/KT-34277) whereby `-Xfriends-path` is interpreted using different path separators between JS and JVM. The present code uses File.pathSeparator to obtain the platform-specific separator. However, the JVM backend uses a system which separates path elements with a comma, as a list. There's also some application of ktlint and buildifier on some files involved in this PR. Finally, the dagger example is partitioned into smaller pieces, to illustrate and validate the use of friend declarations, directly and transitively.
cgruber
force-pushed
the
support_1_3_50
branch
from
October 9, 2019 18:37
dccd083
to
0780508
Compare
inez
reviewed
Oct 9, 2019
src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt
Show resolved
Hide resolved
rogerhu
reviewed
Oct 10, 2019
rogerhu
reviewed
Oct 10, 2019
@@ -161,6 +161,11 @@ _common_attr = utils.add_dicts( | |||
default = [], | |||
allow_files = False, | |||
), | |||
"friend": attr.label( | |||
doc = """A single Kotlin dep which allows this code to access internal members of the given dependency. | |||
Currently uses the output jar of the module -- i.e., exported deps won't be included.""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example helped me understand what you were talking about: https://youtrack.jetbrains.com/issue/KT-34251
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: bazelbuild#211
rogerhu
approved these changes
Oct 10, 2019
inez
approved these changes
Oct 10, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add more robust support for
friend
declarations of a library or test on another compilation unit, causing it to (a) share a module definition, and (b) have access to theinternal
members of that library. This expands the current feature which exposes this to test only, and generalizes it.It also addresses an issue in kotlinc (https://youtrack.jetbrains.com/issue/KT-34277) whereby
-Xfriends-path
is interpreted using different path separators between JS and JVM. The present code usesFile.pathSeparator
to obtain the platform-specific separator. However, the JVM backend uses a system which separates path elements with a comma, as a list.There's also some application of ktlint and buildifier on some files involved in this PR.
Finally, the dagger example is partitioned into smaller pieces, to illustrate and validate the use of
friend
declarations, directly and transitively.