module Language.Drasil.Code.Imperative.Build.AST where
import Build.Drasil (makeS, MakeString, mkImplicitVar, mkWindowsVar, mkOSVar,
Command, mkCheckedCommand, Dependencies)
type CommandFragment = MakeString
data BuildName = BMain
| BPackName
| BPack BuildName
| BWithExt BuildName Ext
data Ext = CodeExt
| OtherExt MakeString
data BuildDependencies = BcSource
| BcSingle BuildName
data BuildConfig = BuildConfig
([CommandFragment] -> CommandFragment -> CommandFragment -> [BuildCommand])
(Maybe BuildName) (Maybe BuildName) BuildDependencies
data RunType = Standalone
| Interpreter [CommandFragment]
data Runnable = Runnable BuildName NameOpts RunType
data DocConfig = DocConfig Dependencies [Command]
data NameOpts = NameOpts {
NameOpts -> String
packSep :: String,
NameOpts -> Bool
includeExt :: Bool
}
nameOpts :: NameOpts
nameOpts :: NameOpts
nameOpts = NameOpts {
packSep :: String
packSep = String
"/",
includeExt :: Bool
includeExt = Bool
True
}
type BuildCommand = [CommandFragment]
type InterpreterCommand = String
type InterpreterOption = String
asFragment :: String -> CommandFragment
asFragment :: String -> CommandFragment
asFragment = String -> CommandFragment
makeS
osClassDefault :: String -> String -> String -> CommandFragment
osClassDefault :: String -> String -> String -> CommandFragment
osClassDefault = String -> String -> String -> CommandFragment
mkWindowsVar
buildAll :: ([CommandFragment] -> CommandFragment -> [BuildCommand]) ->
BuildName -> Maybe BuildConfig
buildAll :: ([CommandFragment] -> CommandFragment -> [[CommandFragment]])
-> BuildName -> Maybe BuildConfig
buildAll [CommandFragment] -> CommandFragment -> [[CommandFragment]]
f BuildName
n = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ ([CommandFragment]
-> CommandFragment -> CommandFragment -> [[CommandFragment]])
-> Maybe BuildName
-> Maybe BuildName
-> BuildDependencies
-> BuildConfig
BuildConfig (\[CommandFragment]
i CommandFragment
o CommandFragment
_ -> [CommandFragment] -> CommandFragment -> [[CommandFragment]]
f [CommandFragment]
i CommandFragment
o) (forall a. a -> Maybe a
Just BuildName
n) forall a. Maybe a
Nothing BuildDependencies
BcSource
buildAllAdditionalName :: ([CommandFragment] -> CommandFragment ->
CommandFragment -> [BuildCommand]) -> BuildName -> BuildName ->
Maybe BuildConfig
buildAllAdditionalName :: ([CommandFragment]
-> CommandFragment -> CommandFragment -> [[CommandFragment]])
-> BuildName -> BuildName -> Maybe BuildConfig
buildAllAdditionalName [CommandFragment]
-> CommandFragment -> CommandFragment -> [[CommandFragment]]
f BuildName
n BuildName
a = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ ([CommandFragment]
-> CommandFragment -> CommandFragment -> [[CommandFragment]])
-> Maybe BuildName
-> Maybe BuildName
-> BuildDependencies
-> BuildConfig
BuildConfig [CommandFragment]
-> CommandFragment -> CommandFragment -> [[CommandFragment]]
f (forall a. a -> Maybe a
Just BuildName
n) (forall a. a -> Maybe a
Just BuildName
a) BuildDependencies
BcSource
buildSingle :: ([CommandFragment] -> CommandFragment -> [BuildCommand]) ->
BuildName -> BuildName -> Maybe BuildConfig
buildSingle :: ([CommandFragment] -> CommandFragment -> [[CommandFragment]])
-> BuildName -> BuildName -> Maybe BuildConfig
buildSingle [CommandFragment] -> CommandFragment -> [[CommandFragment]]
f BuildName
n = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([CommandFragment]
-> CommandFragment -> CommandFragment -> [[CommandFragment]])
-> Maybe BuildName
-> Maybe BuildName
-> BuildDependencies
-> BuildConfig
BuildConfig (\[CommandFragment]
i CommandFragment
o CommandFragment
_ -> [CommandFragment] -> CommandFragment -> [[CommandFragment]]
f [CommandFragment]
i CommandFragment
o) (forall a. a -> Maybe a
Just BuildName
n) forall a. Maybe a
Nothing forall b c a. (b -> c) -> (a -> b) -> a -> c
.
BuildName -> BuildDependencies
BcSingle
nativeBinary :: Maybe Runnable
nativeBinary :: Maybe Runnable
nativeBinary = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ BuildName -> NameOpts -> RunType -> Runnable
Runnable BuildName
executable NameOpts
nameOpts RunType
Standalone
executable :: BuildName
executable :: BuildName
executable = BuildName -> Ext -> BuildName
BWithExt BuildName
BPackName forall a b. (a -> b) -> a -> b
$ CommandFragment -> Ext
OtherExt forall a b. (a -> b) -> a -> b
$
String -> String -> String -> CommandFragment
osClassDefault String
"TARGET_EXTENSION" String
".exe" String
""
sharedLibrary :: BuildName
sharedLibrary :: BuildName
sharedLibrary = BuildName -> Ext -> BuildName
BWithExt BuildName
BPackName forall a b. (a -> b) -> a -> b
$ CommandFragment -> Ext
OtherExt forall a b. (a -> b) -> a -> b
$
String -> String -> String -> String -> CommandFragment
mkOSVar String
"LIB_EXTENSION" String
".dll" String
".dylib" String
".so"
interp :: BuildName -> NameOpts -> InterpreterCommand -> [InterpreterOption]
-> Maybe Runnable
interp :: BuildName -> NameOpts -> String -> [String] -> Maybe Runnable
interp BuildName
b NameOpts
n String
c = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuildName -> NameOpts -> RunType -> Runnable
Runnable BuildName
b NameOpts
n forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CommandFragment] -> RunType
Interpreter forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map String -> CommandFragment
makeS forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
cforall a. a -> [a] -> [a]
:)
interpMM :: InterpreterCommand -> Maybe Runnable
interpMM :: String -> Maybe Runnable
interpMM = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuildName -> NameOpts -> RunType -> Runnable
Runnable BuildName
mainModuleFile NameOpts
nameOpts forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CommandFragment] -> RunType
Interpreter forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. a -> [a] -> [a]
:[]) forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CommandFragment
makeS
mainModule :: BuildName
mainModule :: BuildName
mainModule = BuildName
BMain
mainModuleFile :: BuildName
mainModuleFile :: BuildName
mainModuleFile = BuildName -> Ext -> BuildName
BWithExt BuildName
BMain Ext
CodeExt
inCodePackage :: BuildName -> BuildName
inCodePackage :: BuildName -> BuildName
inCodePackage = BuildName -> BuildName
BPack
withExt :: BuildName -> String -> BuildName
withExt :: BuildName -> String -> BuildName
withExt BuildName
b = BuildName -> Ext -> BuildName
BWithExt BuildName
b forall b c a. (b -> c) -> (a -> b) -> a -> c
. CommandFragment -> Ext
OtherExt forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CommandFragment
makeS
cCompiler :: CommandFragment
cCompiler :: CommandFragment
cCompiler = String -> CommandFragment
mkImplicitVar String
"CC"
cppCompiler :: CommandFragment
cppCompiler :: CommandFragment
cppCompiler = String -> CommandFragment
mkImplicitVar String
"CXX"
doxygenDocConfig :: FilePath -> DocConfig
doxygenDocConfig :: String -> DocConfig
doxygenDocConfig String
fp = [CommandFragment] -> [Command] -> DocConfig
DocConfig [String -> CommandFragment
makeS String
fp]
[CommandFragment -> Command
mkCheckedCommand forall a b. (a -> b) -> a -> b
$ String -> CommandFragment
makeS forall a b. (a -> b) -> a -> b
$ String
"doxygen " forall a. [a] -> [a] -> [a]
++ String
fp]