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(
5050 bridgeJars = scalaCompiler0.bridgeJarsOpt.map(_.map(_.toNIO).toList)
5151 )
5252 }
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+
5373 baseBloopProject(
5474 projectName,
5575 directory.toNIO,
@@ -65,7 +85,8 @@ final case class Project(
6585 platform = Some (platform),
6686 `scala` = scalaConfigOpt,
6787 java = Some (BloopConfig .Java (javacOptions)),
68- resolution = resolution
88+ resolution = resolution,
89+ sourceGenerators = Some (List (sourceGen))
6990 )
7091 }
7192
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ object DirectivesPreprocessingUtils {
3030 directives.ScalaJs .handler,
3131 directives.ScalaNative .handler,
3232 directives.ScalaVersion .handler,
33+ directives.SourceGenerator .handler,
3334 directives.Sources .handler,
3435 directives.Tests .handler
3536 ).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