diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/compositor.lux | 29 | ||||
-rw-r--r-- | stdlib/source/program/compositor/cli.lux | 40 |
2 files changed, 47 insertions, 22 deletions
diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index bc96e7ae0..aa3239de2 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -17,7 +17,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." dictionary] + ["." dictionary (#+ Dictionary)] ["." row (#+ Row)]]] [time ["." instant]] @@ -84,15 +84,32 @@ (format "Duration: ")))]] (wrap output))) -(def: (package! fs [packager package] static archive context) - (-> (file.System Promise) [Packager file.Path] Static Archive Context (Promise (Try Any))) - (case (packager archive context) +(def: (package! fs host_dependencies [packager package] static archive context) + (-> (file.System Promise) (Dictionary file.Path Binary) [Packager file.Path] Static Archive Context (Promise (Try Any))) + (case (packager host_dependencies archive context) (#try.Success content) (\ fs write content package) (#try.Failure error) (\ promise.monad wrap (#try.Failure error)))) +(def: (load_host_dependencies fs host_dependencies) + (-> (file.System Promise) (List file.Path) (Promise (Try (Dictionary file.Path Binary)))) + (do {! (try.with promise.monad)} + [] + (loop [pending host_dependencies + output (: (Dictionary file.Path Binary) + (dictionary.new text.hash))] + (case pending + #.Nil + (wrap output) + + (#.Cons head tail) + (do ! + [content (\ fs read head)] + (recur tail + (dictionary.put head content output))))))) + (with_expansions [<parameters> (as_is anchor expression artifact)] (def: #export (compiler static expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender @@ -118,7 +135,7 @@ (<| (or_crash! "Compilation failed:") ..timed (do (try.with promise.monad) - [#let [[compilation_sources compilation_libraries compilation_target compilation_module] compilation] + [#let [[compilation_sources compilation_host_dependencies compilation_libraries compilation_target compilation_module] compilation] import (/import.import (get@ #platform.&file_system platform) compilation_libraries) [state archive] (:share [<parameters>] (Platform <parameters>) @@ -136,9 +153,11 @@ (:assume (platform.compile import static expander platform compilation [archive state]))) _ (ioW.freeze (get@ #platform.&file_system platform) static archive) program_context (promise\wrap ($/program.context archive)) + host_dependencies (..load_host_dependencies (get@ #platform.&file_system platform) compilation_host_dependencies) _ (..package! (for {@.old (file.async file.default) @.jvm (file.async file.default) @.js file.default}) + host_dependencies packager,package static archive diff --git a/stdlib/source/program/compositor/cli.lux b/stdlib/source/program/compositor/cli.lux index d3b61640b..f0fdb80be 100644 --- a/stdlib/source/program/compositor/cli.lux +++ b/stdlib/source/program/compositor/cli.lux @@ -16,6 +16,9 @@ (type: #export Source Path) +(type: #export Host_Dependency + Path) + (type: #export Library Path) @@ -23,7 +26,7 @@ Path) (type: #export Compilation - [(List Source) (List Library) Target Module]) + [(List Source) (List Host_Dependency) (List Library) Target Module]) (type: #export Export [(List Source) Target]) @@ -38,10 +41,11 @@ (Parser <type>) (cli.named <long> cli.any))] - [^source "--source" Source] - [^library "--library" Library] - [^target "--target" Target] - [^module "--module" Module] + [source_parser "--source" Source] + [host_dependency_parser "--host_dependency" Host_Dependency] + [library_parser "--library" Library] + [target_parser "--target" Target] + [module_parser "--module" Module] ) (def: #export service @@ -49,25 +53,27 @@ ($_ <>.or (<>.after (cli.this "build") ($_ <>.and - (<>.some ..^source) - (<>.some ..^library) - ..^target - ..^module)) + (<>.some ..source_parser) + (<>.some ..host_dependency_parser) + (<>.some ..library_parser) + ..target_parser + ..module_parser)) (<>.after (cli.this "repl") ($_ <>.and - (<>.some ..^source) - (<>.some ..^library) - ..^target - ..^module)) + (<>.some ..source_parser) + (<>.some ..host_dependency_parser) + (<>.some ..library_parser) + ..target_parser + ..module_parser)) (<>.after (cli.this "export") ($_ <>.and - (<>.some ..^source) - ..^target)) + (<>.some ..source_parser) + ..target_parser)) )) (def: #export target (-> Service Target) - (|>> (case> (^or (#Compilation [sources libraries target module]) - (#Interpretation [sources libraries target module]) + (|>> (case> (^or (#Compilation [sources host_dependencies libraries target module]) + (#Interpretation [sources host_dependencies libraries target module]) (#Export [sources target])) target))) |