From 9514eeafa75f74ca30bf2424a71c155609164e88 Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Sat, 29 Jun 2013 13:59:55 +0100 Subject: [PATCH] #24, ensure you create the output directories for the multiple file rule --- CHANGES.txt | 1 + Development/Shake/Files.hs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index db508285e..ecb76797c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ Changelog for Shake + #24, create the output directories for the multiple file rule Improvements to match Ninja behaviour 0.10.6 Include command/cmd in the default module diff --git a/Development/Shake/Files.hs b/Development/Shake/Files.hs index 0f56147c3..03adf4464 100644 --- a/Development/Shake/Files.hs +++ b/Development/Shake/Files.hs @@ -6,7 +6,9 @@ module Development.Shake.Files( import Control.Monad import Control.Monad.IO.Class +import Data.List import Data.Maybe +import System.Directory import Development.Shake.Core import Development.Shake.Types @@ -15,6 +17,9 @@ import Development.Shake.File import Development.Shake.FilePattern import Development.Shake.FileTime +import System.FilePath(takeDirectory) -- important that this is the system local filepath, or wrong slashes go wrong + + infix 1 ?>>, *>> @@ -56,6 +61,7 @@ ps *>> act return () rule $ \(FilesQ xs_) -> let xs = map unpack xs_ in if not $ length xs == length ps && and (zipWith (?==) ps xs) then Nothing else Just $ do + liftIO $ mapM_ (createDirectoryIfMissing True) $ nub $ map takeDirectory xs act xs liftIO $ getFileTimes "*>>" xs_ @@ -92,6 +98,7 @@ ps *>> act rule $ \(FilesQ xs_) -> let xs@(x:_) = map unpack xs_ in case checkedTest x of Just ys | ys == xs -> Just $ do + liftIO $ mapM_ (createDirectoryIfMissing True) $ nub $ map takeDirectory xs act xs liftIO $ getFileTimes "?>>" xs_ Just ys -> error $ "Error, ?>> is incompatible with " ++ show xs ++ " vs " ++ show ys