Skip to content

Commit

Permalink
Update folder layout
Browse files Browse the repository at this point in the history
  • Loading branch information
nasser committed Jan 24, 2015
1 parent 1814abf commit a723150
Show file tree
Hide file tree
Showing 120 changed files with 97 additions and 24 deletions.
4 changes: 4 additions & 0 deletions Compiled/README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions Editor/ClojureRepl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
using System.Collections.Generic;
using System.Threading;

[InitializeOnLoad]
public class ClojureRepl : EditorWindow {
static ClojureRepl() {
// TODO read from config
ClojureRepl.StartREPL();
}

[MenuItem ("Arcadia/REPL/Window...")]
public static void Init () {
ClojureRepl window = (ClojureRepl)EditorWindow.GetWindow (typeof (ClojureRepl));
Expand Down
71 changes: 71 additions & 0 deletions Editor/Initialization.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEditor;
using clojure.lang;

namespace Arcadia {
[InitializeOnLoad]
public class Initialization {
static Initialization() {
Initialize();
}

[MenuItem ("Arcadia/Initialization/Rerun")]
public static void Initialize() {
Debug.Log("Starting Arcadia...");

CheckSettings();
SetClojureLoadPath();
StartREPL();

Debug.Log("Arcadia Started!");
}

public static void CheckSettings() {
Debug.Log("Checking Unity Settings...");
if(PlayerSettings.apiCompatibilityLevel != ApiCompatibilityLevel.NET_2_0) {
Debug.Log("Updating API Compatibility Level");
PlayerSettings.apiCompatibilityLevel = ApiCompatibilityLevel.NET_2_0;
}

if(!PlayerSettings.runInBackground) {
Debug.Log("Updating Run In Background");
PlayerSettings.runInBackground = true;
}
}

public static void SetClojureLoadPath() {
try {
Debug.Log("Setting Load Path...");
string clojureDllFolder = Path.GetDirectoryName(
AssetDatabase.FindAssets("Clojure")
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.Where(x => x.Contains("Clojure.dll"))
.Single());

Environment.SetEnvironmentVariable("CLOJURE_LOAD_PATH",
Path.GetFullPath(VariadicCombine(clojureDllFolder, "..", "Compiled")) + ":" +
Path.GetFullPath(VariadicCombine(clojureDllFolder, "..", "Source")) + ":" +
Path.GetFullPath(Application.dataPath));
Debug.Log("Load Path is " + Environment.GetEnvironmentVariable("CLOJURE_LOAD_PATH"));
} catch(InvalidOperationException e) {
throw new SystemException("Error Loading Arcadia! Arcadia expects exactly one Arcadia folder (a folder with Clojure.dll in it)");
}
}

static void StartREPL() {
ClojureRepl.StartREPL();
}

// old mono...
static string VariadicCombine(params string[] paths) {
string path = "";
foreach(string p in paths) {
path = Path.Combine(path, p);
}
return path;
}
}
}
8 changes: 8 additions & 0 deletions Editor/Initialization.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Infrastructure.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions Source.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
22 changes: 4 additions & 18 deletions arcadia/compiler.clj → Source/arcadia/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,17 @@
[UnityEditor AssetDatabase ImportAssetOptions PlayerSettings ApiCompatibilityLevel]))

(defn assemblies-path []
(Path/Combine
(Path/GetDirectoryName
(.Location (.Assembly clojure.lang.RT)))
"Compiled"))
(let [clj-dll-folder (Path/GetDirectoryName (.Location (.Assembly clojure.lang.RT)))
arcadia-folder (Path/Combine clj-dll-folder "..")
compiled-folder (Path/Combine arcadia-folder "Compiled")]
(Path/GetFullPath compiled-folder)))

;; should we just patch the compiler to make GetFindFilePaths public?
(defn load-path []
(seq (.Invoke (.GetMethod clojure.lang.RT "GetFindFilePaths"
(enum-or BindingFlags/Static BindingFlags/NonPublic))
clojure.lang.RT nil)))

(defn env-load-path []
(System.Environment/GetEnvironmentVariable "CLOJURE_LOAD_PATH"))

(defn initialize-unity []
(set! PlayerSettings/apiCompatibilityLevel ApiCompatibilityLevel/NET_2_0)
(set! PlayerSettings/runInBackground true))

(defn rests
"Returns a sequence of all rests of the input sequence
Expand Down Expand Up @@ -70,15 +63,8 @@
unchecked-math
compiler-options]}
(@configuration :compiler)
load-path (if load-path
(concat load-path ["Assets"])
["Assets"])
assemblies (or assemblies
(assemblies-path))]
(System.Environment/SetEnvironmentVariable
"CLOJURE_LOAD_PATH"
(clojure.string/join ":"
(cons assemblies load-path)))
(if-let [namespace (-> (relative-to-load-path asset)
first
path->ns)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a723150

Please sign in to comment.