Skip to content

Commit

Permalink
Merge pull request #42 from tindzk/feat/link-optimise
Browse files Browse the repository at this point in the history
Cli: Add `--optimise` parameter to `link` command
  • Loading branch information
tindzk authored Aug 5, 2019
2 parents f5fbb46 + 86018d2 commit 43269c0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/main/scala/seed/Cli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ object Cli {
packageConfig: PackageConfig,
webSocket: Option[WebSocketConfig],
watch: Boolean,
optimise: Boolean,
modules: List[String]
) extends Command
case class BuildEvents(webSocket: WebSocketConfig) extends Command
Expand Down Expand Up @@ -109,6 +110,7 @@ object Cli {
packageConfigArg
.and(webSocketConnectArg)
.and(flag("--watch"))
.and(flag("--optimise"))
.and(repeatedAtLeastOnceFree[String])
.to[Command.Link]

Expand Down Expand Up @@ -191,8 +193,9 @@ ${underlined("Usage:")} seed [--build=<path>] [--config=<path>] <command>
- app:native Only compile Native platform of module ${Ansi.italic("app")}
- app:<target> Only build ${Ansi.italic("<target>")} of the module ${Ansi.italic("app")}

${bold("Command:")} ${underlined("link")} [--connect[=${webSocketDefaultConnection.format}]] [--watch] <modules>
${bold("Command:")} ${underlined("link")} [--connect[=${webSocketDefaultConnection.format}]] [--optimise] [--watch] <modules>
${italic("--connect")} Run link command on remote Seed server
${italic("--optimise")} Instruct the linker to perform optimisations on the build
${italic("--watch")} Link upon source changes (cannot be combined with ${Ansi.italic("--connect")})
${italic("<modules>")} One or multiple space-separated modules. The syntax of a module is: ${italic("<name>")} or ${italic("<name>:<platform>")}
${italic("Examples:")}
Expand Down
6 changes: 5 additions & 1 deletion src/main/scala/seed/cli/Link.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ object Link {
import io.circe.syntax._
val build =
if (buildPath.isAbsolute) buildPath else buildPath.toAbsolutePath
(WsCommand.Link(build, command.modules): WsCommand).asJson.noSpaces
(WsCommand
.Link(build, command.modules, command.optimise): WsCommand).asJson.noSpaces
}, log)
client.connect()
}
Expand All @@ -39,6 +40,7 @@ object Link {
link(
buildPath,
command.modules,
command.optimise,
command.watch,
tmpfs,
log,
Expand All @@ -56,6 +58,7 @@ object Link {
def link(
buildPath: Path,
modules: List[String],
optimise: Boolean,
watch: Boolean,
tmpfs: Boolean,
log: Log,
Expand Down Expand Up @@ -89,6 +92,7 @@ object Link {
build,
projectPath,
linkModules,
optimise,
watch,
log,
onStdOut(build)
Expand Down
6 changes: 4 additions & 2 deletions src/main/scala/seed/cli/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import scala.collection.mutable

sealed abstract class WsCommand(val description: String)
object WsCommand {
case class Link(build: Path, modules: List[String]) extends WsCommand("Link")
case class Link(build: Path, modules: List[String], optimise: Boolean = false)
extends WsCommand("Link")
case class Build(build: Path, targets: List[String])
extends WsCommand("Build")
case object BuildEvents extends WsCommand("Build events")
Expand Down Expand Up @@ -132,10 +133,11 @@ object Server {
// TODO Send success state to client too
RTS.unsafeRunAsync(uio)(_ => wsClient.close())
}
case WsCommand.Link(buildPath, modules) =>
case WsCommand.Link(buildPath, modules, optimise) =>
seed.cli.Link.link(
buildPath,
modules,
optimise = optimise,
watch = false,
tmpfs,
clientLog,
Expand Down
6 changes: 5 additions & 1 deletion src/main/scala/seed/cli/util/BloopCli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ object BloopCli {
build: Build,
projectPath: Path,
bloopModules: List[String],
optimise: Boolean,
watch: Boolean,
log: Log,
onStdOut: String => Unit
): Option[ProcessHelper.Process] =
if (bloopModules.isEmpty) None
else {
val args = "link" +: ((if (!watch) List() else List("--watch")) ++ bloopModules)
val watchParam = if (!watch) List() else List("--watch")
val optimiseParam =
if (!optimise) List() else List("--optimize", "release")
val args = List("link") ++ bloopModules ++ watchParam ++ optimiseParam
Some(ProcessHelper.runBloop(projectPath, log, onStdOut)(args: _*))
}
}
1 change: 1 addition & 0 deletions src/test/scala/seed/build/LinkSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ object LinkSpec extends TestSuite[Unit] {
build,
projectPath,
List("example-js"),
optimise = false,
watch = false,
Log.urgent,
onStdOut
Expand Down

0 comments on commit 43269c0

Please sign in to comment.