Commit aa700daf authored by bbr's avatar bbr
Browse files

make is now supporting comparison with multiple files for obsolete check

- changed Make.curry accordingly
- added slight changes to Oracle/Transform (added list)
- add include file name in stricths
parent 82ddf17d
......@@ -14,7 +14,7 @@ WWW = www/
all: $(SRC)InstallDir.hs $(BIN)generate $(BIN)kicslib $(BIN)kics $(BIN)kicsi libs cpns www
.PHONY: tools
tools: $(SRC)InstallDir.hs $(BIN)makeExternalInterface
tools: $(SRC)InstallDir.hs $(BIN)makeExternalInterface $(BIN)prettyflat
$(BIN)generate: $(SRC)InstallDir.hs $(SRC)Generate.hs $(SRC)CurryToHaskell.hs $(SRC)PreTrans.hs
$(GHC) $(SRC)Generate.hs -o $(BIN)generate
......@@ -89,11 +89,11 @@ bioprelude:
cd $(LIB);stricths Prelude;prophecy Prelude;cd ../..
biostdlibraries: bioprelude
cd $(LIB);stricths All_Libraries;prophecy All_Libraries;cd ../..
cd $(LIB);stricths -m All_Libraries;prophecy -m All_Libraries;cd ../..
$(BIN)prettyflat:
$(KICS) -executable -o $(BIN)prettyflat -main mainPrint PrettyFlat.curry
$(KICS) -userlibpath ~/lehrstuhl/curry/libraries -executable -o $(BIN)prettyflat -main mainPrint PrettyFlat.curry
cpns: $(CPNS)CPNS.state
......
......@@ -56,24 +56,32 @@ process done test act modu = do
updateIORef done (\fm -> addToFM fm modu result)
return result
--- a standard test if a given filename is newer than another
obsolete :: (String -> String) -> (String -> String) -> (String -> IO a) -> TestAct a
obsolete f1 f2 action dir modu = do
let fn1 = dir++f1 modu
fn2 = dir++f2 modu
ex <- doesFileExist fn2
--- a standard test if a given file is newer than a list of other files
--- if other files do not exist, the given file is assumed to be up-to-date
--- on up-to-date files a given action is performed
obsolete :: (String -> String) -> [String -> String] -> (String -> IO a) -> TestAct a
obsolete f fs action dir modu = do
let fn = dir++f modu
fns = map ((dir++).($modu)) fs
ex <- doesFileExist fn
if ex then do
t1 <- getModificationTime fn1
t2 <- getModificationTime fn2
if compareClockTime t1 t2/=LT
t <- getModificationTime fn
ns <- mapIO (isNewerThan t) fns
if or ns
then do
putStrLn $ "obsolete : " ++ f2 modu
putStrLn $ "obsolete : " ++ f modu
return Nothing
else do
putStrLn $ "up-to-date: " ++ f2 modu
action fn1 >>= return . Just
else putStrLn ("missing : "++ f2 modu) >>
putStrLn $ "up-to-date: " ++ f modu
action fn >>= return . Just
else putStrLn ("missing : "++ f modu) >>
return Nothing
where
isNewerThan t file = do
ex <- doesFileExist file
if not ex then return False else do
t' <- getModificationTime file
return (compareClockTime t t'/=GT)
fastReadImports :: FileName -> IO [String]
fastReadImports fn = do
......
......@@ -44,7 +44,7 @@ transform :: Bool -> Bool -> String -> IO ()
transform force _ mod = make mod tester writeTrans
where
tester = if force then (\ fn _ -> readTypes fn >>= return . Just)
else obsolete addFcy (addFcy . addOrc) readTypes
else obsolete (addFcy . addOrc) [addFcy] readTypes
readTypes fn = do
prog <- readFile fn
let typeString = dropWhile (/='[') $ dropWhile (/=']') $ dropWhile (/='[') prog
......
......@@ -54,6 +54,9 @@ extCons = map ((,) prelude)
targetName :: String -> String
targetName s = prefix ++ s ++ ".hs"
incName :: String -> String
incName s = prefix ++ s ++ ".inc"
rnm :: QName -> QName
rnm mn@(m,n) =
if elem mn (extTypes++extCons)
......@@ -104,12 +107,12 @@ transform stFile _ False progName =
transform stFile force True progName = make progName tester (writeTrans stFile)
where
tester = if force then (\ _ _ -> return (Just ()))
else obsolete addFcy targetName (const (return ()))
else obsolete targetName [addFcy,incName] (const (return ()))
writeTrans :: String -> String -> [()] -> Prog -> IO ()
writeTrans stFile path _ prog = do
let fn = path ++ targetName (progName prog)
inc = path++prefix++progName prog++".inc"
inc = incName (path++prefix++progName prog)
ex <- doesFileExist inc
include <- if ex then readFile inc else return ""
putStrLn ("generating "++fn)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment