@@ -235,13 +235,14 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
235235 * signature for you source files/folders and decides whether or not downstream
236236 * [[TargetImpl ]]s need to be invalidated and re-computed.
237237 */
238- def sources (values : Result [os.Path ]* )(implicit ctx : mill.define.Ctx ): Target [Seq [PathRef ]] =
239- ??? // macro Internal.sourcesImpl1
238+ inline def sources (inline values : Result [os.Path ]* )(implicit
239+ ctx : mill.define.Ctx
240+ ): Target [Seq [PathRef ]] = $ { Internal .sourcesImpl1(' values )(' ctx , ' this ) }
240241
241242 inline def sources (inline values : Result [Seq [PathRef ]])(implicit
242243 ctx : mill.define.Ctx
243244 ): Target [Seq [PathRef ]] =
244- $ { Internal .sourcesImpl2(' this , ' values )(' ctx ) }
245+ $ { Internal .sourcesImpl2(' values )(' ctx , ' this ) }
245246
246247 /**
247248 * Similar to [[Source ]], but only for a single source file or folder. Defined
@@ -380,8 +381,6 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
380381 ctx : Expr [mill.define.Ctx ],
381382 caller : Expr [Applicative .Applyer [Task , Task , Result , mill.api.Ctx ]]
382383 )(using Quotes ): Expr [Target [T ]] = {
383- import quotes .reflect .*
384-
385384 val taskIsPrivate = isPrivateTargetOption()
386385
387386 val lhs =
@@ -441,35 +440,39 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
441440 ???
442441 }
443442
444- def sourcesImpl1 (c : Context )(values : c.Expr [Result [os.Path ]]* )(ctx : c.Expr [mill.define.Ctx ])
445- : c.Expr [Target [Seq [PathRef ]]] = {
446- // import c.universe._
447- // val wrapped =
448- // for (value <- values.toList)
449- // yield Applicative.impl0[Task, PathRef, mill.api.Ctx](c)(
450- // reify(value.splice.map(PathRef(_))).tree
451- // ).tree
443+ def sourcesImpl1 (using Quotes )(values : Expr [Seq [Result [os.Path ]]])(
444+ ctx : Expr [mill.define.Ctx ],
445+ caller : Expr [Applicative .Applyer [Task , Task , Result , mill.api.Ctx ]]
446+ ): Expr [Target [Seq [PathRef ]]] = {
452447
453- // val taskIsPrivate = isPrivateTargetOption(c)
448+ val unwrapped = Varargs .unapply(values).get
454449
455- // mill.moduledefs.Cacher.impl0[SourcesImpl](c)(
456- // reify(
457- // new SourcesImpl(
458- // Target.sequence(c.Expr[List[Task[PathRef]]](q"_root_.scala.List(..$wrapped)").splice),
459- // ctx.splice,
460- // taskIsPrivate.splice
461- // )
462- // )
463- // )
464- ???
450+ val wrapped =
451+ for (value <- unwrapped.toList)
452+ yield Applicative .impl[Task , Task , Result , PathRef , mill.api.Ctx ](
453+ caller,
454+ ' { $value.map(PathRef (_)) }
455+ )
456+
457+ val taskIsPrivate = isPrivateTargetOption()
458+
459+ mill.moduledefs.Cacher .impl0[SourcesImpl ](
460+ ' {
461+ new SourcesImpl (
462+ Target .sequence(List ($ { Varargs (wrapped) }* )),
463+ $ctx,
464+ $taskIsPrivate
465+ )
466+ }
467+ )
465468 }
466469
467470 def sourcesImpl2 (using Quotes )(
468- caller : Expr [Applicative .Applyer [Task , Task , Result , mill.api.Ctx ]],
469471 values : Expr [Result [Seq [PathRef ]]]
470- )(ctx : Expr [mill.define.Ctx ]): Expr [Target [Seq [PathRef ]]] = {
471- import quotes .reflect .*
472-
472+ )(
473+ ctx : Expr [mill.define.Ctx ],
474+ caller : Expr [Applicative .Applyer [Task , Task , Result , mill.api.Ctx ]]
475+ ): Expr [Target [Seq [PathRef ]]] = {
473476 val taskIsPrivate = isPrivateTargetOption()
474477
475478 val lhs = Applicative .impl[Task , Task , Result , Seq [PathRef ], mill.api.Ctx ](caller, values)
@@ -531,8 +534,6 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
531534 ctx : Expr [mill.define.Ctx ],
532535 caller : Expr [Applicative .Applyer [Task , Task , Result , mill.api.Ctx ]]
533536 ): Expr [Target [T ]] = {
534- import quotes .reflect .*
535-
536537 val taskIsPrivate = isPrivateTargetOption()
537538
538539 val lhs = Applicative .impl[Task , Task , Result , T , mill.api.Ctx ](caller, value)
0 commit comments