From b7f89c5c85c453ec645136db2aea5f0186d3d552 Mon Sep 17 00:00:00 2001 From: Ramsey Nasser Date: Tue, 4 Jun 2019 17:30:54 -0400 Subject: [PATCH] Add :aot-namespaces key to configuration Allows users to specify which namespaces to AOT compile and which to export separately. Fixes #361 --- CHANGELOG.md | 4 +++ Editor/BuildPipeline.cs | 4 +-- Source/arcadia/internal/editor_interop.clj | 34 ++++++++++++++++------ configuration.edn | 4 +++ 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6772226..0cecdd0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/Editor/BuildPipeline.cs b/Editor/BuildPipeline.cs index 81200ab8..3af3882c 100644 --- a/Editor/BuildPipeline.cs +++ b/Editor/BuildPipeline.cs @@ -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); } @@ -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(); + var userNamespaces = ((IList)RT.var("arcadia.internal.editor-interop", "user-export-namespaces-symbols").invoke()).Cast(); CompileNamespacesToFolder(userNamespaces, ExportFolder); diff --git a/Source/arcadia/internal/editor_interop.clj b/Source/arcadia/internal/editor_interop.clj index 0a44699d..f73e88ca 100644 --- a/Source/arcadia/internal/editor_interop.clj +++ b/Source/arcadia/internal/editor_interop.clj @@ -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))) @@ -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))))) diff --git a/configuration.edn b/configuration.edn index 5dd94838..44ff9d80 100644 --- a/configuration.edn +++ b/configuration.edn @@ -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