Skip to content

Commit

Permalink
New build mostly working, but forks still broken
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Dec 4, 2022
1 parent 51b51fa commit a3e1550
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 5 additions & 7 deletions src/core/irk.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ object palette:

object Build:
def apply(pwd: Directory[Unix], command: Maybe[Target], universe: Universe)
(using Environment, Monitor, Threading, Stdout, Log)
(using Environment, Monitor, Threading, Stdout)
: Build throws GitError | IoError | EnvError | RootParentError | CancelError =

Log.info(t"Running command ${command.toString}")

def steps(todo: List[Ref], done: Map[Ref, Step]): Build = todo match
case Nil => Build(pwd, done)
case head :: tail =>
if done.contains(head) then steps(tail, done) else
Log.warn(head.toString)
val project = universe.index(ProjectId(head.project))
val module = project.index(head.module)
val ref = module.id.in(project.id)
Expand All @@ -67,12 +64,13 @@ object Build:
val uses = module.use.map(_.in(project.id))
val resources = module.resource.map(project.resolve(_))
val sources: Set[Directory[Unix]] = module.source.map(project.resolve(_)).sift[Directory[Unix]]

steps((includes ++ uses).to(List) ::: tail, done.updated(ref, Step(universe, project.root, ref.show, ref, includes ++ uses, resources, sources,
Set(), t"1.0.0", Nil, None, None, Nil, None)))

command.mm { cmd => steps(cmd.include.map(_.ref), Map()) }.or(throw AppError(t"No build command was specified"))

command.mm: cmd =>
steps(cmd.include.map(_.ref), Map())
.or(throw AppError(t"No valid build command was specified, and there is no default command"))

case class Build(pwd: Directory[Unix], index: Map[Ref, Step] = Map()):
val steps: Set[Step] = index.values.to(Set)
Expand Down
6 changes: 1 addition & 5 deletions src/core/main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,7 @@ object Irk extends Daemon():
val pwd = env.pwd.directory(Expect)
val (commands, universe) = Universe.resolve(pwd)

Log.info(t"Looking for ${command.toString} in ${commands.toString}")
val command2: Maybe[Target] = command.mm: cmd =>
commands.find(_.id == cmd).getOrElse:
throw AppError(t"The command $cmd is not defined")

val command2: Maybe[Target] = commands.find(_.id == command.or(t"default")).maybe
val build = Build(pwd, command2, universe)
if watch then updateWatches(watcher, build) else build
catch
Expand Down
2 changes: 1 addition & 1 deletion src/core/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ case class Version(digest: Text, major: Int, minor: Int):

case class PluginRef(jarFile: DiskPath[Unix], params: List[Text])

case class Target(id: Text, main: Maybe[Text], args: List[Text], include: List[ModuleId])
case class Target(id: Text, include: List[ModuleId], main: Maybe[Text], args: List[Text])

object NextGen:

Expand Down

0 comments on commit a3e1550

Please sign in to comment.