summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-05-20 13:40:55 +0000
committerkrasimir <krasimir@chalmers.se>2009-05-20 13:40:55 +0000
commit2d1d79a25a8eb110553c6c14b863d87f2b413470 (patch)
tree8872f761be8842850a45f6959b9675760d0a34c4
parentb45bdaefec1778f1557a8b8ba3e2602d033621bf (diff)
Now the toplevel file i.e. from command i is searched both in the current directory and in GF_LIB_PATH
-rw-r--r--src/GF/Compile.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/GF/Compile.hs b/src/GF/Compile.hs
index 4b63c5c2e..d96a37225 100644
--- a/src/GF/Compile.hs
+++ b/src/GF/Compile.hs
@@ -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