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

K2 plugin #116

Merged
merged 5 commits into from
Aug 6, 2024
Merged

K2 plugin #116

merged 5 commits into from
Aug 6, 2024

Conversation

Mr3zee
Copy link
Collaborator

@Mr3zee Mr3zee commented Jun 25, 2024

Subsystem
K2 Compiler plugin

Problem Description
We are migrating from KSP code generation to compiler plugins.

Solution
This is part 2 of 3 in the migration process, which presents the K2 frontend plugin.

K2 plugin overview:

  • Detects RPC services
  • Generated minimal service stub implementation class and its companion object
  • Generates minimal method classes declarations
  • Executes serialization plugin manually for generated classes

Also PR contains addition of an compiler-plugin-common module for shared declarations between backend and frontend(s).

PR contains upgrade to Kotlin 2.0 as it required to make K2 plugin work. Project language level is set to 1.7 by default, so K2 will not be used by default. For it to be used in tests, use dedicated kotlinx.rpc.useK2Plugin=true in root gradle.properties

@Mr3zee
Copy link
Collaborator Author

Mr3zee commented Aug 3, 2024

No tests will be executed for this review for two reasons:

  • No compiler plugin tests are present atm (will be added in the subsequent PRs)
  • Versions earlier than 2.0 will fail due to broken KSP (will be fixed in the subsequent PR)

I tested the PR locally, and it works for existing tests, I just don't want to have an intermediate state of CI configs just for this review.
All will be set before merging into main

@Mr3zee Mr3zee marked this pull request as ready for review August 3, 2024 11:05
@Mr3zee Mr3zee requested a review from e5l August 3, 2024 11:05
Comment on lines -65 to +71
tasks.withType<ProcessResources>().configureEach {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

from(versionNames.map { vsResources.resolve(it) })
include { it.file.parentInAllowList(versionNames) }
}
// todo duplicate (or to many resources are copied, should update the algo)
// tasks.withType<ProcessResources>().configureEach {
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
//
// from(versionNames.map { vsResources.resolve(it) })
// include { it.file.parentInAllowList(versionNames) }
// }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will fix it in a separate PR

Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

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

Let's get someone from the compiler team to check it out as well

@Mr3zee
Copy link
Collaborator Author

Mr3zee commented Aug 5, 2024

@e5l do you have someone specific in mind?

UPD: nevermind, I see

@demiurg906 demiurg906 self-requested a review August 5, 2024 09:57
Copy link
Member

@demiurg906 demiurg906 left a comment

Choose a reason for hiding this comment

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

Generally, the approach is fine

But I recall that we discussed that the plugin also should check some invariants with checkers, and I don't see them here

Will they be implemented later, or I confused it with some other plugin?

@Suppress("unused")
private val logger: MessageCollector,
) : FirDeclarationGenerationExtension(session) {
private val serializationExtension = SerializationFirResolveExtension(session)
Copy link
Member

Choose a reason for hiding this comment

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

The trick with your own generator from serialization plugin is nice
Like it

@Mr3zee
Copy link
Collaborator Author

Mr3zee commented Aug 5, 2024

@demiurg906 thanks for the review!

Yes, you're right, we talked about checkers, they will be shipped separately

@Mr3zee Mr3zee merged commit dd942ec into compiler-plugin Aug 6, 2024
Mr3zee added a commit that referenced this pull request Aug 6, 2024
* Introduce K2 plugin

* Update IR backend

* Update to 2.0

* Fix for KT-70132
@Mr3zee Mr3zee deleted the k2-plugin branch August 6, 2024 13:58
Mr3zee added a commit that referenced this pull request Aug 13, 2024
* Introduce K2 plugin

* Update IR backend

* Update to 2.0

* Fix for KT-70132
Mr3zee added a commit that referenced this pull request Aug 15, 2024
* Introduce K2 plugin

* Update IR backend

* Update to 2.0

* Fix for KT-70132
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