[#389] core.async feature flag

This commit is contained in:
Michiel Borkent 2020-04-29 17:50:38 +02:00 committed by GitHub
parent 0d1cabd4dc
commit 02c7c51ad4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 14 deletions

View file

@ -16,24 +16,26 @@
[borkdude/edamame "0.0.11-alpha.9"] [borkdude/edamame "0.0.11-alpha.9"]
[borkdude/graal.locking "0.0.2"] [borkdude/graal.locking "0.0.2"]
[borkdude/sci.impl.reflector "0.0.1"] [borkdude/sci.impl.reflector "0.0.1"]
[org.clojure/core.async "1.1.587"]
[org.clojure/tools.cli "1.0.194"] [org.clojure/tools.cli "1.0.194"]
[org.clojure/data.csv "1.0.0"] [org.clojure/data.csv "1.0.0"]
[cheshire "5.10.0"] [cheshire "5.10.0"]
[fipp "0.6.22"] [fipp "0.6.22"]
[com.cognitect/transit-clj "1.0.324"]] [com.cognitect/transit-clj "1.0.324"]]
:profiles {:feature/xml {:source-paths ["feature-xml"] :profiles {:feature/xml {:source-paths ["feature-xml"]
:dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]} :dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]}
:feature/yaml {:source-paths ["feature-yaml"] :feature/yaml {:source-paths ["feature-yaml"]
:dependencies [[clj-commons/clj-yaml "0.7.1"]]} :dependencies [[clj-commons/clj-yaml "0.7.1"]]}
:feature/jdbc {:source-paths ["feature-jdbc"] :feature/jdbc {:source-paths ["feature-jdbc"]
:dependencies [[seancorfield/next.jdbc "1.0.424"]]} :dependencies [[seancorfield/next.jdbc "1.0.424"]]}
:feature/postgresql [:feature/jdbc {:dependencies [[org.postgresql/postgresql "42.2.12"]]}] :feature/postgresql [:feature/jdbc {:dependencies [[org.postgresql/postgresql "42.2.12"]]}]
:feature/hsqldb [:feature/jdbc {:dependencies [[org.hsqldb/hsqldb "2.4.0"]]}] :feature/hsqldb [:feature/jdbc {:dependencies [[org.hsqldb/hsqldb "2.4.0"]]}]
:feature/core-async {:source-paths ["feature-core-async"]
:dependencies [[org.clojure/core.async "1.1.587"]]}
:test [:feature/xml :test [:feature/xml
:feature/yaml :feature/yaml
:feature/postgresql :feature/postgresql
:feature/hsqldb :feature/hsqldb
:feature/core-async
{: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"]]}]
:uberjar {:global-vars {*assert* false} :uberjar {:global-vars {*assert* false}

View file

@ -39,6 +39,13 @@ else
BABASHKA_LEIN_PROFILES+=",-feature/yaml" BABASHKA_LEIN_PROFILES+=",-feature/yaml"
fi fi
if [ "$BABASHKA_FEATURE_CORE_ASYNC" != "false" ]
then
BABASHKA_LEIN_PROFILES+=",+feature/core-async"
else
BABASHKA_LEIN_PROFILES+=",-feature/core-async"
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

@ -40,6 +40,12 @@ if not "%BABASHKA_FEATURE_YAML%"=="false" (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/yaml set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/yaml
) )
if not "%BABASHKA_FEATURE_CORE_ASYNC%"=="false" (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/core-async
) else (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/core-async
)
call lein with-profiles %BABASHKA_LEIN_PROFILES% bb "(+ 1 2 3)" call lein with-profiles %BABASHKA_LEIN_PROFILES% bb "(+ 1 2 3)"
call lein with-profiles %BABASHKA_LEIN_PROFILES%,+reflection,-uberjar do run call lein with-profiles %BABASHKA_LEIN_PROFILES%,+reflection,-uberjar do run

View file

@ -2,8 +2,9 @@
{:no-doc true}) {:no-doc true})
;; included by default ;; included by default
(def yaml? (not= "false" (System/getenv "BABASHKA_FEATURE_YAML"))) (def yaml? (not= "false" (System/getenv "BABASHKA_FEATURE_YAML")))
(def xml? (not= "false" (System/getenv "BABASHKA_FEATURE_XML"))) (def xml? (not= "false" (System/getenv "BABASHKA_FEATURE_XML")))
(def core-async? (not= "false" (System/getenv "BABASHKA_FEATURE_CORE_ASYNC")))
;; excluded by default ;; excluded by default
(def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC"))) (def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC")))

View file

@ -1,7 +1,6 @@
(ns babashka.main (ns babashka.main
{:no-doc true} {:no-doc true}
(:require (:require
[babashka.impl.async :refer [async-namespace async-protocols-namespace]]
[babashka.impl.bencode :refer [bencode-namespace]] [babashka.impl.bencode :refer [bencode-namespace]]
[babashka.impl.cheshire :refer [cheshire-core-namespace]] [babashka.impl.cheshire :refer [cheshire-core-namespace]]
[babashka.impl.classes :as classes] [babashka.impl.classes :as classes]
@ -64,6 +63,9 @@
(when features/jdbc? (when features/jdbc?
(require '[babashka.impl.jdbc])) (require '[babashka.impl.jdbc]))
(when features/core-async?
(require '[babashka.impl.async]))
(binding [*unrestricted* true] (binding [*unrestricted* true]
(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*))
@ -277,15 +279,15 @@ Everything after that is bound to *command-line-args*."))
signal babashka.signal signal babashka.signal
shell clojure.java.shell shell clojure.java.shell
io clojure.java.io io clojure.java.io
async clojure.core.async
csv clojure.data.csv csv clojure.data.csv
json cheshire.core json cheshire.core
curl babashka.curl curl babashka.curl
transit cognitect.transit transit cognitect.transit
bencode bencode.core} bencode bencode.core}
features/xml? (assoc 'xml 'clojure.data.xml) features/xml? (assoc 'xml 'clojure.data.xml)
features/yaml? (assoc 'yaml 'clj-yaml.core) features/yaml? (assoc 'yaml 'clj-yaml.core)
features/jdbc? (assoc 'jdbc 'next.jdbc))) features/jdbc? (assoc 'jdbc 'next.jdbc)
features/core-async? (assoc 'async 'clojure.core.async)))
(def cp-state (atom nil)) (def cp-state (atom nil))
@ -307,8 +309,6 @@ Everything after that is bound to *command-line-args*."))
'wait-for-path wait/wait-for-path} 'wait-for-path wait/wait-for-path}
;;'babashka.signal {'pipe-signal-received? pipe-signal-received?} ;;'babashka.signal {'pipe-signal-received? pipe-signal-received?}
'clojure.java.io io-namespace 'clojure.java.io io-namespace
'clojure.core.async async-namespace
'clojure.core.async.impl.protocols async-protocols-namespace
'clojure.data.csv csv/csv-namespace 'clojure.data.csv csv/csv-namespace
'cheshire.core cheshire-core-namespace 'cheshire.core cheshire-core-namespace
'clojure.stacktrace stacktrace-namespace 'clojure.stacktrace stacktrace-namespace
@ -320,10 +320,12 @@ Everything after that is bound to *command-line-args*."))
'babashka.curl curl-namespace 'babashka.curl curl-namespace
'cognitect.transit transit-namespace 'cognitect.transit transit-namespace
'bencode.core bencode-namespace} 'bencode.core bencode-namespace}
features/xml? (assoc 'clojure.data.xml @(resolve 'babashka.impl.xml/xml-namespace)) features/xml? (assoc 'clojure.data.xml @(resolve 'babashka.impl.xml/xml-namespace))
features/yaml? (assoc 'clj-yaml.core @(resolve 'babashka.impl.yaml/yaml-namespace)) features/yaml? (assoc 'clj-yaml.core @(resolve 'babashka.impl.yaml/yaml-namespace))
features/jdbc? (assoc 'next.jdbc @(resolve 'babashka.impl.jdbc/njdbc-namespace) features/jdbc? (assoc 'next.jdbc @(resolve 'babashka.impl.jdbc/njdbc-namespace)
'next.jdbc.sql @(resolve 'babashka.impl.jdbc/next-sql-namespace)))) 'next.jdbc.sql @(resolve 'babashka.impl.jdbc/next-sql-namespace))
features/core-async? (assoc 'clojure.core.async @(resolve 'babashka.impl.async/async-namespace)
'clojure.core.async.impl.protocols @(resolve 'babashka.impl.async/async-protocols-namespace))))
(def bindings (def bindings
{'java.lang.System/exit exit ;; override exit, so we have more control {'java.lang.System/exit exit ;; override exit, so we have more control