#1502 Fantom, C# and Mono

uman Thu 21 Apr 2011

Hi-- I'm new to fantom, and I thought I'd get wet with it on a Mac. I updated my local portfile to 1.0.58, installed it and played around some. fan -version yields:

Fantom Launcher Copyright (c) 2006-2011, Brian Frank and Andy Frank Licensed under the Academic Free License version 3.0

Java Runtime:

java.version:    1.6.0_24
java.vm.name:    Java HotSpot(TM) 64-Bit Server VM
java.vm.vendor:  Apple Inc.
java.vm.version: 19.1-b02-334
java.home:       /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
fan.platform:    macosx-x86_64
fan.version:     1.0.58
fan.env:         util::PathEnv
fan.home:        /opt/local/share/java/fantom

I ran the complete test suite with fant -all and two tests failed:

Failed:

sql::SqlServiceTest.test
testSys::EnvTest.testFindFile

(I have the complete log if anyone is interested).

Anyway, I then installed Mono, and changed etc/sys/config.props to select the dotnet runtime.

Running fan -version shows no change. The doc on the website states that runtime is a Windows-only variable.

Is there a way to change this? I thought that I'd tackle some of the current .Net failures, but being on a Mac, I planned to use Mono.

Thanks.

andy Thu 21 Apr 2011

Hey uman - welcome to Fantom!

You probably won't have much luck with Fantom and Mono out of the box. The bootstrap code is built specifically to load up the CLR on Windows. In fact, the fan launcher script on -nix probably just skips it entirely.

I have never played with Mono - so my first question would be - can it run a DLL compiled with csc right out of the box?

If so, then the next step would be getting Fantom to actually boot into the Mono runtime. I would imagine you can get in there from a shell script - in which cause you can tweak the fanlaunch script.

You will need to load up the sys.dll and then invoke one of the Fanx.Tools.xxx classes (fan, fant, fansh). You can look at the src/launcher/dotnot.cpp code from more info as well.

brian Thu 21 Apr 2011

I would say steps are:

  1. figure out how to get sys/dotnet/build.fan to compile using Mono's compiler which will build sys C# runtime (really probably just need a tweak to CompilerCs)
  2. tweak bin/fanlaunch or create alternate script to run C# version of Fanx.Tools
  3. take a look at testSys failures (you will probably need to compile using JVM runtime until testCompiler is fully working, in which case then you could compile using C# environment fully)

uman Thu 21 Apr 2011

Brian, Andy:

Thanks for the welcome and the reply. To answer Andy's question, yes Mono will run a .NET framework dll from CSC on Linux. I've actually not used Mono on Mac OS X, so I don't know if it works there.

I'm still trying to decide whether to work on the C#/.NET piece, or to help Simon with the LLVM target (I haven't checked with him on whether he wants any help). Which one is more of a priority?

Also, when I posted, I neglected to first search the site before posting; I'll do that in the future. So now I know why the sql test is failing (although imho, you might want to consider using sqlite instead of MySQL for it).

One item that I didn't find any discussion about was the failure of testSys::EnvTest.testFindFile. It fails at:

TEST FAILED
sys::IOErr: Must use trailing slash for dir: file:/opt/local/share/java/fantom/etc/sys
  fan.sys.LocalFile.<init> (LocalFile.java:128)
  fan.sys.File.make (File.java:27)
  fan.sys.LocalFile.plus (LocalFile.java:212)
  fan.sys.File.plus (File.java:169)
  util::PathEnv.findFile (PathEnv.fan:71)
  fan.sys.List.eachWhile (List.java:576)
  ...

I am using the recommended settings for:

export FAN_HOME=/opt/local/share/java/fantom
export FAN_ENV=util::PathEnv
export FAN_ENV_PATH=~/.fan/

Any ideas on what is wrong?

brian Fri 22 Apr 2011

Any ideas on what is wrong?

I suspect it is because you are running the system tests with a PathEnv (they are really designed to be run with BootEnv). Although that might be an easy one to fix.

brian Sat 23 Apr 2011

I pushed a fix so that PathEnv passes the EnvTest suite

Login or Signup to reply.