sci as submodule

This commit is contained in:
Michiel Borkent 2019-08-17 12:42:20 +02:00 committed by GitHub
parent d1ea9f8360
commit d4fee04df6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 91 additions and 59 deletions

View file

@ -13,6 +13,11 @@ jobs:
LEIN_ROOT: "true" LEIN_ROOT: "true"
steps: steps:
- checkout - checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update --remote
- restore_cache: - restore_cache:
keys: keys:
- v1-dependencies-{{ checksum "project.clj" }} - v1-dependencies-{{ checksum "project.clj" }}
@ -51,6 +56,11 @@ jobs:
BABASHKA_TEST_ENV: native BABASHKA_TEST_ENV: native
steps: steps:
- checkout - checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update --remote
- restore_cache: - restore_cache:
keys: keys:
- linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
@ -107,6 +117,11 @@ jobs:
BABASHKA_TEST_ENV: native BABASHKA_TEST_ENV: native
steps: steps:
- checkout - checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update --remote
- restore_cache: - restore_cache:
keys: keys:
- mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
@ -161,6 +176,11 @@ jobs:
LEIN_ROOT: "true" LEIN_ROOT: "true"
steps: steps:
- checkout - checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update --remote
- restore_cache: - restore_cache:
keys: keys:
- v1-dependencies-{{ checksum "project.clj" }} - v1-dependencies-{{ checksum "project.clj" }}

1
.gitignore vendored
View file

@ -12,4 +12,3 @@ pom.xml.asc
.hg/ .hg/
/bb /bb
.clj-kondo/.cache .clj-kondo/.cache
/src/sci

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "sci"]
path = sci
url = https://github.com/borkdude/sci

View file

@ -7,9 +7,9 @@
:url "https://github.com/borkdude/babashka"} :url "https://github.com/borkdude/babashka"}
:license {:name "Eclipse Public License 1.0" :license {:name "Eclipse Public License 1.0"
:url "http://opensource.org/licenses/eclipse-1.0.php"} :url "http://opensource.org/licenses/eclipse-1.0.php"}
:source-paths ["src"] :source-paths ["src" "sci/src"]
:dependencies [[org.clojure/clojure "1.9.0"] :resource-paths ["resources" "sci/resources"]
[borkdude/sci "0.0.7"]] :dependencies [[org.clojure/clojure "1.9.0"]]
:profiles {:clojure-1.9.0 {: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"]]} :clojure-1.10.1 {:dependencies [[org.clojure/clojure "1.10.1"]]}
:test {:dependencies [[clj-commons/conch "0.9.2"]]} :test {:dependencies [[clj-commons/conch "0.9.2"]]}

1
sci Submodule

@ -0,0 +1 @@
Subproject commit 6f3a1882cd03cbba23a35e5bb657772c4a045615

View file

@ -11,11 +11,11 @@ fi
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION) BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
# We also need to AOT sci, else something didn't work in the Mac build on CircleCI # # 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 # # See https://github.com/oracle/graal/issues/1613
( cd /tmp; git clone https://github.com/borkdude/sci 2> /dev/null || true ) # ( cd /tmp; git clone https://github.com/borkdude/sci 2> /dev/null || true )
mkdir -p src/sci # mkdir -p src/sci
cp -R /tmp/sci/src/* src # cp -R /tmp/sci/src/* src
lein with-profiles +clojure-1.10.1 do clean, uberjar lein with-profiles +clojure-1.10.1 do clean, uberjar
$GRAALVM_HOME/bin/native-image \ $GRAALVM_HOME/bin/native-image \

View file

@ -23,6 +23,9 @@
("--stream") (recur (rest options) ("--stream") (recur (rest options)
(assoc opts-map (assoc opts-map
:stream? true)) :stream? true))
("--time") (recur (rest options)
(assoc opts-map
:time? true))
("-i") (recur (rest options) ("-i") (recur (rest options)
(assoc opts-map (assoc opts-map
:raw-in true)) :raw-in true))
@ -125,56 +128,62 @@
[& args] [& args]
#_(binding [*out* *err*] #_(binding [*out* *err*]
(prn ">> args" args)) (prn ">> args" args))
(or (let [t0 (System/currentTimeMillis)
(let [{:keys [:version :raw-in :raw-out :println? {:keys [:version :raw-in :raw-out :println?
:help? :file :command-line-args :help? :file :command-line-args
:expression :stream?] :as _opts} (parse-opts args)] :expression :stream? :time?] :as _opts}
#_(binding [*out* *err*] (parse-opts args)
(prn ">>" _opts)) exit-code
(second (or
(cond version #_(binding [*out* *err*]
[(print-version) 0] (prn ">>" _opts))
help? (second
[(print-help) 0] (cond version
:else [(print-version) 0]
(try help?
(let [expr (if file (read-file file) expression) [(print-help) 0]
read-next #(if stream? :else
(if raw-in (or (read-line) ::EOF) (try
(read-edn)) (let [expr (if file (read-file file) expression)
(delay (let [in (slurp *in*)] read-next #(if stream?
(if raw-in (if raw-in (or (read-line) ::EOF)
(parse-shell-string in) (read-edn))
(edn/read-string in)))))] (delay (let [in (slurp *in*)]
(loop [in (read-next)] (if raw-in
(if (identical? ::EOF in) (parse-shell-string in)
[nil 0] ;; done streaming (edn/read-string in)))))]
(let [res [(do (when-not (or expression file) (loop [in (read-next)]
(throw (Exception. "Missing expression."))) (if (identical? ::EOF in)
(let [res (sci/eval-string [nil 0] ;; done streaming
expr (let [res [(do (when-not (or expression file)
{:bindings (assoc bindings (throw (Exception. "Missing expression.")))
(with-meta '*in* (let [res (sci/eval-string
(when-not stream? {:sci/deref! true})) in expr
#_(with-meta 'bb/*in* {:bindings (assoc bindings
{:sci/deref! true}) #_do-in (with-meta '*in*
'*command-line-args* command-line-args)})] (when-not stream? {:sci/deref! true})) in
(if raw-out #_(with-meta 'bb/*in*
(if (coll? res) {:sci/deref! true}) #_do-in
(doseq [l res] '*command-line-args* command-line-args)})]
(println l)) (if raw-out
(println res)) (if (coll? res)
((if println? println? prn) res)))) 0]] (doseq [l res]
(if stream? (println l))
(recur (read-next)) (println res))
res))))) ((if println? println? prn) res)))) 0]]
(catch Exception e (if stream?
(binding [*out* *err*] (recur (read-next))
(when-let [msg (or (:stderr (ex-data e)) res)))))
(.getMessage e))] (catch Exception e
(println (str/trim msg) ))) (binding [*out* *err*]
[nil 1]))))) (when-let [msg (or (:stderr (ex-data e))
1)) (.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 (defn -main
[& args] [& args]