Skip to content

Instantly share code, notes, and snippets.

@selfsame
Created May 4, 2019 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selfsame/fab7d2b587b9df949504d94dc371a528 to your computer and use it in GitHub Desktop.
Save selfsame/fab7d2b587b9df949504d94dc371a528 to your computer and use it in GitHub Desktop.
arcadia godot compiler ns
(ns arcadia.compiler
(:use
arcadia.core)
(:require
[clojure.spec.alpha :as s]
clojure.string
[arcadia.internal.spec :as as]
[arcadia.config :as config]))
(defn aot-namespaces [path nss]
;; We want to ensure that namespaces are neither double-aot'd, nor
;; _not_ aot'd if already in memory.
;; In other words, we want to walk the forest of all the provided
;; namespaces and their dependency namespaces, aot-ing each
;; namespace we encounter in this walk exactly once. `:reload-all`
;; will re-aot encountered namespaces redundantly, potentially
;; invalidating old type references (I think). Normal `require`
;; will not do a deep walk over already-loaded namespaces. So
;; instead we rebind the *loaded-libs* var to a ref with an empty
;; set and call normal `require`, which gives the desired behavior.
(let [loaded-libs' (binding [*compiler-options* (get config/config :compiler-options {})
*compile-path* path
*compile-files* true
clojure.core/*loaded-libs* (ref #{})]
(doseq [ns nss]
(log "compiling " ns "..")
(require ns))
@#'clojure.core/*loaded-libs*)]
(dosync
(alter @#'clojure.core/*loaded-libs* into @loaded-libs'))
nil))
(defn release! [path ns-syms]
(aot-namespaces path (concat ns-syms [
'clojure.core.server])))
'(release! "test/dlls/" ['selfsame.core])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment