Skip to content

Commit

Permalink
Fix CPP usage
Browse files Browse the repository at this point in the history
The code had a mixtire of `#ifdef mingw32_HOST_OS` and `#if`. The later
works but is not really correct. GHC HEAD has just got a new warning flag
`-Wcpp-undef` which will warn on `#if` used with an undefined identifier.
Since we want to turn that on in the GHC build system we need to fix cabal
first.
  • Loading branch information
erikd committed Oct 23, 2016
1 parent ccbd8d1 commit d916298
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cabal/Distribution/Compat/CreatePipe.hs
Expand Up @@ -11,7 +11,7 @@ import Distribution.Compat.Prelude
import Distribution.Compat.Stack

-- The mingw32_HOST_OS CPP macro is GHC-specific
#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
import qualified Prelude
import Control.Exception (onException)
import Foreign.C.Error (throwErrnoIfMinus1_)
Expand All @@ -31,7 +31,7 @@ import qualified System.Posix.IO as Posix

createPipe :: IO (Handle, Handle)
-- The mingw32_HOST_OS CPP macro is GHC-specific
#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
createPipe = do
(readfd, writefd) <- allocaArray 2 $ \ pfds -> do
throwErrnoIfMinus1_ "_pipe" $ c__pipe pfds 2 ({- _O_BINARY -} 32768)
Expand Down
6 changes: 3 additions & 3 deletions Cabal/Distribution/Simple/InstallDirs.hs
Expand Up @@ -59,7 +59,7 @@ import System.Directory (getAppUserDataDirectory)
import System.FilePath ((</>), isPathSeparator, pathSeparator)
import System.FilePath (dropDrive)

#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
import qualified Prelude
import Foreign
import Foreign.C
Expand Down Expand Up @@ -553,14 +553,14 @@ instance Read PathTemplate where

getWindowsProgramFilesDir :: NoCallStackIO FilePath
getWindowsProgramFilesDir = do
#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
m <- shGetFolderPath csidl_PROGRAM_FILES
#else
let m = Nothing
#endif
return (fromMaybe "C:\\Program Files" m)

#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
shGetFolderPath :: CInt -> NoCallStackIO (Maybe FilePath)
shGetFolderPath n =
allocaArray long_path_size $ \pPath -> do
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/Distribution/Client/InstallSymlink.hs
Expand Up @@ -16,7 +16,7 @@ module Distribution.Client.InstallSymlink (
symlinkBinary,
) where

#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS

import Distribution.Package (PackageIdentifier)
import Distribution.Client.InstallPlan (InstallPlan)
Expand Down
8 changes: 4 additions & 4 deletions cabal-install/Distribution/Client/SetupWrapper.hs
Expand Up @@ -85,7 +85,7 @@ import Distribution.Simple.Utils
import Distribution.Client.Utils
( inDir, tryCanonicalizePath, withExtraPathEnv
, existsAndIsMoreRecentThan, moreRecentFile, withEnv
#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
, canonicalizePathNoThrow
#endif
)
Expand Down Expand Up @@ -462,7 +462,7 @@ externalSetupMethod path verbosity options _ args = do
++ show logHandle

-- See 'Note: win32 clean hack' above.
#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
if useWin32CleanHack options then doWin32CleanHack path else doInvoke path
#else
doInvoke path
Expand All @@ -483,7 +483,7 @@ externalSetupMethod path verbosity options _ args = do
exitCode <- waitForProcess process
unless (exitCode == ExitSuccess) $ exitWith exitCode

#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
doWin32CleanHack path' = do
info verbosity $ "Using the Win32 clean hack."
-- Recursively removes the temp dir on exit.
Expand Down Expand Up @@ -528,7 +528,7 @@ getExternalSetupMethod verbosity options pkg bt = do
path' <- tryCanonicalizePath path

-- See 'Note: win32 clean hack' above.
#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS
-- setupProgFile may not exist if we're using a cached program
setupProgFile' <- canonicalizePathNoThrow setupProgFile
let win32CleanHackNeeded = (useWin32CleanHack options)
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/Distribution/Client/Win32SelfUpgrade.hs
Expand Up @@ -42,7 +42,7 @@ module Distribution.Client.Win32SelfUpgrade (
deleteOldExeFile,
) where

#if mingw32_HOST_OS
#ifdef mingw32_HOST_OS

import qualified System.Win32 as Win32
import System.Win32 (DWORD, BOOL, HANDLE, LPCTSTR)
Expand Down

0 comments on commit d916298

Please sign in to comment.