aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/program')
-rw-r--r--stdlib/source/program/aedifex.lux17
-rw-r--r--stdlib/source/program/aedifex/command/auto.lux6
-rw-r--r--stdlib/source/program/aedifex/command/build.lux20
-rw-r--r--stdlib/source/program/aedifex/command/test.lux57
-rw-r--r--stdlib/source/program/aedifex/format.lux43
-rw-r--r--stdlib/source/program/aedifex/parser.lux28
-rw-r--r--stdlib/source/program/aedifex/profile.lux68
-rw-r--r--stdlib/source/program/aedifex/runtime.lux48
8 files changed, 198 insertions, 89 deletions
diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux
index f5ec4caf2..4cfc376d3 100644
--- a/stdlib/source/program/aedifex.lux
+++ b/stdlib/source/program/aedifex.lux
@@ -31,7 +31,7 @@
[lux
["." syntax]]]]]
[world
- ["." shell (#+ Shell)]
+ ["." shell (#+ Exit Shell)]
["." console (#+ Console)]
["." program (#+ Program)]
["." file (#+ Path)
@@ -72,7 +72,7 @@
(def: (with_dependencies program console command profile)
(All [a]
(-> (Program Promise) (Console Promise)
- (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command a))
+ (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit a]))
(Command a)))
(do /action.monad
[resolution (/command/deps.do! console
@@ -80,8 +80,17 @@
(..repositories profile)
(|>> (/repository/remote.repository http.default #.None)
/repository.async)
- profile)]
- ((command console program (file.async file.default) (shell.async shell.default) resolution) profile)))
+ profile)
+ [exit_code output] ((command console program (file.async file.default) (shell.async shell.default) resolution) profile)
+ _ (case exit_code
+ (^ (static shell.normal))
+ (wrap [])
+
+ _
+ (do promise.monad
+ [_ (\ program exit exit_code)]
+ (wrap (#try.Failure ""))))]
+ (wrap output)))
(exception: (cannot_find_repository {repository Text}
{options (Dictionary Text Address)})
diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux
index 398fb26cf..ee2ab4bbd 100644
--- a/stdlib/source/program/aedifex/command/auto.lux
+++ b/stdlib/source/program/aedifex/command/auto.lux
@@ -12,7 +12,7 @@
["." set]]]
[world
[program (#+ Program)]
- [shell (#+ Shell)]
+ [shell (#+ Exit Shell)]
[console (#+ Console)]
["." file
["." watch (#+ Watcher)]]]]
@@ -45,8 +45,8 @@
(def: #export (do! delay watcher command)
(All [a]
(-> 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))))
+ (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit a]))
+ (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit Any]))))
(function (_ console program fs shell resolution)
(function (_ profile)
(with_expansions [<call> ((command console program fs shell resolution) profile)]
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index 2f603dbc1..34351f636 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -23,7 +23,7 @@
[world
["." program (#+ Program)]
["." file (#+ Path)]
- ["." shell (#+ Process Shell)]
+ ["." shell (#+ Exit Process Shell)]
["." console (#+ Console)]
[net
["." uri]]]]
@@ -169,7 +169,7 @@
)
(def: #export (do! console program fs shell resolution)
- (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Compiler Path]))
+ (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit Compiler Path]))
(function (_ profile)
(let [target (get@ #///.target profile)]
(case (get@ #///.program profile)
@@ -186,13 +186,14 @@
#let [[[command compiler_params] output] (case compiler
(^template [<tag> <runtime> <program>]
[(<tag> dependency)
- [(<runtime> (..path fs home dependency))
+ [(///runtime.for (get@ <runtime> profile)
+ (..path fs home dependency))
<program>]])
- ([#JVM ///runtime.java "program.jar"]
- [#JS ///runtime.node "program.js"]
- [#Python ///runtime.java "program.py"]
- [#Lua ///runtime.java "program.lua"]
- [#Ruby ///runtime.java "program.rb"]))
+ ([#JVM #///.java "program.jar"]
+ [#JS #///.js "program.js"]
+ [#Python #///.java "program.py"]
+ [#Lua #///.java "program.lua"]
+ [#Ruby #///.java "program.rb"]))
/ (\ fs separator)
cache_directory (format working_directory / target)]
_ (console.write_line ..start console)
@@ -212,5 +213,6 @@
..success
..failure)
console)]
- (wrap [compiler
+ (wrap [exit
+ compiler
(format cache_directory / output)])))))))
diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux
index 0ccc0cfb2..55614ba80 100644
--- a/stdlib/source/program/aedifex/command/test.lux
+++ b/stdlib/source/program/aedifex/command/test.lux
@@ -14,7 +14,7 @@
[world
["." program (#+ Program)]
["." file]
- ["." shell (#+ Shell)]
+ ["." shell (#+ Exit Shell)]
["." console (#+ Console)]]]
["." // #_
["#." build]
@@ -31,32 +31,35 @@
(def: #export failure "[TEST FAILED]")
(def: #export (do! console program fs shell resolution profile)
- (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any))
+ (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit Any]))
(do promise.monad
[environment (program.environment promise.monad program)
#let [working_directory (\ program directory)]]
- (do ///action.monad
- [[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
- (^template [<tag> <runtime>]
- [(<tag> artifact)
- (<runtime> program)])
- ([#//build.JVM ///runtime.java]
- [#//build.JS ///runtime.node]
- [#//build.Python ///runtime.python]
- [#//build.Lua ///runtime.lua]
- [#//build.Ruby ///runtime.ruby]))]
- process (\ shell execute [environment
- working_directory
- compiler_command
- compiler_parameters])
- _ (//build.log_output! console process)
- _ (//build.log_error! console process)
- exit (\ process await [])
- _ (console.write_line (if (i.= shell.normal exit)
- ..success
- ..failure)
- console)]
- (wrap []))))
+ (do {! ///action.monad}
+ [[build_exit compiler program] (//build.do! console program fs shell resolution
+ (set@ #///.program (get@ #///.test profile) profile))]
+ (if (i.= shell.normal build_exit)
+ (do !
+ [_ (console.write_line ..start console)
+ #let [[compiler_command compiler_parameters] (case compiler
+ (^template [<tag> <runtime>]
+ [(<tag> artifact)
+ (///runtime.for (get@ <runtime> profile) program)])
+ ([#//build.JVM #///.java]
+ [#//build.JS #///.js]
+ [#//build.Python #///.python]
+ [#//build.Lua #///.lua]
+ [#//build.Ruby #///.ruby]))]
+ process (\ shell execute [environment
+ working_directory
+ compiler_command
+ compiler_parameters])
+ _ (//build.log_output! console process)
+ _ (//build.log_error! console process)
+ exit (\ process await [])
+ _ (console.write_line (if (i.= shell.normal exit)
+ ..success
+ ..failure)
+ console)]
+ (wrap [exit []]))
+ (wrap [build_exit []])))))
diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux
index 9b44eced5..c7fc93b5a 100644
--- a/stdlib/source/program/aedifex/format.lux
+++ b/stdlib/source/program/aedifex/format.lux
@@ -7,9 +7,11 @@
["." list ("#\." functor)]
["." set (#+ Set)]]]
[macro
- ["." code]]]
+ ["." code]
+ ["." template]]]
["." // #_
["/" profile]
+ ["#." runtime (#+ Runtime)]
["#." project (#+ Project)]
["#." dependency (#+ Dependency)]
["#." artifact (#+ Artifact)
@@ -131,21 +133,34 @@
(` [(~+ (..artifact' artifact))
(~ (code.text type))])))
+(def: (runtime [program parameters])
+ (Format Runtime)
+ (` [(~ (code.text program))
+ (~+ (list\map code.text parameters))]))
+
(def: #export (profile value)
(Format /.Profile)
- (|> ..empty
- (..on_list "parents" (get@ #/.parents value) code.text)
- (..on_maybe "identity" (get@ #/.identity value) ..artifact)
- (..on_maybe "info" (get@ #/.info value) ..info)
- (..on_set "repositories" (get@ #/.repositories value) code.text)
- (..on_set "dependencies" (get@ #/.dependencies value) ..dependency)
- (dictionary.put "compiler" (..dependency (get@ #/.compiler value)))
- (..on_set "sources" (get@ #/.sources value) code.text)
- (dictionary.put "target" (code.text (get@ #/.target value)))
- (..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)
- ..aggregate))
+ (`` (|> ..empty
+ (..on_list "parents" (get@ #/.parents value) code.text)
+ (..on_maybe "identity" (get@ #/.identity value) ..artifact)
+ (..on_maybe "info" (get@ #/.info value) ..info)
+ (..on_set "repositories" (get@ #/.repositories value) code.text)
+ (..on_set "dependencies" (get@ #/.dependencies value) ..dependency)
+ (dictionary.put "compiler" (..dependency (get@ #/.compiler value)))
+ (..on_set "sources" (get@ #/.sources value) code.text)
+ (dictionary.put "target" (code.text (get@ #/.target value)))
+ (..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)
+ (~~ (template [<tag>]
+ [(dictionary.put (template.text [<tag>]) (..runtime (get@ <tag> value)))]
+
+ [#/.java]
+ [#/.js]
+ [#/.python]
+ [#/.lua]
+ [#/.ruby]))
+ ..aggregate)))
(def: #export project
(Format Project)
diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux
index 8d0fcdf73..6374f8807 100644
--- a/stdlib/source/program/aedifex/parser.lux
+++ b/stdlib/source/program/aedifex/parser.lux
@@ -19,6 +19,7 @@
[net (#+ URL)]]]
["." // #_
["/" profile]
+ ["#." runtime (#+ Runtime)]
["#." project (#+ Project)]
["#." dependency]
["#." repository #_
@@ -171,6 +172,11 @@
(<>.and <code>.text
..repository))))
+(def: runtime
+ (Parser Runtime)
+ (<code>.tuple (<>.and <code>.text
+ (<>.some <code>.text))))
+
(def: profile
(Parser /.Profile)
(do {! <>.monad}
@@ -216,7 +222,22 @@
^deploy_repositories (: (Parser (Dictionary Text //repository.Address))
(<| (\ ! map (dictionary.from_list text.hash))
(<>.default (list))
- (..singular input "deploy_repositories" ..deploy_repository)))]]
+ (..singular input "deploy_repositories" ..deploy_repository)))
+ ^java (|> ..runtime
+ (..singular input "java")
+ (<>.default //runtime.default_java))
+ ^js (|> ..runtime
+ (..singular input "js")
+ (<>.default //runtime.default_js))
+ ^python (|> ..runtime
+ (..singular input "python")
+ (<>.default //runtime.default_python))
+ ^lua (|> ..runtime
+ (..singular input "lua")
+ (<>.default //runtime.default_lua))
+ ^ruby (|> ..runtime
+ (..singular input "ruby")
+ (<>.default //runtime.default_ruby))]]
($_ <>.and
^parents
^identity
@@ -229,6 +250,11 @@
^program
^test
^deploy_repositories
+ ^java
+ ^js
+ ^python
+ ^lua
+ ^ruby
)))
(def: #export project
diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux
index d31d0aca9..9fe05b10b 100644
--- a/stdlib/source/program/aedifex/profile.lux
+++ b/stdlib/source/program/aedifex/profile.lux
@@ -13,6 +13,8 @@
["." dictionary (#+ Dictionary)]
["." list ("#\." monoid)]
["." set (#+ Set)]]]
+ [macro
+ ["." template]]
[world
[net (#+ URL)]
[file (#+ Path)]]
@@ -22,6 +24,7 @@
[archive
[descriptor (#+ Module)]]]]]]
[//
+ ["." runtime (#+ Runtime) ("#\." equivalence)]
["." dependency (#+ Dependency) ("#\." equivalence)]
["." artifact (#+ Artifact)
["." type]]
@@ -160,7 +163,12 @@
#target Target
#program (Maybe Module)
#test (Maybe Module)
- #deploy_repositories (Dictionary Text Address)})
+ #deploy_repositories (Dictionary Text Address)
+ #java Runtime
+ #js Runtime
+ #python Runtime
+ #lua Runtime
+ #ruby Runtime})
(def: #export equivalence
(Equivalence Profile)
@@ -186,7 +194,17 @@
## #test
(maybe.equivalence text.equivalence)
## #deploy_repositories
- (dictionary.equivalence text.equivalence)))
+ (dictionary.equivalence text.equivalence)
+ ## #java
+ runtime.equivalence
+ ## #js
+ runtime.equivalence
+ ## #python
+ runtime.equivalence
+ ## #lua
+ runtime.equivalence
+ ## #ruby
+ runtime.equivalence))
(implementation: #export monoid
(Monoid Profile)
@@ -202,23 +220,37 @@
#target ..default_target
#program #.None
#test #.None
- #deploy_repositories (dictionary.new text.hash)})
+ #deploy_repositories (dictionary.new text.hash)
+ #java runtime.default_java
+ #js runtime.default_js
+ #python runtime.default_python
+ #lua runtime.default_lua
+ #ruby runtime.default_ruby})
(def: (compose override baseline)
- {#parents (list\compose (get@ #parents baseline) (get@ #parents override))
- #identity (maybe\compose (get@ #identity override) (get@ #identity baseline))
- #info (maybe\compose (get@ #info override) (get@ #info baseline))
- #repositories (set.union (get@ #repositories baseline) (get@ #repositories override))
- #dependencies (set.union (get@ #dependencies baseline) (get@ #dependencies override))
- #compiler (if (dependency\= ..default_compiler (get@ #compiler override))
- (get@ #compiler baseline)
- (get@ #compiler override))
- #sources (set.union (get@ #sources baseline) (get@ #sources override))
- #target (if (text\= ..default_target (get@ #target baseline))
- (get@ #target override)
- (get@ #target baseline))
- #program (maybe\compose (get@ #program override) (get@ #program baseline))
- #test (maybe\compose (get@ #test override) (get@ #test baseline))
- #deploy_repositories (dictionary.merge (get@ #deploy_repositories override) (get@ #deploy_repositories baseline))}))
+ (template.let [(!runtime <tag> <runtime>)
+ [(if (runtime\= <runtime> (get@ <tag> override))
+ (get@ <tag> baseline)
+ (get@ <tag> override))]]
+ {#parents (list\compose (get@ #parents baseline) (get@ #parents override))
+ #identity (maybe\compose (get@ #identity override) (get@ #identity baseline))
+ #info (maybe\compose (get@ #info override) (get@ #info baseline))
+ #repositories (set.union (get@ #repositories baseline) (get@ #repositories override))
+ #dependencies (set.union (get@ #dependencies baseline) (get@ #dependencies override))
+ #compiler (if (dependency\= ..default_compiler (get@ #compiler override))
+ (get@ #compiler baseline)
+ (get@ #compiler override))
+ #sources (set.union (get@ #sources baseline) (get@ #sources override))
+ #target (if (text\= ..default_target (get@ #target baseline))
+ (get@ #target override)
+ (get@ #target baseline))
+ #program (maybe\compose (get@ #program override) (get@ #program baseline))
+ #test (maybe\compose (get@ #test override) (get@ #test baseline))
+ #deploy_repositories (dictionary.merge (get@ #deploy_repositories override) (get@ #deploy_repositories baseline))
+ #java (!runtime #java runtime.default_java)
+ #js (!runtime #js runtime.default_js)
+ #python (!runtime #python runtime.default_python)
+ #lua (!runtime #lua runtime.default_lua)
+ #ruby (!runtime #ruby runtime.default_ruby)})))
(exception: #export no_identity)
diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux
index e3f5a4e92..571a9fc43 100644
--- a/stdlib/source/program/aedifex/runtime.lux
+++ b/stdlib/source/program/aedifex/runtime.lux
@@ -1,22 +1,44 @@
(.module:
- [lux #*
+ [lux (#- for)
+ [abstract
+ [equivalence (#+ Equivalence)]]
[data
- [text
- ["%" format (#+ format)]]]
+ ["." product]
+ ["." text
+ ["%" format (#+ format)]]
+ [collection
+ ["." list ("#\." monoid)]]]
[macro
["." template]]
[world
- [file (#+ Path)]
- [shell (#+ Command)]]])
+ ["." file]]])
+
+(type: #export Runtime
+ {#program Text
+ #parameters (List Text)})
+
+(def: #export equivalence
+ (Equivalence Runtime)
+ (product.equivalence
+ text.equivalence
+ (list.equivalence text.equivalence)))
(template [<name> <command> <parameters>]
- [(def: #export (<name> path)
- (-> Path [Text (List Text)])
- (`` (format [<command> (list (~~ (template.splice <parameters>)) path)])))]
+ [(def: #export <name>
+ Runtime
+ {#program <command>
+ #parameters (`` (list (~~ (template.splice <parameters>))))})]
- [java "java" ["-jar"]]
- [node "node" ["--stack_size=8192"]]
- [python "python3" []]
- [lua "lua" []]
- [ruby "RUBY_THREAD_VM_STACK_SIZE=15700000 ruby" []]
+ [default_java "java" ["-jar"]]
+ [default_js "node" ["--stack_size=8192"]]
+ [default_python "python3" []]
+ [default_lua "lua" []]
+ [default_ruby "RUBY_THREAD_VM_STACK_SIZE=15700000 ruby" []]
)
+
+(def: #export (for runtime path)
+ (-> Runtime file.Path Runtime)
+ (update@ #parameters
+ (function (_ parameters)
+ (list\compose parameters (list path)))
+ runtime))