diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/aedifex/command/build.lux | 59 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/command/deps.lux | 12 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/command/test.lux | 9 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/dependency/resolution.lux | 47 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/parser.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/runtime.lux | 14 | ||||
-rw-r--r-- | stdlib/source/program/compositor.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/compositor/static.lux | 4 |
8 files changed, 93 insertions, 56 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 diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index 89ad6368f..2d92e1438 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -196,7 +196,7 @@ failures tail resolution) - _ (do promise.monad + _ (do {! promise.monad} [?package (case (dictionary.get head resolution) (#.Some package) (wrap (#try.Success package)) @@ -205,23 +205,32 @@ (..any repositories head))] (case ?package (#try.Success package) - (let [sub_dependencies (|> package - ///package.dependencies - (try\map set.to_list) - (try.default (list))) - sub_repositories (|> package - ///package.repositories - (try\map set.to_list) - (try.default (list)) - (list\map (|>> (///repository/remote.repository #.None) - ///repository.async)) - (list\compose repositories))] - (|> resolution - (dictionary.put head package) - (recur sub_repositories - (#.Cons head successes) - failures - sub_dependencies))) + (do ! + [#let [sub_dependencies (|> package + ///package.dependencies + (try\map set.to_list) + (try.default (list))) + sub_repositories (|> package + ///package.repositories + (try\map set.to_list) + (try.default (list)) + (list\map (|>> (///repository/remote.repository #.None) + ///repository.async)) + (list\compose repositories))] + [successes failures resolution] (recur sub_repositories + (#.Cons head successes) + failures + sub_dependencies + (dictionary.put head package resolution))] + (recur repositories + successes + failures + tail + resolution)) (#try.Failure error) - (wrap [successes (#.Cons head failures) resolution]))))))) + (recur repositories + successes + (#.Cons head failures) + tail + resolution))))))) diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux index 411b4665b..046c8893c 100644 --- a/stdlib/source/program/aedifex/parser.lux +++ b/stdlib/source/program/aedifex/parser.lux @@ -215,7 +215,7 @@ ^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)))]] ($_ <>.and ^parents ^identity diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux index 6abfc5a62..42b1c315a 100644 --- a/stdlib/source/program/aedifex/runtime.lux +++ b/stdlib/source/program/aedifex/runtime.lux @@ -3,15 +3,17 @@ [data [text ["%" format (#+ format)]]] + [macro + ["." template]] [world [file (#+ Path)] [shell (#+ Command)]]]) -(template [<name> <command>] - [(def: #export <name> - (-> Path Command) - (|>> (format <command>)))] +(template [<name> <command> <parameters>] + [(def: #export (<name> path) + (-> Path [Text (List Text)]) + (`` (format [<command> (list (~~ (template.splice <parameters>)) path)])))] - [java "java -jar "] - [node "node --stack_size=8192 "] + [java "java" ["-jar"]] + [node "node" ["--stack_size=8192"]] ) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index 03e9b281d..a6b85ccf0 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -2,7 +2,7 @@ [lux (#- Module) [type (#+ :share)] ["." debug] - ["@" target (#+ Host)] + ["@" target] [abstract [monad (#+ Monad do)]] [control diff --git a/stdlib/source/program/compositor/static.lux b/stdlib/source/program/compositor/static.lux index 51bbef0e9..d5e100f30 100644 --- a/stdlib/source/program/compositor/static.lux +++ b/stdlib/source/program/compositor/static.lux @@ -1,11 +1,11 @@ (.module: [lux #* - [target (#+ Host)] + [target (#+ Target)] [world [file (#+ Path)]]]) (type: #export Static - {#host Host + {#host Target #host_module_extension Text #target Path #artifact_extension Text}) |