still can't express custom-setup deps
They need unix on non-windows, for Utility.Env, which Build.Configure uses, but cabal can't express that in a custom-setup stanza. To avoid this problem, Utility.Env would need to be moved into unix-compat..
This commit is contained in:
parent
061f5ddd43
commit
1b6cbb63e9
12 changed files with 32 additions and 60 deletions
|
@ -16,6 +16,7 @@ import Control.Applicative
|
|||
import Data.Maybe
|
||||
import Prelude
|
||||
import qualified System.Environment as E
|
||||
import qualified System.SetEnv
|
||||
#else
|
||||
import qualified System.Posix.Env as PE
|
||||
#endif
|
||||
|
@ -41,6 +42,29 @@ getEnvironment = PE.getEnvironment
|
|||
getEnvironment = E.getEnvironment
|
||||
#endif
|
||||
|
||||
{- Sets an environment variable. To overwrite an existing variable,
|
||||
- overwrite must be True.
|
||||
-
|
||||
- On Windows, setting a variable to "" unsets it. -}
|
||||
setEnv :: String -> String -> Bool -> IO ()
|
||||
#ifndef mingw32_HOST_OS
|
||||
setEnv var val overwrite = PE.setEnv var val overwrite
|
||||
#else
|
||||
setEnv var val True = System.SetEnv.setEnv var val
|
||||
setEnv var val False = do
|
||||
r <- getEnv var
|
||||
case r of
|
||||
Nothing -> setEnv var val True
|
||||
Just _ -> return ()
|
||||
#endif
|
||||
|
||||
unsetEnv :: String -> IO ()
|
||||
#ifndef mingw32_HOST_OS
|
||||
unsetEnv = PE.unsetEnv
|
||||
#else
|
||||
unsetEnv = System.SetEnv.unsetEnv
|
||||
#endif
|
||||
|
||||
{- Adds the environment variable to the input environment. If already
|
||||
- present in the list, removes the old value.
|
||||
-
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
{- portable environment variables
|
||||
-
|
||||
- Copyright 2013 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- License: BSD-2-clause
|
||||
-}
|
||||
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module Utility.Env.Set where
|
||||
|
||||
#ifdef mingw32_HOST_OS
|
||||
import qualified System.Environment as E
|
||||
import qualified System.SetEnv
|
||||
#else
|
||||
import qualified System.Posix.Env as PE
|
||||
#endif
|
||||
|
||||
{- Sets an environment variable. To overwrite an existing variable,
|
||||
- overwrite must be True.
|
||||
-
|
||||
- On Windows, setting a variable to "" unsets it. -}
|
||||
setEnv :: String -> String -> Bool -> IO ()
|
||||
#ifndef mingw32_HOST_OS
|
||||
setEnv var val overwrite = PE.setEnv var val overwrite
|
||||
#else
|
||||
setEnv var val True = System.SetEnv.setEnv var val
|
||||
setEnv var val False = do
|
||||
r <- getEnv var
|
||||
case r of
|
||||
Nothing -> setEnv var val True
|
||||
Just _ -> return ()
|
||||
#endif
|
||||
|
||||
unsetEnv :: String -> IO ()
|
||||
#ifndef mingw32_HOST_OS
|
||||
unsetEnv = PE.unsetEnv
|
||||
#else
|
||||
unsetEnv = System.SetEnv.unsetEnv
|
||||
#endif
|
|
@ -15,7 +15,6 @@ import qualified Build.SysConfig as SysConfig
|
|||
import System.Posix.Types
|
||||
import qualified System.Posix.IO
|
||||
import Utility.Env
|
||||
import Utility.Env.Set
|
||||
#endif
|
||||
import Utility.Tmp
|
||||
import Utility.Format (decode_c)
|
||||
|
|
|
@ -11,7 +11,7 @@ module Utility.Lsof where
|
|||
|
||||
import Common
|
||||
import Build.SysConfig as SysConfig
|
||||
import Utility.Env.Set
|
||||
import Utility.Env
|
||||
|
||||
import System.Posix.Types
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue