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

Support friend-declarations for access to internal members of upstream deps #37

Merged
merged 4 commits into from
Oct 15, 2019

Conversation

cgruber
Copy link
Owner

@cgruber cgruber commented Oct 9, 2019

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 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.

…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.
@@ -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.""",
Copy link

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

@cgruber cgruber merged commit da4fd3a into legacy_continued Oct 15, 2019
@cgruber cgruber deleted the support_1_3_50 branch October 17, 2019 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants