sci as submodule
This commit is contained in:
parent
d1ea9f8360
commit
d4fee04df6
7 changed files with 91 additions and 59 deletions
|
|
@ -13,6 +13,11 @@ jobs:
|
|||
LEIN_ROOT: "true"
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Pull Submodules"
|
||||
command: |
|
||||
git submodule init
|
||||
git submodule update --remote
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "project.clj" }}
|
||||
|
|
@ -51,6 +56,11 @@ jobs:
|
|||
BABASHKA_TEST_ENV: native
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Pull Submodules"
|
||||
command: |
|
||||
git submodule init
|
||||
git submodule update --remote
|
||||
- restore_cache:
|
||||
keys:
|
||||
- linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
|
||||
|
|
@ -107,6 +117,11 @@ jobs:
|
|||
BABASHKA_TEST_ENV: native
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Pull Submodules"
|
||||
command: |
|
||||
git submodule init
|
||||
git submodule update --remote
|
||||
- restore_cache:
|
||||
keys:
|
||||
- mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
|
||||
|
|
@ -161,6 +176,11 @@ jobs:
|
|||
LEIN_ROOT: "true"
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Pull Submodules"
|
||||
command: |
|
||||
git submodule init
|
||||
git submodule update --remote
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "project.clj" }}
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -12,4 +12,3 @@ pom.xml.asc
|
|||
.hg/
|
||||
/bb
|
||||
.clj-kondo/.cache
|
||||
/src/sci
|
||||
|
|
|
|||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "sci"]
|
||||
path = sci
|
||||
url = https://github.com/borkdude/sci
|
||||
|
|
@ -7,9 +7,9 @@
|
|||
:url "https://github.com/borkdude/babashka"}
|
||||
:license {:name "Eclipse Public License 1.0"
|
||||
:url "http://opensource.org/licenses/eclipse-1.0.php"}
|
||||
:source-paths ["src"]
|
||||
:dependencies [[org.clojure/clojure "1.9.0"]
|
||||
[borkdude/sci "0.0.7"]]
|
||||
:source-paths ["src" "sci/src"]
|
||||
:resource-paths ["resources" "sci/resources"]
|
||||
:dependencies [[org.clojure/clojure "1.9.0"]]
|
||||
:profiles {:clojure-1.9.0 {:dependencies [[org.clojure/clojure "1.9.0"]]}
|
||||
:clojure-1.10.1 {:dependencies [[org.clojure/clojure "1.10.1"]]}
|
||||
:test {:dependencies [[clj-commons/conch "0.9.2"]]}
|
||||
|
|
|
|||
1
sci
Submodule
1
sci
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 6f3a1882cd03cbba23a35e5bb657772c4a045615
|
||||
|
|
@ -11,11 +11,11 @@ fi
|
|||
|
||||
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
|
||||
|
||||
# We also need to AOT sci, else something didn't work in the Mac build on CircleCI
|
||||
# See https://github.com/oracle/graal/issues/1613
|
||||
( cd /tmp; git clone https://github.com/borkdude/sci 2> /dev/null || true )
|
||||
mkdir -p src/sci
|
||||
cp -R /tmp/sci/src/* src
|
||||
# # We also need to AOT sci, else something didn't work in the Mac build on CircleCI
|
||||
# # See https://github.com/oracle/graal/issues/1613
|
||||
# ( cd /tmp; git clone https://github.com/borkdude/sci 2> /dev/null || true )
|
||||
# mkdir -p src/sci
|
||||
# cp -R /tmp/sci/src/* src
|
||||
|
||||
lein with-profiles +clojure-1.10.1 do clean, uberjar
|
||||
$GRAALVM_HOME/bin/native-image \
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@
|
|||
("--stream") (recur (rest options)
|
||||
(assoc opts-map
|
||||
:stream? true))
|
||||
("--time") (recur (rest options)
|
||||
(assoc opts-map
|
||||
:time? true))
|
||||
("-i") (recur (rest options)
|
||||
(assoc opts-map
|
||||
:raw-in true))
|
||||
|
|
@ -125,56 +128,62 @@
|
|||
[& args]
|
||||
#_(binding [*out* *err*]
|
||||
(prn ">> args" args))
|
||||
(or
|
||||
(let [{:keys [:version :raw-in :raw-out :println?
|
||||
:help? :file :command-line-args
|
||||
:expression :stream?] :as _opts} (parse-opts args)]
|
||||
#_(binding [*out* *err*]
|
||||
(prn ">>" _opts))
|
||||
(second
|
||||
(cond version
|
||||
[(print-version) 0]
|
||||
help?
|
||||
[(print-help) 0]
|
||||
:else
|
||||
(try
|
||||
(let [expr (if file (read-file file) expression)
|
||||
read-next #(if stream?
|
||||
(if raw-in (or (read-line) ::EOF)
|
||||
(read-edn))
|
||||
(delay (let [in (slurp *in*)]
|
||||
(if raw-in
|
||||
(parse-shell-string in)
|
||||
(edn/read-string in)))))]
|
||||
(loop [in (read-next)]
|
||||
(if (identical? ::EOF in)
|
||||
[nil 0] ;; done streaming
|
||||
(let [res [(do (when-not (or expression file)
|
||||
(throw (Exception. "Missing expression.")))
|
||||
(let [res (sci/eval-string
|
||||
expr
|
||||
{:bindings (assoc bindings
|
||||
(with-meta '*in*
|
||||
(when-not stream? {:sci/deref! true})) in
|
||||
#_(with-meta 'bb/*in*
|
||||
{:sci/deref! true}) #_do-in
|
||||
'*command-line-args* command-line-args)})]
|
||||
(if raw-out
|
||||
(if (coll? res)
|
||||
(doseq [l res]
|
||||
(println l))
|
||||
(println res))
|
||||
((if println? println? prn) res)))) 0]]
|
||||
(if stream?
|
||||
(recur (read-next))
|
||||
res)))))
|
||||
(catch Exception e
|
||||
(binding [*out* *err*]
|
||||
(when-let [msg (or (:stderr (ex-data e))
|
||||
(.getMessage e))]
|
||||
(println (str/trim msg) )))
|
||||
[nil 1])))))
|
||||
1))
|
||||
(let [t0 (System/currentTimeMillis)
|
||||
{:keys [:version :raw-in :raw-out :println?
|
||||
:help? :file :command-line-args
|
||||
:expression :stream? :time?] :as _opts}
|
||||
(parse-opts args)
|
||||
exit-code
|
||||
(or
|
||||
#_(binding [*out* *err*]
|
||||
(prn ">>" _opts))
|
||||
(second
|
||||
(cond version
|
||||
[(print-version) 0]
|
||||
help?
|
||||
[(print-help) 0]
|
||||
:else
|
||||
(try
|
||||
(let [expr (if file (read-file file) expression)
|
||||
read-next #(if stream?
|
||||
(if raw-in (or (read-line) ::EOF)
|
||||
(read-edn))
|
||||
(delay (let [in (slurp *in*)]
|
||||
(if raw-in
|
||||
(parse-shell-string in)
|
||||
(edn/read-string in)))))]
|
||||
(loop [in (read-next)]
|
||||
(if (identical? ::EOF in)
|
||||
[nil 0] ;; done streaming
|
||||
(let [res [(do (when-not (or expression file)
|
||||
(throw (Exception. "Missing expression.")))
|
||||
(let [res (sci/eval-string
|
||||
expr
|
||||
{:bindings (assoc bindings
|
||||
(with-meta '*in*
|
||||
(when-not stream? {:sci/deref! true})) in
|
||||
#_(with-meta 'bb/*in*
|
||||
{:sci/deref! true}) #_do-in
|
||||
'*command-line-args* command-line-args)})]
|
||||
(if raw-out
|
||||
(if (coll? res)
|
||||
(doseq [l res]
|
||||
(println l))
|
||||
(println res))
|
||||
((if println? println? prn) res)))) 0]]
|
||||
(if stream?
|
||||
(recur (read-next))
|
||||
res)))))
|
||||
(catch Exception e
|
||||
(binding [*out* *err*]
|
||||
(when-let [msg (or (:stderr (ex-data e))
|
||||
(.getMessage e))]
|
||||
(println (str/trim msg) )))
|
||||
[nil 1]))))
|
||||
1)
|
||||
t1 (System/currentTimeMillis)]
|
||||
(when time? (println "bb took" (str (- t1 t0) "ms.")))
|
||||
exit-code))
|
||||
|
||||
(defn -main
|
||||
[& args]
|
||||
|
|
|
|||
Loading…
Reference in a new issue