[commit: packages/directory] master: Work around lack of #const_str when cross-compiling (8926fb1)

git at git.haskell.org git at git.haskell.org
Fri Dec 18 09:52:18 UTC 2015


Repository : ssh://git@git.haskell.org/directory

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8926fb113ce84a2eef359704b6b0286e7dc353fd/directory

>---------------------------------------------------------------

commit 8926fb113ce84a2eef359704b6b0286e7dc353fd
Author: Phil Ruffwind <rf at rufflewind.com>
Date:   Sat Aug 15 18:12:41 2015 -0400

    Work around lack of #const_str when cross-compiling
    
    We simply paste the C string literal in Haskell code and hope it works.


>---------------------------------------------------------------

8926fb113ce84a2eef359704b6b0286e7dc353fd
 System/Directory/Internal.hsc       | 10 +++-------
 System/Directory/Internal/Config.hs | 12 ++++++++++++
 changelog.md                        |  7 +++++++
 directory.cabal                     |  3 ++-
 4 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/System/Directory/Internal.hsc b/System/Directory/Internal.hsc
index a0a71db..e6bd979 100644
--- a/System/Directory/Internal.hsc
+++ b/System/Directory/Internal.hsc
@@ -1,7 +1,7 @@
 #include <HsDirectoryConfig.h>
 
 module System.Directory.Internal
-  ( module System.Directory.Internal
+  ( module System.Directory.Internal.Config
 
 #ifdef HAVE_UTIMENSAT
   , module System.Directory.Internal.C_utimensat
@@ -13,7 +13,8 @@ module System.Directory.Internal
   , module System.Directory.Internal.Posix
 #endif
 
-) where
+  ) where
+import System.Directory.Internal.Config
 
 #ifdef HAVE_UTIMENSAT
 import System.Directory.Internal.C_utimensat
@@ -24,8 +25,3 @@ import System.Directory.Internal.Windows
 #else
 import System.Directory.Internal.Posix
 #endif
-
--- | Filename extension for executable files (including the dot if any)
---   (usually @\"\"@ on POSIX systems and @\".exe\"@ on Windows or OS\/2).
-exeExtension :: String
-exeExtension = (#const_str EXE_EXTENSION)
diff --git a/System/Directory/Internal/Config.hs b/System/Directory/Internal/Config.hs
new file mode 100644
index 0000000..4547897
--- /dev/null
+++ b/System/Directory/Internal/Config.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE CPP #-}
+#include <HsDirectoryConfig.h>
+module System.Directory.Internal.Config where
+
+-- | Filename extension for executable files (including the dot if any)
+--   (usually @\"\"@ on POSIX systems and @\".exe\"@ on Windows or OS\/2).
+exeExtension :: String
+exeExtension = EXE_EXTENSION
+-- We avoid using #const_str from hsc because it breaks cross-compilation
+-- builds, so we use this ugly workaround where we simply paste the C string
+-- literal directly in here.  This will probably break if the EXE_EXTENSION
+-- contains strange characters, but hopefully no sane OS would ever do that.
diff --git a/changelog.md b/changelog.md
index 5e2bd85..10f12c9 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,13 @@
 Changelog for the [`directory`][1] package
 ==========================================
 
+## 1.2.3.2 (August 2015)
+
+  * Work around lack of `#const_str` when cross-compiling
+    ([haskell-cafe](F7D))
+
+[F7D]: https://mail.haskell.org/pipermail/haskell-cafe/2015-August/120892.html
+
 ## 1.2.3.1 (August 2015)
 
   * Restore support for Safe Haskell with base < 4.8
diff --git a/directory.cabal b/directory.cabal
index 9f82899..9300897 100644
--- a/directory.cabal
+++ b/directory.cabal
@@ -1,5 +1,5 @@
 name:           directory
-version:        1.2.3.1
+version:        1.2.3.2
 -- NOTE: Don't forget to update ./changelog.md
 license:        BSD3
 license-file:   LICENSE
@@ -45,6 +45,7 @@ Library
         System.Directory
     other-modules:
         System.Directory.Internal
+        System.Directory.Internal.Config
         System.Directory.Internal.C_utimensat
         System.Directory.Internal.Posix
         System.Directory.Internal.Windows



More information about the ghc-commits mailing list