Skip to content

Commit

Permalink
Start work on MAGIC Nostrand bootstrap
Browse files Browse the repository at this point in the history
Working but not 100% reproducible yet
  • Loading branch information
nasser committed Oct 13, 2020
1 parent 636f6db commit f88c3e4
Show file tree
Hide file tree
Showing 79 changed files with 52 additions and 24 deletions.
43 changes: 34 additions & 9 deletions Nostrand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public static Var FindFunction(string name)
return null;
}

[DllImport("__Internal", EntryPoint = "mono_get_runtime_build_info")]
public extern static string GetMonoVersion();
// [DllImport("__Internal", EntryPoint = "mono_get_runtime_build_info")]
// public extern static string GetRuntimeVersion();

public static string Version()
{
Expand All @@ -86,17 +86,42 @@ public static string FileToRelativePath(string file)
return file.Replace(".clj", "").Replace(".cljc", "");
}

static void BootClojureAndNostrand()
{
var assemblyPath = Path.GetDirectoryName(Assembly.Load("Clojure").Location);
foreach(var cljDll in Directory.EnumerateFiles(assemblyPath, "*.clj.dll"))
{
// Terminal.Message("[loading]", cljDll, ConsoleColor.DarkGray);
Assembly.LoadFile(cljDll);
}

// Terminal.Message("[booting]", "runtime", ConsoleColor.DarkGray);
RT.Initialize(doRuntimePostBoostrap: false);
// Terminal.Message("[booting]", "clojure/core", ConsoleColor.DarkGray);
RT.TryLoadInitType("clojure/core");
// Terminal.Message("[booting]", "magic/api", ConsoleColor.DarkGray);
RT.TryLoadInitType("magic/api");

// Terminal.Message("[booting]", "establishing root bindings", ConsoleColor.DarkGray);
RT.var("clojure.core", "*eval-form-fn*").bindRoot(RT.var("magic.api", "eval"));
RT.var("clojure.core", "*load-file-fn*").bindRoot(RT.var("magic.api", "runtime-load-file"));
RT.var("clojure.core", "*compile-file-fn*").bindRoot(RT.var("magic.api", "runtime-compile-file"));

// var loadFunction = RT.var("clojure.core", "*load-fn*");
// Terminal.Message("[loading]", "nostrand/core", ConsoleColor.DarkGray);
// loadFunction.invoke("nostrand/core");
RT.TryLoadInitType("nostrand/core");
// Terminal.Message("[loading]", "nostrand/tasks", ConsoleColor.DarkGray);
// loadFunction.invoke("nostrand/tasks");
RT.TryLoadInitType("nostrand/tasks");
}

public static void Main(string[] args)
{
new Mono.Terminal.LineEditor("#force-mono.terminal-assembly-load#");
BootClojureAndNostrand();
if (args.Length > 0)
{
RuntimeBootstrapFlag._doRTBootstrap = false;

RT.load("clojure/core");
RT.load("nostrand/core");
RT.load("nostrand/tasks");

AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.Resolve;

if (File.Exists("project.edn"))
Expand Down Expand Up @@ -150,7 +175,7 @@ public static void Main(string[] args)
else
{
Terminal.Message("Nostrand", Version(), ConsoleColor.White);
Terminal.Message("Mono", GetMonoVersion(), ConsoleColor.White);
// Terminal.Message("Mono", GetRuntimeVersion(), ConsoleColor.White);
Terminal.Message("Clojure", RT.var("clojure.core", "clojure-version").invoke(), ConsoleColor.White);
}
}
Expand Down
13 changes: 6 additions & 7 deletions Nostrand.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project InitialTargets="PreBuild" Sdk="Microsoft.NET.Sdk">
<!-- <Project InitialTargets="PreBuild" Sdk="Microsoft.NET.Sdk"> -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net471</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<Content Include="Scripts/nos" Link="nos" CopyToOutputDirectory="PreserveNewest" />
<!-- <Content Include="Scripts/nos" Link="nos" CopyToOutputDirectory="PreserveNewest" /> -->
<Content Include="nostrand/**/*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand All @@ -18,16 +19,14 @@
</ItemGroup>

<ItemGroup>
<Reference Include="Clojure">
<HintPath>References/Clojure.dll</HintPath>
</Reference>
<Reference Include="References/*.dll" />
</ItemGroup>

<Target Name="PreBuild">
<!-- <Target Name="PreBuild">
<Exec Command="sh Scripts/patch-assembly-info.sh" />
</Target>
<Target Name="PostBuild" AfterTargets="Build">
<Exec Command="sh Scripts/unpatch-assembly-info.sh" />
<Exec Command="sh Scripts/aot-assemblies.sh $(OutDir)" Condition="'$(Configuration)'=='Release'" />
</Target>
</Target> -->
</Project>
Binary file modified References/Clojure.dll
Binary file not shown.
Binary file added References/Magic.Runtime.dll
Binary file not shown.
Binary file added References/clojure.clr.io.clj.dll
Binary file not shown.
Binary file added References/clojure.clr.shell.clj.dll
Binary file not shown.
Binary file added References/clojure.core.clj.dll
Binary file not shown.
Binary file added References/clojure.core.protocols.clj.dll
Binary file not shown.
Binary file added References/clojure.core.reducers.clj.dll
Binary file not shown.
Binary file added References/clojure.core.server.clj.dll
Binary file not shown.
Binary file added References/clojure.core.specs.alpha.clj.dll
Binary file not shown.
Binary file added References/clojure.core_clr.clj.dll
Binary file not shown.
Binary file added References/clojure.core_deftype.clj.dll
Binary file not shown.
Binary file added References/clojure.core_print.clj.dll
Binary file not shown.
Binary file added References/clojure.core_proxy.clj.dll
Binary file not shown.
Binary file added References/clojure.data.clj.dll
Binary file not shown.
Binary file added References/clojure.edn.clj.dll
Binary file not shown.
Binary file added References/clojure.genclass.clj.dll
Binary file not shown.
Binary file added References/clojure.gvec.clj.dll
Binary file not shown.
Binary file added References/clojure.instant.clj.dll
Binary file not shown.
Binary file added References/clojure.main.clj.dll
Binary file not shown.
Binary file added References/clojure.repl.clj.dll
Binary file not shown.
Binary file added References/clojure.set.clj.dll
Binary file not shown.
Binary file added References/clojure.spec.alpha.clj.dll
Binary file not shown.
Binary file added References/clojure.spec.gen.alpha.clj.dll
Binary file not shown.
Binary file added References/clojure.stacktrace.clj.dll
Binary file not shown.
Binary file added References/clojure.string.clj.dll
Binary file not shown.
Binary file added References/clojure.template.clj.dll
Binary file not shown.
Binary file added References/clojure.test.clj.dll
Binary file not shown.
Binary file added References/clojure.tools.analyzer.ast.clj.dll
Binary file not shown.
Binary file added References/clojure.tools.analyzer.clj.dll
Binary file not shown.
Binary file added References/clojure.tools.analyzer.env.clj.dll
Binary file not shown.
Binary file not shown.
Binary file added References/clojure.tools.analyzer.passes.clj.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added References/clojure.uuid.clj.dll
Binary file not shown.
Binary file added References/clojure.walk.clj.dll
Binary file not shown.
Binary file added References/clojure.zip.clj.dll
Binary file not shown.
Binary file added References/mage.core.clj.dll
Binary file not shown.
Binary file not shown.
Binary file added References/magic.analyzer.binder.clj.dll
Binary file not shown.
Binary file added References/magic.analyzer.clj.dll
Binary file not shown.
Binary file not shown.
Binary file added References/magic.analyzer.errors.clj.dll
Binary file not shown.
Binary file not shown.
Binary file added References/magic.analyzer.intrinsics.clj.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added References/magic.analyzer.novel.clj.dll
Binary file not shown.
Binary file added References/magic.analyzer.reflection.clj.dll
Binary file not shown.
Binary file not shown.
Binary file added References/magic.analyzer.typed_passes.clj.dll
Binary file not shown.
Binary file added References/magic.analyzer.types.clj.dll
Binary file not shown.
Binary file added References/magic.analyzer.uniquify.clj.dll
Binary file not shown.
Binary file not shown.
Binary file added References/magic.analyzer.util.clj.dll
Binary file not shown.
Binary file added References/magic.api.clj.dll
Binary file not shown.
Binary file added References/magic.core.clj.dll
Binary file not shown.
Binary file added References/magic.emission.clj.dll
Binary file not shown.
Binary file added References/magic.interop.clj.dll
Binary file not shown.
Binary file added References/magic.intrinsics.clj.dll
Binary file not shown.
Binary file added References/magic.spells.lift_keywords.clj.dll
Binary file not shown.
Binary file added References/magic.spells.lift_vars.clj.dll
Binary file not shown.
Binary file added References/magic.util.clj.dll
Binary file not shown.
Binary file added References/nostrand.core.clj.dll
Binary file not shown.
Binary file added References/nostrand.deps.clj.dll
Binary file not shown.
Binary file added References/nostrand.deps.github.clj.dll
Binary file not shown.
Binary file added References/nostrand.deps.maven.clj.dll
Binary file not shown.
Binary file added References/nostrand.deps.nuget.clj.dll
Binary file not shown.
Binary file added References/nostrand.deps.shell.clj.dll
Binary file not shown.
Binary file added References/nostrand.repl.clj.dll
Binary file not shown.
Binary file added References/nostrand.tasks.clj.dll
Binary file not shown.
9 changes: 4 additions & 5 deletions nostrand/bootstrap.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
(ns nostrand.bootstrap)

(defn full-aot []
(binding [*compile-path* "."
*compile-files* true]
(require 'nostrand.core :reload-all)
(require 'nostrand.tasks :reload-all)
(require 'nostrand.repl :reload-all)))
(binding [clojure.core/*loaded-libs* (ref (sorted-set))]
(compile 'nostrand.core)
(compile 'nostrand.tasks)
(compile 'nostrand.repl)))
7 changes: 6 additions & 1 deletion nostrand/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
(defn update-load-path []
(Environment/SetEnvironmentVariable
"CLOJURE_LOAD_PATH"
(string/join Path/PathSeparator @-load-path)))
(string/join Path/PathSeparator @-load-path))
(alter-var-root #'*load-paths*
(fn [load-paths]
(mapv
#(System.IO.Path/GetFullPath %)
(concat @-load-path load-paths)))))

(defn set-load-path [val]
(reset! -load-path val)
Expand Down
2 changes: 1 addition & 1 deletion nostrand/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[System.Net IPEndPoint IPAddress]
[System.Net.Sockets UdpClient SocketException]
[Nostrand Nostrand Terminal]
; [Mono.Terminal LineEditor]
[Mono.Terminal LineEditor]
))

(defn- prompt []
Expand Down
2 changes: 1 addition & 1 deletion nostrand/tasks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

(defn version []
(msg "Nostrand" (Nostrand/Version))
(msg "Mono" (Nostrand/GetMonoVersion))
;; (msg "Mono" (Nostrand/GetMonoVersion))
(msg "Clojure" (clojure-version)))

(defn cli-repl [args]
Expand Down

0 comments on commit f88c3e4

Please sign in to comment.