static void Main(string[] args)
{
TextWriter outTW = (TextWriter)RT.OutVar.deref();
TextWriter errTW = RT.errPrintWriter();
string path = Environment.GetEnvironmentVariable(PATH_PROP);
// TODO: get rid of this when we have the full build process set up
path = path ?? ".";
if ( path == null )
{
errTW.WriteLine("ERROR: Must set system property {0}",PATH_PROP);
errTW.WriteLine("to the location for the compiled .class files.");
errTW.WriteLine("This directory must also be on your {0}.",RT.ClojureLoadPathString);
Environment.Exit(1);
}
string warnVal = Environment.GetEnvironmentVariable(REFLECTION_WARNING_PROP);
bool warnOnReflection = warnVal == null ? false : warnVal.Equals(true);
string mathVal = Environment.GetEnvironmentVariable(UNCHECKED_MATH_PROP);
bool uncheckedMath = mathVal == null ? false : mathVal.Equals(true);
try
{
Var.pushThreadBindings(RT.map(
Compiler.CompilePathVar, path,
RT.WarnOnReflectionVar, warnOnReflection,
RT.UncheckedMathVar, uncheckedMath
));
Stopwatch sw = new Stopwatch();
foreach (string lib in args)
{
sw.Reset();
sw.Start();
outTW.Write("Compiling {0} to {1}", lib, path);
outTW.Flush();
Compiler.CompileVar.invoke(Symbol.intern(lib));
sw.Stop();
outTW.WriteLine(" -- {0} milliseconds.", sw.ElapsedMilliseconds);
}
}
catch (Exception e)
{
errTW.WriteLine(e.ToString());
Environment.Exit(1);
}
finally
{
Var.popThreadBindings();
try {
outTW.Flush();
outTW.Close();
}
catch ( IOException e)
{
errTW.WriteLine(e.StackTrace);
}
}
}