Skip to content

Commit 02c7c51

Browse files
authored
[#389] core.async feature flag
1 parent 0d1cabd commit 02c7c51

File tree

6 files changed

+32
-14
lines changed

6 files changed

+32
-14
lines changed
File renamed without changes.

project.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,26 @@
1616
[borkdude/edamame "0.0.11-alpha.9"]
1717
[borkdude/graal.locking "0.0.2"]
1818
[borkdude/sci.impl.reflector "0.0.1"]
19-
[org.clojure/core.async "1.1.587"]
2019
[org.clojure/tools.cli "1.0.194"]
2120
[org.clojure/data.csv "1.0.0"]
2221
[cheshire "5.10.0"]
2322
[fipp "0.6.22"]
2423
[com.cognitect/transit-clj "1.0.324"]]
25-
:profiles {:feature/xml {:source-paths ["feature-xml"]
26-
:dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]}
24+
:profiles {:feature/xml {:source-paths ["feature-xml"]
25+
:dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]}
2726
:feature/yaml {:source-paths ["feature-yaml"]
2827
:dependencies [[clj-commons/clj-yaml "0.7.1"]]}
2928
:feature/jdbc {:source-paths ["feature-jdbc"]
3029
:dependencies [[seancorfield/next.jdbc "1.0.424"]]}
3130
:feature/postgresql [:feature/jdbc {:dependencies [[org.postgresql/postgresql "42.2.12"]]}]
3231
:feature/hsqldb [:feature/jdbc {:dependencies [[org.hsqldb/hsqldb "2.4.0"]]}]
32+
:feature/core-async {:source-paths ["feature-core-async"]
33+
:dependencies [[org.clojure/core.async "1.1.587"]]}
3334
:test [:feature/xml
3435
:feature/yaml
3536
:feature/postgresql
3637
:feature/hsqldb
38+
:feature/core-async
3739
{:dependencies [[clj-commons/conch "0.9.2"]
3840
[com.clojure-goes-fast/clj-async-profiler "0.4.1"]]}]
3941
:uberjar {:global-vars {*assert* false}

script/uberjar

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ else
3939
BABASHKA_LEIN_PROFILES+=",-feature/yaml"
4040
fi
4141

42+
if [ "$BABASHKA_FEATURE_CORE_ASYNC" != "false" ]
43+
then
44+
BABASHKA_LEIN_PROFILES+=",+feature/core-async"
45+
else
46+
BABASHKA_LEIN_PROFILES+=",-feature/core-async"
47+
fi
48+
4249
if [ -z "$BABASHKA_JAR" ]; then
4350
lein with-profiles "$BABASHKA_LEIN_PROFILES,+reflection,-uberjar" do run
4451
lein with-profiles "$BABASHKA_LEIN_PROFILES" do clean, uberjar

script/uberjar.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ if not "%BABASHKA_FEATURE_YAML%"=="false" (
4040
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/yaml
4141
)
4242

43+
if not "%BABASHKA_FEATURE_CORE_ASYNC%"=="false" (
44+
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/core-async
45+
) else (
46+
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/core-async
47+
)
48+
4349
call lein with-profiles %BABASHKA_LEIN_PROFILES% bb "(+ 1 2 3)"
4450

4551
call lein with-profiles %BABASHKA_LEIN_PROFILES%,+reflection,-uberjar do run

src/babashka/impl/features.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
{:no-doc true})
33

44
;; included by default
5-
(def yaml? (not= "false" (System/getenv "BABASHKA_FEATURE_YAML")))
6-
(def xml? (not= "false" (System/getenv "BABASHKA_FEATURE_XML")))
5+
(def yaml? (not= "false" (System/getenv "BABASHKA_FEATURE_YAML")))
6+
(def xml? (not= "false" (System/getenv "BABASHKA_FEATURE_XML")))
7+
(def core-async? (not= "false" (System/getenv "BABASHKA_FEATURE_CORE_ASYNC")))
78

89
;; excluded by default
910
(def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC")))

src/babashka/main.clj

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
(ns babashka.main
22
{:no-doc true}
33
(:require
4-
[babashka.impl.async :refer [async-namespace async-protocols-namespace]]
54
[babashka.impl.bencode :refer [bencode-namespace]]
65
[babashka.impl.cheshire :refer [cheshire-core-namespace]]
76
[babashka.impl.classes :as classes]
@@ -64,6 +63,9 @@
6463
(when features/jdbc?
6564
(require '[babashka.impl.jdbc]))
6665

66+
(when features/core-async?
67+
(require '[babashka.impl.async]))
68+
6769
(binding [*unrestricted* true]
6870
(sci/alter-var-root sci/in (constantly *in*))
6971
(sci/alter-var-root sci/out (constantly *out*))
@@ -277,15 +279,15 @@ Everything after that is bound to *command-line-args*."))
277279
signal babashka.signal
278280
shell clojure.java.shell
279281
io clojure.java.io
280-
async clojure.core.async
281282
csv clojure.data.csv
282283
json cheshire.core
283284
curl babashka.curl
284285
transit cognitect.transit
285286
bencode bencode.core}
286-
features/xml? (assoc 'xml 'clojure.data.xml)
287-
features/yaml? (assoc 'yaml 'clj-yaml.core)
288-
features/jdbc? (assoc 'jdbc 'next.jdbc)))
287+
features/xml? (assoc 'xml 'clojure.data.xml)
288+
features/yaml? (assoc 'yaml 'clj-yaml.core)
289+
features/jdbc? (assoc 'jdbc 'next.jdbc)
290+
features/core-async? (assoc 'async 'clojure.core.async)))
289291

290292
(def cp-state (atom nil))
291293

@@ -307,8 +309,6 @@ Everything after that is bound to *command-line-args*."))
307309
'wait-for-path wait/wait-for-path}
308310
;;'babashka.signal {'pipe-signal-received? pipe-signal-received?}
309311
'clojure.java.io io-namespace
310-
'clojure.core.async async-namespace
311-
'clojure.core.async.impl.protocols async-protocols-namespace
312312
'clojure.data.csv csv/csv-namespace
313313
'cheshire.core cheshire-core-namespace
314314
'clojure.stacktrace stacktrace-namespace
@@ -320,10 +320,12 @@ Everything after that is bound to *command-line-args*."))
320320
'babashka.curl curl-namespace
321321
'cognitect.transit transit-namespace
322322
'bencode.core bencode-namespace}
323-
features/xml? (assoc 'clojure.data.xml @(resolve 'babashka.impl.xml/xml-namespace))
323+
features/xml? (assoc 'clojure.data.xml @(resolve 'babashka.impl.xml/xml-namespace))
324324
features/yaml? (assoc 'clj-yaml.core @(resolve 'babashka.impl.yaml/yaml-namespace))
325325
features/jdbc? (assoc 'next.jdbc @(resolve 'babashka.impl.jdbc/njdbc-namespace)
326-
'next.jdbc.sql @(resolve 'babashka.impl.jdbc/next-sql-namespace))))
326+
'next.jdbc.sql @(resolve 'babashka.impl.jdbc/next-sql-namespace))
327+
features/core-async? (assoc 'clojure.core.async @(resolve 'babashka.impl.async/async-namespace)
328+
'clojure.core.async.impl.protocols @(resolve 'babashka.impl.async/async-protocols-namespace))))
327329

328330
(def bindings
329331
{'java.lang.System/exit exit ;; override exit, so we have more control

0 commit comments

Comments
 (0)