From 8a14912ee3b692bc578465b6920575f5d7b11b4c Mon Sep 17 00:00:00 2001 From: meng wong Date: Sat, 19 Aug 2017 14:27:07 +0300 Subject: GF_LIB_PATH can now be path1:path2:path3, not just path1 Traditionally, GF_LIB_PATH points to something like `.../share/ghc-8.0.2-x86_64/gf-3.9/lib` and if you want prelude and alltenses and present, you add a `--# -path=.:present` compiler pragma to the top of your .gf file But if you are developing some kind of application grammar library or contrib of your own, you might find yourself repeating your library path at the top of all your .gf files. After painstakingly maintaining the same library path at the top of all your .gf files, you might say, let's factor this out into GF_LIB_PATH. Then you might then find to your surprise that GF_LIB_PATH doesn't accept the usual colon:separated:path notation familiar from, say, unix PATH and MANPATH. This patch allows you to define `GF_LIB_PATH=gf-3.9.lib:$HOME/gf-contrib/whatever/lib` in a more natural way. If you are an RGL hacker and have your own version of the RGL tree sitting somewhere, you should be able to have both paths in the GF_LIB_PATH, for added convenience. This minor convenience will probably lead to obscure bugs and great frustration when you find that your changes are mysteriously not being picked up by GF; so keep this in mind and use it cautiously. This caution should probably sit in the documentation somewhere. A subsequent commit will do that. If you use zsh, you can do this to quickly build up a big GF_LIB_PATH: % gf_lib_path=( $HOME/src/GF/lib/src/{api,abstract,common,english,api/libraryBrowser,prelude,..} ) % typeset -xT GF_LIB_PATH gf_lib_path --- src/compiler/GF/Infra/Option.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/compiler/GF/Infra/Option.hs') diff --git a/src/compiler/GF/Infra/Option.hs b/src/compiler/GF/Infra/Option.hs index f68c7d121..27aa1c256 100644 --- a/src/compiler/GF/Infra/Option.hs +++ b/src/compiler/GF/Infra/Option.hs @@ -153,7 +153,7 @@ data Flags = Flags { optLiteralCats :: Set Ident, optGFODir :: Maybe FilePath, optOutputDir :: Maybe FilePath, - optGFLibPath :: Maybe FilePath, + optGFLibPath :: Maybe [FilePath], optDocumentRoot :: Maybe FilePath, -- For --server mode optRecomp :: Recomp, optProbsFile :: Maybe FilePath, @@ -208,9 +208,10 @@ parseModuleOptions args = do then return opts else errors $ map ("Non-option among module options: " ++) nonopts -fixRelativeLibPaths curr_dir lib_dir (Options o) = Options (fixPathFlags . o) +fixRelativeLibPaths curr_dir lib_dirs (Options o) = Options (fixPathFlags . o) where - fixPathFlags f@(Flags{optLibraryPath=path}) = f{optLibraryPath=concatMap (\dir -> [curr_dir dir, lib_dir dir]) path} + fixPathFlags f@(Flags{optLibraryPath=path}) = f{optLibraryPath=concatMap (\dir -> [parent dir + | parent <- curr_dir : lib_dirs]) path} -- Showing options @@ -423,7 +424,7 @@ optDescr = literalCat x = set $ \o -> o { optLiteralCats = foldr Set.insert (optLiteralCats o) ((map identS . splitBy (==',')) x) } lexicalCat x = set $ \o -> o { optLexicalCats = foldr Set.insert (optLexicalCats o) (splitBy (==',') x) } outDir x = set $ \o -> o { optOutputDir = Just x } - gfLibPath x = set $ \o -> o { optGFLibPath = Just x } + gfLibPath x = set $ \o -> o { optGFLibPath = Just $ splitInModuleSearchPath x } gfDocuRoot x = set $ \o -> o { optDocumentRoot = Just x } recomp x = set $ \o -> o { optRecomp = x } probsFile x = set $ \o -> o { optProbsFile = Just x } -- cgit v1.2.3