@@ -74,12 +74,10 @@ buildMakeActions outputDir filePathMap usePrefix =
74 let path = fromMaybe (error "Module has no filename in 'make'") $ M.lookup mn filePathMap
74 let path = fromMaybe (error "Module has no filename in 'make'") $ M.lookup mn filePathMap
75 let filePath = either (const []) takeDirectory path
75 let filePath = either (const []) takeDirectory path
76 fileBase = filePath </> (last . words . dotsTo ' ' $ P.runModuleName mn)
76 fileBase = filePath </> (last . words . dotsTo ' ' $ P.runModuleName mn)
77− sourceFFI = addExtension fileBase sourceExt
77+ ffis = addExtension fileBase <$> [sourceExt, headerExt] ++ otherExts
78− headerFFI = addExtension fileBase headerExt
79 e1 <- traverse getTimestamp path
78 e1 <- traverse getTimestamp path
80− sffi <- getTimestamp sourceFFI
81− hffi <- getTimestamp headerFFI
79+ ffimax <- foldl1 max <$> mapM getTimestamp ffis
82− return $ fmap (max (max sffi hffi)) e1
80+ return $ max ffimax <$> e1
84 getOutputTimestamp :: P.ModuleName -> Make (Maybe UTCTime)
82 getOutputTimestamp :: P.ModuleName -> Make (Maybe UTCTime)
85 getOutputTimestamp mn = do
83 getOutputTimestamp mn = do
@@ -135,6 +133,8 @@ buildMakeActions outputDir filePathMap usePrefix =
135 sfileExists <- textFileExists sfile
133 sfileExists <- textFileExists sfile
136 when (sfileExists) $ do
134 when (sfileExists) $ do
137 copyTextFile (addExtension (fileBase ++ ffiMangle) sourceExt) sfile
135 copyTextFile (addExtension (fileBase ++ ffiMangle) sourceExt) sfile
136+ mapM (copyTextFileWithExt fileBase inputPath) otherExts
139 requiresForeign :: CF.Module a -> Bool
139 requiresForeign :: CF.Module a -> Bool
140 requiresForeign = not . null . CF.moduleForeign
140 requiresForeign = not . null . CF.moduleForeign
@@ -160,6 +160,12 @@ buildMakeActions outputDir filePathMap usePrefix =
160 createDirectoryIfMissing True (takeDirectory to)
160 createDirectoryIfMissing True (takeDirectory to)
161 copyFile from to
161 copyFile from to
163+ copyTextFileWithExt :: FilePath -> FilePath -> String -> Make ()
164+ copyTextFileWithExt to from ext = makeIO (const (ErrorMessage [] $ CannotWriteFile to)) $ do
165+ createDirectoryIfMissing True (takeDirectory to)
166+ _ <- tryIOError $ copyFile (addExtension from ext) (addExtension to ext)
163 writeTextFile :: FilePath -> String -> Make ()
169 writeTextFile :: FilePath -> String -> Make ()
164 writeTextFile path text = makeIO (const (ErrorMessage [] $ CannotWriteFile path)) $ do
170 writeTextFile path text = makeIO (const (ErrorMessage [] $ CannotWriteFile path)) $ do
165 createDirectoryIfMissing True (takeDirectory path)
171 createDirectoryIfMissing True (takeDirectory path)
@@ -182,5 +188,8 @@ headerExt = "hh"
182sourceExt :: String
188sourceExt :: String
183sourceExt = "cc"
189sourceExt = "cc"
191+otherExts :: [String]
192+otherExts = ["h", "inl"]
185ffiMangle :: String
194ffiMangle :: String
186ffiMangle = "_ffi"
195ffiMangle = "_ffi"