module Lastik.Java.Javac(
Debug(..),
Proc,
noneProc,
only,
proc',
Implicit,
noneImplicit,
class',
implicit',
Javac,
debug,
nowarn,
verbose,
deprecation,
classpath,
sourcepath,
bootclasspath,
extdirs,
endorseddirs,
proc,
processor,
processorpath,
directory,
src,
implicit,
encoding,
source,
target,
version,
help,
akv,
flags,
etc,
javac,
javac'
)where
import Lastik.Util
import Lastik.Compile
import Lastik.Extension
import Lastik.Output
import Data.List
import Control.Arrow
data Debug = Lines
| Vars
| Source
| None
| All
deriving Eq
instance Show Debug where
show Lines = "lines"
show Vars = "vars"
show Source = "source"
show None = "none"
show All = "all"
newtype Proc = Proc Bool deriving Eq
noneProc :: Proc
noneProc = Proc False
only :: Proc
only = Proc True
proc' :: Proc -> a -> a -> a
proc' (Proc False) _ f = f
proc' (Proc True) t _ = t
instance Show Proc where
show (Proc False) = "none"
show (Proc True) = "only"
newtype Implicit = Implicit Bool deriving Eq
noneImplicit :: Implicit
noneImplicit = Implicit False
class' :: Implicit
class' = Implicit True
implicit' :: Implicit -> a -> a -> a
implicit' (Implicit False) _ f = f
implicit' (Implicit True) t _ = t
instance Show Implicit where
show (Implicit False) = "none"
show (Implicit True) = "class"
data Javac = Javac {
debug :: Maybe Debug,
nowarn :: Bool,
verbose :: Bool,
deprecation :: Bool,
classpath :: [FilePath],
sourcepath :: [FilePath],
bootclasspath :: [FilePath],
extdirs :: [FilePath],
endorseddirs :: [FilePath],
proc :: Maybe Proc,
processor :: [String],
processorpath :: Maybe FilePath,
directory :: Maybe FilePath,
src :: Maybe FilePath,
implicit :: Maybe Implicit,
encoding :: Maybe String,
source :: Maybe String,
target :: Maybe String,
version :: Bool,
help :: Bool,
akv :: Maybe ([String], Maybe String),
flags :: [String],
etc :: Maybe String
}
javac :: Javac
javac = Javac Nothing False False False [] [] [] [] [] Nothing [] Nothing Nothing Nothing Nothing Nothing Nothing Nothing False False Nothing [] Nothing
javac' :: Maybe Debug
-> Bool
-> Bool
-> Bool
-> [FilePath]
-> [FilePath]
-> [FilePath]
-> [FilePath]
-> [FilePath]
-> Maybe Proc
-> [String]
-> Maybe FilePath
-> Maybe FilePath
-> Maybe FilePath
-> Maybe Implicit
-> Maybe String
-> Maybe String
-> Maybe String
-> Bool
-> Bool
-> Maybe ([String], Maybe String)
-> [String]
-> Maybe String
-> Javac
javac' = Javac
instance Show Javac where
show (Javac debug
nowarn
verbose
deprecation
classpath
sourcepath
bootclasspath
extdirs
endorseddirs
proc
processor
processorpath
directory
src
implicit
encoding
source
target
version
help
akv
flags
etc) = [d debug,
"nowarn" ~~ nowarn,
"verbose" ~~ verbose,
"deprecation" ~~ deprecation,
"classpath" ~?? classpath,
"sourcepath" ~?? sourcepath,
"bootclasspath" ~?? bootclasspath,
"extdirs" ~?? extdirs,
"endorseddirs" ~?? extdirs,
"proc" ~~> show $ proc,
uncons [] ((intercalate "," .) . (:)) processor,
"processorpath" ~~~> processorpath,
"d" ~~> id $ directory,
"s" ~~> id $ src,
"implicit" ~~> show $ implicit,
"encoding" ~~~> encoding,
"source" ~~~> source,
"target" ~~~> target,
"version" ~~ version,
"help" ~~ help,
(\z -> "-A" ++ case first (intercalate ".") z of (k, Just v) -> k ++ '=' : v
(k, Nothing) -> k) ~? akv,
intercalate " " $ map ("-J" ++) flags,
id ~? etc] ^^^ " "
where
d (Just All) = "g" ~~ True
d k = "g" -~> show $ k
instance Compile Javac where
compile s ps = "javac " ++ show s ++ ' ' : space ps
instance Output Javac where
output = directory
instance Extension Javac where
ext _ = "java"
instance OutputReference Javac where
reference p j = j { classpath = p }
reference' = classpath