aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program
diff options
context:
space:
mode:
authorEduardo Julian2020-11-27 00:07:51 -0400
committerEduardo Julian2020-11-27 00:07:51 -0400
commit889139602b77e4387a6e8bfbedacc2a08703e976 (patch)
tree3a113e298037122e81b5529475bd1e59286f733f /stdlib/source/program
parentdbb658bd7976c073a2bf314f194b36b30c45784b (diff)
Re-named lux/data/format/context to lux/control/parser/environment.
Diffstat (limited to 'stdlib/source/program')
-rw-r--r--stdlib/source/program/aedifex.lux8
-rw-r--r--stdlib/source/program/aedifex/artifact.lux14
-rw-r--r--stdlib/source/program/aedifex/command/auto.lux23
-rw-r--r--stdlib/source/program/aedifex/command/build.lux40
-rw-r--r--stdlib/source/program/aedifex/command/deps.lux6
-rw-r--r--stdlib/source/program/aedifex/command/test.lux21
-rw-r--r--stdlib/source/program/aedifex/runtime.lux17
7 files changed, 71 insertions, 58 deletions
diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux
index 6f98c7651..bc8f75ee0 100644
--- a/stdlib/source/program/aedifex.lux
+++ b/stdlib/source/program/aedifex.lux
@@ -43,7 +43,7 @@
["#." cache]
["#." repository (#+ Address Repository)]
["#." dependency #_
- ["#" resolution]]
+ ["#" resolution (#+ Resolution)]]
["#." command (#+ Command)
["#/." clean]
["#/." pom]
@@ -61,10 +61,10 @@
(list\map (|>> /repository.remote /repository.async))))
(def: (with-dependencies command profile)
- (All [a] (-> (Command a) (Command a)))
+ (All [a] (-> (-> (file.System Promise) Resolution (Command a)) (Command a)))
(do /action.monad
- [_ (/command/deps.do! (file.async file.default) (..repositories profile) profile)]
- (command profile)))
+ [resolution (/command/deps.do! (file.async file.default) (..repositories profile) profile)]
+ (command (file.async file.default) resolution profile)))
(exception: (cannot-find-repository {repository Text}
{options (Dictionary Text Address)})
diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux
index c29cc7b2d..84e7839f8 100644
--- a/stdlib/source/program/aedifex/artifact.lux
+++ b/stdlib/source/program/aedifex/artifact.lux
@@ -1,7 +1,7 @@
(.module:
[lux (#- Name)
[abstract
- ["." equivalence (#+ Equivalence)]
+ [equivalence (#+ Equivalence)]
["." hash (#+ Hash)]]
[data
["." text
@@ -27,14 +27,6 @@
#name Name
#version Version})
-(def: #export equivalence
- (Equivalence Artifact)
- ($_ equivalence.product
- text.equivalence
- text.equivalence
- text.equivalence
- ))
-
(def: #export hash
(Hash Artifact)
($_ hash.product
@@ -43,6 +35,10 @@
text.hash
))
+(def: #export equivalence
+ (Equivalence Artifact)
+ (:: ..hash &equivalence))
+
(template [<separator> <definition>]
[(def: <definition>
Text
diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux
index 0fc223376..80ff8ac8c 100644
--- a/stdlib/source/program/aedifex/command/auto.lux
+++ b/stdlib/source/program/aedifex/command/auto.lux
@@ -7,19 +7,21 @@
["." try (#+ Try)]
["." io (#+ IO)]
[concurrency
- ["." promise]]]
+ ["." promise (#+ Promise)]]]
[data
[collection
["." array]
["." list]
["." set]]]
[world
- [file (#+ Path)]]]
+ ["." file (#+ Path)]]]
["." // #_
["/#" // #_
["#" profile]
["#." action (#+ Action)]
- ["#." command (#+ Command)]]])
+ ["#." command (#+ Command)]
+ [dependency
+ [resolution (#+ Resolution)]]]])
(import: java/nio/file/WatchKey
["#::."
@@ -124,18 +126,21 @@
#.None
(wrap []))))
-(def: #export (do! command profile)
- (All [a] (-> (Command a) (Command Any)))
+(def: #export (do! command fs resolution profile)
+ (All [a]
+ (-> (-> (file.System Promise) Resolution (Command a))
+ (-> (file.System Promise) Resolution (Command Any))))
(do {! ///action.monad}
- [#let [fs (java/nio/file/FileSystems::getDefault)]
- watcher (promise.future (java/nio/file/FileSystem::newWatchService fs))
+ [watcher (promise.future
+ (java/nio/file/FileSystem::newWatchService
+ (java/nio/file/FileSystems::getDefault)))
targets (|> profile
(get@ #///.sources)
set.to-list
(monad.map ! ..targets)
(:: ! map list.concat))
_ (monad.map ! (..watch! watcher) targets)
- _ (command profile)]
+ _ (command fs resolution profile)]
(loop [_ []]
(do !
[?key (..poll! watcher)
@@ -143,7 +148,7 @@
(#.Some key)
(do !
[_ (promise.future (..drain! watcher))
- _ (command profile)]
+ _ (command fs resolution profile)]
(wrap []))
#.None
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index b3a096ea8..72f96b25e 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -8,7 +8,7 @@
["." exception (#+ exception:)]
["." io (#+ IO)]
[concurrency
- ["." promise ("#@." monad)]]]
+ ["." promise (#+ Promise) ("#@." monad)]]]
[data
["." product]
["." maybe]
@@ -27,9 +27,10 @@
["#." local]
["#." cache]
["#." repository]
+ ["#." shell]
+ ["#." runtime]
["#." dependency (#+ Dependency)
["#/." resolution (#+ Resolution)]]
- ["#." shell]
["#." artifact (#+ Group Name Artifact)
["#/." type]]])
@@ -87,11 +88,11 @@
_
(exception.throw ..no-available-compiler [])))
-(def: libraries
- (-> Resolution (List Path))
+(def: (libraries fs)
+ (All [!] (-> (file.System !) Resolution (List Path)))
(|>> dictionary.keys
(list.filter (|>> (get@ #///dependency.type) (text@= ///artifact/type.lux-library)))
- (list@map (|>> (get@ #///dependency.artifact) (///local.path file.default)))))
+ (list@map (|>> (get@ #///dependency.artifact) (///local.path fs)))))
(import: java/lang/String)
@@ -114,9 +115,8 @@
(-> Text (List Text) Text)
(|> values (list@map (|>> (format name " "))) (text.join-with " ")))
-(def: #export (do! profile)
- (Command [Compiler
- Path])
+(def: #export (do! fs resolution profile)
+ (-> (file.System Promise) Resolution (Command [Compiler Path]))
(case [(get@ #///.program profile)
(get@ #///.target profile)]
[#.None _]
@@ -127,26 +127,16 @@
[(#.Some program) (#.Some target)]
(do ///action.monad
- [cache (///cache.read-all (file.async file.default)
- (set.to-list (get@ #///.dependencies profile))
- ///dependency/resolution.empty)
- resolution (///dependency/resolution.all (list@map (|>> ///repository.remote ///repository.async)
- (set.to-list (get@ #///.repositories profile)))
- (set.to-list (get@ #///.dependencies profile))
- cache)
- _ (///cache.write-all (file.async file.default)
- resolution)
- [resolution compiler] (promise@wrap (..compiler resolution))
+ [[resolution compiler] (promise@wrap (..compiler resolution))
working-directory (promise.future ..working-directory)
- #let [libraries (..libraries resolution)
- [prefix output] (case compiler
- (#JVM artifact) [(format "java -jar " (///local.path file.default artifact))
+ #let [[prefix output] (case compiler
+ (#JVM artifact) [(///runtime.java (///local.path fs artifact))
"program.jar"]
- (#JS artifact) [(format "node --stack_size=8192 " (///local.path file.default artifact))
+ (#JS artifact) [(///runtime.node (///local.path fs artifact))
"program.js"])
- cache-directory (format working-directory (:: file.default separator) target)
+ cache-directory (format working-directory (:: fs separator) target)
command (format prefix " build"
- " " (..plural-parameter "--library" libraries)
+ " " (..plural-parameter "--library" (..libraries fs resolution))
" " (..plural-parameter "--source" (set.to-list (get@ #///.sources profile)))
" " (..singular-parameter "--target" cache-directory)
" " (..singular-parameter "--module" program))]
@@ -154,5 +144,5 @@
outcome (///shell.execute command working-directory)
#let [_ (log! "[BUILD ENDED]")]]
(wrap [compiler
- (format cache-directory (:: file.default separator) output)]))
+ (format cache-directory (:: fs separator) output)]))
))
diff --git a/stdlib/source/program/aedifex/command/deps.lux b/stdlib/source/program/aedifex/command/deps.lux
index bc4d88f6c..dfe58d707 100644
--- a/stdlib/source/program/aedifex/command/deps.lux
+++ b/stdlib/source/program/aedifex/command/deps.lux
@@ -18,14 +18,14 @@
["#." action (#+ Action)]
["#." cache]
["#." dependency #_
- ["#/." resolution]]])
+ ["#/." resolution (#+ Resolution)]]])
(def: #export (do! fs repositories profile)
- (-> (file.System Promise) (List (Repository Promise)) (Command (Set Artifact)))
+ (-> (file.System Promise) (List (Repository Promise)) (Command Resolution))
(do ///action.monad
[#let [dependencies (set.to-list (get@ #///.dependencies profile))]
cache (///cache.read-all fs dependencies ///dependency/resolution.empty)
resolution (///dependency/resolution.all repositories dependencies cache)
cached (///cache.write-all fs resolution)
#let [_ (log! "Successfully resolved dependencies!")]]
- (wrap cached)))
+ (wrap resolution)))
diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux
index a27c07f10..d4519b2d0 100644
--- a/stdlib/source/program/aedifex/command/test.lux
+++ b/stdlib/source/program/aedifex/command/test.lux
@@ -4,25 +4,30 @@
[monad (#+ do)]]
[control
[concurrency
- ["." promise]]]
+ ["." promise (#+ Promise)]]]
[data
[text
- ["%" format (#+ format)]]]]
+ ["%" format (#+ format)]]]
+ [world
+ ["." file]]]
["." // #_
["#." build]
["/#" // #_
["#." action]
["#." command (#+ Command)]
- ["#." shell]]])
+ ["#." shell]
+ ["#." runtime]
+ [dependency
+ [resolution (#+ Resolution)]]]])
-(def: #export (do! project)
- (Command Any)
+(def: #export (do! fs resolution profile)
+ (-> (file.System Promise) Resolution (Command Any))
(do ///action.monad
- [[compiler program] (//build.do! project)
+ [[compiler program] (//build.do! fs resolution profile)
working-directory (promise.future //build.working-directory)
#let [command (case compiler
- (#//build.JVM artifact) (format "java -jar " program)
- (#//build.JS artifact) (format "node --stack_size=8192 " program))]
+ (#//build.JVM artifact) (///runtime.java program)
+ (#//build.JS artifact) (///runtime.node program))]
#let [_ (log! "[TEST STARTED]")]
outcome (///shell.execute command working-directory)
#let [_ (log! "[TEST ENDED]")]]
diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux
new file mode 100644
index 000000000..6abfc5a62
--- /dev/null
+++ b/stdlib/source/program/aedifex/runtime.lux
@@ -0,0 +1,17 @@
+(.module:
+ [lux #*
+ [data
+ [text
+ ["%" format (#+ format)]]]
+ [world
+ [file (#+ Path)]
+ [shell (#+ Command)]]])
+
+(template [<name> <command>]
+ [(def: #export <name>
+ (-> Path Command)
+ (|>> (format <command>)))]
+
+ [java "java -jar "]
+ [node "node --stack_size=8192 "]
+ )