Add experimental add-classpath!
This commit is contained in:
parent
19767b54a3
commit
b933610626
1 changed files with 20 additions and 6 deletions
|
|
@ -253,6 +253,19 @@ Everything after that is bound to *command-line-args*."))
|
||||||
(flush)
|
(flush)
|
||||||
[nil 1])))))
|
[nil 1])))))
|
||||||
|
|
||||||
|
(def cp-state (atom {:loader nil
|
||||||
|
:cp nil}))
|
||||||
|
|
||||||
|
(defn add-classpath! [add-to-cp]
|
||||||
|
(swap! cp-state
|
||||||
|
(fn [{:keys [:cp]}]
|
||||||
|
(let [new-cp
|
||||||
|
(if-not cp add-to-cp
|
||||||
|
(str cp (System/getProperty "path.separator") add-to-cp))]
|
||||||
|
{:loader (cp/loader new-cp)
|
||||||
|
:cp new-cp})))
|
||||||
|
nil)
|
||||||
|
|
||||||
(defn main
|
(defn main
|
||||||
[& args]
|
[& args]
|
||||||
(handle-pipe!)
|
(handle-pipe!)
|
||||||
|
|
@ -282,10 +295,10 @@ Everything after that is bound to *command-line-args*."))
|
||||||
env (atom {})
|
env (atom {})
|
||||||
classpath (or classpath
|
classpath (or classpath
|
||||||
(System/getenv "BABASHKA_CLASSPATH"))
|
(System/getenv "BABASHKA_CLASSPATH"))
|
||||||
loader (when classpath
|
_ (when classpath
|
||||||
(cp/loader classpath))
|
(add-classpath! classpath))
|
||||||
load-fn (when classpath
|
load-fn (fn [{:keys [:namespace]}]
|
||||||
(fn [{:keys [:namespace]}]
|
(when-let [{:keys [:loader]} @cp-state]
|
||||||
(let [res (cp/source-for-namespace loader namespace nil)]
|
(let [res (cp/source-for-namespace loader namespace nil)]
|
||||||
(when uberscript (swap! uberscript-sources conj (:source res)))
|
(when uberscript (swap! uberscript-sources conj (:source res)))
|
||||||
res)))
|
res)))
|
||||||
|
|
@ -297,9 +310,10 @@ Everything after that is bound to *command-line-args*."))
|
||||||
'*command-line-args*
|
'*command-line-args*
|
||||||
(sci/new-dynamic-var '*command-line-args* command-line-args)
|
(sci/new-dynamic-var '*command-line-args* command-line-args)
|
||||||
'*file* vars/file-var
|
'*file* vars/file-var
|
||||||
'*warn-on-reflection* reflection-var))
|
'*warn-on-reflection* reflection-var
|
||||||
|
'add-classpath! add-classpath!))
|
||||||
(assoc-in ['clojure.java.io 'resource]
|
(assoc-in ['clojure.java.io 'resource]
|
||||||
#(when classpath (cp/getResource loader % {:url? true}))))
|
#(when-let [{:keys [:loader]} @cp-state] (cp/getResource loader % {:url? true}))))
|
||||||
:bindings bindings
|
:bindings bindings
|
||||||
:env env
|
:env env
|
||||||
:features #{:bb}
|
:features #{:bb}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue