This repository was archived by the owner on Aug 5, 2022. It is now read-only.
File tree 4 files changed +71
-1
lines changed
4 files changed +71
-1
lines changed Original file line number Diff line number Diff line change @@ -238,7 +238,7 @@ CurrentTarget: {current_target}
238
238
compiler_classpath = _join_path (compiler_classpath_jars .to_list (), separator )
239
239
240
240
toolchain = ctx .toolchains ["@io_bazel_rules_scala//scala:toolchain_type" ]
241
- scalacopts = toolchain .scalacopts + in_scalacopts
241
+ scalacopts = [ ctx . expand_location ( v , ctx . attr . plugins ) for v in toolchain .scalacopts + in_scalacopts ]
242
242
243
243
scalac_args = """
244
244
Classpath: {cp}
Original file line number Diff line number Diff line change
1
+ load ("//scala:scala.bzl" , "scala_library" )
2
+
3
+ scala_library (
4
+ name = "check_expand_location" ,
5
+ srcs = ["trivial.scala" ],
6
+ plugins = [
7
+ ":check_expand_location_plugin_deploy.jar" ,
8
+ ],
9
+ scalacopts = [
10
+ "-P:diablerie:location=$(location :check_expand_location_plugin_deploy.jar)" ,
11
+ ],
12
+ )
13
+
14
+ scala_library (
15
+ name = "check_expand_location_plugin" ,
16
+ srcs = [
17
+ "check_expand_location_plugin.scala" ,
18
+ ],
19
+ resource_strip_prefix = package_name (),
20
+ resources = [
21
+ ":gen-scalac-plugin.xml" ,
22
+ ],
23
+ deps = [
24
+ "@io_bazel_rules_scala_scala_compiler" ,
25
+ ],
26
+ )
27
+
28
+ _gen_plugin_xml_cmd = """
29
+ cat > $@ << EOF
30
+ <plugin>
31
+ <name>plugin</name>
32
+ <classname>plugin.Plugin</classname>
33
+ </plugin>
34
+ """
35
+
36
+ genrule (
37
+ name = "gen-scalac-plugin.xml" ,
38
+ outs = ["scalac-plugin.xml" ],
39
+ cmd = _gen_plugin_xml_cmd ,
40
+ )
Original file line number Diff line number Diff line change
1
+ package plugin
2
+
3
+ import scala .tools .nsc .Global
4
+ import scala .tools .nsc .Phase
5
+ import scala .tools .nsc .plugins .{ Plugin => NscPlugin }
6
+ import scala .tools .nsc .plugins .PluginComponent
7
+
8
+ import java .io .File
9
+
10
+ final class Plugin (override val global : Global ) extends NscPlugin {
11
+ override val name : String = " diablerie"
12
+ override val description : String = " just another plugin"
13
+ override val components : List [PluginComponent ] = Nil
14
+
15
+ override def processOptions (options : List [String ], error : String => Unit ): Unit = {
16
+ options
17
+ .find(_.startsWith(" location=" ))
18
+ .map(_.stripPrefix(" location=" ))
19
+ .map(v => new File (v).exists) match {
20
+ case Some (true ) => ()
21
+ case Some (false ) => error(" expanded location doesn't exist" )
22
+ case None => error(" missing location argument" )
23
+ }
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ package trivial
2
+
3
+ object Trivial {
4
+ // feel free to reuse this file for other plugin tests
5
+ }
You can’t perform that action at this time.
0 commit comments