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

Introduce mandatoryScalacOptions to keep system scalacOptions #1428

Merged
merged 6 commits into from
Aug 24, 2021

Conversation

lolgab
Copy link
Member

@lolgab lolgab commented Jul 29, 2021

It's easy to override scalacOptions in a Scala.js + Scala 3 module.
When you do so, the compiler silently fails to compile Scala.js files.
This is a source of errors for Mill users that can be mitigated by
defining a separate list of compile options which is used internally
to add these mandatory flags.

@lolgab lolgab requested a review from lefou July 29, 2021 08:12
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

I agree this is a very useful new setting/target. Yet, I don't like the chosen name. The suffix "internal" doesn't transport any meaning or purpose. Can you elaborate. Something like "platformScalacOptions" came to my mind, but I'm very open for better suggestions.

@lolgab
Copy link
Member Author

lolgab commented Aug 12, 2021

I used internalScalacOptions in the sense that they are Mill internal options that users don't need / shouldn't touch (they are still protected so users can change them if they have good reasons to do so).
If we call them platformScalacOptions then they can't be reused in plugins or other scopes to define scalacOptions that people should not change otherwise things break if you remove them. ( I'm imagining Scalafix specific scalacOptions, foo specific scalacOptions or things like that ).

@lefou lefou added the feedback wanted Additional feedback or testing is apreciated label Aug 17, 2021
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

The allScalacOptions is nice. It also aligns with e.g. allSources.

I still struggle with the name. What about mandatoryScalacOptions. It reflects it own current scaladoc and tells it's purpose.

@lolgab
Copy link
Member Author

lolgab commented Aug 24, 2021

The allScalacOptions is nice. It also aligns with e.g. allSources.

Cool! Also cool that it aligns since I didn't think about allSources 😄

I still struggle with the name. What about mandatoryScalacOptions. It reflects it own current scaladoc and tells it's purpose.

I like it! Going to change it to mandatoryScalacOptions.

It's easy to override scalacOptions in a Scala.js + Scala 3 module.
When you do so, the compiler silently fails to compile Scala.js files.
This is a source of errors for Mill users that can be mitigated by
defining a separate list of compile options which is used internally
to add these mandatory flags.
It's important that all consumers use both the user defined options and
internalScalacOptions. So we define `allScalacOptions` for consumers.
Improve Scaladoc in allScalacOptions and scalacOptions
@lolgab
Copy link
Member Author

lolgab commented Aug 24, 2021

I am now thinking, what if we change scalacOptions visibility to protected?
We are already breaking binary compatibility for 0.10 and consumers should now use allScalacOptions to read the options.
The only components that need to see scalacOptions are subclasses to override them, so protected seems the perfect visibility.
@lefou Let me know if I'm missing something.

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Only some minor text suggestions.

scalalib/src/ScalaModule.scala Outdated Show resolved Hide resolved
scalalib/src/ScalaModule.scala Outdated Show resolved Hide resolved
@lefou
Copy link
Member

lefou commented Aug 24, 2021

I am now thinking, what if we change scalacOptions visibility to protected?
We are already breaking binary compatibility for 0.10 and consumers should now use allScalacOptions to read the options.
The only components that need to see scalacOptions are subclasses to override them, so protected seems the perfect visibility.
@lefou Let me know if I'm missing something.

I don't think this is a good idea. Although we're designing an API here, we also try to build a convenient build tool, and in such a scenario pragmatic solutions are in most cases preferred over lengthy and well-constructed code. You never know how this is going to be used. E.g. if I'm going to need the same options in another module and some visibility prohibits it that would be rather inconvenient. I don't see any big issues with having the scalacOptions public. It's in mills concept, that some targets present some rather intermediate or detailed interim results. You don't want to save some user from using it by restricting it for all. Take the sources vs. allSources as another example. There are perfect reasons in a real project build, to access both from the outside.
And if this is not enough: being public means I can invoke and also debug (via show) the target from the command line (or a tool).

@lolgab lolgab changed the title Introduce internalScalacOptions to keep system scalacOptions Introduce mandatoryScalacOptions to keep system scalacOptions Aug 24, 2021
lolgab and others added 2 commits August 24, 2021 12:42
Co-authored-by: Tobias Roeser <le.petit.fou@web.de>
Co-authored-by: Tobias Roeser <le.petit.fou@web.de>
@lolgab
Copy link
Member Author

lolgab commented Aug 24, 2021

And if this is not enough: being public means I can invoke and also debug (via show) the target from the command line (or a tool).

This alone is already a more than legit reason to leave it public. I imagine users that are used to check this value from the command line and then, subtlety, can't.
Thank you for the thorough reasoning :)

@lefou lefou merged commit 3aaec28 into com-lihaoyi:main Aug 24, 2021
@lefou lefou added this to the 0.10.0 milestone Aug 24, 2021
@lefou lefou removed the feedback wanted Additional feedback or testing is apreciated label Aug 24, 2021
@lefou
Copy link
Member

lefou commented Aug 24, 2021

@lolgab Thank you!

@lolgab lolgab deleted the add-internalScalacOptions branch August 24, 2021 13:38
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.

2 participants