Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: clojure/tools.build
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: WhimsicalCode/tools.build
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dc/no-temp-dir
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on May 24, 2022

  1. Don't use a temp directory when compiling Clojure

    The recursive copy of files from the temp dir to the working dir
    (usually target/) takes a very long time if you have any security
    software which scans file events.
    
    This is a temporary commit to work around this until a cleaner solution
    is found.
    https://clojurians.slack.com/archives/C02B5GHQWP4/p1653334397740989
    https://ask.clojure.org/index.php/11905/can-tools-build-configured-compile-directly-project-target
    danielcompton committed May 24, 2022
    Copy the full SHA
    b8dc724 View commit details

Commits on Jan 2, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9822167 View commit details
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/main/clojure/clojure/tools/build/tasks/compile_clj.clj
14 changes: 9 additions & 5 deletions src/main/clojure/clojure/tools/build/tasks/compile_clj.clj
Original file line number Diff line number Diff line change
@@ -80,15 +80,16 @@
(defn compile-clj
[{:keys [basis src-dirs compile-opts ns-compile filter-nses class-dir sort bindings] :as params
:or {sort :topo}}]
(let [working-dir (.toFile (Files/createTempDirectory "compile-clj" (into-array FileAttribute [])))
(let [#_ #_ working-dir (.toFile (Files/createTempDirectory "compile-clj" (into-array FileAttribute [])))
compile-dir-file (file/ensure-dir (api/resolve-path class-dir))
working-dir compile-dir-file
clj-paths (map api/resolve-path (or src-dirs (basis-paths basis)))
nses (cond
(seq ns-compile) ns-compile
(= sort :topo) (nses-in-topo clj-paths)
(= sort :bfs) (nses-in-bfs clj-paths)
:else (throw (ex-info "Missing :ns-compile or :sort order in compile-clj task" {})))
working-compile-dir (file/ensure-dir (jio/file working-dir "compile-clj"))
working-compile-dir working-dir #_(file/ensure-dir (jio/file working-dir "compile-clj"))
compile-script (jio/file working-dir "compile.clj")
_ (write-compile-script! compile-script working-compile-dir nses compile-opts bindings)

@@ -100,13 +101,16 @@
:basis basis
:main 'clojure.main
:main-args [(.getCanonicalPath compile-script)]}))
_ (spit (jio/file working-dir "compile.args") (str/join " " (:command-args process-args)))
compile-args (spit (jio/file working-dir "compile.args") (str/join " " (:command-args process-args)))
exit (:exit (process/process process-args))]
(if (zero? exit)
(do
(if (seq filter-nses)
;; NOTE: this disables filter-nses.
#_(if (seq filter-nses)
(file/copy-contents working-compile-dir compile-dir-file (map ns->path filter-nses))
(file/copy-contents working-compile-dir compile-dir-file))
;; only delete on success, otherwise leave the evidence!
(file/delete working-dir))
#_ (file/delete working-dir)
(file/delete compile-script)
#_(file/delete compile-args))
(throw (ex-info (str "Clojure compilation failed, working dir preserved: " (.toString working-dir)) {})))))