mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
Setup.hs: improved langs=... option
Instead of just giving an explicit list of languages to compile, you can
now also add and remove languages from the default list by using langs=+...
or langs=-...
Examples:
cabal build langs=Eng,Swe,Ger -- as before, compile the given 3 langs
cabal build langs=-Fin -- use default languages, but omit Fin
cabal build langs=+Urd -- use default languages + Urd
("cabal build ..." is the same as "runhaskell Setup.hs build ...")
This commit is contained in:
23
Setup.hs
23
Setup.hs
@@ -76,7 +76,7 @@ rglCommands =
|
|||||||
return ()
|
return ()
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
optl ls args = fromMaybe ls $ getOptLangs args
|
optl ls args = getOptLangs ls args
|
||||||
|
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
|
|
||||||
@@ -262,12 +262,21 @@ getOptMode args
|
|||||||
| otherwise = AllTenses
|
| otherwise = AllTenses
|
||||||
|
|
||||||
-- list of languages overriding the definitions above
|
-- list of languages overriding the definitions above
|
||||||
getOptLangs args = case [ls | arg <- args, let (f,ls) = splitAt (length langs_prefix) arg, f==langs_prefix] of
|
getOptLangs defaultLangs args =
|
||||||
ls:_ -> return $ findLangs $ seps ls
|
case [ls | arg <- args,
|
||||||
_ -> Nothing
|
let (f,ls) = splitAt (length langs_prefix) arg,
|
||||||
where
|
f==langs_prefix] of
|
||||||
seps = words . map (\c -> if c==',' then ' ' else c)
|
('+':ls):_ -> foldr addLang defaultLangs (seps ls)
|
||||||
findLangs ls = [lang | lang@(_,la) <- langs, elem la ls]
|
('-':ls):_ -> foldr removeLang defaultLangs (seps ls)
|
||||||
|
ls:_ -> findLangs langs (seps ls)
|
||||||
|
_ -> defaultLangs
|
||||||
|
where
|
||||||
|
seps = words . map (\c -> if c==',' then ' ' else c)
|
||||||
|
findLangs langs ls = [lang | lang@(_,la) <- langs, la `elem` ls]
|
||||||
|
removeLang l ls = [lang | lang@(_,la) <- ls, la/=l]
|
||||||
|
addLang l ls = if null (findLangs ls [l])
|
||||||
|
then findLangs langs [l]++ls
|
||||||
|
else ls
|
||||||
|
|
||||||
getRGLBuildSubDir lbi mode =
|
getRGLBuildSubDir lbi mode =
|
||||||
case mode of
|
case mode of
|
||||||
|
|||||||
Reference in New Issue
Block a user