From f27a91a7b67790272578692ea20e2d875dbb3d35 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 23 Feb 2022 05:30:53 -0400 Subject: ADDED Can pass config parameters to compiler and select code based on it. Can also select code based on compiler version. --- stdlib/source/program/aedifex/command/build.lux | 15 ++- stdlib/source/program/aedifex/command/deploy.lux | 107 +++++++++++---------- stdlib/source/program/aedifex/command/install.lux | 87 ++++++++--------- stdlib/source/program/aedifex/command/version.lux | 31 +++--- .../program/aedifex/dependency/resolution.lux | 5 +- stdlib/source/program/aedifex/format.lux | 3 +- stdlib/source/program/aedifex/hash.lux | 44 ++++----- stdlib/source/program/aedifex/parser.lux | 26 +++-- stdlib/source/program/aedifex/profile.lux | 15 ++- .../source/program/aedifex/repository/identity.lux | 23 ++--- .../source/program/aedifex/repository/remote.lux | 61 ++++++------ 11 files changed, 219 insertions(+), 198 deletions(-) (limited to 'stdlib/source/program/aedifex') diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 8570207be..599887fe4 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -6,7 +6,7 @@ [order {"+" Order}] [monad {"+" do}]] [control - ["[0]" try {"+" Try}] + ["[0]" try {"+" Try} ("[1]#[0]" functor)] ["[0]" exception {"+" exception:}] ["[0]" io {"+" IO}] [concurrency @@ -23,10 +23,13 @@ [number {"+" hex} ["n" nat] ["i" int]]] + [meta + ["[0]" configuration]] [tool [compiler [meta - ["[0]" cli] + [cli + ["[0]" compiler]] ["[0]" packager ["[0]_[1]" ruby]]]]] [world @@ -238,8 +241,9 @@ (def: windows? Bit - (|> (java/lang/System::getProperty "os.name") + (|> (java/lang/System::getProperty (ffi.as_string "os.name")) io.run! + (try#each (|>> ffi.of_string)) (try.else "") text.lower_cased (text.starts_with? "windows"))) @@ -306,10 +310,11 @@ (list "build") (..plural "--library" (..libraries fs home resolution)) (..plural "--host_dependency" host_dependencies) - (..plural "--compiler" (list#each cli.compiler_format (value@ ///.#compilers profile))) + (..plural "--compiler" (list#each compiler.format (value@ ///.#compilers profile))) (..plural "--source" (set.list (value@ ///.#sources profile))) (..singular "--target" cache_directory) - (..singular "--module" program_module)))] + (..singular "--module" program_module) + (..singular "--configuration" (configuration.format (value@ ///.#configuration profile)))))] process (# shell execute [environment working_directory command diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux index f80ed0275..3ceefa7c1 100644 --- a/stdlib/source/program/aedifex/command/deploy.lux +++ b/stdlib/source/program/aedifex/command/deploy.lux @@ -1,57 +1,58 @@ (.using - [library - [lux "*" - [abstract - [monad {"+" do}]] - [control - [pipe {"+" do>}] - ["[0]" try {"+" Try}] - [concurrency - ["[0]" async {"+" Async} ("[1]#[0]" monad)]] - ["<>" parser - ["<[0]>" xml]]] - [data - [binary {"+" Binary}] - [text - ["%" format {"+" format}] - [encoding - ["[0]" utf8]]] - [collection - ["[0]" set]] - [format - ["[0]" binary] - ["[0]" tar] - ["[0]" xml]]] - [time - ["[0]" instant {"+" Instant}]] - [world - ["[0]" file] - ["[0]" console {"+" Console}]]]] - [program - [compositor - ["[0]" export]]] - ["[0]" // "_" - ["[1][0]" clean] - ["/[1]" // "_" - [command {"+" Command}] - ["/" profile] - ["[1][0]" action {"+" Action}] - ["[1][0]" pom] - ["[1][0]" hash] - ["[1][0]" package] - ["[1][0]" dependency - ["[1]/[0]" deployment] - ["[1]/[0]" status {"+" Status}]] - ["[1][0]" repository {"+" Repository} - [identity {"+" Identity}] - ["[1]/[0]" remote] - ["[1]/[0]" origin]] - ["[1][0]" metadata - ["[1]/[0]" artifact] - ["[1]/[0]" snapshot]] - ["[1][0]" artifact {"+" Artifact} - ["[1]/[0]" extension {"+" Extension}] - ["[1]/[0]" type]]]]) + [library + [lux "*" + [abstract + [monad {"+" do}]] + [control + [pipe {"+" do>}] + ["[0]" try {"+" Try}] + [concurrency + ["[0]" async {"+" Async} ("[1]#[0]" monad)]] + ["<>" parser + ["<[0]>" xml]]] + [data + [binary {"+" Binary}] + [text + ["%" format {"+" format}] + [encoding + ["[0]" utf8]]] + [collection + ["[0]" set]] + [format + ["[0]" binary] + ["[0]" tar] + ["[0]" xml]]] + [time + ["[0]" instant {"+" Instant}]] + [tool + [compiler + [meta + ["[0]" export]]]] + [world + ["[0]" file] + ["[0]" console {"+" Console}]]]] + ["[0]" // "_" + ["[1][0]" clean] + ["/[1]" // "_" + [command {"+" Command}] + ["/" profile] + ["[1][0]" action {"+" Action}] + ["[1][0]" pom] + ["[1][0]" hash] + ["[1][0]" package] + ["[1][0]" dependency + ["[1]/[0]" deployment] + ["[1]/[0]" status {"+" Status}]] + ["[1][0]" repository {"+" Repository} + [identity {"+" Identity}] + ["[1]/[0]" remote] + ["[1]/[0]" origin]] + ["[1][0]" metadata + ["[1]/[0]" artifact] + ["[1]/[0]" snapshot]] + ["[1][0]" artifact {"+" Artifact} + ["[1]/[0]" extension {"+" Extension}] + ["[1]/[0]" type]]]]) (def: .public success "Successfully deployed the project.") diff --git a/stdlib/source/program/aedifex/command/install.lux b/stdlib/source/program/aedifex/command/install.lux index 06f3197f8..a1553e4bd 100644 --- a/stdlib/source/program/aedifex/command/install.lux +++ b/stdlib/source/program/aedifex/command/install.lux @@ -1,47 +1,48 @@ (.using - [library - [lux "*" - [abstract - [monad {"+" do}]] - [control - ["[0]" try {"+" Try}] - ["[0]" exception] - [concurrency - ["[0]" async {"+" Async}]]] - [data - [binary {"+" Binary}] - [text - [encoding - ["[0]" utf8]]] - [collection - ["[0]" set]] - [format - ["[0]" binary] - ["[0]" tar] - ["[0]" xml]]] - [world - [program {"+" Program}] - ["[0]" file] - ["[0]" console {"+" Console}]]]] - [program - [compositor - ["[0]" export]]] - ["[0]" // "_" - ["[1][0]" clean] - ["/[1]" // "_" - ["/" profile {"+" Profile}] - ["[1][0]" action {"+" Action}] - ["[1][0]" command {"+" Command}] - ["[1][0]" local] - ["[1][0]" pom] - ["[1][0]" package] - [repository {"+" Repository} - ["[1][0]" origin]] - ["[1][0]" dependency "_" - ["[1]/[0]" deployment] - ["[1]/[0]" status]] - ["[1][0]" artifact {"+" Artifact} - ["[1]/[0]" type]]]]) + [library + [lux "*" + [abstract + [monad {"+" do}]] + [control + ["[0]" try {"+" Try}] + ["[0]" exception] + [concurrency + ["[0]" async {"+" Async}]]] + [data + [binary {"+" Binary}] + [text + [encoding + ["[0]" utf8]]] + [collection + ["[0]" set]] + [format + ["[0]" binary] + ["[0]" tar] + ["[0]" xml]]] + [tool + [compiler + [meta + ["[0]" export]]]] + [world + [program {"+" Program}] + ["[0]" file] + ["[0]" console {"+" Console}]]]] + ["[0]" // "_" + ["[1][0]" clean] + ["/[1]" // "_" + ["/" profile {"+" Profile}] + ["[1][0]" action {"+" Action}] + ["[1][0]" command {"+" Command}] + ["[1][0]" local] + ["[1][0]" pom] + ["[1][0]" package] + [repository {"+" Repository} + ["[1][0]" origin]] + ["[1][0]" dependency "_" + ["[1]/[0]" deployment] + ["[1]/[0]" status]] + ["[1][0]" artifact {"+" Artifact} + ["[1]/[0]" type]]]]) (def: .public success "Successfully installed the project locally.") diff --git a/stdlib/source/program/aedifex/command/version.lux b/stdlib/source/program/aedifex/command/version.lux index 2a9072c39..c61e796df 100644 --- a/stdlib/source/program/aedifex/command/version.lux +++ b/stdlib/source/program/aedifex/command/version.lux @@ -1,21 +1,20 @@ (.using - [library - [lux "*" - [control - [concurrency - ["[0]" async {"+" Async}]]] - [tool - [compiler - ["[0]" version] - ["[0]" language "_" - ["[1]/[0]" lux "_" - ["[1]" version]]]]] - [world - ["[0]" console {"+" Console}]]]] - [/// - [command {"+" Command}]]) + [library + [lux "*" + [control + [concurrency + ["[0]" async {"+" Async}]]] + ["[0]" meta "_" + ["[1]/[0]" version]] + [tool + [compiler + ["[0]" version]]] + [world + ["[0]" console {"+" Console}]]]] + [/// + [command {"+" Command}]]) (def: .public (do! console profile) (-> (Console Async) (Command Any)) - (console.write_line (version.format language/lux.version) + (console.write_line (version.format meta/version.latest) console)) diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index ffea5d458..627a3e6ef 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -86,10 +86,7 @@ (case ?actual {try.#Success actual} (in (do [! try.monad] - [output (# ! each (for [@.old (|>> (:as java/lang/String) - java/lang/String::trim - (:as Text)) - @.jvm (|>> java/lang/String::trim)]) + [output (# ! each (|>> ffi.as_string java/lang/String::trim ffi.of_string) (# utf8.codec decoded actual)) actual (|> output (text.all_split_by " ") diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux index 54e1ed57f..d0628f160 100644 --- a/stdlib/source/program/aedifex/format.lux +++ b/stdlib/source/program/aedifex/format.lux @@ -13,7 +13,8 @@ [tool [compiler [meta - [cli {"+" Compiler}]]]]]] + [cli + [compiler {"+" Compiler}]]]]]]] ["[0]" // "_" ["/" profile] ["[1][0]" runtime {"+" Runtime}] diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 093f5fbe4..30b0cdcee 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -1,25 +1,25 @@ (.using - [library - [lux "*" - ["[0]" ffi {"+" import:}] - [abstract - [codec {"+" Codec}] - [equivalence {"+" Equivalence}] - [monad {"+" do}]] - [control - ["[0]" try {"+" Try}] - ["[0]" exception {"+" exception:}]] - [data - ["[0]" binary {"+" Binary}] - ["[0]" text - ["%" format {"+" Format format}] - ["[0]" encoding]]] - [math - [number - ["n" nat] - ["[0]" i64]]] - [type - abstract]]]) + [library + [lux "*" + ["[0]" ffi {"+" import:}] + [abstract + [codec {"+" Codec}] + [equivalence {"+" Equivalence}] + [monad {"+" do}]] + [control + ["[0]" try {"+" Try}] + ["[0]" exception {"+" exception:}]] + [data + ["[0]" binary {"+" Binary}] + ["[0]" text + ["%" format {"+" Format format}] + ["[0]" encoding]]] + [math + [number + ["n" nat] + ["[0]" i64]]] + [type + abstract]]]) ... TODO: Replace with pure-Lux implementations of these algorithms ... https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode @@ -44,7 +44,7 @@ (template [ ] [(def: .public ( value) (-> Binary (Hash )) - (|> (java/security/MessageDigest::getInstance []) + (|> (java/security/MessageDigest::getInstance [(ffi.as_string )]) (java/security/MessageDigest::digest [value]) :abstraction))] diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux index 52a9a292c..097373529 100644 --- a/stdlib/source/program/aedifex/parser.lux +++ b/stdlib/source/program/aedifex/parser.lux @@ -9,12 +9,14 @@ [data ["[0]" text] [collection - ["[0]" dictionary {"+" Dictionary}] - ["[0]" set {"+" Set}]]] + ["[0]" set {"+" Set}] + ["[0]" dictionary {"+" Dictionary} + ["[0]" plist {"+" PList}]]]] [tool [compiler [meta - [cli {"+" Compiler}] + [cli + [compiler {"+" Compiler}]] [archive [module [descriptor {"+" Module}]]]]]] @@ -179,10 +181,14 @@ .text) (def: deploy_repository - (Parser (List [Text //repository.Address])) - (.tuple (<>.some - (<>.and .text - ..repository)))) + (Parser [Text //repository.Address]) + (<>.and .text + ..repository)) + +(def: configuration/1 + (Parser [Text Text]) + (<>.and .text + .text)) (def: runtime (Parser Runtime) @@ -237,7 +243,10 @@ ^deploy_repositories (: (Parser (Dictionary Text //repository.Address)) (<| (# ! each (dictionary.of_list text.hash)) (<>.else (list)) - (..singular input "deploy_repositories" ..deploy_repository))) + (..plural input "deploy_repositories" ..deploy_repository))) + ^configuration (: (Parser (PList Text)) + (<| (<>.else (list)) + (..plural input "configuration" ..configuration/1))) ^java (|> ..runtime (..singular input "java") (<>.else //runtime.default_java)) @@ -266,6 +275,7 @@ ^program ^test ^deploy_repositories + ^configuration ^java ^js ^python diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index eeabf5f82..43887caa4 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -11,9 +11,10 @@ ["[0]" product] ["[0]" text ("[1]#[0]" equivalence)] [collection - ["[0]" dictionary {"+" Dictionary}] ["[0]" list ("[1]#[0]" monoid)] - ["[0]" set {"+" Set}]]] + ["[0]" set {"+" Set}] + ["[0]" dictionary {"+" Dictionary} + ["[0]" plist {"+" PList} ("[1]#[0]" monoid)]]]] [macro ["[0]" template]] [meta @@ -24,7 +25,8 @@ [tool [compiler [meta - ["[0]" cli {"+" Compiler}] + ["[0]" cli + ["[0]" compiler {"+" Compiler}]] [archive [module [descriptor {"+" Module}]]]]]]]] @@ -173,6 +175,7 @@ #program (Maybe Module) #test (Maybe Module) #deploy_repositories (Dictionary Text Address) + #configuration (PList Text) #java Runtime #js Runtime #python Runtime @@ -195,7 +198,7 @@ ... #lux dependency.equivalence ... #compilers - (list.equivalence cli.compiler_equivalence) + (list.equivalence compiler.equivalence) ... #sources set.equivalence ... #target @@ -206,6 +209,8 @@ (maybe.equivalence text.equivalence) ... #deploy_repositories (dictionary.equivalence text.equivalence) + ... #configuration + (plist.equivalence text.equivalence) ... #java runtime.equivalence ... #js @@ -233,6 +238,7 @@ #program {.#None} #test {.#None} #deploy_repositories (dictionary.empty text.hash) + #configuration plist.empty #java runtime.default_java #js runtime.default_js #python runtime.default_python @@ -260,6 +266,7 @@ #program (maybe#composite (value@ #program override) (value@ #program baseline)) #test (maybe#composite (value@ #test override) (value@ #test baseline)) #deploy_repositories (dictionary.merged (value@ #deploy_repositories override) (value@ #deploy_repositories baseline)) + #configuration (plist#composite (value@ #configuration override) (value@ #configuration baseline)) #java (!runtime #java runtime.default_java) #js (!runtime #js runtime.default_js) #python (!runtime #python runtime.default_python) diff --git a/stdlib/source/program/aedifex/repository/identity.lux b/stdlib/source/program/aedifex/repository/identity.lux index 6e058850d..8288f2d74 100644 --- a/stdlib/source/program/aedifex/repository/identity.lux +++ b/stdlib/source/program/aedifex/repository/identity.lux @@ -1,15 +1,15 @@ (.using - [library - [lux "*" - ["[0]" ffi {"+" import:}] - [abstract - [equivalence {"+" Equivalence}]] - [data - ["[0]" product] - ["[0]" text - ["%" format {"+" format}] - [encoding - ["[0]" utf8]]]]]]) + [library + [lux "*" + ["[0]" ffi {"+" import:}] + [abstract + [equivalence {"+" Equivalence}]] + [data + ["[0]" product] + ["[0]" text + ["%" format {"+" format}] + [encoding + ["[0]" utf8]]]]]]) (type: .public User Text) @@ -42,4 +42,5 @@ (let [credentials (# utf8.codec encoded (format user ":" password))] (|> (java/util/Base64::getEncoder) (java/util/Base64$Encoder::encodeToString credentials) + ffi.of_string (format "Basic ")))) diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index 9e50e71a6..7f1a735b8 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -1,34 +1,33 @@ (.using - [library - [lux "*" - [abstract - [monad {"+" do}]] - [control - ["[0]" io {"+" IO}] - ["[0]" try {"+" Try}] - ["[0]" exception {"+" exception:}]] - [data - ["[0]" product] - [text - ["%" format {"+" format}]]] - [tool - [compiler - ["[0]" version] - ["[0]" language "_" - ["[1]/[0]" lux "_" - ["[1]" version]]]]] - [world - [net {"+" URL} - [uri {"+" URI}] - ["[0]" http "_" - ["[1]" client] - ["[1]/[0]" status] - ["@[1]" /]]]]]] - ["[0]" // - ["[1][0]" identity {"+" Identity}] - ["/[1]" // "_" - ["[1][0]" artifact {"+" Version Artifact} - [extension {"+" Extension}]]]]) + [library + [lux "*" + [abstract + [monad {"+" do}]] + [control + ["[0]" io {"+" IO}] + ["[0]" try {"+" Try}] + ["[0]" exception {"+" exception:}]] + [data + ["[0]" product] + [text + ["%" format {"+" format}]]] + ["[0]" meta "_" + ["[1]/[0]" version]] + [tool + [compiler + ["[0]" version]]] + [world + [net {"+" URL} + [uri {"+" URI}] + ["[0]" http "_" + ["[1]" client] + ["[1]/[0]" status] + ["@[1]" /]]]]]] + ["[0]" // + ["[1][0]" identity {"+" Identity}] + ["/[1]" // "_" + ["[1][0]" artifact {"+" Version Artifact} + [extension {"+" Extension}]]]]) (type: .public Address URL) @@ -49,7 +48,7 @@ (format (///artifact.uri version_template artifact) extension)) (def: .public user_agent - (format "LuxAedifex/" (version.format language/lux.version))) + (format "LuxAedifex/" (version.format meta/version.latest))) (def: base_headers (List [Text Text]) -- cgit v1.2.3