Skip to content

Commit

Permalink
Remove hardcoded references to Arcadia folder
Browse files Browse the repository at this point in the history
Location of Arcadia folder is computed relative to Clojure.dll
  • Loading branch information
nasser committed May 1, 2019
1 parent 6527d87 commit c0bd3a2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Editor/BuildPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class BuildPipeline

public static string CompiledFolder = Path.Combine("Arcadia", "Compiled");
public static string ExportFolder = Path.Combine("Arcadia", "Export");
public static string ExportAssetsFolder = Path.Combine("Assets", Path.Combine("Arcadia", "Export"));
public static string ExportAssetsFolder = Path.Combine(Initialization.GetArcadiaFolder(), "Export");

static BuildPipeline ()
{
Expand Down
9 changes: 7 additions & 2 deletions Editor/Initialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class Initialization
// ============================================================
// Data
public static string PathToCompiled = Path.GetFullPath(VariadicPathCombine(Application.dataPath, "..", "Arcadia", "Compiled"));

public static string PathToCompiledForExport = Path.GetFullPath(VariadicPathCombine(Application.dataPath, "Arcadia", "Export"));
public static string PathToCompiledForExport = Path.GetFullPath(VariadicPathCombine(GetArcadiaFolder(), "Arcadia", "Export"));

static Initialization ()
{
Expand All @@ -28,6 +28,11 @@ public static String GetClojureDllFolder ()
return Path.GetDirectoryName(typeof(clojure.lang.RT).Assembly.Location).Substring(Directory.GetCurrentDirectory().Length + 1);
}

public static String GetArcadiaFolder()
{
return Directory.GetParent(GetClojureDllFolder()).ToString();
}

public static void StartWatching ()
{
//AssetPostprocessor.StartWatchingFiles();
Expand Down
7 changes: 4 additions & 3 deletions Source/arcadia/internal/components.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
arcadia.internal.components
(:require [clojure.string :as string]
[arcadia.internal.events :as events])
(:import [clojure.lang RT]))
(:import [clojure.lang RT]
[Arcadia Initialization]
[System.IO Path]))

;; TODO path seperators
(def path "Assets/Arcadia/Components/")
(def path (Path/Combine (Initialization/GetArcadiaFolder) "Components"))

(defn component-name [event]
(str event "Hook"))
Expand Down
3 changes: 2 additions & 1 deletion Source/arcadia/internal/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
[arcadia.internal.filewatcher :as fw]
[arcadia.internal.file-system :as fs])
(:import
[Arcadia Initialization]
[System DateTime]
[System.IO FileSystemInfo File Path]
[UnityEngine Debug]
[System.Text.RegularExpressions Regex]))

(def default-config-file-path (Path/Combine "Assets" "Arcadia" "configuration.edn"))
(def default-config-file-path (Path/Combine (Initialization/GetArcadiaFolder) "configuration.edn"))
(def user-config-file-path (Path/Combine "Assets" "configuration.edn"))

(defn config []
Expand Down
12 changes: 6 additions & 6 deletions Source/arcadia/internal/leiningen.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
[arcadia.internal.compiler :as compiler]
[arcadia.internal.config :as config])
(:import [System.Text.RegularExpressions Regex]
[System.IO FileSystemInfo StringReader DirectoryInfo Path]
[System.IO FileSystemInfo StringReader Directory DirectoryInfo Path]
[UnityEditor AssetDatabase]
[clojure.lang PushbackTextReader]))

;; ------------------------------------------------------------
Expand Down Expand Up @@ -72,14 +73,10 @@
;; ============================================================
;; filesystem

(def ^:private assets-dir
(.FullName (fs/info "Assets")))

;; if anyone can think of another way lemme know -tsg
(defn leiningen-project-file? [fi]
(when-let [fi (fs/info fi)] ;; not sure this stupid function returns nil if input is already a filesysteminfo for a non existant filesystemthing
(and (= "project.clj" (.Name fi))
(= assets-dir (first (drop 2 (fs/path-supers (.FullName fi)))))
(boolean
(re-find #"(?m)^\s*\(defproject(?:$|\s.*?$)" ;; shift to something less expensive
(slurp fi))))))
Expand Down Expand Up @@ -108,7 +105,10 @@
(.GetFiles di))))

(defn leiningen-project-directories []
(->> (.GetDirectories (DirectoryInfo. "Assets"))
(->> "project"
AssetDatabase/FindAssets
(map #(AssetDatabase/GUIDToAssetPath %))
(map #(Directory/GetParent %))
(filter leiningen-structured-directory?)))

(s/fdef all-project-data
Expand Down
6 changes: 4 additions & 2 deletions Source/arcadia/internal/mozroots.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
Mozilla uses in Firefox. We load the assembly and simulate a
command line session passing --import --sync as arguments."}
arcadia.internal.mozroots
(:import Arcadia.Shell))
(:import [Arcadia Initialization Shell]
[System.IO Path]))

;; TODO fix hardcoded path here
(defn import-sync-mozroots []
(Shell/MonoRun Shell/MozrootsExePath
"--file Assets/Arcadia/Infrastructure/certdata.txt --import --sync"))
(str "--file " (Path/Combine (Initialization/GetArcadiaFolder) "Infrastructure" "certdata.txt") " --import --sync")))
6 changes: 3 additions & 3 deletions Source/arcadia/internal/packages.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[clojure.edn :as edn]
[arcadia.internal.leiningen :as lein]
[arcadia.internal.config :as config])
(:import [Arcadia ProgressBar Shell]
(:import [Arcadia Initialization ProgressBar Shell]
UnityEditor.EditorUtility
UnityEngine.Debug
[System.Diagnostics Process]
Expand Down Expand Up @@ -72,7 +72,7 @@

;;;; NuGet & JSON wrangling

(def nuget-exe-path (Path/Combine "Assets" "Arcadia" "Infrastructure" "NuGet.exe"))
(def nuget-exe-path (Path/Combine (Initialization/GetArcadiaFolder) "Infrastructure" "NuGet.exe"))
(def external-packages-folder (Path/Combine "Arcadia" "Libraries"))
(def internal-packages-folder (Path/Combine "Assets" "Arcadia" "Libraries"))
(def external-package-files-folder (Path/Combine external-packages-folder "Files"))
Expand Down Expand Up @@ -121,7 +121,7 @@
(defn install [destination]
(let [to-copy (volatile! [])]
(Shell/MonoRun
"Assets/Arcadia/Infrastructure/NuGetAssetParser.exe"
(Path/Combine (Initialization/GetArcadiaFolder) "Infrastructure" "NuGetAssetParser.exe")
(str package-lock-file " 4.6")
{:output (fn [s] (vswap! to-copy conj s))
:done (fn []
Expand Down

0 comments on commit c0bd3a2

Please sign in to comment.