|
| 1 | +"""Shared attributes for rules""" |
| 2 | + |
| 3 | +load( |
| 4 | + "@io_bazel_rules_scala//scala/private:coverage_replacements_provider.bzl", |
| 5 | + _coverage_replacements_provider = "coverage_replacements_provider", |
| 6 | +) |
| 7 | +load( |
| 8 | + "@io_bazel_rules_scala//scala:plusone.bzl", |
| 9 | + _collect_plus_one_deps_aspect = "collect_plus_one_deps_aspect", |
| 10 | +) |
| 11 | + |
| 12 | +common_attrs_for_plugin_bootstrapping = { |
| 13 | + "srcs": attr.label_list(allow_files = [ |
| 14 | + ".scala", |
| 15 | + ".srcjar", |
| 16 | + ".java", |
| 17 | + ]), |
| 18 | + "deps": attr.label_list( |
| 19 | + aspects = [ |
| 20 | + _collect_plus_one_deps_aspect, |
| 21 | + _coverage_replacements_provider.aspect, |
| 22 | + ], |
| 23 | + providers = [[JavaInfo]], |
| 24 | + ), |
| 25 | + "plugins": attr.label_list(allow_files = [".jar"]), |
| 26 | + "runtime_deps": attr.label_list(providers = [[JavaInfo]]), |
| 27 | + "data": attr.label_list(allow_files = True), |
| 28 | + "resources": attr.label_list(allow_files = True), |
| 29 | + "resource_strip_prefix": attr.string(), |
| 30 | + "resource_jars": attr.label_list(allow_files = True), |
| 31 | + "scalacopts": attr.string_list(), |
| 32 | + "javacopts": attr.string_list(), |
| 33 | + "jvm_flags": attr.string_list(), |
| 34 | + "scalac_jvm_flags": attr.string_list(), |
| 35 | + "javac_jvm_flags": attr.string_list(), |
| 36 | + "expect_java_output": attr.bool( |
| 37 | + default = True, |
| 38 | + mandatory = False, |
| 39 | + ), |
| 40 | + "print_compile_time": attr.bool( |
| 41 | + default = False, |
| 42 | + mandatory = False, |
| 43 | + ), |
| 44 | +} |
| 45 | + |
| 46 | +common_attrs = {} |
| 47 | + |
| 48 | +common_attrs.update(common_attrs_for_plugin_bootstrapping) |
| 49 | + |
| 50 | +common_attrs.update({ |
| 51 | + # using stricts scala deps is done by using command line flag called 'strict_java_deps' |
| 52 | + # switching mode to "on" means that ANY API change in a target's transitive dependencies will trigger a recompilation of that target, |
| 53 | + # on the other hand any internal change (i.e. on code that ijar omits) WON’T trigger recompilation by transitive dependencies |
| 54 | + "_dependency_analyzer_plugin": attr.label( |
| 55 | + default = Label( |
| 56 | + "@io_bazel_rules_scala//third_party/dependency_analyzer/src/main:dependency_analyzer", |
| 57 | + ), |
| 58 | + allow_files = [".jar"], |
| 59 | + mandatory = False, |
| 60 | + ), |
| 61 | + "unused_dependency_checker_mode": attr.string( |
| 62 | + values = [ |
| 63 | + "warn", |
| 64 | + "error", |
| 65 | + "off", |
| 66 | + "", |
| 67 | + ], |
| 68 | + mandatory = False, |
| 69 | + ), |
| 70 | + "_unused_dependency_checker_plugin": attr.label( |
| 71 | + default = Label( |
| 72 | + "@io_bazel_rules_scala//third_party/unused_dependency_checker/src/main:unused_dependency_checker", |
| 73 | + ), |
| 74 | + allow_files = [".jar"], |
| 75 | + mandatory = False, |
| 76 | + ), |
| 77 | + "unused_dependency_checker_ignored_targets": attr.label_list(default = []), |
| 78 | + "_code_coverage_instrumentation_worker": attr.label( |
| 79 | + default = "@io_bazel_rules_scala//src/java/io/bazel/rulesscala/coverage/instrumenter", |
| 80 | + allow_files = True, |
| 81 | + executable = True, |
| 82 | + cfg = "host", |
| 83 | + ), |
| 84 | +}) |
| 85 | + |
| 86 | +implicit_deps = { |
| 87 | + "_singlejar": attr.label( |
| 88 | + executable = True, |
| 89 | + cfg = "host", |
| 90 | + default = Label("@bazel_tools//tools/jdk:singlejar"), |
| 91 | + allow_files = True, |
| 92 | + ), |
| 93 | + "_zipper": attr.label( |
| 94 | + executable = True, |
| 95 | + cfg = "host", |
| 96 | + default = Label("@bazel_tools//tools/zip:zipper"), |
| 97 | + allow_files = True, |
| 98 | + ), |
| 99 | + "_java_toolchain": attr.label( |
| 100 | + default = Label("@bazel_tools//tools/jdk:current_java_toolchain"), |
| 101 | + ), |
| 102 | + "_host_javabase": attr.label( |
| 103 | + default = Label("@bazel_tools//tools/jdk:current_java_runtime"), |
| 104 | + cfg = "host", |
| 105 | + ), |
| 106 | + "_java_runtime": attr.label( |
| 107 | + default = Label("@bazel_tools//tools/jdk:current_java_runtime"), |
| 108 | + ), |
| 109 | + "_scalac": attr.label( |
| 110 | + default = Label( |
| 111 | + "@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac", |
| 112 | + ), |
| 113 | + ), |
| 114 | + "_exe": attr.label( |
| 115 | + executable = True, |
| 116 | + cfg = "host", |
| 117 | + default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/exe:exe"), |
| 118 | + ), |
| 119 | +} |
| 120 | + |
| 121 | +launcher_template = { |
| 122 | + "_java_stub_template": attr.label( |
| 123 | + default = Label("@io_bazel_rules_scala//java_stub_template/file"), |
| 124 | + ), |
| 125 | +} |
| 126 | + |
| 127 | +# Single dep to allow IDEs to pickup all the implicit dependencies. |
| 128 | +resolve_deps = { |
| 129 | + "_scala_toolchain": attr.label_list( |
| 130 | + default = [ |
| 131 | + Label( |
| 132 | + "//external:io_bazel_rules_scala/dependency/scala/scala_library", |
| 133 | + ), |
| 134 | + ], |
| 135 | + allow_files = False, |
| 136 | + ), |
| 137 | +} |
0 commit comments