-
Notifications
You must be signed in to change notification settings - Fork 281
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
For Windows: Fix to enable scala_test and scala_binary outputs to be executed on Windows #1502
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Passing the correct path forms (i.e. rpathlocation vs rootpath) to Windows Launcher. This enables running scala_test and scala_binary outputs through bazel on windows.
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.
Thanks, @crt-31! LGTM (assuming I have no Windows environment to test), please address the nits.
scala/private/common.bzl
Outdated
#generates rpathlocation that should be used with the rlocation() at runtime. (rpathlocations start with repo name) | ||
#rootpath arg expects "rootpath" format (i.e. relative to runfilesDir/workspacename). Rootpath can be obtained by $rootpath macro or File.short_path | ||
def rpathlocation_from_rootpath(ctx, rootpath): | ||
p = paths.normalize(ctx.workspace_name + "/" + rootpath) |
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: please inline p
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.
done.
|
||
cpfile = ctx.actions.declare_file("%s.classpath" % ctx.label.name) | ||
ctx.actions.write(cpfile, classpath) | ||
|
||
specifiedEnv = {} |
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 add code comment explaining this change. Also, please consider using https://bazel.build/rules/lib/globals/all#getattr with a default value
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.
done
- Added comment on use of env in _write_executable_windows() - Removed unecessary var in rpathlocation_from_rootpath()
Description
For Windows, this PR fixes issue where outputs of scala_test and scala_binary are failing when ran with 'bazel run' and 'bazel test'. When trying to do run or test, Bazel shows error like:
The Fix: On Windows, Bazel’s Java Launcher was being passed paths in the wrong ‘form’. The launcher expects rpathlocation form for some paths and rootpath form for others. Fix is to pass the right forms of the paths to the LauncherFileWriter which in turn passes correct paths into the Launcher.
Motivation
scala_test and scala_binary should work properly on Windows
Seems to have been caused by #1313
Should also fix #1497
Test/Reproduction
The following can be used as a demonstration test on windows (will fail before this PR):
bazel test //test/RunScalaBinary --enable_runfiles --extra_toolchains=//scala:minimal_direct_source_deps
Note that: 'bazel test' requires --enable_runfiles to be set on Windows.
Also note that many other tests fail in Windows, but fixes for those are for a separate PR.