diff --git a/modules/build/src/main/scala/scala/build/Project.scala b/modules/build/src/main/scala/scala/build/Project.scala index 559841d346..23a1abd1b9 100644 --- a/modules/build/src/main/scala/scala/build/Project.scala +++ b/modules/build/src/main/scala/scala/build/Project.scala @@ -63,10 +63,11 @@ final case class Project( Nil ) + println(s"This is script path ${command0}") BloopConfig.SourceGenerator( List(sourceGlobs0), (config.outputPath / "source-generator-output").toNIO, - command0 + List("/Users/kiki/Kerja/scala-cli/testing-a/scala-cli", "--power", "run", command0) ) }.toList ) diff --git a/modules/directives/src/main/scala/scala/build/directives/DirectiveSpecialSyntax.scala b/modules/directives/src/main/scala/scala/build/directives/DirectiveSpecialSyntax.scala index 892fa770e5..3004ecbabf 100644 --- a/modules/directives/src/main/scala/scala/build/directives/DirectiveSpecialSyntax.scala +++ b/modules/directives/src/main/scala/scala/build/directives/DirectiveSpecialSyntax.scala @@ -21,6 +21,7 @@ object DirectiveSpecialSyntax { val pattern = """(((?:\$)+)(\{\.\}))""".r path match { case Right(p) => + println(p) pattern.replaceAllIn( directiveValue, (m: Regex.Match) => { diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/SourceGenerator.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/SourceGenerator.scala index 92efcc1cd4..e317847854 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/SourceGenerator.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/SourceGenerator.scala @@ -36,20 +36,17 @@ final case class SourceGenerator( inputDirectory: DirectiveValueParser.WithScopePath[Option[Positioned[String]]] = DirectiveValueParser.WithScopePath.empty(None), glob: Option[Positioned[String]] = None, - commandProcessor: DirectiveValueParser.WithScopePath[Option[Positioned[String]]] = - DirectiveValueParser.WithScopePath.empty(None), ) extends HasBuildOptions { def buildOptions: Either[BuildException, BuildOptions] = // println(s"ScopePath of Scripts: ${scripts.scopePath}") // println(s"Values of Scripts: ${scripts.value(0).value}") // println(s"Values of InputDir: ${inputDirectory.value}") - SourceGenerator.buildOptions(testy,scripts) + SourceGenerator.buildOptions(scripts) } object SourceGenerator { val handler: DirectiveHandler[SourceGenerator] = DirectiveHandler.derive def buildOptions( - sourceGenerator: DirectiveValueParser.WithScopePath[List[Positioned[String]]], scripts: DirectiveValueParser.WithScopePath[List[Positioned[String]]] ): Either[BuildException, BuildOptions] = { val proc = UsingDirectivesProcessor() @@ -84,18 +81,25 @@ object SourceGenerator { } } - val strictDirectives = scriptConvert - .map(modify(_)) - .map(_.take(3)) + val componentKeyword = Seq("inputDirectory", "glob") + val strictDirectives = scriptConvert.map(modify(_)) - // println(scripts.scopePath.subPath) - // strictDirectives.map(f => f.map(w => println(w))) + val generatorComponents = strictDirectives.map(directiveSeq => + directiveSeq.filter(rawDirective => + componentKeyword.exists(keyword => rawDirective.key.contains(keyword)) + ) + ) - val directive = strictDirectives.collect { - case Seq(inputDir, glob, processor) => - GeneratorConfig(inputDir.values.mkString, List(glob.values.mkString), processor.values.mkString.split(" ").toList,scripts.scopePath.subPath) + // generatorComponents.map(f => f.map(g => println(g.values))) + val directive = generatorComponents.collect { + case Seq(inputDir, glob) => + GeneratorConfig( + inputDir.values.mkString, + List(glob.values.mkString), + scripts.value(0).value, + scripts.scopePath.subPath + ) } - println(directive.size) // val sourceGenValue = sourceGenerator.value // sourceGenValue @@ -107,9 +111,10 @@ object SourceGenerator { // SourceGeneratorOptions(generatorConfig = configs) // ) // } - // directive.map { f => println(f)} - Right(BuildOptions(sourceGeneratorOptions = SourceGeneratorOptions(generatorConfig = directive))) + Right(BuildOptions(sourceGeneratorOptions = + SourceGeneratorOptions(generatorConfig = directive) + )) } } diff --git a/modules/options/src/main/scala/scala/build/options/GeneratorConfig.scala b/modules/options/src/main/scala/scala/build/options/GeneratorConfig.scala index ac900f4eda..7b59db3483 100644 --- a/modules/options/src/main/scala/scala/build/options/GeneratorConfig.scala +++ b/modules/options/src/main/scala/scala/build/options/GeneratorConfig.scala @@ -6,25 +6,25 @@ import scala.build.errors.{BuildException, MalformedInputError} final case class GeneratorConfig( inputDir: String, glob: List[String], - commandFilePath: List[String], + commandFilePath: String, outputPath: os.SubPath ) object GeneratorConfig { - def parse(input: Positioned[String], output: os.SubPath): Either[BuildException, GeneratorConfig] = - input.value.split("\\|", 3) match { - case Array(inputDir, glob, commandFilePath) => - val commandFileList = commandFilePath.split(" ").toList - Right(GeneratorConfig(inputDir, List(glob), commandFileList, output)) - case _ => - Left( - new MalformedInputError( - "sourceGenerator", - input.value, - "inputDir|glob|commandFilePath", - input.positions - ) - ) - } + // def parse(input: Positioned[String], output: os.SubPath): Either[BuildException, GeneratorConfig] = + // input.value.split("\\|", 3) match { + // case Array(inputDir, glob, commandFilePath) => + // val commandFileList = commandFilePath.split(" ").toList + // Right(GeneratorConfig(inputDir, List(glob), commandFileList, output)) + // case _ => + // Left( + // new MalformedInputError( + // "sourceGenerator", + // input.value, + // "inputDir|glob|commandFilePath", + // input.positions + // ) + // ) + // } }