This commit is contained in:
Michiel Borkent 2021-01-23 14:21:54 +01:00
parent 57497f850b
commit b8cf100209
7 changed files with 46 additions and 5 deletions

View file

@ -28,7 +28,8 @@
http-kit/http-kit {:mvn/version "2.5.0"} http-kit/http-kit {:mvn/version "2.5.0"}
babashka/clojure-lanterna {:mvn/version "0.9.8-SNAPSHOT"} babashka/clojure-lanterna {:mvn/version "0.9.8-SNAPSHOT"}
org.clojure/math.combinatorics {:mvn/version "0.1.6"} org.clojure/math.combinatorics {:mvn/version "0.1.6"}
org.clojure/core.match {:mvn/version "1.0.0"}} org.clojure/core.match {:mvn/version "1.0.0"}
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}}
:aliases {:main :aliases {:main
{:main-opts ["-m" "babashka.main"]} {:main-opts ["-m" "babashka.main"]}
:profile :profile

View file

@ -0,0 +1,21 @@
(ns babashka.impl.hiccup
{:no-doc true}
(:require [hiccup.core :as hiccup]
[hiccup.util :as util]
[hiccup2.core :as hiccup2]
[sci.core :as sci :refer [copy-var]]))
(def hns (sci/create-ns 'hiccup.core nil))
(def hns2 (sci/create-ns 'hiccup2.core nil))
(def uns (sci/create-ns 'hiccup.util nil))
(def hiccup-namespace
{'html (copy-var hiccup/html hns)})
(def hiccup2-namespace
{'html (copy-var hiccup2/html hns2)})
(def hiccup-util-namespace
{'*html-mode* (copy-var util/*html-mode* uns)
'*escape-strings?* (copy-var util/*escape-strings?* uns)
'raw-string (copy-var util/raw-string uns)})

View file

@ -48,7 +48,8 @@
:dependencies [[babashka/clojure-lanterna "0.9.8-SNAPSHOT"]]} :dependencies [[babashka/clojure-lanterna "0.9.8-SNAPSHOT"]]}
:feature/core-match {:source-paths ["feature-core-match"] :feature/core-match {:source-paths ["feature-core-match"]
:dependencies [[org.clojure/core.match "1.0.0"]]} :dependencies [[org.clojure/core.match "1.0.0"]]}
:feature/hiccup {:source-paths ["feature-hiccup"]
:dependencies [[hiccup/hiccup "2.0.0-alpha2"]]}
:test [:feature/xml :test [:feature/xml
:feature/lanterna :feature/lanterna
:feature/yaml :feature/yaml
@ -61,6 +62,7 @@
:feature/httpkit-client :feature/httpkit-client
:feature/httpkit-server :feature/httpkit-server
:feature/core-match :feature/core-match
:feature/hiccup
{:dependencies [[clj-commons/conch "0.9.2"] {:dependencies [[clj-commons/conch "0.9.2"]
[com.clojure-goes-fast/clj-async-profiler "0.4.1"] [com.clojure-goes-fast/clj-async-profiler "0.4.1"]
[com.opentable.components/otj-pg-embedded "0.13.3"]]}] [com.opentable.components/otj-pg-embedded "0.13.3"]]}]

View file

@ -95,6 +95,7 @@ then
export BABASHKA_FEATURE_HTTPKIT_CLIENT="${BABASHKA_FEATURE_HTTPKIT_CLIENT:-false}" export BABASHKA_FEATURE_HTTPKIT_CLIENT="${BABASHKA_FEATURE_HTTPKIT_CLIENT:-false}"
export BABASHKA_FEATURE_HTTPKIT_SERVER="${BABASHKA_FEATURE_HTTPKIT_SERVER:-false}" export BABASHKA_FEATURE_HTTPKIT_SERVER="${BABASHKA_FEATURE_HTTPKIT_SERVER:-false}"
export BABASHKA_FEATURE_CORE_MATCH="${BABASHKA_FEATURE_CORE_MATCH:-false}" export BABASHKA_FEATURE_CORE_MATCH="${BABASHKA_FEATURE_CORE_MATCH:-false}"
export BABASHKA_FEATURE_HICCUP="${BABASHKA_FEATURE_HICCUP:-false}"
fi fi
"$GRAALVM_HOME/bin/native-image" "${args[@]}" "$GRAALVM_HOME/bin/native-image" "${args[@]}"

View file

@ -125,6 +125,13 @@ else
BABASHKA_LEIN_PROFILES+=",-feature/core-match" BABASHKA_LEIN_PROFILES+=",-feature/core-match"
fi fi
if [ "$BABASHKA_FEATURE_HICCUP" != "false" ]
then
BABASHKA_LEIN_PROFILES+=",+feature/hiccup"
else
BABASHKA_LEIN_PROFILES+=",-feature/hiccup"
fi
if [ -z "$BABASHKA_JAR" ]; then if [ -z "$BABASHKA_JAR" ]; then
lein with-profiles "$BABASHKA_LEIN_PROFILES,+reflection,-uberjar" do run lein with-profiles "$BABASHKA_LEIN_PROFILES,+reflection,-uberjar" do run
lein with-profiles "$BABASHKA_LEIN_PROFILES" do clean, uberjar lein with-profiles "$BABASHKA_LEIN_PROFILES" do clean, uberjar

View file

@ -12,6 +12,7 @@
(def httpkit-client? (not= "false" (System/getenv "BABASHKA_FEATURE_HTTPKIT_CLIENT"))) (def httpkit-client? (not= "false" (System/getenv "BABASHKA_FEATURE_HTTPKIT_CLIENT")))
(def httpkit-server? (not= "false" (System/getenv "BABASHKA_FEATURE_HTTPKIT_SERVER"))) (def httpkit-server? (not= "false" (System/getenv "BABASHKA_FEATURE_HTTPKIT_SERVER")))
(def core-match? (not= "false" (System/getenv "BABASHKA_FEATURE_CORE_MATCH"))) (def core-match? (not= "false" (System/getenv "BABASHKA_FEATURE_CORE_MATCH")))
(def hiccup? (not= "false" (System/getenv "BABASHKA_FEATURE_HICCUP")))
;; excluded by default ;; excluded by default
(def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC"))) (def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC")))

View file

@ -97,6 +97,9 @@
(when features/core-match? (when features/core-match?
(require '[babashka.impl.match])) (require '[babashka.impl.match]))
(when features/hiccup?
(require '[babashka.impl.hiccup]))
(sci/alter-var-root sci/in (constantly *in*)) (sci/alter-var-root sci/in (constantly *in*))
(sci/alter-var-root sci/out (constantly *out*)) (sci/alter-var-root sci/out (constantly *out*))
(sci/alter-var-root sci/err (constantly *err*)) (sci/alter-var-root sci/err (constantly *err*))
@ -303,7 +306,8 @@ Use -- to separate script command line args from bb command line args.
:feature/oracledb %s :feature/oracledb %s
:feature/httpkit-client %s :feature/httpkit-client %s
:feature/lanterna %s :feature/lanterna %s
:feature/core-match %s}") :feature/core-match %s
:feature/hiccup %s}")
version version
features/core-async? features/core-async?
features/csv? features/csv?
@ -317,7 +321,8 @@ Use -- to separate script command line args from bb command line args.
features/oracledb? features/oracledb?
features/httpkit-client? features/httpkit-client?
features/lanterna? features/lanterna?
features/core-match?))) features/core-match?
features/hiccup?)))
(defn read-file [file] (defn read-file [file]
(let [f (io/file file)] (let [f (io/file file)]
@ -427,7 +432,10 @@ Use -- to separate script command line args from bb command line args.
features/lanterna? (assoc 'lanterna.screen @(resolve 'babashka.impl.lanterna/lanterna-screen-namespace) features/lanterna? (assoc 'lanterna.screen @(resolve 'babashka.impl.lanterna/lanterna-screen-namespace)
'lanterna.terminal @(resolve 'babashka.impl.lanterna/lanterna-terminal-namespace) 'lanterna.terminal @(resolve 'babashka.impl.lanterna/lanterna-terminal-namespace)
'lanterna.constants @(resolve 'babashka.impl.lanterna/lanterna-constants-namespace)) 'lanterna.constants @(resolve 'babashka.impl.lanterna/lanterna-constants-namespace))
features/core-match? (assoc 'clojure.core.match @(resolve 'babashka.impl.match/core-match-namespace)))) features/core-match? (assoc 'clojure.core.match @(resolve 'babashka.impl.match/core-match-namespace))
features/hiccup? (-> (assoc 'hiccup.core @(resolve 'babashka.impl.hiccup/hiccup-namespace))
(assoc 'hiccup2.core @(resolve 'babashka.impl.hiccup/hiccup2-namespace))
(assoc 'hiccup.util @(resolve 'babashka.impl.hiccup/hiccup-util-namespace)))))
(def imports (def imports
'{ArithmeticException java.lang.ArithmeticException '{ArithmeticException java.lang.ArithmeticException