diff options
| author | krasimir <krasimir@chalmers.se> | 2009-10-06 10:27:34 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2009-10-06 10:27:34 +0000 |
| commit | cbcdae91484a13780a3d827a1b6ae85f7e3a9ab3 (patch) | |
| tree | c796c0e036905810fae1d2c4005bcea67be68a4c /src/GF/Infra/Option.hs | |
| parent | 332dbf7b9b79f9cb2fa60212cc5529e0c490c1de (diff) | |
hopefully the last revision of the relative paths handling algorithm
Diffstat (limited to 'src/GF/Infra/Option.hs')
| -rw-r--r-- | src/GF/Infra/Option.hs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/GF/Infra/Option.hs b/src/GF/Infra/Option.hs index 8c3d4d267..2963da609 100644 --- a/src/GF/Infra/Option.hs +++ b/src/GF/Infra/Option.hs @@ -7,7 +7,7 @@ module GF.Infra.Option SISRFormat(..), Optimization(..), CFGTransform(..), HaskellOption(..), Dump(..), Printer(..), Recomp(..), BuildParser(..), -- * Option parsing - parseOptions, parseModuleOptions, + parseOptions, parseModuleOptions, fixRelativeLibPaths, -- * Option pretty-printing optionsGFO, optionsPGF, @@ -186,29 +186,27 @@ instance Show Options where -- Option parsing -parseOptions :: FilePath -- ^ if there are relative file paths they will be interpreted as relative to this path - -> [String] -- ^ list of string arguments +parseOptions :: [String] -- ^ list of string arguments -> Err (Options, [FilePath]) -parseOptions root args +parseOptions args | not (null errs) = errors errs | otherwise = do opts <- liftM concatOptions $ sequence optss - return (fixRelativeLibPaths opts, files) + return (opts, files) where (optss, files, errs) = getOpt RequireOrder optDescr args - - fixRelativeLibPaths (Options o) = Options (fixPathFlags . o) - where - fixPathFlags f@(Flags{optLibraryPath=path}) = f{optLibraryPath=map (root </>) path} -parseModuleOptions :: FilePath -- ^ if there are relative file paths they will be interpreted as relative to this path - -> [String] -- ^ list of string arguments +parseModuleOptions :: [String] -- ^ list of string arguments -> Err Options -parseModuleOptions root args = do - (opts,nonopts) <- parseOptions root args +parseModuleOptions args = do + (opts,nonopts) <- parseOptions args if null nonopts then return opts else errors $ map ("Non-option among module options: " ++) nonopts +fixRelativeLibPaths curr_dir lib_dir (Options o) = Options (fixPathFlags . o) + where + fixPathFlags f@(Flags{optLibraryPath=path}) = f{optLibraryPath=concatMap (\dir -> [curr_dir </> dir, lib_dir </> dir]) path} + -- Showing options -- | Pretty-print the options that are preserved in .gfo files. |
