forked from GitHub/gf-core
changed suffix gfc to gfo in the gfc program to enable sharing directories with gf
This commit is contained in:
@@ -106,7 +106,7 @@ compileOne opts env@(_,srcgr) file = do
|
|||||||
|
|
||||||
-- for compiled gf, read the file and update environment
|
-- for compiled gf, read the file and update environment
|
||||||
-- also undo common subexp optimization, to enable normal computations
|
-- also undo common subexp optimization, to enable normal computations
|
||||||
"gfc" -> do
|
"gfo" -> do
|
||||||
sm0 <- putp ("+ reading" +++ file) $ getSourceModule opts file
|
sm0 <- putp ("+ reading" +++ file) $ getSourceModule opts file
|
||||||
let sm1 = unsubexpModule sm0
|
let sm1 = unsubexpModule sm0
|
||||||
sm <- {- putp "creating indirections" $ -} ioeErr $ extendModule mos sm1
|
sm <- {- putp "creating indirections" $ -} ioeErr $ extendModule mos sm1
|
||||||
@@ -118,7 +118,7 @@ compileOne opts env@(_,srcgr) file = do
|
|||||||
let modu = unsuffixFile file
|
let modu = unsuffixFile file
|
||||||
b1 <- ioeIO $ doesFileExist file
|
b1 <- ioeIO $ doesFileExist file
|
||||||
if not b1
|
if not b1
|
||||||
then compileOne opts env $ gfcFile $ modu
|
then compileOne opts env $ gfoFile $ modu
|
||||||
else do
|
else do
|
||||||
|
|
||||||
sm0 <- putpOpt ("- parsing" +++ file) ("- compiling" +++ file ++ "... ") $
|
sm0 <- putpOpt ("- parsing" +++ file) ("- compiling" +++ file ++ "... ") $
|
||||||
@@ -175,7 +175,7 @@ generateModuleCode opts path minfo@(name,info) = do
|
|||||||
let minfo1 = (if isConcr info then optModule else id) minfo
|
let minfo1 = (if isConcr info then optModule else id) minfo
|
||||||
let minfo2 = minfo1
|
let minfo2 = minfo1
|
||||||
|
|
||||||
let (file,out) = (gfcFile pname, prGrammar (MGrammar [minfo2]))
|
let (file,out) = (gfoFile pname, prGrammar (MGrammar [minfo2]))
|
||||||
putp (" wrote file" +++ file) $ ioeIO $ writeFile file $ compactPrint out
|
putp (" wrote file" +++ file) $ ioeIO $ writeFile file $ compactPrint out
|
||||||
|
|
||||||
return minfo2
|
return minfo2
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
--
|
--
|
||||||
-- to find all files that have to be read, put them in dependency order, and
|
-- to find all files that have to be read, put them in dependency order, and
|
||||||
-- decide which files need recompilation. Name @file.gf@ is returned for them,
|
-- decide which files need recompilation. Name @file.gf@ is returned for them,
|
||||||
-- and @file.gfc@ or @file.gfr@ otherwise.
|
-- and @file.gfo@ otherwise.
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module GF.Devel.ReadFiles (-- * Heading 1
|
module GF.Devel.ReadFiles (-- * Heading 1
|
||||||
getAllFiles,fixNewlines,ModName,getOptionsFromFile,
|
getAllFiles,fixNewlines,ModName,getOptionsFromFile,
|
||||||
-- * Heading 2
|
-- * Heading 2
|
||||||
gfcFile,gfFile,gfrFile,isGFC,resModName,isOldFile
|
gfoFile,gfFile,isGFO,resModName,isOldFile
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import GF.Devel.Arch (selectLater, modifiedFiles, ModTime, getModTime,laterModTime)
|
import GF.Devel.Arch (selectLater, modifiedFiles, ModTime, getModTime,laterModTime)
|
||||||
@@ -67,18 +67,18 @@ getAllFiles opts ps env file = do
|
|||||||
let ds4 = needCompile opts (map fst ds0) ds2
|
let ds4 = needCompile opts (map fst ds0) ds2
|
||||||
return ds4
|
return ds4
|
||||||
|
|
||||||
-- to decide whether to read gf or gfc, or if in env; returns full file path
|
-- to decide whether to read gf or gfo, or if in env; returns full file path
|
||||||
|
|
||||||
data CompStatus =
|
data CompStatus =
|
||||||
CSComp -- compile: read gf
|
CSComp -- compile: read gf
|
||||||
| CSRead -- read gfc
|
| CSRead -- read gfo
|
||||||
| CSEnv -- gfc is in env
|
| CSEnv -- gfo is in env
|
||||||
| CSEnvR -- also gfr is in env
|
| CSEnvR -- also gfr is in env
|
||||||
| CSDont -- don't read at all
|
| CSDont -- don't read at all
|
||||||
| CSRes -- read gfr
|
| CSRes -- read gfr
|
||||||
deriving (Eq,Show)
|
deriving (Eq,Show)
|
||||||
|
|
||||||
-- for gfc, we also return ModTime to cope with earlier compilation of libs
|
-- for gfo, we also return ModTime to cope with earlier compilation of libs
|
||||||
|
|
||||||
selectFormat :: Options -> ModEnv -> (InitPath,ModName) ->
|
selectFormat :: Options -> ModEnv -> (InitPath,ModName) ->
|
||||||
IO (ModName,(InitPath,(CompStatus,Maybe ModTime)))
|
IO (ModName,(InitPath,(CompStatus,Maybe ModTime)))
|
||||||
@@ -87,8 +87,8 @@ selectFormat opts env (p,f) = do
|
|||||||
let pf = prefixPathName p f
|
let pf = prefixPathName p f
|
||||||
let mtenv = lookup f env -- Nothing if f is not in env
|
let mtenv = lookup f env -- Nothing if f is not in env
|
||||||
let rtenv = lookup (resModName f) env
|
let rtenv = lookup (resModName f) env
|
||||||
let fromComp = oElem isCompiled opts -- i -gfc
|
let fromComp = oElem isCompiled opts -- i -gfo
|
||||||
mtgfc <- getModTime $ gfcFile pf
|
mtgfc <- getModTime $ gfoFile pf
|
||||||
mtgf <- getModTime $ gfFile pf
|
mtgf <- getModTime $ gfFile pf
|
||||||
let stat = case (rtenv,mtenv,mtgfc,mtgf) of
|
let stat = case (rtenv,mtenv,mtgfc,mtgf) of
|
||||||
(_,Just tenv,_,_) | fromComp -> (CSEnv, Just tenv)
|
(_,Just tenv,_,_) | fromComp -> (CSEnv, Just tenv)
|
||||||
@@ -131,7 +131,7 @@ needCompile opts headers sfiles0 = paths $ res $ mark $ iter changed where
|
|||||||
isAux = flip elem [MUReuse,MUInstance,MUComplete] . snd
|
isAux = flip elem [MUReuse,MUInstance,MUComplete] . snd
|
||||||
noComp = flip elem [CSRead,CSEnv,CSEnvR] . stat0 . fst
|
noComp = flip elem [CSRead,CSEnv,CSEnvR] . stat0 . fst
|
||||||
|
|
||||||
-- mark as to be compiled those whose gfc is earlier than a deeper gfc
|
-- mark as to be compiled those whose gfo is earlier than a deeper gfo
|
||||||
sfiles1 = map compTimes sfiles
|
sfiles1 = map compTimes sfiles
|
||||||
compTimes fp@(f,(p,(_, Just t))) =
|
compTimes fp@(f,(p,(_, Just t))) =
|
||||||
if any (> t) [t' | Just fs <- [lookup f deps],
|
if any (> t) [t' | Just fs <- [lookup f deps],
|
||||||
@@ -156,8 +156,6 @@ needCompile opts headers sfiles0 = paths $ res $ mark $ iter changed where
|
|||||||
let st = if (elem f cs) then CSComp else st0]
|
let st = if (elem f cs) then CSComp else st0]
|
||||||
|
|
||||||
|
|
||||||
-- if a compilable file depends on a resource, read gfr instead of gfc/env
|
|
||||||
-- but don't read gfr if already in env (by CSEnvR)
|
|
||||||
-- Also read res if the option "retain" is present
|
-- Also read res if the option "retain" is present
|
||||||
-- Also, if a "with" file has to be compiled, read its mother file from source
|
-- Also, if a "with" file has to be compiled, read its mother file from source
|
||||||
|
|
||||||
@@ -182,17 +180,14 @@ needCompile opts headers sfiles0 = paths $ res $ mark $ iter changed where
|
|||||||
mkName f p st = mk $ prefixPathName p f where
|
mkName f p st = mk $ prefixPathName p f where
|
||||||
mk = case st of
|
mk = case st of
|
||||||
CSComp -> gfFile
|
CSComp -> gfFile
|
||||||
CSRead -> gfcFile
|
CSRead -> gfoFile
|
||||||
CSRes -> gfrFile
|
CSRes -> gfoFile ---- gfr
|
||||||
|
|
||||||
isGFC :: FilePath -> Bool
|
isGFO :: FilePath -> Bool
|
||||||
isGFC = (== "gfc") . fileSuffix
|
isGFO = (== "gfo") . fileSuffix
|
||||||
|
|
||||||
gfcFile :: FilePath -> FilePath
|
gfoFile :: FilePath -> FilePath
|
||||||
gfcFile = suffixFile "gfc"
|
gfoFile = suffixFile "gfo"
|
||||||
|
|
||||||
gfrFile :: FilePath -> FilePath
|
|
||||||
gfrFile = suffixFile "gfr"
|
|
||||||
|
|
||||||
gfFile :: FilePath -> FilePath
|
gfFile :: FilePath -> FilePath
|
||||||
gfFile = suffixFile "gf"
|
gfFile = suffixFile "gf"
|
||||||
@@ -222,10 +217,7 @@ getImports ps = get [] where
|
|||||||
let file_gf = gfFile name
|
let file_gf = gfFile name
|
||||||
b <- doesFileExistPath ps file_gf -- try gf file first
|
b <- doesFileExistPath ps file_gf -- try gf file first
|
||||||
if b then return file_gf else do
|
if b then return file_gf else do
|
||||||
let file_gfr = gfrFile name
|
return (gfoFile name) -- gfo next
|
||||||
bb <- doesFileExistPath ps file_gfr -- gfr file next
|
|
||||||
if bb then return file_gfr else do
|
|
||||||
return (gfcFile name) -- gfc next
|
|
||||||
|
|
||||||
readFileIfPath ps $ file
|
readFileIfPath ps $ file
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user