forked from GitHub/gf-rgl
Better output when no files specified in Make.hs
This commit is contained in:
20
Make.hs
20
Make.hs
@@ -198,10 +198,10 @@ rglCommands =
|
|||||||
sc mode args = (symbolic,optml mode langSymbolic args)
|
sc mode args = (symbolic,optml mode langSymbolic args)
|
||||||
|
|
||||||
optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo])
|
optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo])
|
||||||
optml mode ls args =
|
optml mode pred args =
|
||||||
\langs ->
|
\langsAll ->
|
||||||
let defLangs = filter (if mode == Present then langPresent else const True) (filter ls langs)
|
let langsDefault = filter (if mode == Present then langPresent else const True) (filter pred langsAll)
|
||||||
in getOptLangs langs defLangs args
|
in getOptLangs langsAll langsDefault args
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Getting module paths/names
|
-- Getting module paths/names
|
||||||
@@ -327,6 +327,10 @@ getFlag flag args = fmap (drop (length flag)) $ find (isPrefixOf flag) args
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Languages of the RGL
|
-- Languages of the RGL
|
||||||
|
|
||||||
|
-- | Path to language config file
|
||||||
|
configFile :: FilePath
|
||||||
|
configFile = "languages.csv"
|
||||||
|
|
||||||
-- | Information about a language
|
-- | Information about a language
|
||||||
data LangInfo = LangInfo
|
data LangInfo = LangInfo
|
||||||
{ langCode :: String -- ^ 3-letter ISO 639-2/B code
|
{ langCode :: String -- ^ 3-letter ISO 639-2/B code
|
||||||
@@ -343,16 +347,15 @@ data LangInfo = LangInfo
|
|||||||
-- | Load language information from config file
|
-- | Load language information from config file
|
||||||
loadLangs :: IO [LangInfo]
|
loadLangs :: IO [LangInfo]
|
||||||
loadLangs = do
|
loadLangs = do
|
||||||
lns <- readFile conffile >>= return . lines
|
lns <- readFile configFile >>= return . lines
|
||||||
mapM mkLangInfo (tail lns)
|
mapM mkLangInfo (tail lns)
|
||||||
where
|
where
|
||||||
conffile = "languages.csv"
|
|
||||||
maybeBit bits n = if length bits >= (n+1) && length (bits !! n) > 0 then Just (bits !! n) else Nothing
|
maybeBit bits n = if length bits >= (n+1) && length (bits !! n) > 0 then Just (bits !! n) else Nothing
|
||||||
boolBit bits n def = if length bits >= (n+1) && length (bits !! n) > 0 then (if def then bits !! n /= "n" else bits !! n == "y") else def
|
boolBit bits n def = if length bits >= (n+1) && length (bits !! n) > 0 then (if def then bits !! n /= "n" else bits !! n == "y") else def
|
||||||
mkLangInfo s =
|
mkLangInfo s =
|
||||||
let bits = separateBy ',' s in
|
let bits = separateBy ',' s in
|
||||||
if length bits < 2
|
if length bits < 2
|
||||||
then die $ "Invalid entry in " ++ conffile ++ ": " ++ s
|
then die $ "Invalid entry in " ++ configFile ++ ": " ++ s
|
||||||
else return $ LangInfo
|
else return $ LangInfo
|
||||||
{ langCode = bits !! 0
|
{ langCode = bits !! 0
|
||||||
, langDir = bits !! 1
|
, langDir = bits !! 1
|
||||||
@@ -380,6 +383,7 @@ gfc bi modes summary files =
|
|||||||
parallel_ [gfcn bi mode summary files | mode<-modes]
|
parallel_ [gfcn bi mode summary files | mode<-modes]
|
||||||
|
|
||||||
gfcn :: Info -> Mode -> String -> [String] -> IO ()
|
gfcn :: Info -> Mode -> String -> [String] -> IO ()
|
||||||
|
gfcn _ _ _ [] = die $ "No files specified.\nMake sure the language is in " ++ configFile ++ " and that it supports the modes/modules specified."
|
||||||
gfcn bi mode summary files = do
|
gfcn bi mode summary files = do
|
||||||
let dir = getRGLBuildDir bi mode
|
let dir = getRGLBuildDir bi mode
|
||||||
preproc = case mode of
|
preproc = case mode of
|
||||||
@@ -393,7 +397,7 @@ gfcn bi mode summary files = do
|
|||||||
run_gfc :: Info -> [String] -> IO ()
|
run_gfc :: Info -> [String] -> IO ()
|
||||||
run_gfc bi args = do
|
run_gfc bi args = do
|
||||||
let
|
let
|
||||||
args' = ["--batch"] ++ filter (not . null) args
|
args' = ["--batch","--gf-lib-path="] ++ filter (not . null) args
|
||||||
gf = infoGFPath bi
|
gf = infoGFPath bi
|
||||||
execute gf args'
|
execute gf args'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user