Skip to content

Implemented additional compiler flags for KT-75078 #531

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

Merged
merged 5 commits into from
May 2, 2025

Conversation

mvicsokolova
Copy link
Collaborator

No description provided.

@mvicsokolova mvicsokolova requested a review from shanshin April 28, 2025 08:37
@mvicsokolova
Copy link
Collaborator Author

@shanshin hi! Could you please have a look, if my changes for compiler flags make sense?

https://youtrack.jetbrains.com/issue/KT-75078

@mvicsokolova mvicsokolova requested a review from woainikk April 28, 2025 09:20
fun KotlinCommonCompilerOptions.addExtraCompilerFlags(project: Project) {
val extraOptions = project.rootProject.properties["kotlin_additional_cli_options"] as? String
if (extraOptions != null) {
LOGGER.info("""Adding extra compiler flags '$extraOptions' for a compilation in the project $${project.name}""")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It makes sense to use the same logging format across all our projects, and the one from kotlinx-serialization looks fine: https://github.com/Kotlin/kotlinx.serialization/pull/2996/files#diff-09e3a69c8143d7af22e62f518f556102bbdea00485f9e30be972303bc6c7dc19R58

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you) I've fixed that

* `true` means that warnings should be treated as errors,`false` means that they should not.
*/
private fun warningsAreErrorsOverride(project: Project): Boolean? =
when (val prop = project.rootProject.properties["kotlin_Werror_override"] as? String) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to use providers.gradleProperty instead of project.rootProject.properties, see the changes in the serialization

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed that

* Pass additional CLI options to the Kotlin compiler.
*/
fun KotlinCommonCompilerOptions.addExtraCompilerFlags(project: Project) {
val extraOptions = project.rootProject.properties["kotlin_additional_cli_options"] as? String
Copy link
Contributor

Choose a reason for hiding this comment

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

Same about project.rootProject.properties

@mvicsokolova
Copy link
Collaborator Author

@fzhinkin, hi!) Are we good to merge these changes?

*/
fun KotlinCommonCompilerOptions.addExtraCompilerFlags(project: Project) {
project.providers.gradleProperty("kotlin_additional_cli_options").orNull?.let { options ->
options.removeSurrounding("\"").split(" ").filter { it.isNotBlank() }.forEach {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We discussed it with @woainikk, and it seems like removeSurrounding("\"") is unnecessary here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I just saw that in the implementation for serialization and added here as well

Copy link
Contributor

Choose a reason for hiding this comment

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

after implementing it in serialization, we understand that we can avoid it by passing parameters in other way, so yes, it's not needed anymore, sorry for confusing

@fzhinkin fzhinkin self-requested a review May 1, 2025 12:22
@mvicsokolova mvicsokolova merged commit 97d2e6a into develop May 2, 2025
2 checks passed
@mvicsokolova mvicsokolova deleted the additional-compiler-flags branch May 2, 2025 07:42
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.

4 participants