-
Notifications
You must be signed in to change notification settings - Fork 1
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
More Workspace Info #98
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e486674
done
aishfenton 9b782ca
refactors
aishfenton 0fbfbc0
typoes
aishfenton 34e4a5f
done
aishfenton 1b6dbb8
add to github actions
aishfenton 4ed7de1
done
aishfenton 20b21d0
Merge branch 'main' into aish/workspaceInfo
aishfenton b80fa8e
better error message
aishfenton 61f9af3
done
aishfenton 7559656
fix wrong path
aishfenton 3a634c3
pr feedback
aishfenton 58a5c22
Merge branch 'main' into aish/workspaceInfoInScala
aishfenton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
load("@io_bazel_rules_scala//scala/private/toolchain_deps:toolchain_deps.bzl", "find_deps_info_on") | ||
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSION") | ||
|
||
def _copy_files(ctx, files): | ||
output_files = [] | ||
|
||
for file in files: | ||
output_file = ctx.actions.declare_file(ctx.attr.name + "_" + file.basename) | ||
|
||
ctx.actions.run_shell( | ||
inputs = [file], | ||
outputs = [output_file], | ||
command = "cp {src} {out}".format(src = file.path, out = output_file.path), | ||
) | ||
|
||
output_files.append(output_file) | ||
|
||
return output_files | ||
|
||
def _bsp_workspace_info_impl(ctx): | ||
""" | ||
Outputs metadata about the BSP workspace, as well as copying depenendies to output (so that downstream tools can use them) | ||
|
||
Args: | ||
ctx: The context object. | ||
|
||
Returns: | ||
A list of dependencies for the BSP workspace. | ||
""" | ||
|
||
compile_classpath = [ | ||
file | ||
for deps in find_deps_info_on(ctx, "@io_bazel_rules_scala//scala:toolchain_type", "scala_compile_classpath").deps | ||
for file in deps[JavaInfo].compile_jars.to_list() | ||
] | ||
|
||
# Why not use the class_jar in SemanticdbInfo? Because it's a string, not a File, so we can't pass | ||
# pass it to outputs. | ||
# https://github.com/bazelbuild/rules_scala/issues/1527 | ||
semanticdb_classpath = [ | ||
file | ||
for deps in find_deps_info_on(ctx, "@io_bazel_rules_scala//scala:toolchain_type", "semanticdb").deps | ||
for file in deps[JavaInfo].compile_jars.to_list() | ||
] | ||
|
||
scalac_output_files = _copy_files(ctx, compile_classpath) | ||
semanticdb_output_files = _copy_files(ctx, semanticdb_classpath) | ||
|
||
json_output_file = ctx.actions.declare_file(ctx.attr.name + ".json") | ||
output_struct = struct( | ||
scala_version = SCALA_VERSION, | ||
scalac_deps = [file.path for file in scalac_output_files], | ||
semanticdb_dep = [file.path for file in semanticdb_output_files][0], | ||
) | ||
ctx.actions.write(json_output_file, json.encode_indent(output_struct)) | ||
|
||
return [DefaultInfo(files = depset(scalac_output_files + semanticdb_output_files + [json_output_file]))] | ||
|
||
bsp_workspace_info = rule( | ||
implementation = _bsp_workspace_info_impl, | ||
toolchains = ["@io_bazel_rules_scala//scala:toolchain_type"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
load("@bsp4bazel-rules//:bsp4bazel.bzl", "bsp_workspace_info") | ||
|
||
bsp_workspace_info() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
load("@bsp4bazel-rules//:bsp4bazel.bzl", "bsp_workspace_info") | ||
|
||
bsp_workspace_info() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why does this require a name, but set it as default, then fail if it has been changed?