forked from nasser/magic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.clj
94 lines (87 loc) · 3.28 KB
/
build.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(ns build
(:require [magic.core :refer [*spells*]]
[magic.api :refer [compile-namespace]]
[magic.spells.sparse-case :refer [sparse-case]])
(:import [System.IO File Directory Path DirectoryInfo]))
(in-ns 'clojure.core)
;; forward declare vars added to clojure.core after 1.9 to preserve
;; bootstrapping. ideally we would just compile clojure.core first but that
;; causes its own problems.
(defmacro -forward-declare-new-vars [vars]
`(do
~@(map (fn [v] `(let [vv# (declare ~v)] (println "forward declaring" vv#))) vars)))
(-forward-declare-new-vars [requiring-resolve])
(in-ns 'build)
(def std-libs-to-compile
'[clojure.tools.analyzer.env
clojure.tools.analyzer.utils
clojure.tools.analyzer
clojure.string
clojure.set
clojure.tools.analyzer.ast
magic.analyzer.binder
magic.analyzer.util
magic.analyzer.reflection
magic.flags
magic.emission
magic.analyzer.types
magic.analyzer.generated-types
magic.analyzer.loop-bindings
magic.analyzer.uniquify
magic.interop
mage.core
magic.util
magic.core
magic.spells.lift-vars
magic.spells.lift-keywords
magic.analyzer.errors
magic.analyzer.analyze-host-forms
magic.analyzer.novel
magic.analyzer.intrinsics
magic.analyzer.typed-passes
clojure.tools.analyzer.passes
clojure.tools.analyzer.passes.source-info
clojure.tools.analyzer.passes.elide-meta
clojure.tools.analyzer.passes.trim
clojure.tools.analyzer.passes.cleanup
magic.analyzer.collect-closed-overs
magic.analyzer.remove-local-children
magic.analyzer.untyped-passes
clojure.walk
magic.analyzer
magic.analyzer.literal-reinterpretation
magic.intrinsics
magic.api
clojure.core-proxy
clojure.core-print
clojure.genclass
clojure.core-deftype
clojure.core.protocols
clojure.gvec
clojure.clr.io
clojure.core]) ;; if clojure.core not at the end, prevent other files from being compiled
(defn bootstrap-portable [& opts]
(let [opts (set opts)]
(binding [*print-meta* true
clojure.core/*loaded-libs* (ref (sorted-set))
*spells* [sparse-case] ; (if (:portable opts) (conj *spells* sparse-case) *spells*)
*eval-form-fn* magic.api/eval
*compile-file-fn* magic.api/runtime-compile-file
*load-file-fn* magic.api/runtime-load-file
*warn-on-reflection* true
*compile-path* "bootstrap"]
(doseq [lib std-libs-to-compile]
(println (str "building " lib))
(compile-namespace lib {:write-files true :suppress-print-forms true})))))
(defn bootstrap [& opts]
(let [opts (set opts)]
(binding [*print-meta* true
clojure.core/*loaded-libs* (ref (sorted-set))
*eval-form-fn* magic.api/eval
*compile-file-fn* magic.api/runtime-compile-file
*load-file-fn* magic.api/runtime-load-file
*warn-on-reflection* true
*compile-path* "bootstrap"]
(doseq [lib std-libs-to-compile]
(println (str "building " lib))
(compile-namespace lib {:write-files true :suppress-print-forms true})))))