mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-16 16:29:32 -06:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user