# HG changeset patch # User koda # Date 1351994660 -3600 # Node ID 620331af6b9ad7b75a74009090624e46a75c5090 # Parent 497ec84e0c21abd168dd8d73724ab91922afa2f5 pas2c can search for inc files in alternate folders (needed for out of source builds) diff -r 497ec84e0c21 -r 620331af6b9a tools/PascalPreprocessor.hs --- a/tools/PascalPreprocessor.hs Sun Nov 04 02:35:17 2012 +0100 +++ b/tools/PascalPreprocessor.hs Sun Nov 04 03:04:20 2012 +0100 @@ -22,8 +22,8 @@ , ("S3D_DISABLED", "") ] -preprocess :: String -> String -> IO String -preprocess inputPath fn = do +preprocess :: String -> String -> String -> IO String +preprocess inputPath alternateInputPath fn = do r <- runParserT (preprocessFile (inputPath ++ fn)) (initDefines, [True]) "" "" case r of (Left a) -> do @@ -79,7 +79,7 @@ char '"' spaces char '}' - f <- liftIO (readFile (inputPath ++ fn) `catch` error ("File not found: " ++ fn)) + f <- liftIO (readFile (inputPath ++ fn) `catch` (\exc -> readFile (alternateInputPath ++ fn) `catch` error ("File not found: " ++ fn))) c <- getInput setInput $ f ++ c return "" diff -r 497ec84e0c21 -r 620331af6b9a tools/pas2c.hs --- a/tools/pas2c.hs Sun Nov 04 02:35:17 2012 +0100 +++ b/tools/pas2c.hs Sun Nov 04 03:04:20 2012 +0100 @@ -94,8 +94,8 @@ docToLower :: Doc -> Doc docToLower = text . map toLower . render -pas2C :: String -> String -> String -> IO () -pas2C fn inputPath outputPath = do +pas2C :: String -> String -> String -> String -> IO () +pas2C fn inputPath alternateInputPath outputPath = do s <- flip execStateT initState $ f fn renderCFiles s outputPath where @@ -109,7 +109,7 @@ print ("Preprocessing '" ++ fileName ++ ".pas'... ") fc' <- liftIO $ tryJust (guard . isDoesNotExistError) - $ preprocess inputPath (fileName ++ ".pas") + $ preprocess inputPath alternateInputPath (fileName ++ ".pas") case fc' of (Left a) -> do modify (Map.insert fileName (System [])) @@ -1087,4 +1087,5 @@ let programName = "hwengine" let inputPath = "../hedgewars/" let outputPath = "./" - pas2C programName inputPath outputPath + let alternateInputPath = "./" + pas2C programName inputPath alternateInputPath outputPath