diff --git a/src/babashka/impl/async.clj b/feature-core-async/babashka/impl/async.clj similarity index 100% rename from src/babashka/impl/async.clj rename to feature-core-async/babashka/impl/async.clj diff --git a/project.clj b/project.clj index 57045f62..04698e6f 100644 --- a/project.clj +++ b/project.clj @@ -16,24 +16,26 @@ [borkdude/edamame "0.0.11-alpha.9"] [borkdude/graal.locking "0.0.2"] [borkdude/sci.impl.reflector "0.0.1"] - [org.clojure/core.async "1.1.587"] [org.clojure/tools.cli "1.0.194"] [org.clojure/data.csv "1.0.0"] [cheshire "5.10.0"] [fipp "0.6.22"] [com.cognitect/transit-clj "1.0.324"]] - :profiles {:feature/xml {:source-paths ["feature-xml"] - :dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]} + :profiles {:feature/xml {:source-paths ["feature-xml"] + :dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]} :feature/yaml {:source-paths ["feature-yaml"] :dependencies [[clj-commons/clj-yaml "0.7.1"]]} :feature/jdbc {:source-paths ["feature-jdbc"] :dependencies [[seancorfield/next.jdbc "1.0.424"]]} :feature/postgresql [:feature/jdbc {:dependencies [[org.postgresql/postgresql "42.2.12"]]}] :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 :feature/yaml :feature/postgresql :feature/hsqldb + :feature/core-async {:dependencies [[clj-commons/conch "0.9.2"] [com.clojure-goes-fast/clj-async-profiler "0.4.1"]]}] :uberjar {:global-vars {*assert* false} diff --git a/script/uberjar b/script/uberjar index 82cf8c13..7d2875fb 100755 --- a/script/uberjar +++ b/script/uberjar @@ -39,6 +39,13 @@ else BABASHKA_LEIN_PROFILES+=",-feature/yaml" 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 lein with-profiles "$BABASHKA_LEIN_PROFILES,+reflection,-uberjar" do run lein with-profiles "$BABASHKA_LEIN_PROFILES" do clean, uberjar diff --git a/script/uberjar.bat b/script/uberjar.bat index 55db1895..060e8a0b 100755 --- a/script/uberjar.bat +++ b/script/uberjar.bat @@ -40,6 +40,12 @@ if not "%BABASHKA_FEATURE_YAML%"=="false" ( 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%,+reflection,-uberjar do run diff --git a/src/babashka/impl/features.clj b/src/babashka/impl/features.clj index ba6e9228..990a3721 100644 --- a/src/babashka/impl/features.clj +++ b/src/babashka/impl/features.clj @@ -2,8 +2,9 @@ {:no-doc true}) ;; included by default -(def yaml? (not= "false" (System/getenv "BABASHKA_FEATURE_YAML"))) -(def xml? (not= "false" (System/getenv "BABASHKA_FEATURE_XML"))) +(def yaml? (not= "false" (System/getenv "BABASHKA_FEATURE_YAML"))) +(def xml? (not= "false" (System/getenv "BABASHKA_FEATURE_XML"))) +(def core-async? (not= "false" (System/getenv "BABASHKA_FEATURE_CORE_ASYNC"))) ;; excluded by default (def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC"))) diff --git a/src/babashka/main.clj b/src/babashka/main.clj index b80c8224..26c65560 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -1,7 +1,6 @@ (ns babashka.main {:no-doc true} (:require - [babashka.impl.async :refer [async-namespace async-protocols-namespace]] [babashka.impl.bencode :refer [bencode-namespace]] [babashka.impl.cheshire :refer [cheshire-core-namespace]] [babashka.impl.classes :as classes] @@ -64,6 +63,9 @@ (when features/jdbc? (require '[babashka.impl.jdbc])) +(when features/core-async? + (require '[babashka.impl.async])) + (binding [*unrestricted* true] (sci/alter-var-root sci/in (constantly *in*)) (sci/alter-var-root sci/out (constantly *out*)) @@ -277,15 +279,15 @@ Everything after that is bound to *command-line-args*.")) signal babashka.signal shell clojure.java.shell io clojure.java.io - async clojure.core.async csv clojure.data.csv json cheshire.core curl babashka.curl transit cognitect.transit bencode bencode.core} - features/xml? (assoc 'xml 'clojure.data.xml) - features/yaml? (assoc 'yaml 'clj-yaml.core) - features/jdbc? (assoc 'jdbc 'next.jdbc))) + features/xml? (assoc 'xml 'clojure.data.xml) + features/yaml? (assoc 'yaml 'clj-yaml.core) + features/jdbc? (assoc 'jdbc 'next.jdbc) + features/core-async? (assoc 'async 'clojure.core.async))) (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} ;;'babashka.signal {'pipe-signal-received? pipe-signal-received?} 'clojure.java.io io-namespace - 'clojure.core.async async-namespace - 'clojure.core.async.impl.protocols async-protocols-namespace 'clojure.data.csv csv/csv-namespace 'cheshire.core cheshire-core-namespace 'clojure.stacktrace stacktrace-namespace @@ -320,10 +320,12 @@ Everything after that is bound to *command-line-args*.")) 'babashka.curl curl-namespace 'cognitect.transit transit-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/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 {'java.lang.System/exit exit ;; override exit, so we have more control