Now the toplevel file i.e. from command i is searched both in the current directory and in GF_LIB_PATH

This commit is contained in:
krasimir
2009-05-20 13:40:55 +00:00
parent 45a9c1666b
commit 819db9b7ad

View File

@@ -115,6 +115,7 @@ type CompileEnv = (Int,SourceGrammar,ModEnv)
compileModule :: Options -- ^ Options from program command line and shell command.
-> CompileEnv -> FilePath -> IOE CompileEnv
compileModule opts1 env file = do
file <- getRealFile file
opts0 <- getOptionsFromFile file
let opts = addOptions opts0 opts1
let fdir = dropFileName file
@@ -126,6 +127,19 @@ compileModule opts1 env file = do
let names = map justModuleName files
ioeIO $ putIfVerb opts $ "modules to include:" +++ show names ----
foldM (compileOne opts) (0,sgr,rfs) files
where
getRealFile file1 = do
exists <- ioeIO $ doesFileExist file1
if exists
then return file
else if isRelative file
then do libpath <- ioeIO $ getLibraryPath opts1
let file1 = libpath </> file
exists <- ioeIO $ doesFileExist file1
if exists
then return file1
else ioeErr $ Bad (render (text "None of this files exist:" $$ nest 2 (text file $$ text file1)))
else ioeErr $ Bad (render (text "File" <+> text file <+> text "does not exist."))
compileOne :: Options -> CompileEnv -> FullPath -> IOE CompileEnv
compileOne opts env@(_,srcgr,_) file = do