예제 #1
0
#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-
# NOTE - this file is mostly for examining compilation results, not for building the project

from __future__ import print_function
from collections import namedtuple
import optparse, os, re, subprocess, sys
import path_resolv
from path_resolv import Path

# setup classpath
os.environ["CLASSPATH"] = Path.pathjoin(os.environ["CLASSPATH"],
    path_resolv.resolve("lib/scala-library.jar"),
    path_resolv.resolve("lib/scala-compiler.jar"))
# reinit with updated classpath
path_resolv.resolvers[0] = path_resolv.EnvironPathResolver()

class Compiler(object):
    def __init__(self, **kwargs):
        self.__dict__.update(kwargs)
        self.src_path = Path(self.src_path)
        self.out_path = Path(self.out_path)
        self.print = self.print or self.src_filter
        self.classpath = os.environ["CLASSPATH"]
        self.src_extensions = self.src_extensions.split(",")
        try:
            self.plugin_path = path_resolv.resolve("lib/sketchrewriter.jar")
        except:
            self.plugin_path = ""
        assert self.src_path.exists() and self.out_path.exists()