Skip to content

Commit 1d676bd

Browse files
committed
CLJS-2597: Shared AOT cache: JAR version not included in hash
1 parent a0b9521 commit 1d676bd

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -569,22 +569,24 @@
569569
(map compiled-file
570570
(comp/compile-root src-dir out-dir opts))))
571571

572-
(defn build-affecting-options-sha [opts]
573-
(util/content-sha (pr-str (comp/build-affecting-options opts)) 7))
572+
(defn build-affecting-options-sha [path opts]
573+
(let [m (assoc (comp/build-affecting-options opts) :path path)]
574+
(util/content-sha (pr-str m) 7)))
574575

575576
(defn ^File cache-base-path
576-
([]
577-
(cache-base-path nil))
578-
([opts]
577+
([path]
578+
(cache-base-path path nil))
579+
([path opts]
579580
(io/file (System/getProperty "user.home")
580581
".cljs" ".aot_cache" (util/clojurescript-version)
581-
(build-affecting-options-sha opts))))
582+
(build-affecting-options-sha path opts))))
582583

583584
(defn cacheable-files
584-
([ns ext]
585-
(cacheable-files ns ext nil))
586-
([ns ext opts]
587-
(let [path (cache-base-path opts)
585+
([rsrc ext]
586+
(cacheable-files rsrc ext nil))
587+
([rsrc ext opts]
588+
(let [{:keys [ns]} (ana/parse-ns rsrc)
589+
path (cache-base-path (util/path rsrc) opts)
588590
name (util/ns->relpath ns nil)]
589591
(into {}
590592
(map
@@ -624,17 +626,16 @@
624626
(defn compile-from-jar
625627
"Compile a file from a jar if necessary. Returns IJavaScript."
626628
[jar-file {:keys [output-file] :as opts}]
627-
(let [{:keys [ns]} (ana/parse-ns jar-file)
628-
out-file (when output-file
629+
(let [out-file (when output-file
629630
(io/file (util/output-directory opts) output-file))
630-
cacheable (cacheable-files ns (util/ext jar-file) opts)]
631+
cacheable (cacheable-files jar-file (util/ext jar-file) opts)]
631632
(when (or (nil? out-file)
632633
(not (.exists ^File out-file))
633634
(not= (util/compiled-by-version out-file)
634635
(util/clojurescript-version))
635636
(util/changed? jar-file out-file))
636637
;; actually compile from JAR
637-
(let [cache-path (cache-base-path opts)]
638+
(let [cache-path (cache-base-path (util/path jar-file) opts)]
638639
(when-not (.exists (:output-file cacheable))
639640
(-compile (jar-file-to-disk jar-file cache-path opts)
640641
(assoc opts :output-dir (util/path cache-path))))

0 commit comments

Comments
 (0)