* Added constant processes 'true' and 'false'

* Added simple processes that do no I/O and return an exit value
 * Fixed support for defining a process in scala.xml.Elem



git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@840 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
dmharrah 2009-07-05 18:57:25 +00:00
parent f3c776dab3
commit 947271dc47
3 changed files with 19 additions and 3 deletions

View File

@ -17,7 +17,9 @@ object Process
implicit def apply(builder: JProcessBuilder): ProcessBuilder = new SimpleProcessBuilder(builder)
implicit def apply(file: File): FilePartialBuilder = new FileBuilder(file)
implicit def apply(url: URL): URLPartialBuilder = new URLBuilder(url)
implicit def apply(command: scala.xml.Elem): ProcessBuilder = apply(command.text)
implicit def apply(command: scala.xml.Elem): ProcessBuilder = apply(command.text.trim)
def apply(value: Boolean): ProcessBuilder = apply(value.toString, if(value) 0 else 1)
def apply(name: String, exitValue: => Int): ProcessBuilder = new DummyProcessBuilder(name, exitValue)
}
trait URLPartialBuilder extends NotNull

View File

@ -53,9 +53,11 @@ trait SimpleScalaProject extends Project
pathClean orElse restored
}
}
def execTask(command: => ProcessBuilder): Task =
def execTask(buildCommand: => ProcessBuilder): Task =
task
{
val command = buildCommand
log.debug("Executing command " + command)
val exitValue = command ! log
if(exitValue == 0)
None

View File

@ -292,7 +292,19 @@ private class PipeSink(pipe: PipedInputStream, currentSink: SyncVar[Option[Outpu
}
}
private[sbt] class DummyProcessBuilder(override val toString: String, exitValue : => Int) extends AbstractProcessBuilder
{
override def run(io: ProcessIO): Process = new DummyProcess(exitValue)
override def canPipeTo = true
}
/** A thin wrapper around a java.lang.Process. `ioThreads` are the Threads created to do I/O.
* The implementation of `exitValue` waits until these threads die before returning. */
private class DummyProcess(action: => Int) extends Process
{
private[this] val exitCode = scala.concurrent.ops.future(action)
override def exitValue() = exitCode()
override def destroy() {}
}
/** Represents a simple command without any redirection or combination. */
private[sbt] class SimpleProcessBuilder(p: JProcessBuilder) extends AbstractProcessBuilder
{