summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-11-16 10:27:02 +0000
committerSimon Marlow <marlowsd@gmail.com>2011-11-16 14:39:25 +0000
commite7b42bd4925ce91999f070d74e137a6a0ff6e3e4 (patch)
tree662ed4d7b0e8da66ce2df0ec062d50dbc3ba31a9
parent1df28a805b465a28b61f4cfe4db28f247a183206 (diff)
downloadhaskell-e7b42bd4925ce91999f070d74e137a6a0ff6e3e4.tar.gz
Create parent directories when touching the object file (#5584)
-rw-r--r--compiler/main/DriverPipeline.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 4ef2bcbf9d..8103f66239 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -172,8 +172,7 @@ compile' (nothingCompiler, interactiveCompiler, batchCompiler)
handleBatch (HscRecomp hasStub _)
| isHsBoot src_flavour
= do when (isObjectTarget hsc_lang) $ -- interpreted reaches here too
- liftIO $ SysTools.touch dflags' "Touching object file"
- object_filename
+ liftIO $ touchObjectFile dflags' object_filename
return maybe_old_linkable
| otherwise
@@ -956,7 +955,7 @@ runPhase (Hsc src_flavour) input_fn dflags0
case result of
HscNoRecomp
- -> do io $ SysTools.touch dflags' "Touching object file" o_file
+ -> do io $ touchObjectFile dflags' o_file
-- The .o file must have a later modification date
-- than the source file (else we wouldn't be in HscNoRecomp)
-- but we touch it anyway, to keep 'make' happy (we think).
@@ -970,7 +969,7 @@ runPhase (Hsc src_flavour) input_fn dflags0
-- In the case of hs-boot files, generate a dummy .o-boot
-- stamp file for the benefit of Make
when (isHsBoot src_flavour) $
- io $ SysTools.touch dflags' "Touching object file" o_file
+ io $ touchObjectFile dflags' o_file
return (next_phase, output_fn)
-----------------------------------------------------------------------------
@@ -2084,3 +2083,8 @@ hscNextPhase dflags _ hsc_lang =
HscNothing -> StopLn
HscInterpreted -> StopLn
+touchObjectFile :: DynFlags -> FilePath -> IO ()
+touchObjectFile dflags path = do
+ createDirectoryHierarchy $ takeDirectory path
+ SysTools.touch dflags "Touching object file" path
+