Use doesDirectoryExist to workaround a getDirectoryContents bug.
authorAndrey Mokhov <andrey.mokhov@gmail.com>
Thu, 14 Jan 2016 13:01:48 +0000 (13:01 +0000)
committerAndrey Mokhov <andrey.mokhov@gmail.com>
Thu, 14 Jan 2016 13:01:48 +0000 (13:01 +0000)
See #168.

src/Rules/Gmp.hs
src/Rules/Library.hs

index f6d6fe8..c788ed2 100644 (file)
@@ -118,10 +118,8 @@ gmpRules = do
 
         createDirectory $ takeDirectory gmpLibraryH
         -- check whether we need to build in tree gmp
-        -- this is indicated by line "HaveFrameworkGMP = YES" in `config.mk`
         configMk <- liftIO . readFile $ gmpBase -/- "config.mk"
-        if "HaveFrameworkGMP = YES" `isInfixOf` configMk
-               || "HaveLibGmp = YES" `isInfixOf` configMk
+        if any (`isInfixOf` configMk) ["HaveFrameworkGMP = YES", "HaveLibGmp = YES"]
         then do
             putBuild "| GMP library/framework detected and will be used"
             copyFile gmpLibraryFakeH gmpLibraryH
index 6b2180c..0ffaf3f 100644 (file)
@@ -84,5 +84,8 @@ extraObjects :: PartialTarget -> Action [FilePath]
 extraObjects (PartialTarget _ pkg)
     | pkg == integerGmp = do
         orderOnly [gmpLibraryH] -- TODO: move this dependency elsewhere, #113?
-        getDirectoryFiles "" [gmpObjects -/- "*.o"]
+        exists <- doesDirectoryExist gmpObjects
+        if exists
+        then getDirectoryFiles "" [gmpObjects -/- "*.o"]
+        else return []
     | otherwise         = return []