From 9965c551e7ccd6de8c47c7b1b78f804801810dac Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 16 May 2020 20:19:34 -0400 Subject: Parallel compilation for the new compiler(s). --- stdlib/source/program/compositor.lux | 56 +++++++---------------------- stdlib/source/program/compositor/cli.lux | 31 ++++++++-------- stdlib/source/program/compositor/static.lux | 11 ++++++ 3 files changed, 39 insertions(+), 59 deletions(-) create mode 100644 stdlib/source/program/compositor/static.lux (limited to 'stdlib/source/program') diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index fcf05f164..43bc084c5 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -49,7 +49,8 @@ ## ["." interpreter] ]] ["." / #_ - ["#." cli (#+ Service)]]) + ["#." cli (#+ Configuration)] + ["#." static (#+ Static)]]) (def: (or-crash! failure-description action) (All [a] @@ -67,48 +68,20 @@ (wrap output)))) (with-expansions [ (as-is anchor expression artifact)] - ## TODO: Clean-up ASAP. - ## (def: (save-artifacts! system state [packager package]) - ## (All [] - ## (-> (file.System Promise) - ## (directive.State+ ) - ## [(-> (Row [Module (generation.Buffer artifact)]) Binary) Path] - ## (Promise (Try Any)))) - ## (let [?outcome (phase.run' state - ## (:share [] - ## {(directive.State+ ) - ## state} - ## {(directive.Operation - ## (generation.Output artifact)) - ## (directive.lift-generation generation.output)}))] - ## (case ?outcome - ## (#try.Success [state output]) - ## (do (try.with promise.monad) - ## [file (: (Promise (Try (File Promise))) - ## (file.get-file promise.monad system package))] - ## (!.use (:: file over-write) (packager output))) - - ## (#try.Failure error) - ## (promise@wrap (#try.Failure error))))) - - (def: #export (compiler target partial-host-extension - expander host-analysis platform host generation-bundle host-directive-bundle program extender - service - extension + (def: #export (compiler static + expander host-analysis platform generation-bundle host-directive-bundle program extender + configuration packager,package) (All [] - (-> Path - Text + (-> Static Expander analysis.Bundle (IO (Platform )) - Host (generation.Bundle ) (directive.Bundle ) (-> expression artifact) Extender - Service - Text + Configuration [(-> (Row [Module (generation.Buffer artifact)]) Binary) Path] (Promise Any))) (do promise.monad @@ -116,8 +89,8 @@ console (|> console.system promise.future (:: @ map (|>> try.assume console.async)))] - (case service - (#/cli.Compilation configuration) + (case (get@ #/cli.service configuration) + #/cli.Compilation (<| (or-crash! "Compilation failed:") (do (try.with promise.monad) [[state archive] (:share [] @@ -125,19 +98,16 @@ platform} {(Promise (Try [(directive.State+ ) Archive])) - (platform.initialize extension target host (get@ #/cli.module configuration) expander host-analysis platform generation-bundle host-directive-bundle program extender)}) + (platform.initialize static (get@ #/cli.module configuration) expander host-analysis platform generation-bundle host-directive-bundle program extender)}) [archive state] (:share [] {(Platform ) platform} {(Promise (Try [Archive (directive.State+ )])) - (platform.compile target partial-host-extension expander platform host configuration archive extension state)}) - _ (ioW.freeze (get@ #platform.&file-system platform) host target archive) - ## _ (save-artifacts! (get@ #platform.&file-system platform) state packager,package) - ## _ (cache/io.clean target ...) - ] + (platform.compile static expander platform configuration [archive state])}) + _ (ioW.freeze (get@ #platform.&file-system platform) (get@ #/static.host static) (get@ #/static.target static) archive)] (wrap (log! "Compilation complete!")))) - (#/cli.Interpretation configuration) + #/cli.Interpretation ## TODO: Fix the interpreter... (undefined) ## (<| (or-crash! "Interpretation failed:") diff --git a/stdlib/source/program/compositor/cli.lux b/stdlib/source/program/compositor/cli.lux index 4453d5d36..0c20257ed 100644 --- a/stdlib/source/program/compositor/cli.lux +++ b/stdlib/source/program/compositor/cli.lux @@ -4,23 +4,20 @@ ["p" parser ["." cli (#+ Parser)]]] [world - [file (#+ Path)]]] - ## [/// - ## [importer (#+ Source)]] - ) + [file (#+ Path)]]]) + +(type: #export Service + #Compilation + #Interpretation) (type: #export Configuration - {## #sources (List Source) + {#service Service #sources (List Path) #target Path #module Text}) -(type: #export Service - (#Compilation Configuration) - (#Interpretation Configuration)) - (template [ ] - [(def: #export + [(def: (Parser Text) (cli.named cli.any))] @@ -29,15 +26,17 @@ [module "--module"] ) + +(def: service + (Parser Service) + ($_ p.or + (cli.this "build") + (cli.this "repl"))) + (def: #export configuration (Parser Configuration) ($_ p.and + ..service (p.some ..source) ..target ..module)) - -(def: #export service - (Parser Service) - ($_ p.or - (p.after (cli.this "build") ..configuration) - (p.after (cli.this "repl") ..configuration))) diff --git a/stdlib/source/program/compositor/static.lux b/stdlib/source/program/compositor/static.lux new file mode 100644 index 000000000..3fdd8727e --- /dev/null +++ b/stdlib/source/program/compositor/static.lux @@ -0,0 +1,11 @@ +(.module: + [lux #* + [target (#+ Host)] + [world + [file (#+ Path)]]]) + +(type: #export Static + {#host Host + #host-module-extension Text + #target Path + #artifact-extension Text}) -- cgit v1.2.3