aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command
diff options
context:
space:
mode:
authorEduardo Julian2021-06-18 14:21:41 -0400
committerEduardo Julian2021-06-18 14:21:41 -0400
commita82bd1eabe94763162c2b0707d9c198fbe9835e3 (patch)
tree032473704af6e7db41e1f6dc87ab995788d8ab17 /stdlib/source/program/aedifex/command
parent519c0c0c71cdf7ce3dfc64b9781ab826760b3d94 (diff)
Refactored the machinery to make local macros into its own module.
Diffstat (limited to 'stdlib/source/program/aedifex/command')
-rw-r--r--stdlib/source/program/aedifex/command/build.lux59
-rw-r--r--stdlib/source/program/aedifex/command/deps.lux12
-rw-r--r--stdlib/source/program/aedifex/command/test.lux9
3 files changed, 53 insertions, 27 deletions
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index 388a48c89..7052109fb 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -25,7 +25,7 @@
[world
[program (#+ Program)]
["." file (#+ Path)]
- ["." shell (#+ Shell)]
+ ["." shell (#+ Process Shell)]
["." console (#+ Console)]
[net
["." uri]]]]
@@ -79,8 +79,8 @@
(exception: #export no_specified_target)
(type: #export Compiler
- (#JVM Artifact)
- (#JS Artifact))
+ (#JVM Dependency)
+ (#JS Dependency))
(def: (remove_dependency dependency)
(-> Dependency (-> Resolution Resolution))
@@ -94,28 +94,30 @@
(..js_compiler resolution)]
[(#.Some dependency) _]
(#try.Success [(..remove_dependency dependency resolution)
- (#JVM (get@ #///dependency.artifact dependency))])
+ (#JVM dependency)])
[_ (#.Some dependency)]
(#try.Success [(..remove_dependency dependency resolution)
- (#JS (get@ #///dependency.artifact dependency))])
+ (#JS dependency)])
_
(exception.throw ..no_available_compiler [])))
-(def: (path fs home artifact)
- (All [!] (-> (file.System !) Path Artifact Path))
- (let [/ (\ fs separator)]
+(def: (path fs home dependency)
+ (All [!] (-> (file.System !) Path Dependency Path))
+ (let [/ (\ fs separator)
+ artifact (get@ #///dependency.artifact dependency)]
(|> artifact
(///local.uri (get@ #///artifact.version artifact))
(text.replace_all uri.separator /)
- (format home /))))
+ (format home /)
+ (text.suffix (format "." (get@ #///dependency.type dependency))))))
(def: (libraries fs home)
(All [!] (-> (file.System !) Path Resolution (List Path)))
(|>> dictionary.keys
(list.filter (|>> (get@ #///dependency.type) (text\= ///artifact/type.lux_library)))
- (list\map (|>> (get@ #///dependency.artifact) (..path fs home)))))
+ (list\map (..path fs home))))
(def: (singular name)
(-> Text Text (List Text))
@@ -129,6 +131,26 @@
(def: #export success "[BUILD ENDED]")
(def: #export failure "[BUILD FAILED]")
+(template [<name> <capability>]
+ [(def: (<name> console process)
+ (-> (Console Promise) (Process Promise) (Promise (Try Any)))
+ (do {! promise.monad}
+ [?line (!.use (\ process <capability>) [])]
+ (case ?line
+ (#try.Failure error)
+ (if (exception.match? shell.no_more_output error)
+ (wrap (#try.Success []))
+ (console.write_line error console))
+
+ (#try.Success line)
+ (do (try.with !)
+ [_ (console.write_line line console)]
+ (log_output! console process)))))]
+
+ [log_output! read]
+ [log_error! error]
+ )
+
(def: #export (do! console program fs shell resolution profile)
(-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Compiler Path]))
(case [(get@ #///.program profile)
@@ -146,12 +168,11 @@
working_directory (\ program directory [])]
(do ///action.monad
[[resolution compiler] (promise\wrap (..compiler resolution))
- #let [[command output] (let [[compiler output] (case compiler
- (#JVM artifact) [(///runtime.java (..path fs home artifact))
- "program.jar"]
- (#JS artifact) [(///runtime.node (..path fs home artifact))
- "program.js"])]
- [(format compiler " build") output])
+ #let [[[command compiler_params] output] (case compiler
+ (#JVM dependency) [(///runtime.java (..path fs home dependency))
+ "program.jar"]
+ (#JS dependency) [(///runtime.node (..path fs home dependency))
+ "program.js"])
/ (\ fs separator)
cache_directory (format working_directory / target)]
_ (console.write_line ..start console)
@@ -159,10 +180,14 @@
[environment
working_directory
command
- (list.concat (list (..plural "--library" (..libraries fs home resolution))
+ (list.concat (list compiler_params
+ (list "build")
+ (..plural "--library" (..libraries fs home resolution))
(..plural "--source" (set.to_list (get@ #///.sources profile)))
(..singular "--target" cache_directory)
(..singular "--module" program_module)))])
+ _ (..log_output! console process)
+ _ (..log_error! console process)
exit (!.use (\ process await) [])
_ (console.write_line (if (i.= shell.normal exit)
..success
diff --git a/stdlib/source/program/aedifex/command/deps.lux b/stdlib/source/program/aedifex/command/deps.lux
index 14b5d803f..d699de528 100644
--- a/stdlib/source/program/aedifex/command/deps.lux
+++ b/stdlib/source/program/aedifex/command/deps.lux
@@ -12,7 +12,7 @@
["." list ("#\." fold)]
["." dictionary]]
[text
- ["%" format (#+ format)]]]
+ ["%" format]]]
[world
[program (#+ Program)]
["." file]
@@ -29,7 +29,7 @@
["#/." resolution (#+ Resolution)]
["#/." deployment]]]])
-(def: %dependency
+(def: format
(%.Format Dependency)
(|>> (get@ #///dependency.artifact)
///artifact.format
@@ -47,13 +47,13 @@
(///dependency/deployment.all local))
_ (console.write_line //clean.success console)
_ (console.write_line (exception.report
- ["Local successes" (exception.enumerate %dependency local_successes)]
- ["Local failures" (exception.enumerate %dependency local_failures)]
+ ["Local successes" (exception.enumerate ..format local_successes)]
+ ["Local failures" (exception.enumerate ..format local_failures)]
["Remote successes" (let [remote_successes (|> remote_successes
(set.from_list ///dependency.hash)
(set.difference (set.from_list ///dependency.hash local_successes))
set.to_list)]
- (exception.enumerate %dependency remote_successes))]
- ["Remote failures" (exception.enumerate %dependency remote_failures)])
+ (exception.enumerate ..format remote_successes))]
+ ["Remote failures" (exception.enumerate ..format remote_failures)])
console)]
(wrap resolution))))
diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux
index dff9b14ee..c3b517437 100644
--- a/stdlib/source/program/aedifex/command/test.lux
+++ b/stdlib/source/program/aedifex/command/test.lux
@@ -39,13 +39,14 @@
(do ///action.monad
[[compiler program] (//build.do! console program fs shell resolution profile)
_ (console.write_line ..start console)
+ #let [[compiler_command compiler_parameters] (case compiler
+ (#//build.JVM artifact) (///runtime.java program)
+ (#//build.JS artifact) (///runtime.node program))]
process (!.use (\ shell execute)
[environment
working_directory
- (case compiler
- (#//build.JVM artifact) (///runtime.java program)
- (#//build.JS artifact) (///runtime.node program))
- (list)])
+ compiler_command
+ compiler_parameters])
exit (!.use (\ process await) [])
_ (console.write_line (if (i.= shell.normal exit)
..success