File tree Expand file tree Collapse file tree 3 files changed +52
-1
lines changed
build/src/main/scala/scala/build
directives/src/main/scala/scala/build/preprocessing/directives Expand file tree Collapse file tree 3 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,26 @@ final case class Project(
50
50
bridgeJars = scalaCompiler0.bridgeJarsOpt.map(_.map(_.toNIO).toList)
51
51
)
52
52
}
53
+
54
+ val sourceGen : BloopConfig .SourceGenerator = {
55
+ val command = " /Users/kiki/Kerja/scala-cli/testing-a/source-generator.py"
56
+
57
+
58
+ val sourceGlobs = BloopConfig .SourcesGlobs (
59
+ (os.root / " Users" / " kiki" / " Kerja" / " scala-cli" / " testing-a" / " generator-inputs" ).toNIO,
60
+ None ,
61
+ List (" glob:test.in" ),
62
+ Nil
63
+ )
64
+
65
+ BloopConfig .SourceGenerator (
66
+ List (sourceGlobs),
67
+ (os.root / " Users" / " kiki" / " Kerja" / " scala-cli" / " testing-a" / " source-generator-a" ).toNIO,
68
+ List (" python3" ,command)
69
+ // Nil
70
+ )
71
+ }
72
+
53
73
baseBloopProject(
54
74
projectName,
55
75
directory.toNIO,
@@ -65,7 +85,8 @@ final case class Project(
65
85
platform = Some (platform),
66
86
`scala` = scalaConfigOpt,
67
87
java = Some (BloopConfig .Java (javacOptions)),
68
- resolution = resolution
88
+ resolution = resolution,
89
+ sourceGenerators = Some (List (sourceGen))
69
90
)
70
91
}
71
92
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ object DirectivesPreprocessingUtils {
30
30
directives.ScalaJs .handler,
31
31
directives.ScalaNative .handler,
32
32
directives.ScalaVersion .handler,
33
+ directives.SourceGenerator .handler,
33
34
directives.Sources .handler,
34
35
directives.Tests .handler
35
36
).map(_.mapE(_.buildOptions))
Original file line number Diff line number Diff line change
1
+ package scala .build .preprocessing .directives
2
+
3
+ import scala .build .directives .*
4
+ import scala .build .errors .BuildException
5
+ import scala .build .options .BuildOptions
6
+ import scala .cli .commands .SpecificationLevel
7
+
8
+ @ DirectiveExamples (" //> using generator" )
9
+ @ DirectiveUsage (
10
+ " //> using generator" ,
11
+ " `//> using generator`"
12
+ )
13
+ @ DirectiveDescription (" Generate code using Source Generator" )
14
+ @ DirectiveLevel (SpecificationLevel .EXPERIMENTAL )
15
+ final case class SourceGenerator (
16
+ placeHolderGenerator : Boolean = false
17
+ ) extends HasBuildOptions {
18
+ def buildOptions : Either [BuildException , BuildOptions ] = {
19
+ val buildOpt = BuildOptions (
20
+ useBuildServer = Some (true )
21
+ )
22
+ Right (buildOpt)
23
+ }
24
+ }
25
+
26
+
27
+ object SourceGenerator {
28
+ val handler : DirectiveHandler [SourceGenerator ] = DirectiveHandler .derive
29
+ }
You can’t perform that action at this time.
0 commit comments