mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 08:32:50 -06:00
Show paths relative to the current directory in progress reports
It is much nicer to see something like - compiling FoodsSwe.gf... write file FoodsSwe.gfo - compiling FoodsTha.gf... write file FoodsTha.gfo - compiling FoodsTsn.gf... write file FoodsTsn.gfo - compiling FoodsTur.gf... write file FoodsTur.gfo - compiling FoodsUrd.gf... write file FoodsUrd.gfo linking ... OK Writing Foods.pgf... instead of - compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsSwe.gf... write file /Users/hallgren/src/GF/gf/examples/foods/FoodsSwe.gfo - compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsTha.gf... write file /Users/hallgren/src/GF/gf/examples/foods/FoodsTha.gfo - compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsTsn.gf... write file /Users/hallgren/src/GF/gf/examples/foods/FoodsTsn.gfo - compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsTur.gf... write file /Users/hallgren/src/GF/gf/examples/foods/FoodsTur.gfo - compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsUrd.gf... write file /Users/hallgren/src/GF/gf/examples/foods/FoodsUrd.gfo linking ... OK Writing Foods.pgf...
This commit is contained in:
@@ -24,6 +24,7 @@ import GF.Infra.CheckM(runCheck')
|
|||||||
import GF.Data.Operations(ErrorMonad,liftErr,(+++),done)
|
import GF.Data.Operations(ErrorMonad,liftErr,(+++),done)
|
||||||
|
|
||||||
import GF.System.Directory(doesFileExist,getCurrentDirectory,renameFile)
|
import GF.System.Directory(doesFileExist,getCurrentDirectory,renameFile)
|
||||||
|
import System.FilePath(makeRelative)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
import GF.Text.Pretty(render,(<+>),($$)) --Doc,
|
import GF.Text.Pretty(render,(<+>),($$)) --Doc,
|
||||||
import Control.Monad((<=<))
|
import Control.Monad((<=<))
|
||||||
@@ -48,14 +49,15 @@ compileOne opts srcgr file =
|
|||||||
-- | Read a compiled GF module.
|
-- | Read a compiled GF module.
|
||||||
-- Also undo common subexp optimization, to enable normal computations.
|
-- Also undo common subexp optimization, to enable normal computations.
|
||||||
reuseGFO opts srcgr file =
|
reuseGFO opts srcgr file =
|
||||||
do sm00 <- putPointE Verbose opts ("+ reading" +++ file) $
|
do cwd <- getCurrentDirectory
|
||||||
|
let rfile = makeRelative cwd file
|
||||||
|
sm00 <- putPointE Verbose opts ("+ reading" +++ rfile) $
|
||||||
decodeModule file
|
decodeModule file
|
||||||
let sm0 = (fst sm00,(snd sm00){mflags=mflags (snd sm00) `addOptions` opts})
|
let sm0 = (fst sm00,(snd sm00){mflags=mflags (snd sm00) `addOptions` opts})
|
||||||
|
|
||||||
idump opts Source sm0
|
idump opts Source sm0
|
||||||
|
|
||||||
let sm1 = unsubexpModule sm0
|
let sm1 = unsubexpModule sm0
|
||||||
cwd <- getCurrentDirectory
|
|
||||||
(sm,warnings) <- -- putPointE Normal opts "creating indirections" $
|
(sm,warnings) <- -- putPointE Normal opts "creating indirections" $
|
||||||
runCheck' opts $ extendModule cwd srcgr sm1
|
runCheck' opts $ extendModule cwd srcgr sm1
|
||||||
warnOut opts warnings
|
warnOut opts warnings
|
||||||
@@ -71,11 +73,12 @@ reuseGFO opts srcgr file =
|
|||||||
-- stores it in a @.gfo@ file
|
-- stores it in a @.gfo@ file
|
||||||
-- (or a tags file, if running with the @-tags@ option)
|
-- (or a tags file, if running with the @-tags@ option)
|
||||||
useTheSource opts srcgr file =
|
useTheSource opts srcgr file =
|
||||||
do sm <- putpOpt ("- parsing" +++ file)
|
do cwd <- getCurrentDirectory
|
||||||
("- compiling" +++ file ++ "... ")
|
let rfile = makeRelative cwd file
|
||||||
|
sm <- putpOpt ("- parsing" +++ rfile)
|
||||||
|
("- compiling" +++ rfile ++ "... ")
|
||||||
(getSourceModule opts file)
|
(getSourceModule opts file)
|
||||||
idump opts Source sm
|
idump opts Source sm
|
||||||
cwd <- getCurrentDirectory
|
|
||||||
compileSourceModule opts cwd (Just file) srcgr sm
|
compileSourceModule opts cwd (Just file) srcgr sm
|
||||||
where
|
where
|
||||||
putpOpt v m act
|
putpOpt v m act
|
||||||
@@ -85,7 +88,7 @@ useTheSource opts srcgr file =
|
|||||||
|
|
||||||
type CompileSource = Grammar -> Module -> IOE OneOutput
|
type CompileSource = Grammar -> Module -> IOE OneOutput
|
||||||
|
|
||||||
--compileSourceModule :: Options -> FilePath -> Maybe FilePath -> CompileSource
|
--compileSourceModule :: Options -> InitPath -> Maybe FilePath -> CompileSource
|
||||||
compileSourceModule opts cwd mb_gfFile gr =
|
compileSourceModule opts cwd mb_gfFile gr =
|
||||||
if flag optTagsOnly opts
|
if flag optTagsOnly opts
|
||||||
then generateTags <=< ifComplete middle <=< frontend
|
then generateTags <=< ifComplete middle <=< frontend
|
||||||
@@ -111,7 +114,7 @@ compileSourceModule opts cwd mb_gfFile gr =
|
|||||||
|
|
||||||
generateGFO mo =
|
generateGFO mo =
|
||||||
do let mb_gfo = fmap (gf2gfo opts) mb_gfFile
|
do let mb_gfo = fmap (gf2gfo opts) mb_gfFile
|
||||||
maybeM (flip (writeGFO opts) mo) mb_gfo
|
maybeM (flip (writeGFO opts cwd) mo) mb_gfo
|
||||||
return (mb_gfo,mo)
|
return (mb_gfo,mo)
|
||||||
|
|
||||||
generateTags mo =
|
generateTags mo =
|
||||||
@@ -135,12 +138,13 @@ compileSourceModule opts cwd mb_gfFile gr =
|
|||||||
maybeM f = maybe done f
|
maybeM f = maybe done f
|
||||||
|
|
||||||
|
|
||||||
--writeGFO :: Options -> FilePath -> SourceModule -> IOE ()
|
--writeGFO :: Options -> InitPath -> FilePath -> SourceModule -> IOE ()
|
||||||
writeGFO opts file mo =
|
writeGFO opts cwd file mo =
|
||||||
putPointE Normal opts (" write file" +++ file) $
|
putPointE Normal opts (" write file" +++ rfile) $
|
||||||
do encodeModule tmp mo2
|
do encodeModule tmp mo2
|
||||||
renameFile tmp file
|
renameFile tmp file
|
||||||
where
|
where
|
||||||
|
rfile = makeRelative cwd file
|
||||||
tmp = file++".tmp"
|
tmp = file++".tmp"
|
||||||
mo2 = (m,mi{jments=Map.filter notAnyInd (jments mi)})
|
mo2 = (m,mi{jments=Map.filter notAnyInd (jments mi)})
|
||||||
(m,mi) = subexpModule mo
|
(m,mi) = subexpModule mo
|
||||||
|
|||||||
Reference in New Issue
Block a user