Skip to content

Commit

Permalink
Add :aot-namespaces key to configuration
Browse files Browse the repository at this point in the history
Allows users to specify which namespaces to AOT compile and which to
export separately.

Fixes #361
  • Loading branch information
nasser committed Jun 4, 2019
1 parent 736ec4c commit b7f89c5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Arcadia Changelog

## Beta 1.0.11

- Fixed issue [#361](https://github.com/arcadia-unity/Arcadia/issues/361).

## Beta 1.0.10

- Fixed issue [#363](https://github.com/arcadia-unity/Arcadia/issues/363).
Expand Down
4 changes: 2 additions & 2 deletions Editor/BuildPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static void CompileNamespacesToFolder (IEnumerable userNameSpaces, string target
public static void BuildAll ()
{
EnsureCompiledFolders();
IList internalAndUserNameSpaces = (IList)RT.var("arcadia.internal.editor-interop", "internal-and-user-root-namespaces").invoke();
IList internalAndUserNameSpaces = (IList)RT.var("arcadia.internal.editor-interop", "internal-and-user-aot-root-namespaces").invoke();
CompileNamespacesToFolder(internalAndUserNameSpaces, CompiledFolder);
}

Expand All @@ -158,7 +158,7 @@ public static void PrepareExport ()
UnityEngine.Debug.Log("newLoadPath: " + newLoadPath);
System.Environment.SetEnvironmentVariable("CLOJURE_LOAD_PATH", newLoadPath);

var userNamespaces = ((IList)RT.var("arcadia.internal.editor-interop", "all-user-namespaces-symbols").invoke()).Cast<Symbol>();
var userNamespaces = ((IList)RT.var("arcadia.internal.editor-interop", "user-export-namespaces-symbols").invoke()).Cast<Symbol>();

CompileNamespacesToFolder(userNamespaces, ExportFolder);

Expand Down
34 changes: 25 additions & 9 deletions Source/arcadia/internal/editor_interop.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,36 @@
[UnityEditor EditorGUILayout EditorGUIUtility MessageType EditorStyles EditorSkin]))

;; PERF memoize
(defn all-user-namespaces-symbols []
(defn user-export-namespaces-symbols []
(cons 'clojure.core
(-> (config/config) :export-namespaces)))

(defn all-loaded-user-namespaces []
(keep find-ns (all-user-namespaces-symbols)))
(defn user-aot-namespaces-symbols []
(:aot-namespaces (config/config)))

(defn load-user-namespaces! []
(doseq [n (all-user-namespaces-symbols)]
(defn all-loaded-aot-namespaces []
(keep find-ns (user-aot-namespaces-symbols)))

(defn all-loaded-export-namespaces []
(keep find-ns (user-export-namespaces-symbols)))

(defn load-aot-namespaces! []
(doseq [n (user-aot-namespaces-symbols)]
(Debug/Log (str "Loading " n))
(require n)))

(defn load-export-namespaces! []
(doseq [n (user-export-namespaces-symbols)]
(Debug/Log (str "Loading " n))
(require n)))

(defn reload-user-namespaces! []
(doseq [n (all-user-namespaces-symbols)]
(defn reload-aot-namespaces! []
(doseq [n (user-aot-namespaces-symbols)]
(Debug/Log (str "Reloading " n))
(require n :reload)))

(defn reload-export-namespaces! []
(doseq [n (user-export-namespaces-symbols)]
(Debug/Log (str "Reloading " n))
(require n :reload)))

Expand Down Expand Up @@ -264,5 +280,5 @@
arcadia.internal.components arcadia.internal.benchmarking arcadia.internal.asset-watcher
arcadia.internal.array-utils arcadia.internal.packages.data arcadia.internal.socket-repl])

(defn internal-and-user-root-namespaces []
(vec (set (concat internal-namespaces (all-user-namespaces-symbols)))))
(defn internal-and-user-aot-root-namespaces []
(vec (set (concat internal-namespaces (user-aot-namespaces-symbols)))))
4 changes: 4 additions & 0 deletions configuration.edn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
;; declare specific compilation targets, will also compile their dependencies
;; :export-namespaces [foo.core]

;; declare specific namespaces to compile in response to the AOT Compile menu
;; option, will also compile their dependencies
;; :aot-namespaces [foo.core]

;; set to true in user configuration.edn to enable automatic code
;; reloading when a clojure file is saved
:reload-on-change false
Expand Down

0 comments on commit b7f89c5

Please sign in to comment.