Compare commits

...

3 commits

Author SHA1 Message Date
Michiel Borkent
a19eb2cf90 Avoid compilation 2021-01-23 15:51:10 +01:00
Michiel Borkent
e4a25c7927 Merge branch 'master' into hiccup 2021-01-23 15:48:37 +01:00
Michiel Borkent
b8cf100209 [#646] hiccup 2021-01-23 14:22:07 +01:00
7 changed files with 52 additions and 5 deletions

View file

@ -28,7 +28,8 @@
http-kit/http-kit {:mvn/version "2.5.0"}
babashka/clojure-lanterna {:mvn/version "0.9.8-SNAPSHOT"}
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
{:main-opts ["-m" "babashka.main"]}
:profile

View file

@ -0,0 +1,27 @@
(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))
(defn html [x]
(hiccup/html x))
(def hiccup-namespace
{'html (copy-var html hns)})
(defn html2 [x]
(hiccup2/html x))
(def hiccup2-namespace
{'html (copy-var html2 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"]]}
:feature/core-match {:source-paths ["feature-core-match"]
:dependencies [[org.clojure/core.match "1.0.0"]]}
:feature/hiccup {:source-paths ["feature-hiccup"]
:dependencies [[hiccup/hiccup "2.0.0-alpha2"]]}
:test [:feature/xml
:feature/lanterna
:feature/yaml
@ -61,6 +62,7 @@
:feature/httpkit-client
:feature/httpkit-server
:feature/core-match
:feature/hiccup
{:dependencies [[clj-commons/conch "0.9.2"]
[com.clojure-goes-fast/clj-async-profiler "0.4.1"]
[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_SERVER="${BABASHKA_FEATURE_HTTPKIT_SERVER:-false}"
export BABASHKA_FEATURE_CORE_MATCH="${BABASHKA_FEATURE_CORE_MATCH:-false}"
export BABASHKA_FEATURE_HICCUP="${BABASHKA_FEATURE_HICCUP:-false}"
fi
"$GRAALVM_HOME/bin/native-image" "${args[@]}"

View file

@ -125,6 +125,13 @@ else
BABASHKA_LEIN_PROFILES+=",-feature/core-match"
fi
if [ "$BABASHKA_FEATURE_HICCUP" != "false" ]
then
BABASHKA_LEIN_PROFILES+=",+feature/hiccup"
else
BABASHKA_LEIN_PROFILES+=",-feature/hiccup"
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

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

View file

@ -97,6 +97,9 @@
(when features/core-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/out (constantly *out*))
(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/httpkit-client %s
:feature/lanterna %s
:feature/core-match %s}")
:feature/core-match %s
:feature/hiccup %s}")
version
features/core-async?
features/csv?
@ -317,7 +321,8 @@ Use -- to separate script command line args from bb command line args.
features/oracledb?
features/httpkit-client?
features/lanterna?
features/core-match?)))
features/core-match?
features/hiccup?)))
(defn read-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)
'lanterna.terminal @(resolve 'babashka.impl.lanterna/lanterna-terminal-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
'{ArithmeticException java.lang.ArithmeticException