ANN: lein-clr 0.2.0 for ClojureCLR

401 views
Skip to first unread message

Shantanu Kumar

unread,
Nov 18, 2012, 4:03:03 PM11/18/12
to clo...@googlegroups.com
Hi,

I pushed lein-clr 0.2.0 https://github.com/kumarshantanu/lein-clr JARs to Clojars a little while ago. The focus of this release is to

1. add dependency support (via NuGet/wget/curl, Leiningen :dependencies)
2. lower the bar to get started with ClojureCLR (with automated download of ClojureCLR)
3. remove the need to call `assembly-load-from` in code


I hope this release is usable enough to start building ClojureCLR apps and libraries with it. This is an early project and can certainly use feedback and contribution. Please let me know what you think.

Shantanu

dmiller

unread,
Nov 21, 2012, 12:44:21 AM11/21/12
to clo...@googlegroups.com
Shantanu,

This has been much requested.  I plan to give a test-drive over the imminent holiday weekend.  

-David

Aaron

unread,
Dec 15, 2012, 6:15:16 PM12/15/12
to clo...@googlegroups.com
Cool.  I'm just seeing this now.  I actually spent some time a while back getting a very simple nleiningen working in ClojureCLR.  I had nuget downloads working and also the ability to AOT compile namespaces and merge them into a single DLL.  It's not fully ready for prime time yet though, in part because it depends on some custom modifications to the ClojureCLR compiler.  In the long run, I'd like to work together on getting a full lein clr implementation working.  I'd love to discuss further if you have time.

By the way Dave - speaking of custom modifications to ClojureCLR, this past week, my colleague and I merged your latest master with our changes (https://github.com/kocubinski/clojure-clr).  I hope to put together some formal patches soon which clearly identify the changes I'm suggesting for the main compiler.

While we're at it, a few other things I'm working on or have working in clojure-clr are:
tools.logging and pinvoke (https://github.com/aaronc/ClojureClrEx) - logging is mostly ported but with only one backend working, pinvoke/dllimport works great, but no docs
a nice interface to WPF (https://github.com/aaronc/ClojureWpf) - pretty stable, but again no docs yet
nrepl (https://github.com/aaronc/tools.nrepl/tree/clr) - needs quite a bit more work

Unfortunately, I haven't been too diligent with documentation, but I hope to correct that as time allows.  

Shantanu Kumar

unread,
Dec 16, 2012, 10:44:14 AM12/16/12
to clo...@googlegroups.com
Hi Aaron,


On Sunday, 16 December 2012 04:45:16 UTC+5:30, Aaron wrote:
Cool.  I'm just seeing this now.  I actually spent some time a while back getting a very simple nleiningen working in ClojureCLR.  I had nuget downloads working and also the ability to AOT compile namespaces and merge them into a single DLL.  It's not fully ready for prime time yet though, in part because it depends on some custom modifications to the ClojureCLR compiler.  In the long run, I'd like to work together on getting a full lein clr implementation working.  I'd love to discuss further if you have time.

I would also be happy to discuss -- my contact details are in the lein-clr repo README. As of now, lein-clr runs on the JVM and tunnels the input/output from the Clojure.Compile.exe and Clojure.Main.exe processes. As part of the next (0.3.0) release I am currently focusing on compilation support for CLR languages e.g. C#, F# etc.

tools.logging and pinvoke (https://github.com/aaronc/ClojureClrEx) - logging is mostly ported but with only one backend working, pinvoke/dllimport works great, but no docs
a nice interface to WPF (https://github.com/aaronc/ClojureWpf) - pretty stable, but again no docs yet
nrepl (https://github.com/aaronc/tools.nrepl/tree/clr) - needs quite a bit more work

Nice to know they are on track. nREPL would be a great addition for ClojureCLR tooling support.

Shantanu

dmiller

unread,
Dec 17, 2012, 4:14:16 PM12/17/12
to clo...@googlegroups.com
Aaron,

tools.logging and nrepl are important.  I'm glad to see the effort.
I haven't forgotten about your single-DLL work.
I'm going to have plenty of time next week if you can get something to me.

-David

Aaron Craelius

unread,
Dec 17, 2012, 6:25:51 PM12/17/12
to clo...@googlegroups.com
Ok, sounds good.  I can do that.  I have 2-3 pretty specific changes that I can outline.  I also have one bug fix (support for IntPtr and UIntPtr in HostExpr).  Should I maybe start a separate thread in this group describing the proposed changes or should we do this via JIRA or github?  I'm not really sure whether the best method for doing this is git format-patch (which generates a lot of patches) or some other method.


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Aaron Craelius

unread,
Feb 28, 2013, 1:31:27 PM2/28/13
to clo...@googlegroups.com
Hi Rainer, glad you're checking this out.  This code (as I believe I mentioned above) requires a special build of the ClojureCLR compiler (see this github branch https://github.com/aaronc/clojure-clr - I just merged it with the clojure-clr master).  I'm going to try to make some effort today to see if I can get Dave the patches so he can review them for inclusion in clojure-clr master.  Hopefully soon we can have an official nuget package.  Here's ClojureClrEx: https://github.com/aaronc/ClojureClrEx


On Thu, Feb 28, 2013 at 11:55 AM, Rainer Schuster <Schuste...@web.de> wrote:
I had a quick look into nleiningen. I'm not able to bootstrap the build atm. Can't build the ClojureClrEx dep. What I basically did was:
git submodules init
git submodules update

nuget install Nuget.Core -o packages

$env:CLOJURE_LOAD_PATH="./src;./ClojureClrEx/src/;./ClojureClrEx"

created an init.clj with content and changed nleiningen.core/main to nleiningen.core/-main

init.clj:
(assembly-load-from "packages/Nuget.Core.2.2.0/lib/net40-Client/NuGet.Core.dll")

nleiningen.signing is missing from the sources. Just commented it out from nleiningen/core.clj

afterwards executed:
Clojure.Main.exe -i .\init.clj -m nleiningen.core repl

Mono.Cecil.dll
Loaded #<RuntimeAssembly Mono.Cecil, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756>
Mono.Cecil.Mdb.dll
Loaded #<RuntimeAssembly Mono.Cecil.Mdb, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756>
Mono.Cecil.Pdb.dll
Loaded #<RuntimeAssembly Mono.Cecil.Pdb, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756>
Mono.Cecil.Rocks.dll
Loaded #<RuntimeAssembly Mono.Cecil.Rocks, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756>
Trying to resolve ClojureClrEx
project.clj not found
Mono.Cecil.dll
Loaded #<RuntimeAssembly Mono.Cecil, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756>
Mono.Cecil.Mdb.dll
Loaded #<RuntimeAssembly Mono.Cecil.Mdb, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756>
Mono.Cecil.Pdb.dll
Loaded #<RuntimeAssembly Mono.Cecil.Pdb, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756>
Mono.Cecil.Rocks.dll
Loaded #<RuntimeAssembly Mono.Cecil.Rocks, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756>
Compile path: D:\Projects\Playground\clojure\test\clr\clode_org\nleiningen\bin
Error loading ClojureClrEx : #<NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object.
   at clojure.lang.CljCompiler.Ast.GenContext..ctor(String sourceName, String assyName, String extension, String directory, Boolean createDynInitHelper) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\CljCompiler\Ast\GenContext.cs:line 105
   at clojure.lang.CljCompiler.Ast.GenContext.CreateWithExternalAssembly(String sourceName, String assyName, String extension, Boolean createDynInitHelper) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\CljCompiler\Ast\GenContext.cs:line 86
   at clojure.lang.CljCompiler.Ast.GenContext.CreateWithExternalAssembly(String assyName, String extension, Boolean createDynInitHelper) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\CljCompiler\Ast\GenContext.cs:line 91
   at nleiningen/core$compile_project__1078.doInvoke(Object ) in eval:line 233
   at clojure.lang.RestFn.invoke() in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\RestFn.cs:line 456
   at nleiningen/core$load_sub_project$fn__788__792.invoke() in eval:line 152
   at nleiningen/core$load_sub_project__795.invoke(Object ) in eval:line 144
   at nleiningen/core$bootstrap_project$fn__826__830.invoke() in eval:line 171>
Clojure 1.4.1

uncommented the local-dependencies in the project file, because ClojureClrEx doesn't have a project.clj, only a csproj. Therefore I added the ClojureClrEx to the load path

and now the repl works. but compile fails with

Compile path: D:\Projects\Playground\clojure\test\clr\clode_org\nleiningen\bin

Unhandled Exception: System.MissingMethodException: Cannot find member Compile matching args
   at CallSite.Target(Closure , CallSite , Object , Object , Object , Object , Object , Object )
   at CallSite.Target(Closure , CallSite , Object , Object , Object , Object , Object , Object )
   at nleiningen/core$compile_project$fn__959__963.__interop_Compile965(Object , Object __temp_1, Object __temp_2, Object __temp_3, Object __temp_4, Object __temp_5)
   at nleiningen/core$compile_project$fn__959__963.invoke() in eval:line 239
   at nleiningen/core$compile_project__1078.doInvoke(Object ) in eval:line 238
   at clojure.lang.RestFn.invoke() in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\RestFn.cs:line 456
   at nleiningen/core$_main__1146.doInvoke(Object ) in eval:line 393
   at clojure.lang.RestFn.invoke(Object arg1) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\RestFn.cs:line 468
   at clojure.lang.Var.invoke(Object arg1) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\Var.cs:line 741
   at clojure.lang.AFn.ApplyToHelper(IFn fn, ISeq argList) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\AFn.cs:line 191
   at clojure.lang.Var.applyTo(ISeq arglist) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\Var.cs:line 874
   at clojure/core$apply__12458.invoke(Object , Object ) in core.clj:line 601
   at clojure/main$main_opt__263.invoke(Object , Object ) in eval:line 343
   at clojure/main$main__338.doInvoke(Object ) in eval:line 446
   at clojure.lang.RestFn.invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\RestFn.cs:line 586
   at clojure.lang.Var.invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\Var.cs:line 761
   at clojure.lang.AFn.ApplyToHelper(IFn fn, ISeq argList) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\AFn.cs:line 208
   at clojure.lang.Var.applyTo(ISeq arglist) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure\Lib\Var.cs:line 874
   at Clojure.CljMain.Main(String[] args) in D:\work\clojure-clr-1.4.1-fix\Clojure\Clojure.Main\Main.cs:line 34

and I didn't figure out yet what the issue is.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/_7tqNWmQuGU/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Aaron

unread,
Feb 28, 2013, 3:00:33 PM2/28/13
to clo...@googlegroups.com
Hi David,

I finally got around to creating patches for my commits and opened these two JIRA issues on them:


I have more stuff, but let's start with this.

Aaron

Aaron

unread,
Feb 28, 2013, 8:59:18 PM2/28/13
to clo...@googlegroups.com
Rainer, I've pushed some updates to nleiningen.  Be sure you do a git submodule update first.  There is now a Bootstrap project that you can build from VS 2010 - enable Nuget package restore on it first and then try building.  There is a private nuget package for Clojure.dll that it pulls.  Then you use script\repl.bat to start a repl (you must do this from the root of the nleiningen dir).  You should be again to compile nlein.exe using the following commands:

user=> (use 'nleiningen.core)
user=> (main "compile")

Let me know if you get this to work or if you have any problems.  Please keep in mind that this is just a proof of concept really - the code is not too well organized yet.

Rainer Schuster

unread,
Mar 1, 2013, 6:48:28 PM3/1/13
to clo...@googlegroups.com
Thx and great work. I have a working nlein.exe ... and had serveral issues so far. 

First of all: I"m using VS2012. Don't this is not an issue.

1. your packages.config from Bootstrap has the following content

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Clojure" version="1.4.0.1" targetFramework="net40-Client" />
  <package id="IronPython" version="2.7.3" targetFramework="net40-Client" />
  <package id="Mono.Cecil" version="0.9.5.4" targetFramework="net40-Client" />
  <package id="Nuget.Core" version="2.3.0-alpha002" targetFramework="net40-Client" />
</packages>

2. I assume, you created your a nuget and added it to a local repo. I don't have one and don't know what version you are using.
3. I deleted the Clojure and Nuget.Core dependency. Using Stable Nuget.Core Version 2.2.0 but thats not an issue.
4. cloned YOUR clojure master (and setup DLR and test dependencies as described in the clojure-clr wiki)
5. compiled 1.5.0-master-SNAPSHOT 
6. Added the reference for clojure.dll from output dir to the Bootstrap solution
7. Compiled Bootstrap
8. Microsoft.Scripting is missing (not referenced, and therefore not copied over to the output dir).
9. Copied Microsoft.Scripting.dll to the bin\Debug
10. running script\repl.bat throws:
Unhandled Exception: System.TypeInitializationException: The type initializer for 'Bootstrap.Program' threw an exception. ---> System.TypeInitializationException: The type initializer for 'clojure.lang.RT' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at clojure.lang.RT..cctor()
   --- End of inner exception stack trace ---
   at clojure.lang.RT.var(String ns, String name)
   at Bootstrap.Program..cctor() in d:\Projects\Playground\clojure\test\clr\clode_org\nleiningen\Bootstrap\Bootstrap\Program.cs:line 11
   --- End of inner exception stack trace ---
   at Bootstrap.Program.Main(String[] args)

11. removed the IronPython dependencies because the Microsoft.Scripting from clojure-clr is a different one you are using. The most recent version from IronPyhton 2.7.3 isn't not compatible with clojure. 

12. added Microsoft.Scripting.dll and Microsoft.Dynamic.dll as Reference
13. finally executed your instructions (haha its friday and we have step 13)
Clojure 1.5.0-master-SNAPSHOT
user=> (use 'nleiningen.core)
nil
user=> (main "compile")
Error:  #<MissingMethodException System.MissingMethodException: Cannot find instance field/property/member name SourcePath
   at CallSite.Target(Closure , CallSite , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at nleiningen/core$load_dependencies__457.__interop_SourcePath460(Object )
   at nleiningen/core$load_dependencies__457.invoke() in eval:line 70
   at nleiningen/core$bootstrap_project__590.invoke() in eval:line 165
   at nleiningen/core$compile_project__797.doInvoke(Object ) in eval:line 239
   at clojure.lang.RestFn.invoke()
   at nleiningen/core$main$fn__873__878.invoke() in eval:line 418
   at nleiningen/core$main__881.doInvoke(Object ) in eval:line 407>
-1


14. Added a (println asmref) to load-dependencies. output: 
#<ZipPackageAssemblyReference .NETFramework,Version=v4.0 Mono.Cecil.dll (lib\net40\Mono.Cecil.dll)>

16. Wtf... ok, get-dependency-assembly-references uses nuget to resolve the dependencies

17. Used the 2.3.0-alpha002 Version again ... tada works ...

Rainer Schuster

unread,
Mar 1, 2013, 6:57:14 PM3/1/13
to clo...@googlegroups.com
Btw. I like how you package all the clojure assemblies into clojure.dll, very smart. But that'll break ngen speed up, doesn't it? Atm. I'm running a native x86 image of clojure-clr (1.4.1) which is pretty descent, regarding the startup. I'll try building a ngened versio of your current fork and running nlein as a module

Aaron Craelius

unread,
Mar 2, 2013, 12:44:28 AM3/2/13
to clo...@googlegroups.com

On Fri, Mar 1, 2013 at 6:48 PM, Rainer Schuster <Schuste...@web.de> wrote:
2. I assume, you created your a nuget and added it to a local repo. I don't have one and don't know what version you are using.
3. I deleted the Clojure and Nuget.Core dependency. Using Stable Nuget.Core Version 2.2.0 but thats not an issue.

Don't delete Clojure, I'm not using a local repo.  It's in the Nuget main repo, it's just unlisted because there hasn't been an official release yet.  You should just be able to do Nuget package restore and everything should work.  I suggest just pulling a fresh copy of nleiningen and try just building it unmodified.  If you have any problems let me know.

Aaron Craelius

unread,
Mar 2, 2013, 12:51:15 AM3/2/13
to clo...@googlegroups.com
My Clojure.dll shouldn't break ngen.  I ilmerge'd it from AOT compiled assemblies - it doesn't use embedded assemblies which would break ngen.  For me ngen seems to work fine.  Open up the Clojure.dll from nuget in Ilspy or DotPeek to see how it's done.  Btw, I just posted a new build on nuget today in preparation for hopefully an official public release soon - I'm hoping this will be possible even next week.  I'll leave this build unlisted under the assumption that we can make it official quite soon.  See here: https://nuget.org/packages/Clojure/


--
Reply all
Reply to author
Forward
0 new messages