Print meta only during compile, fixes #2079

Passing in the project map as a parameter to eval-in-subprocess causes
havoc, as it has references to the functions reduce-dep-step and
reduce-repo-step in its metadata.
This commit is contained in:
Jean Niklas L'orange 2016-02-07 01:23:59 +01:00
parent dca5627403
commit 4383caecce
2 changed files with 27 additions and 28 deletions

View file

@ -245,10 +245,9 @@
(io/file (:target-path project) (str checksum "-init.clj"))
(File/createTempFile "form-init" ".clj"))]
(spit init-file
(binding [*print-dup* true]
(pr-str (if-not (System/getenv "LEIN_FAST_TRAMPOLINE")
`(.deleteOnExit (File. ~(.getCanonicalPath init-file))))
form)))
(pr-str (if-not (System/getenv "LEIN_FAST_TRAMPOLINE")
`(.deleteOnExit (File. ~(.getCanonicalPath init-file))))
form))
`(~(or (:java-cmd project) (System/getenv "JAVA_CMD") "java")
~@(classpath-arg project)
~@(get-jvm-args project)
@ -325,8 +324,7 @@
:port (Integer. (slurp port-file)))
client (client-session (client transport Long/MAX_VALUE))
pending (atom #{})]
(message client {:op "eval" :code (binding [*print-dup* true]
(pr-str form))})
(message client {:op "eval" :code (pr-str form)})
(doseq [{:keys [out err status session] :as msg} (repeatedly
#(recv transport 100))
:while (not (done? msg pending))]

View file

@ -146,26 +146,27 @@ shouldn't need to be manually invoked. See the javac task as well.
Compiling code loads the namespace, so keep side-effects out of the top level.
Code that should run on startup belongs in a -main defn."
([project]
(if-let [namespaces (seq (stale-namespaces project))]
(let [ns-sym (gensym "namespace")
form `(do
~set-agent-threadpool-form
(doseq [~ns-sym '~namespaces]
~(if main/*info*
`(binding [*out* *err*]
(println "Compiling" ~ns-sym)))
(try
(clojure.core/compile ~ns-sym)
(catch Throwable t#
(binding [*out* *err*]
(println (.getMessage t#)))
(throw t#)))))
project (update-in project [:prep-tasks]
(partial remove #{"compile"}))]
(try (eval/eval-in-project project form)
(catch Exception e
(main/abort "Compilation failed:" (.getMessage e)))
(finally (clean-non-project-classes project))))
(main/debug "All namespaces already AOT compiled.")))
(if-let [namespaces (seq (stale-namespaces project))]
(let [ns-sym (gensym "namespace")
form `(do
~set-agent-threadpool-form
(doseq [~ns-sym '~namespaces]
~(if main/*info*
`(binding [*out* *err*]
(println "Compiling" ~ns-sym)))
(try
(clojure.core/compile ~ns-sym)
(catch Throwable t#
(binding [*out* *err*]
(println (.getMessage t#)))
(throw t#)))))
project (update-in project [:prep-tasks]
(partial remove #{"compile"}))]
(try (binding [*print-dup* true]
(eval/eval-in-project project form))
(catch Exception e
(main/abort "Compilation failed:" (.getMessage e)))
(finally (clean-non-project-classes project))))
(main/debug "All namespaces already AOT compiled.")))
([project & args]
(compile (assoc project :aot (compilation-specs args)))))
(compile (assoc project :aot (compilation-specs args)))))