aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/program/aedifex.lux4
-rw-r--r--stdlib/source/program/aedifex/command/auto.lux16
-rw-r--r--stdlib/source/program/aedifex/command/build.lux128
-rw-r--r--stdlib/source/program/aedifex/command/test.lux6
-rw-r--r--stdlib/source/program/aedifex/format.lux2
-rw-r--r--stdlib/source/program/aedifex/parser.lux5
-rw-r--r--stdlib/source/program/aedifex/profile.lux12
7 files changed, 99 insertions, 74 deletions
diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux
index 4b812bef4..2d873f8a8 100644
--- a/stdlib/source/program/aedifex.lux
+++ b/stdlib/source/program/aedifex.lux
@@ -190,8 +190,8 @@
(#try.Success watcher)
(..command
(case auto
- #/cli.Build (..with_dependencies program console (/command/auto.do! watcher /command/build.do!) profile)
- #/cli.Test (..with_dependencies program console (/command/auto.do! watcher /command/test.do!) profile)))))
+ #/cli.Build (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/build.do!) profile)
+ #/cli.Test (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/test.do!) profile)))))
_
(undefined)))
diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux
index afce4d6ff..000384ccd 100644
--- a/stdlib/source/program/aedifex/command/auto.lux
+++ b/stdlib/source/program/aedifex/command/auto.lux
@@ -42,13 +42,17 @@
(#try.Failure error)
(wrap (list)))))
-(def: (pause _)
- (-> Any (Promise (Try Any)))
- (promise.delay 1,000 (#try.Success [])))
+(def: #export delay
+ Nat
+ 1,000)
-(def: #export (do! watcher command)
+(def: (pause delay)
+ (-> Nat (Promise (Try Any)))
+ (promise.delay delay (#try.Success [])))
+
+(def: #export (do! delay watcher command)
(All [a]
- (-> (Watcher Promise)
+ (-> Nat (Watcher Promise)
(-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command a))
(-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any))))
(function (_ console program fs shell resolution)
@@ -65,7 +69,7 @@
_ <call>]
(loop [_ []]
(do !
- [_ (..pause [])
+ [_ (..pause delay)
events (\ watcher poll [])
_ (case events
(#.Cons _)
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index 7052109fb..e2d6f78b8 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -132,66 +132,82 @@
(def: #export failure "[BUILD FAILED]")
(template [<name> <capability>]
- [(def: (<name> console process)
+ [(def: #export (<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)))))]
+ ## This is a very odd way of implementing this function.
+ ## But it's written this way because the more straightforward way (i.e. by using (try.with promise.monad))
+ ## eventually led to the function hanging/freezing.
+ ## I'm not sure why it happened, but I got this weirder implementation to work.
+ (let [[read! write!] (: [(Promise (Try Any))
+ (promise.Resolver (Try Any))]
+ (promise.promise []))
+ _ (|> (!.use (\ process <capability>) [])
+ (promise.await (function (recur ?line)
+ (case ?line
+ (#try.Failure error)
+ (if (exception.match? shell.no_more_output error)
+ (write! (#try.Success []))
+ (promise.await write! (console.write_line error console)))
+
+ (#try.Success line)
+ (promise.await (function (_ outcome)
+ (case outcome
+ (#try.Failure error)
+ (write! (#try.Failure error))
+
+ (#try.Success _)
+ (promise.await recur
+ (!.use (\ process <capability>) []))))
+ (console.write_line line console)))))
+ io.run)]
+ read!))]
[log_output! read]
[log_error! error]
)
-(def: #export (do! console program fs shell resolution profile)
+(def: #export (do! console program fs shell resolution)
(-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Compiler Path]))
- (case [(get@ #///.program profile)
- (get@ #///.target profile)]
- [#.None _]
- (promise\wrap (exception.throw ..no_specified_program []))
-
- [_ #.None]
- (promise\wrap (exception.throw ..no_specified_target []))
-
- [(#.Some program_module) (#.Some target)]
- (do promise.monad
- [environment (\ program environment [])
- home (\ program home [])
- working_directory (\ program directory [])]
- (do ///action.monad
- [[resolution compiler] (promise\wrap (..compiler resolution))
- #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)
- process (!.use (\ shell execute)
- [environment
- working_directory
- command
- (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
- ..failure)
- console)]
- (wrap [compiler
- (format cache_directory / output)])))))
+ (function (_ profile)
+ (case [(get@ #///.program profile)
+ (get@ #///.target profile)]
+ [#.None _]
+ (promise\wrap (exception.throw ..no_specified_program []))
+
+ [_ #.None]
+ (promise\wrap (exception.throw ..no_specified_target []))
+
+ [(#.Some program_module) (#.Some target)]
+ (do promise.monad
+ [environment (\ program environment [])
+ home (\ program home [])
+ working_directory (\ program directory [])]
+ (do ///action.monad
+ [[resolution compiler] (promise\wrap (..compiler resolution))
+ #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)
+ process (!.use (\ shell execute)
+ [environment
+ working_directory
+ command
+ (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
+ ..failure)
+ console)]
+ (wrap [compiler
+ (format cache_directory / output)]))))))
diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux
index c3b517437..e717b7cd6 100644
--- a/stdlib/source/program/aedifex/command/test.lux
+++ b/stdlib/source/program/aedifex/command/test.lux
@@ -21,6 +21,7 @@
["." // #_
["#." build]
["/#" // #_
+ ["#" profile]
["#." action]
["#." command (#+ Command)]
["#." runtime]
@@ -37,7 +38,8 @@
[environment (\ program environment [])
working_directory (\ program directory [])]
(do ///action.monad
- [[compiler program] (//build.do! console program fs shell resolution profile)
+ [[compiler program] (//build.do! console program fs shell resolution
+ (set@ #///.program (get@ #///.test profile) profile))
_ (console.write_line ..start console)
#let [[compiler_command compiler_parameters] (case compiler
(#//build.JVM artifact) (///runtime.java program)
@@ -47,6 +49,8 @@
working_directory
compiler_command
compiler_parameters])
+ _ (//build.log_output! console process)
+ _ (//build.log_error! console process)
exit (!.use (\ process await) [])
_ (console.write_line (if (i.= shell.normal exit)
..success
diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux
index d42333fd9..6fcbb2db7 100644
--- a/stdlib/source/program/aedifex/format.lux
+++ b/stdlib/source/program/aedifex/format.lux
@@ -143,7 +143,7 @@
(..on_maybe "target" (get@ #/.target value) code.text)
(..on_maybe "program" (get@ #/.program value) code.text)
(..on_maybe "test" (get@ #/.test value) code.text)
- (..on_dictionary "deploy-repositories" (get@ #/.deploy_repositories value) code.text code.text)
+ (..on_dictionary "deploy_repositories" (get@ #/.deploy_repositories value) code.text code.text)
..aggregate))
(def: #export project
diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux
index 046c8893c..3c1b4144a 100644
--- a/stdlib/source/program/aedifex/parser.lux
+++ b/stdlib/source/program/aedifex/parser.lux
@@ -171,9 +171,6 @@
(<>.and <c>.text
..repository))))
-(def: default_repository
- "https://repo1.maven.org/maven2/")
-
(def: profile
(Parser /.Profile)
(do {! <>.monad}
@@ -194,7 +191,7 @@
(|> (..plural input "repositories" ..repository)
(\ ! map (set.from_list text.hash))
(<>.default (set.new text.hash))
- (\ ! map (set.add ..default_repository))))
+ (\ ! map (set.add /.default_repository))))
^dependencies (: (Parser (Set //dependency.Dependency))
(|> (..plural input "dependencies" ..dependency)
(\ ! map (set.from_list //dependency.hash))
diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux
index fa49e41cd..592e221fd 100644
--- a/stdlib/source/program/aedifex/profile.lux
+++ b/stdlib/source/program/aedifex/profile.lux
@@ -24,8 +24,8 @@
[//
["." artifact (#+ Artifact)]
["." dependency]
- ["." repository #_
- ["#" remote (#+ Address)]]])
+ [repository
+ [remote (#+ Address)]]])
(type: #export Distribution
#Repo
@@ -132,6 +132,10 @@
Target
"target")
+(def: #export default_repository
+ Address
+ "https://repo1.maven.org/maven2/")
+
(type: #export Name
Text)
@@ -143,13 +147,13 @@
{#parents (List Name)
#identity (Maybe Artifact)
#info (Maybe Info)
- #repositories (Set repository.Address)
+ #repositories (Set Address)
#dependencies (Set dependency.Dependency)
#sources (Set Source)
#target (Maybe Target)
#program (Maybe Module)
#test (Maybe Module)
- #deploy_repositories (Dictionary Text repository.Address)})
+ #deploy_repositories (Dictionary Text Address)})
(def: #export equivalence
(Equivalence Profile)