Skip to content

Commit 5758cc8

Browse files
committed
working wip
1 parent dd9d660 commit 5758cc8

File tree

4 files changed

+39
-32
lines changed

4 files changed

+39
-32
lines changed

modules/build/src/main/scala/scala/build/Project.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ final case class Project(
6363
Nil
6464
)
6565

66+
println(s"This is script path ${command0}")
6667
BloopConfig.SourceGenerator(
6768
List(sourceGlobs0),
6869
(config.outputPath / "source-generator-output").toNIO,
69-
command0
70+
List("/Users/kiki/Kerja/scala-cli/testing-a/scala-cli", "--power", "run", command0)
7071
)
7172
}.toList
7273
)

modules/directives/src/main/scala/scala/build/directives/DirectiveSpecialSyntax.scala

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ object DirectiveSpecialSyntax {
2121
val pattern = """(((?:\$)+)(\{\.\}))""".r
2222
path match {
2323
case Right(p) =>
24+
println(p)
2425
pattern.replaceAllIn(
2526
directiveValue,
2627
(m: Regex.Match) => {

modules/directives/src/main/scala/scala/build/preprocessing/directives/SourceGenerator.scala

+20-15
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,17 @@ final case class SourceGenerator(
3636
inputDirectory: DirectiveValueParser.WithScopePath[Option[Positioned[String]]] =
3737
DirectiveValueParser.WithScopePath.empty(None),
3838
glob: Option[Positioned[String]] = None,
39-
commandProcessor: DirectiveValueParser.WithScopePath[Option[Positioned[String]]] =
40-
DirectiveValueParser.WithScopePath.empty(None),
4139
) extends HasBuildOptions {
4240
def buildOptions: Either[BuildException, BuildOptions] =
4341
// println(s"ScopePath of Scripts: ${scripts.scopePath}")
4442
// println(s"Values of Scripts: ${scripts.value(0).value}")
4543
// println(s"Values of InputDir: ${inputDirectory.value}")
46-
SourceGenerator.buildOptions(testy,scripts)
44+
SourceGenerator.buildOptions(scripts)
4745
}
4846

4947
object SourceGenerator {
5048
val handler: DirectiveHandler[SourceGenerator] = DirectiveHandler.derive
5149
def buildOptions(
52-
sourceGenerator: DirectiveValueParser.WithScopePath[List[Positioned[String]]],
5350
scripts: DirectiveValueParser.WithScopePath[List[Positioned[String]]]
5451
): Either[BuildException, BuildOptions] = {
5552
val proc = UsingDirectivesProcessor()
@@ -84,18 +81,25 @@ object SourceGenerator {
8481
}
8582
}
8683

87-
val strictDirectives = scriptConvert
88-
.map(modify(_))
89-
.map(_.take(3))
84+
val componentKeyword = Seq("inputDirectory", "glob")
85+
val strictDirectives = scriptConvert.map(modify(_))
9086

91-
// println(scripts.scopePath.subPath)
92-
// strictDirectives.map(f => f.map(w => println(w)))
87+
val generatorComponents = strictDirectives.map(directiveSeq =>
88+
directiveSeq.filter(rawDirective =>
89+
componentKeyword.exists(keyword => rawDirective.key.contains(keyword))
90+
)
91+
)
9392

94-
val directive = strictDirectives.collect {
95-
case Seq(inputDir, glob, processor) =>
96-
GeneratorConfig(inputDir.values.mkString, List(glob.values.mkString), processor.values.mkString.split(" ").toList,scripts.scopePath.subPath)
93+
// generatorComponents.map(f => f.map(g => println(g.values)))
94+
val directive = generatorComponents.collect {
95+
case Seq(inputDir, glob) =>
96+
GeneratorConfig(
97+
inputDir.values.mkString,
98+
List(glob.values.mkString),
99+
scripts.value(0).value,
100+
scripts.scopePath.subPath
101+
)
97102
}
98-
println(directive.size)
99103

100104
// val sourceGenValue = sourceGenerator.value
101105
// sourceGenValue
@@ -107,9 +111,10 @@ object SourceGenerator {
107111
// SourceGeneratorOptions(generatorConfig = configs)
108112
// )
109113
// }
110-
111114
// directive.map { f => println(f)}
112115

113-
Right(BuildOptions(sourceGeneratorOptions = SourceGeneratorOptions(generatorConfig = directive)))
116+
Right(BuildOptions(sourceGeneratorOptions =
117+
SourceGeneratorOptions(generatorConfig = directive)
118+
))
114119
}
115120
}

modules/options/src/main/scala/scala/build/options/GeneratorConfig.scala

+16-16
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ import scala.build.errors.{BuildException, MalformedInputError}
66
final case class GeneratorConfig(
77
inputDir: String,
88
glob: List[String],
9-
commandFilePath: List[String],
9+
commandFilePath: String,
1010
outputPath: os.SubPath
1111
)
1212

1313
object GeneratorConfig {
1414

15-
def parse(input: Positioned[String], output: os.SubPath): Either[BuildException, GeneratorConfig] =
16-
input.value.split("\\|", 3) match {
17-
case Array(inputDir, glob, commandFilePath) =>
18-
val commandFileList = commandFilePath.split(" ").toList
19-
Right(GeneratorConfig(inputDir, List(glob), commandFileList, output))
20-
case _ =>
21-
Left(
22-
new MalformedInputError(
23-
"sourceGenerator",
24-
input.value,
25-
"inputDir|glob|commandFilePath",
26-
input.positions
27-
)
28-
)
29-
}
15+
// def parse(input: Positioned[String], output: os.SubPath): Either[BuildException, GeneratorConfig] =
16+
// input.value.split("\\|", 3) match {
17+
// case Array(inputDir, glob, commandFilePath) =>
18+
// val commandFileList = commandFilePath.split(" ").toList
19+
// Right(GeneratorConfig(inputDir, List(glob), commandFileList, output))
20+
// case _ =>
21+
// Left(
22+
// new MalformedInputError(
23+
// "sourceGenerator",
24+
// input.value,
25+
// "inputDir|glob|commandFilePath",
26+
// input.positions
27+
// )
28+
// )
29+
// }
3030
}

0 commit comments

Comments
 (0)