Skip to content

Commit

Permalink
Support filepath >= 1.5.0.0 and os-string
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Nov 26, 2023
1 parent 71e5648 commit c109ef0
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
7 changes: 6 additions & 1 deletion System/Posix/Env/PosixString.hsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PackageImports #-}

-----------------------------------------------------------------------------
-- |
Expand Down Expand Up @@ -42,7 +43,11 @@ import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
import System.Posix.Env ( clearEnv )
import System.OsPath.Posix
import System.OsString.Internal.Types
import qualified System.OsPath.Data.ByteString.Short as B
#if MIN_VERSION_filepath(1, 5, 0)
import qualified "os-string" System.OsString.Data.ByteString.Short as B
#else
import qualified "filepath" System.OsPath.Data.ByteString.Short as B
#endif
import Data.ByteString.Short.Internal ( copyToPtr )

import qualified System.Posix.Env.Internal as Internal
Expand Down
7 changes: 6 additions & 1 deletion System/Posix/PosixPath/FilePath.hsc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE PackageImports #-}

-----------------------------------------------------------------------------
-- |
Expand Down Expand Up @@ -45,7 +46,11 @@ import Data.ByteString.Internal (c_strlen)
import Control.Monad
import Control.Exception
import System.OsPath.Posix as PS
import System.OsPath.Data.ByteString.Short as BSS
#if MIN_VERSION_filepath(1, 5, 0)
import "os-string" System.OsString.Data.ByteString.Short as BSS
#else
import "filepath" System.OsPath.Data.ByteString.Short as BSS
#endif
import Prelude hiding (FilePath)
import System.OsString.Internal.Types (PosixString(..), pattern PS)
import GHC.IO.Exception
Expand Down
7 changes: 6 additions & 1 deletion System/Posix/Process/PosixString.hsc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE PackageImports #-}
-----------------------------------------------------------------------------
-- |
-- Module : System.Posix.Process.PosixString
Expand Down Expand Up @@ -79,7 +80,11 @@ import Foreign.C hiding (

import System.OsPath.Types
import System.OsString.Internal.Types (PosixString(..))
import qualified System.OsPath.Data.ByteString.Short as BC
#if MIN_VERSION_filepath(1, 5, 0)
import qualified "os-string" System.OsString.Data.ByteString.Short as BC
#else
import qualified "filepath" System.OsPath.Data.ByteString.Short as BC
#endif

import System.Posix.PosixPath.FilePath

Expand Down
7 changes: 6 additions & 1 deletion System/Posix/Temp/PosixString.hsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PackageImports #-}
-----------------------------------------------------------------------------
-- |
-- Module : System.Posix.Temp.PosixString
Expand All @@ -20,7 +21,11 @@ module System.Posix.Temp.PosixString (

#include "HsUnix.h"

import qualified System.OsPath.Data.ByteString.Short as BC
#if MIN_VERSION_filepath(1, 5, 0)
import qualified "os-string" System.OsString.Data.ByteString.Short as BC
#else
import qualified "filepath" System.OsPath.Data.ByteString.Short as BC
#endif
import Data.Word

import Foreign.C
Expand Down
7 changes: 6 additions & 1 deletion tests/T13660.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}

module Main where

Expand All @@ -15,7 +16,11 @@ import System.Posix.IO (defaultFileFlags, OpenFileFlags(..), OpenMode(..))
import System.Posix.ByteString.FilePath

import qualified Data.ByteString.Char8 as C
import qualified System.OsPath.Data.ByteString.Short as SBS
#if MIN_VERSION_filepath(1, 5, 0)
import qualified "os-string" System.OsString.Data.ByteString.Short as SBS
#else
import qualified "filepath" System.OsPath.Data.ByteString.Short as SBS
#endif
import qualified System.Posix.Env.PosixString as PS
import qualified System.Posix.IO.PosixString as PS
import qualified System.Posix.IO.ByteString as BS
Expand Down
23 changes: 20 additions & 3 deletions unix.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ extra-tmp-files:
include/HsUnixConfig.h
unix.buildinfo

flag os-string
description: Use the new os-string package
default: False
manual: False

source-repository head
type: git
location: https://github.com/haskell/unix.git
Expand All @@ -71,9 +76,13 @@ library
build-depends:
base >= 4.12.0.0 && < 4.20,
bytestring >= 0.9.2 && < 0.13,
filepath >= 1.4.100.0 && < 1.5,
time >= 1.9.1 && < 1.13

if flag(os-string)
build-depends: filepath >= 1.5.0.0, os-string >= 2.0.0
else
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0

exposed-modules:
System.Posix
System.Posix.ByteString
Expand Down Expand Up @@ -172,7 +181,11 @@ test-suite unix-tests
Signals001
type: exitcode-stdio-1.0
default-language: Haskell2010
build-depends: base, bytestring, filepath, tasty, tasty-hunit, tasty-quickcheck, unix
build-depends: base, bytestring, tasty, tasty-hunit, tasty-quickcheck, unix
if flag(os-string)
build-depends: filepath >= 1.5.0.0, os-string >= 2.0.0
else
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0
ghc-options: -Wall -with-rtsopts=-V0

test-suite FdReadBuf001
Expand Down Expand Up @@ -362,5 +375,9 @@ test-suite T13660
main-is: T13660.hs
type: exitcode-stdio-1.0
default-language: Haskell2010
build-depends: base, unix, filepath >= 1.4.100.0 && < 1.5, bytestring
build-depends: base, unix, bytestring
if flag(os-string)
build-depends: filepath >= 1.5.0.0, os-string >= 2.0.0
else
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0
ghc-options: -Wall

0 comments on commit c109ef0

Please sign in to comment.