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/ ...@@ -14,7 +14,7 @@ WWW = www/
all: $(SRC)InstallDir.hs $(BIN)generate $(BIN)kicslib $(BIN)kics $(BIN)kicsi libs cpns www all: $(SRC)InstallDir.hs $(BIN)generate $(BIN)kicslib $(BIN)kics $(BIN)kicsi libs cpns www
.PHONY: tools .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 $(BIN)generate: $(SRC)InstallDir.hs $(SRC)Generate.hs $(SRC)CurryToHaskell.hs $(SRC)PreTrans.hs
$(GHC) $(SRC)Generate.hs -o $(BIN)generate $(GHC) $(SRC)Generate.hs -o $(BIN)generate
...@@ -89,11 +89,11 @@ bioprelude: ...@@ -89,11 +89,11 @@ bioprelude:
cd $(LIB);stricths Prelude;prophecy Prelude;cd ../.. cd $(LIB);stricths Prelude;prophecy Prelude;cd ../..
biostdlibraries: bioprelude biostdlibraries: bioprelude
cd $(LIB);stricths All_Libraries;prophecy All_Libraries;cd ../.. cd $(LIB);stricths -m All_Libraries;prophecy -m All_Libraries;cd ../..
$(BIN)prettyflat: $(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 cpns: $(CPNS)CPNS.state
......
...@@ -56,24 +56,32 @@ process done test act modu = do ...@@ -56,24 +56,32 @@ process done test act modu = do
updateIORef done (\fm -> addToFM fm modu result) updateIORef done (\fm -> addToFM fm modu result)
return result return result
--- a standard test if a given filename is newer than another --- a standard test if a given file is newer than a list of other files
obsolete :: (String -> String) -> (String -> String) -> (String -> IO a) -> TestAct a --- if other files do not exist, the given file is assumed to be up-to-date
obsolete f1 f2 action dir modu = do --- on up-to-date files a given action is performed
let fn1 = dir++f1 modu obsolete :: (String -> String) -> [String -> String] -> (String -> IO a) -> TestAct a
fn2 = dir++f2 modu obsolete f fs action dir modu = do
ex <- doesFileExist fn2 let fn = dir++f modu
fns = map ((dir++).($modu)) fs
ex <- doesFileExist fn
if ex then do if ex then do
t1 <- getModificationTime fn1 t <- getModificationTime fn
t2 <- getModificationTime fn2 ns <- mapIO (isNewerThan t) fns
if compareClockTime t1 t2/=LT if or ns
then do then do
putStrLn $ "obsolete : " ++ f2 modu putStrLn $ "obsolete : " ++ f modu
return Nothing return Nothing
else do else do
putStrLn $ "up-to-date: " ++ f2 modu putStrLn $ "up-to-date: " ++ f modu
action fn1 >>= return . Just action fn >>= return . Just
else putStrLn ("missing : "++ f2 modu) >> else putStrLn ("missing : "++ f modu) >>
return Nothing 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 :: FileName -> IO [String]
fastReadImports fn = do fastReadImports fn = do
......
...@@ -44,7 +44,7 @@ transform :: Bool -> Bool -> String -> IO () ...@@ -44,7 +44,7 @@ transform :: Bool -> Bool -> String -> IO ()
transform force _ mod = make mod tester writeTrans transform force _ mod = make mod tester writeTrans
where where
tester = if force then (\ fn _ -> readTypes fn >>= return . Just) tester = if force then (\ fn _ -> readTypes fn >>= return . Just)
else obsolete addFcy (addFcy . addOrc) readTypes else obsolete (addFcy . addOrc) [addFcy] readTypes
readTypes fn = do readTypes fn = do
prog <- readFile fn prog <- readFile fn
let typeString = dropWhile (/='[') $ dropWhile (/=']') $ dropWhile (/='[') prog let typeString = dropWhile (/='[') $ dropWhile (/=']') $ dropWhile (/='[') prog
......
...@@ -54,6 +54,9 @@ extCons = map ((,) prelude) ...@@ -54,6 +54,9 @@ extCons = map ((,) prelude)
targetName :: String -> String targetName :: String -> String
targetName s = prefix ++ s ++ ".hs" targetName s = prefix ++ s ++ ".hs"
incName :: String -> String
incName s = prefix ++ s ++ ".inc"
rnm :: QName -> QName rnm :: QName -> QName
rnm mn@(m,n) = rnm mn@(m,n) =
if elem mn (extTypes++extCons) if elem mn (extTypes++extCons)
...@@ -104,12 +107,12 @@ transform stFile _ False progName = ...@@ -104,12 +107,12 @@ transform stFile _ False progName =
transform stFile force True progName = make progName tester (writeTrans stFile) transform stFile force True progName = make progName tester (writeTrans stFile)
where where
tester = if force then (\ _ _ -> return (Just ())) 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 :: String -> String -> [()] -> Prog -> IO ()
writeTrans stFile path _ prog = do writeTrans stFile path _ prog = do
let fn = path ++ targetName (progName prog) let fn = path ++ targetName (progName prog)
inc = path++prefix++progName prog++".inc" inc = incName (path++prefix++progName prog)
ex <- doesFileExist inc ex <- doesFileExist inc
include <- if ex then readFile inc else return "" include <- if ex then readFile inc else return ""
putStrLn ("generating "++fn) 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