-
Notifications
You must be signed in to change notification settings - Fork 13
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
Reintegrate the compiler CLI into this repo, implement toolchains, and update all the things #55
Conversation
Heads up that there's a circular dependency between the cli repo and this repo, so things will be broken until the new cli gets published and then another commit to this repo is made.
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.
I ended up just reviewing the entire repository, as you suggested.
|
||
```python | ||
# update version as needed | ||
rules_play_routes_version = "bfaca5f186f2c3b989c80fd00f37a53b84406b3d" | ||
rules_play_routes_version = "TODO" |
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.
Rather than putting TODO
here or updating this commit manually, should we instruct users to insert the latest commit ID? This applies to the other repositories pulled in here.
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.
Oh, sorry, I should have left a comment.
I intend to update this as soon as I have a commit with everything working. I'm not too concerned about doing much more than that as we'll be moving to bzlmod very soon and Bazel 8 will disable workspace support by default.
|
||
This installs `rules_play_routes` to your `WORKSPACE` and binds the default play routes compiler cli the rules will use. Update the commit as needed. | ||
play_routes_compiler_cli_3_repositories() |
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.
Don't this and play_routes_compiler_cli_2_13_repositories
need to be imported?
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.
Yep. Good catch.
workspace.bzl
Outdated
maven_install( | ||
name = "play_routes_compiler_cli_3", | ||
artifacts = [ | ||
"com.github.scopt:scopt_3:4.1.0", |
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.
Nit: Might we also want to deduplicate the version of scopt
?
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.
Good idea.
play_version = "3.0.4" | ||
specs2_version = "4.20.8" | ||
|
||
def play_routes_test_3_repositories(): |
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.
Nit: There's a lot of overlap between this and play_routes_test_2_13_repositories
. Could we merge them into a single macro?
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.
Yep. I'll change it to have a single underlying private function with two top level public functions to keep calling it simple.
configuration = DEFAULT_TOOLCHAIN_CONFIGURATION, | ||
java_runtime = "@rules_java//toolchains:remotejdk_21", | ||
javac_supports_worker_multiplex_sandboxing = True, | ||
# some of the default options make scala compilation fail in the test package |
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.
Could you elaborate on what these options are?
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.
I believe it's the error prone compiler options. The -Xep
ones
I'm honestly not too familiar with this as I believe I found this like this and copied it over from the other repo https://github.com/google/error-prone
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.
Ah, gotcha. I was just curious, since I wasn't familiar with these.
last play_routes_toolchain_transition. | ||
""" | ||
|
||
if settings[original_toolchain_setting_key] != "": |
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.
Wouldn't it be much simpler to just reset the setting to its default value? In what situation would resetting it to its previous value not be equivalent?
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.
Is it possible to end up in a state in which it wouldn't be equivalent? If not, then we can use the default value.
I was defensively programming here. Are there downsides to doing it this way? If not, then I say we keep it this way to be safe. If so, then I say we go default to avoid the downsides.
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.
Actually, now that I think about it, you could supply a command-line argument to override the default value, in which case they wouldn't be equivalent. This makes the most sense to me.
""" | ||
if attr.play_routes_toolchain_name == "": | ||
return {} | ||
elif settings[toolchain_setting_key] == attr.play_routes_toolchain_name: |
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.
Nit: This can be an if
instead of an elif
.
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.
I'll just combine the if and elif into a single if
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.
Even better!
# we store the original value in | ||
return {} | ||
|
||
new_settings = {} |
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.
Nit:
return {
toolchain_setting_key: attr.play_routes_toolchain_name
original_toolchain_setting_key: json.encode(settings[toolchain_setting_key])
}
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.
FWIW I like the way it is even if it is more verbose as it makes it clearer to those unfamiliar with toolchains that these are new settings because of the variable name.
attrs = { | ||
"srcs": attr.label_list( | ||
doc = "Play routes files", | ||
allow_files = True, | ||
mandatory = True, | ||
cfg = reset_play_routes_toolchain_transition, |
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.
We may want to add a comment explaining that this outgoing transition should be added to every attr.label
or attr.label_list
attribute, lest the configuration change and things be re-built unnecessarily.
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.
Good idea.
play_routes_toolchain_name = play_routes_toolchain_name, | ||
) | ||
|
||
# TOOD: Figure out what this does and add the test for it |
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.
Nit: TODO
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 has been here since the dawn of time for this repo. I don't think anyone's ever figured this one out. I'ma leave it as it's just copy pasted from the CLI repo and was written forever ago.
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.
Ah, okie dokie. There's no problem preserving relics of the past.
55ce187
to
21adb38
Compare
21adb38
to
65f5417
Compare
This brings the Compiler CLI from https://github.com/lucidsoftware/play_routes_compiler_cli back into this repo. Having it split across repos was causing a lot of code duplication. We still will publish the CLI to maven, but it's all in one repo to avoid people copy pasting tests, etc. across the repos.
It also implements toolchains to replace our use of
bind
for choosing which Play routes compiler CLI to use.It also updates nearly all the dependencies.
With how many changes there are in this PR it may just be easier to review the codebase as whole than the diff.