Compare commits

...

9 commits

Author SHA1 Message Date
Michiel Borkent
151583e0b5 Merge branch 'master' into feature-malli 2021-04-01 21:57:11 +02:00
Michiel Borkent
d144d8344d Add decode 2021-02-25 13:05:05 +01:00
Michiel Borkent
a4d8509f7b fix 2021-02-25 12:31:32 +01:00
Michiel Borkent
2449a7b5f0 transform 2021-02-25 12:30:53 +01:00
Michiel Borkent
9d08f94c99 Add decoder 2021-02-25 12:27:32 +01:00
Michiel Borkent
a7301852f6 snapshot 2021-02-25 12:20:38 +01:00
Michiel Borkent
f1a830abc4 error 2021-02-25 11:58:03 +01:00
Michiel Borkent
bdfc6e09b6 dynaload 2021-02-25 11:22:59 +01:00
Michiel Borkent
cdbf94943e malli 2021-02-25 11:15:59 +01:00
8 changed files with 64 additions and 7 deletions

View file

@ -7,6 +7,7 @@
"feature-hiccup"
"feature-test-check"
"feature-spec-alpha"
"feature-malli"
"pods/src"
"babashka.nrepl/src"
"depstar/src" "process/src"
@ -33,7 +34,8 @@
http-kit/http-kit {:mvn/version "2.5.3"}
babashka/clojure-lanterna {:mvn/version "0.9.8-SNAPSHOT"}
org.clojure/core.match {:mvn/version "1.0.0"}
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}}
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
metosin/malli {:mvn/version "0.3.0-SNAPSHOT"}}
:aliases {:babashka/dev
{:main-opts ["-m" "babashka.main"]}
:profile

View file

@ -0,0 +1,26 @@
(ns babashka.impl.malli
{:no-doc true}
(:require [malli.core :as m]
[malli.error :as me]
[malli.transform :as mt]
[sci.core :as sci :refer [copy-var]]))
(def mns (sci/create-ns 'malli.core nil))
(def tns (sci/create-ns 'malli.transform nil))
(def ens (sci/create-ns 'malli.error nil))
(def malli-namespace
{'validate (copy-var m/validate mns)
'validator (copy-var m/validator mns)
'explain (copy-var m/explain mns)
'decoder (copy-var m/decoder mns)
'decode (copy-var m/decode mns)
})
(def malli-transform-namespace
{'string-transformer (copy-var mt/string-transformer tns)
})
(def malli-error-namespace
{'humanize (copy-var me/humanize ens)
})

View file

@ -52,6 +52,8 @@
:dependencies [[hiccup/hiccup "2.0.0-alpha2"]]}
:feature/test-check {:source-paths ["feature-test-check"]}
:feature/spec-alpha {:source-paths ["feature-spec-alpha"]}
:feature/malli {:source-paths ["feature-malli"]
:dependencies [[metosin/malli "0.3.0-SNAPSHOT"]]}
:test [:feature/xml
:feature/lanterna
:feature/yaml
@ -71,7 +73,8 @@
[com.opentable.components/otj-pg-embedded "0.13.3"]]}]
:uberjar {:global-vars {*assert* false}
:jvm-opts ["-Dclojure.compiler.direct-linking=true"
"-Dclojure.spec.skip-macros=true"]
"-Dclojure.spec.skip-macros=true"
"-Dborkdude.dynaload.aot=true"]
:main babashka.main
:aot :all}
:reflection {:main babashka.impl.classes/generate-reflection-file}}

View file

@ -41,8 +41,7 @@ BABASHKA_BINARY=${BABASHKA_BINARY:-"bb"}
args=( "-jar" "$BABASHKA_JAR"
"-H:Name=$BABASHKA_BINARY"
"-H:+ReportExceptionStackTraces"
"-J-Dclojure.spec.skip-macros=true"
"-J-Dclojure.compiler.direct-linking=true"
"-J-Dborkdude.dynaload.aot=true"
"-H:IncludeResources=BABASHKA_VERSION"
"-H:IncludeResources=SCI_VERSION"
"-H:ReflectionConfigurationFiles=reflection.json"
@ -104,6 +103,7 @@ then
export BABASHKA_FEATURE_HICCUP="${BABASHKA_FEATURE_HICCUP:-false}"
export BABASHKA_FEATURE_TEST_CHECK="${BABASHKA_FEATURE_TEST_CHECK:-false}"
export BABASHKA_FEATURE_SPEC_ALPHA="${BABASHKA_FEATURE_SPEC_ALPHA:-false}"
export BABASHKA_FEATURE_MALLI="${BABASHKA_FEATURE_MALLI:-false}"
fi
"$GRAALVM_HOME/bin/native-image" "${args[@]}"

View file

@ -146,6 +146,13 @@ else
BABASHKA_LEIN_PROFILES+=",-feature/spec-alpha"
fi
if [ "$BABASHKA_FEATURE_MALLI" != "false" ]
then
BABASHKA_LEIN_PROFILES+=",+feature/malli"
else
BABASHKA_LEIN_PROFILES+=",-feature/malli"
fi
if [ -z "$BABASHKA_JAR" ]; then
lein with-profiles "$BABASHKA_LEIN_PROFILES,+reflection,-uberjar" do run
lein with-profiles "$BABASHKA_LEIN_PROFILES" do clean, uberjar

View file

@ -112,6 +112,13 @@ set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/spec-alpha
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/spec-alpha
)
if not "%BABASHKA_FEATURE_MALLI%"=="false" (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/malli
) else (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/malli
)
call lein with-profiles %BABASHKA_LEIN_PROFILES% bb "(+ 1 2 3)"
call lein with-profiles %BABASHKA_LEIN_PROFILES%,+reflection,-uberjar do run

View file

@ -14,6 +14,7 @@
(def core-match? (not= "false" (System/getenv "BABASHKA_FEATURE_CORE_MATCH")))
(def hiccup? (not= "false" (System/getenv "BABASHKA_FEATURE_HICCUP")))
(def test-check? (not= "false" (System/getenv "BABASHKA_FEATURE_TEST_CHECK")))
(def malli? (not= "false" (System/getenv "BABASHKA_FEATURE_MALLI")))
;; excluded by default
(def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC")))
@ -66,3 +67,6 @@
(when spec-alpha?
(require '[babashka.impl.spec]))
(when malli?
(require '[babashka.impl.malli]))

View file

@ -191,7 +191,8 @@ When no eval opts or subcommand is provided, the implicit subcommand is repl.")
:feature/core-match %s
:feature/hiccup %s
:feature/test-check %s
:feature/spec-alpha %s}")
:feature/spec-alpha %s
:feature/malli %s}")
version
features/core-async?
features/csv?
@ -208,7 +209,8 @@ When no eval opts or subcommand is provided, the implicit subcommand is repl.")
features/core-match?
features/hiccup?
features/test-check?
features/spec-alpha?)))
features/spec-alpha?
features/malli?)))
(defn read-file [file]
(let [f (io/file file)]
@ -337,7 +339,13 @@ When no eval opts or subcommand is provided, the implicit subcommand is repl.")
features/spec-alpha? (-> (assoc ;; spec
'clojure.spec.alpha @(resolve 'babashka.impl.spec/spec-namespace)
'clojure.spec.gen.alpha @(resolve 'babashka.impl.spec/gen-namespace)
'clojure.spec.test.alpha @(resolve 'babashka.impl.spec/test-namespace)))))
'clojure.spec.test.alpha @(resolve 'babashka.impl.spec/test-namespace)))
features/malli? (assoc 'malli.core
@(resolve 'babashka.impl.malli/malli-namespace)
'malli.transform
@(resolve 'babashka.impl.malli/malli-transform-namespace)
'malli.error
@(resolve 'babashka.impl.malli/malli-error-namespace))))
(def imports
'{ArithmeticException java.lang.ArithmeticException