-
Notifications
You must be signed in to change notification settings - Fork 278
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
Require JavaInfo on deps, move scrooge srcjar to srcs #523
Changes from 2 commits
564e1bc
ad920a0
8d63397
90dcb05
d1a3d5e
4dc2edd
2a78628
eb50d82
026fdb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,15 +26,12 @@ def _collect_jars_when_dependency_analyzer_is_off(dep_targets): | |
runtime_jars = [] | ||
|
||
for dep_target in dep_targets: | ||
# we require a JavaInfo for dependencies | ||
# must use java_import or scala_import if you have raw files | ||
if JavaInfo in dep_target: | ||
java_provider = dep_target[JavaInfo] | ||
compile_jars.append(java_provider.compile_jars) | ||
runtime_jars.append(java_provider.transitive_runtime_jars) | ||
else: | ||
# support http_file pointed at a jar. http_jar uses ijar, | ||
# which breaks scala macros | ||
compile_jars.append(filter_not_sources(dep_target.files)) | ||
runtime_jars.append(filter_not_sources(dep_target.files)) | ||
|
||
return struct( | ||
compile_jars = depset(transitive = compile_jars), | ||
|
@@ -52,17 +49,13 @@ def _collect_jars_when_dependency_analyzer_is_on(dep_targets): | |
current_dep_compile_jars = None | ||
current_dep_transitive_compile_jars = None | ||
|
||
# we require a JavaInfo for dependencies | ||
# must use java_import or scala_import if you have raw files | ||
if JavaInfo in dep_target: | ||
java_provider = dep_target[JavaInfo] | ||
current_dep_compile_jars = java_provider.compile_jars | ||
current_dep_transitive_compile_jars = java_provider.transitive_compile_time_jars | ||
runtime_jars.append(java_provider.transitive_runtime_jars) | ||
else: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again the whole conditional as above but even if I’m wrong why silently ignore and not fail? |
||
# support http_file pointed at a jar. http_jar uses ijar, | ||
# which breaks scala macros | ||
current_dep_compile_jars = filter_not_sources(dep_target.files) | ||
current_dep_transitive_compile_jars = filter_not_sources(dep_target.files) | ||
runtime_jars.append(filter_not_sources(dep_target.files)) | ||
|
||
compile_jars.append(current_dep_compile_jars) | ||
transitive_compile_jars.append(current_dep_transitive_compile_jars) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,9 +460,7 @@ def _collect_runtime_jars(dep_targets): | |
if JavaInfo in dep_target: | ||
runtime_jars.append(dep_target[JavaInfo].transitive_runtime_jars) | ||
else: | ||
# support http_file pointed at a jar. http_jar uses ijar, | ||
# which breaks scala macros | ||
runtime_jars.append(filter_not_sources(dep_target.files)) | ||
fail("we expect JavaInfo for runtime jars: " + str(dep_target)) | ||
|
||
return runtime_jars | ||
|
||
|
@@ -562,7 +560,9 @@ def _lib(ctx, non_macro_lib): | |
# this information through. extra_information allows passing | ||
# this information through, and it is up to the new_targets | ||
# to filter and make sense of this information. | ||
extra_information=_collect_extra_information(ctx.attr.deps), | ||
# unfortunately, we need to see this for scrooge and protobuf to work, | ||
# but those are generating srcjar, so they should really come in via srcs | ||
extra_information=_collect_extra_information(ctx.attr.deps + ctx.attr.srcs), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m sorry but I don’t understand this. Where does scroog euse this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. search for all the extra information in the file. For instance: https://github.com/bazelbuild/rules_scala/blob/master/twitter_scrooge/twitter_scrooge.bzl#L85 Really this is something that should be replaced with #510 but that is staged behind a few layers of tech debt removal (a supported skylark function to compile scala and get a JavaInfo, and a toolchain that sets up all the things we need for scala so we don't have to copy-paste the scala setup for the ctx). |
||
jars_to_labels = jars.jars2labels, | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,11 @@ load( | |
"@io_bazel_rules_scala//specs2:specs2_junit.bzl", | ||
_specs2_junit_dependencies = "specs2_junit_dependencies") | ||
|
||
load( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leftover? |
||
"@io_bazel_rules_scala//scala:scala_import.bzl", | ||
_scala_import = "scala_import" | ||
) | ||
|
||
_launcher_template = { | ||
"_java_stub_template": attr.label( | ||
default = Label("@java_stub_template//file")), | ||
|
@@ -219,13 +224,10 @@ _scala_test_attrs = { | |
"full_stacktraces": attr.bool(default = True), | ||
"_scalatest": attr.label( | ||
default = Label( | ||
"//external:io_bazel_rules_scala/dependency/scalatest/scalatest"), | ||
allow_files = True), | ||
"//external:io_bazel_rules_scala/dependency/scalatest/scalatest")), | ||
"_scalatest_runner": attr.label( | ||
executable = True, | ||
cfg = "host", | ||
default = Label("//src/java/io/bazel/rulesscala/scala_test:runner.jar"), | ||
allow_files = True), | ||
default = Label("//src/java/io/bazel/rulesscala/scala_test:runner")), | ||
"_scalatest_reporter": attr.label( | ||
default = Label("//scala/support:test_reporter")), | ||
} | ||
|
@@ -476,7 +478,7 @@ _scala_junit_test_attrs = { | |
"//external:io_bazel_rules_scala/dependency/hamcrest/hamcrest_core") | ||
), | ||
"_bazel_test_runner": attr.label( | ||
default = Label("@bazel_tools//tools/jdk:TestRunner_deploy.jar"), | ||
default = Label("@io_bazel_rules_scala//scala:bazel_test_runner_deploy"), | ||
allow_files = True), | ||
} | ||
_scala_junit_test_attrs.update(_launcher_template) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
java_binary( | ||
java_library( | ||
name = "runner", | ||
srcs = ["Runner.java"], | ||
visibility = ["//visibility:public"], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
if grep -q $1 $2 ; then | ||
echo "ERROR: found $1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add what was expected? Either in the assertion or in the test name since 6 months from now I won’t remember :) |
||
exit 1 | ||
else | ||
exit 0 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,12 +289,11 @@ def scrooge_scala_library(name, | |
with_finagle = with_finagle, | ||
) | ||
|
||
# deps from macro invocation would come via srcjar | ||
# however, retained to make dependency analysis via aspects easier | ||
scala_library( | ||
name = name, | ||
srcs = [srcjar], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this work? i think the scala_library rule is restricted to only allow actual files in the srcs not targets? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (or does it intelligently realize the output file?... interesting) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it does use the output file here. We could be more precise and just list the output filename. That might actually solve the problem.... Maybe by putting the whole target we are sucking up all the deps. |
||
deps = deps + remote_jars + [ | ||
srcjar, "//external:io_bazel_rules_scala/dependency/thrift/libthrift", | ||
"//external:io_bazel_rules_scala/dependency/thrift/libthrift", | ||
"//external:io_bazel_rules_scala/dependency/thrift/scrooge_core" | ||
], | ||
exports = deps + remote_jars + [ | ||
|
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 keep the “if”? I think you can require the divider on the signature of the attribute and so throw all of the conditionals away
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.
because scrooge puts everything in the deps sadly... we want to fix it, but one step at a time.
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.
scrooge macro puts all the thrift dependencies on the deps. :( we need #510