mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-05-28 09:28:54 -06:00
Search for module by name and do not require language folder
This commit is contained in:
25
Make.hs
25
Make.hs
@@ -4,10 +4,10 @@ import System.IO (hPutStrLn,stderr)
|
||||
import System.IO.Error (catchIOError)
|
||||
import System.Exit (ExitCode(..),die)
|
||||
import System.Environment (getArgs,lookupEnv)
|
||||
import System.Process (rawSystem,readProcess)
|
||||
import System.FilePath ((</>),(<.>),takeFileName,addExtension,dropExtension)
|
||||
import System.Directory (createDirectoryIfMissing,copyFile,getDirectoryContents,removeDirectoryRecursive,doesFileExist)
|
||||
import Control.Monad (unless,when)
|
||||
import System.Process (rawSystem)
|
||||
import System.FilePath ((</>),takeFileName,addExtension,dropExtension)
|
||||
import System.Directory (createDirectoryIfMissing,copyFile,getDirectoryContents,removeDirectoryRecursive,findFile)
|
||||
import Control.Monad (when)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
@@ -159,13 +159,11 @@ rglCommands =
|
||||
, RGLCommand "modules" False $ \modes args bi -> do
|
||||
let modules = getOptModules args
|
||||
flip mapM_ modules $ \m -> do
|
||||
-- TODO search for modules so that folder name is not needed
|
||||
-- TODO determine dependants, e.g. include ExtraEngAbs when specifying ExtraEng
|
||||
let mfull = sourceDir </> m
|
||||
ex <- doesFileExist mfull
|
||||
if not ex
|
||||
then die $ "Cannot find module: " ++ m
|
||||
else flip mapM_ modes $ \mode -> do
|
||||
mex <- findModule m
|
||||
case mex of
|
||||
Nothing -> die $ "Cannot find module: " ++ m
|
||||
Just mfull -> flip mapM_ modes $ \mode -> do
|
||||
let dst = getRGLBuildDir bi mode
|
||||
putStrLn $ "Building [" ++ m ++ "] " ++ dst
|
||||
run_gfc bi ["-s", "--gfo-dir="++dst, mfull]
|
||||
@@ -211,6 +209,13 @@ rglCommands =
|
||||
Present -> intersect langsPresent
|
||||
_ -> id
|
||||
|
||||
-- | Search all language dirs for module name
|
||||
findModule :: String -> IO (Maybe FilePath)
|
||||
findModule file = do
|
||||
let langdirs = map langDir langs
|
||||
let searchdirs = map ((</>) sourceDir) langdirs
|
||||
findFile searchdirs file
|
||||
|
||||
-- | Get commands from args
|
||||
-- Fails on command error
|
||||
getCommands :: [String] -> [RGLCommand]
|
||||
|
||||
@@ -64,12 +64,12 @@ clean
|
||||
`compat`,
|
||||
<!-- `pgf`, -->
|
||||
`parse`,
|
||||
or an explicit module name (e.g. `english/ExtraEng.gf`).
|
||||
or an explicit module name (e.g. `ExtraEng.gf`).
|
||||
- `MODE` is one of:
|
||||
`present`,
|
||||
`alltenses`
|
||||
(default is both).
|
||||
- `FILES` is a space separated list of module names (e.g. `english/ExtraEng.gf german/DictGer.gf`)
|
||||
- `FILES` is a space separated list of module names (e.g. `ExtraEng.gf DictGer.gf`)
|
||||
- You can _override_ the default language list with `--langs=...`
|
||||
- You can _add_ languages to the default list with `--langs=+...`
|
||||
- You can _remove_ languages from the default list with `langs=-...`
|
||||
|
||||
Reference in New Issue
Block a user