Commit e9ea7591 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Rename Distribution.System.os to .buildOS and eliminate Windows sub-type

parent 178de1dc
......@@ -245,8 +245,8 @@ buildPathsModule pkg_descr lbi =
|| not (supportsRelocatableProgs (compilerFlavor (compiler lbi)))
supportsRelocatableProgs Hugs = True
supportsRelocatableProgs GHC = case os of
Windows _ -> True
supportsRelocatableProgs GHC = case buildOS of
Windows -> True
_ -> False
supportsRelocatableProgs _ = False
......@@ -321,11 +321,11 @@ filename_stuff =
" _ -> path1\n"++
"\n"++
"pathSeparator :: Char\n"++
(case os of
Windows _ -> "pathSeparator = '\\\\'\n"
(case buildOS of
Windows -> "pathSeparator = '\\\\'\n"
_ -> "pathSeparator = '/'\n") ++
"\n"++
"isPathSeparator :: Char -> Bool\n"++
(case os of
Windows _ -> "isPathSeparator c = c == '/' || c == '\\\\'\n"
(case buildOS of
Windows -> "isPathSeparator c = c == '/' || c == '\\\\'\n"
_ -> "isPathSeparator c = c == '/'\n")
......@@ -66,7 +66,7 @@ import Distribution.Package (PackageIdentifier(..), Package(..))
import Distribution.PackageDescription (PackageDescription)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(buildDir))
import Distribution.Version (showVersion)
import Distribution.System (OS(..), os)
import Distribution.System (OS(..), buildOS)
-- ---------------------------------------------------------------------------
-- Build directories and files
......@@ -131,9 +131,9 @@ mkSharedLibName pref lib (PackageIdentifier compilerName compilerVersion)
-- | Extension for executable files
-- (typically @\"\"@ on Unix and @\"exe\"@ on Windows or OS\/2)
exeExtension :: String
exeExtension = case os of
Windows _ -> "exe"
_ -> ""
exeExtension = case buildOS of
Windows -> "exe"
_ -> ""
-- ToDo: This should be determined via autoconf (AC_OBJEXT)
-- | Extension for object files. For GHC and NHC the extension is @\"o\"@.
......@@ -144,7 +144,7 @@ objExtension = "o"
-- | Extension for dynamically linked (or shared) libraries
-- (typically @\"so\"@ on Unix and @\"dll\"@ on Windows)
dllExtension :: String
dllExtension = case os of
Windows _ -> "dll"
OSX -> "dylib"
_ -> "so"
dllExtension = case buildOS of
Windows -> "dll"
OSX -> "dylib"
_ -> "so"
......@@ -100,7 +100,7 @@ import Distribution.Simple.Utils
import Distribution.Simple.Register
( removeInstalledConfig )
import Distribution.System
( os, OS(..), Windows(..), buildArch )
( OS(..), buildOS, buildArch )
import Distribution.Version
( Version(..), Dependency(..), VersionRange(..), showVersion, readVersion
, showVersionRange, orLaterVersion, withinRange )
......@@ -293,7 +293,7 @@ configure (pkg_descr0, pbi) cfg
case finalizePackageDescription
(configConfigurationsFlags cfg)
maybePackageIndex
Distribution.System.os
Distribution.System.buildOS
Distribution.System.buildArch
(map toLower (show flavor),version)
ppd
......@@ -422,11 +422,11 @@ configure (pkg_descr0, pbi) cfg
let dirinfo name dir isPrefixRelative =
info verbosity $ name ++ " installed in: " ++ dir ++ relNote
where relNote = case os of
Windows MingW | not (hasLibs pkg_descr)
&& isNothing isPrefixRelative
-> " (fixed location)"
_ -> ""
where relNote = case buildOS of
Windows | not (hasLibs pkg_descr)
&& isNothing isPrefixRelative
-> " (fixed location)"
_ -> ""
dirinfo "Binaries" (bindir dirs) (bindir relative)
dirinfo "Libraries" (libdir dirs) (libdir relative)
......
......@@ -80,6 +80,7 @@ import Distribution.Simple.Compiler
import Distribution.Version ( Version(..), showVersion,
VersionRange(..), orLaterVersion )
import Distribution.System
( OS(..), buildOS )
import Distribution.Verbosity
import Language.Haskell.Extension (Extension(..))
......@@ -124,8 +125,8 @@ configure verbosity hcPath hcPkgPath conf = do
++ programPath ghcPkgProg ++ " is version " ++ showVersion ghcPkgVersion
-- finding ghc's local ld is a bit tricky as it's not on the path:
let ldProgram' = case os of
Windows _ ->
let ldProgram' = case buildOS of
Windows ->
let compilerDir = takeDirectory (programPath ghcProg)
baseDir = takeDirectory compilerDir
binInstallLd = baseDir </> "gcc-lib" </> "ld.exe"
......
......@@ -69,6 +69,7 @@ import Language.Haskell.Extension
import System.FilePath ( (</>), takeExtension, (<.>),
searchPathSeparator, normalise, takeDirectory )
import Distribution.System
( OS(..), buildOS )
import Distribution.Verbosity
import Distribution.Package ( PackageIdentifier(..) )
......@@ -371,11 +372,11 @@ install verbosity libDir installProgDir binDir targetProgDir buildPref (progpref
-- see http://hackage.haskell.org/trac/hackage/ticket/43
let hugsOptions = hcOptions Hugs (buildInfo exe)
let baseExeFile = progprefix ++ (exeName exe) ++ progsuffix
let exeFile = case os of
Windows _ -> binDir </> baseExeFile <.> ".bat"
_ -> binDir </> baseExeFile
let script = case os of
Windows _ ->
let exeFile = case buildOS of
Windows -> binDir </> baseExeFile <.> ".bat"
_ -> binDir </> baseExeFile
let script = case buildOS of
Windows ->
let args = hugsOptions ++ [targetName, "%*"]
in unlines ["@echo off",
unwords ("runhugs" : args)]
......
......@@ -76,7 +76,8 @@ import System.FilePath (dropDrive)
import Distribution.Package (PackageIdentifier(..), showPackageId)
import Distribution.Version (showVersion)
import Distribution.System (OS(..), os)
import Distribution.System
( OS(..), buildOS )
import Distribution.Simple.Compiler (CompilerFlavor(..))
#if mingw32_HOST_OS || mingw32_TARGET_OS
......@@ -212,30 +213,30 @@ defaultInstallDirs comp userInstall hasLibs = do
return $ fmap toPathTemplate $ InstallDirs {
prefix = if userInstall
then userInstallPrefix
else case os of
Windows _ -> windowsProgramFilesDir </> "Haskell"
else case buildOS of
Windows -> windowsProgramFilesDir </> "Haskell"
_other -> "/usr/local",
bindir = "$prefix" </> "bin",
libdir = case os of
Windows _ -> "$prefix"
libdir = case buildOS of
Windows -> "$prefix"
_other -> "$prefix" </> "lib",
libsubdir = case comp of
Hugs -> "hugs" </> "packages" </> "$pkg"
JHC -> "$compiler"
_other -> "$pkgid" </> "$compiler",
dynlibdir = "$libdir",
libexecdir = case os of
Windows _ -> "$prefix" </> "$pkgid"
libexecdir = case buildOS of
Windows -> "$prefix" </> "$pkgid"
_other -> "$prefix" </> "libexec",
progdir = "$libdir" </> "hugs" </> "programs",
includedir = "$libdir" </> "$libsubdir" </> "include",
datadir = case os of
Windows _ | hasLibs -> windowsProgramFilesDir </> "Haskell"
datadir = case buildOS of
Windows | hasLibs -> windowsProgramFilesDir </> "Haskell"
| otherwise -> "$prefix"
_other -> "$prefix" </> "share",
datasubdir = "$pkgid",
docdir = case os of
Windows _ -> "$prefix" </> "doc" </> "$pkgid"
docdir = case buildOS of
Windows -> "$prefix" </> "doc" </> "$pkgid"
_other -> "$datadir" </> "doc" </> "$pkgid",
mandir = "$datadir" </> "man",
htmldir = "$docdir" </> "html",
......@@ -536,7 +537,7 @@ dropDrive (_:':':cs) | isWindows = cs
dropDrive cs = cs
isWindows :: Bool
isWindows = case os of
Windows _ -> True
_ -> False
isWindows = case buildOS of
Windows -> True
_ -> False
#endif
......@@ -71,6 +71,7 @@ import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, copyFileVerbose
, die, info, notice, setupMessage )
import Distribution.System
( OS(..), buildOS )
import System.FilePath ((</>), (<.>), isAbsolute)
import System.Directory (removeFile, getCurrentDirectory,
......@@ -84,14 +85,14 @@ import Data.Maybe (isNothing, isJust, fromJust, fromMaybe)
import Data.List (partition)
regScriptLocation :: FilePath
regScriptLocation = case os of
Windows _ -> "register.bat"
_ -> "register.sh"
regScriptLocation = case buildOS of
Windows -> "register.bat"
_ -> "register.sh"
unregScriptLocation :: FilePath
unregScriptLocation = case os of
Windows _ -> "unregister.bat"
_ -> "unregister.sh"
unregScriptLocation = case buildOS of
Windows -> "unregister.bat"
_ -> "unregister.sh"
-- -----------------------------------------------------------------------------
-- Registration
......@@ -104,7 +105,7 @@ register pkg_descr lbi regFlags
setupMessage (fromFlag $ regVerbose regFlags) "No package to register" (packageId pkg_descr)
return ()
| otherwise = do
let isWindows = case os of Windows _ -> True; _ -> False
let isWindows = case buildOS of Windows -> True; _ -> False
genScript = fromFlag (regGenScript regFlags)
genPkgConf = isJust (fromFlag (regGenPkgConf regFlags))
genPkgConfigDefault = showPackageId (packageId pkg_descr) <.> "conf"
......@@ -308,8 +309,8 @@ rawSystemEmit :: ConfiguredProgram -- ^Program to run
-> [String] -- ^Args
-> IO ()
rawSystemEmit prog scriptName extraArgs
= case os of
Windows _ ->
= case buildOS of
Windows ->
writeFile scriptName ("@" ++ path ++ concatMap (' ':) args)
_ -> do writeFile scriptName ("#!/bin/sh\n\n"
++ (path ++ concatMap (' ':) args)
......@@ -326,8 +327,8 @@ rawSystemPipe :: ConfiguredProgram
-> [String] -- ^Args
-> IO ()
rawSystemPipe prog scriptName pipeFrom extraArgs
= case os of
Windows _ ->
= case buildOS of
Windows ->
writeFile scriptName ("@" ++ path ++ concatMap (' ':) args)
_ -> do writeFile scriptName ("#!/bin/sh\n\n"
++ "echo '" ++ escapeForShell pipeFrom
......
module Distribution.System (
-- * Operating System
OS(..),
Windows(..),
showOS,
readOS,
os,
buildOS,
-- * Machine Architecture
Arch(..),
......@@ -20,23 +19,19 @@ import qualified Data.Char as Char (toLower)
-- * Operating System
-- ------------------------------------------------------------
data OS = Linux | Windows Windows | OSX
data OS = Linux | Windows | OSX
| FreeBSD | OpenBSD | NetBSD
| Solaris | AIX | HPUX | IRIX
| OtherOS String
deriving (Eq, Ord, Show, Read)
--TODO: eliminate Windows data type
data Windows = MingW
deriving (Eq, Ord, Show, Read)
knownOSs :: [OS]
knownOSs = [Linux, Windows MingW, OSX
knownOSs = [Linux, Windows, OSX
,FreeBSD, OpenBSD, NetBSD
,Solaris, AIX, HPUX, IRIX]
osAliases :: OS -> [String]
osAliases (Windows _) = ["mingw32", "cygwin32"]
osAliases Windows = ["mingw32", "cygwin32"]
osAliases OSX = ["darwin"]
osAliases FreeBSD = ["kfreebsdgnu"]
osAliases Solaris = ["solaris2"]
......@@ -49,16 +44,15 @@ showOS other = lowercase (show other)
readOS :: String -> OS
readOS s =
case lookup (lowercase s) osMap of
Just os' -> os'
Nothing -> OtherOS (lowercase s)
Just os -> os
Nothing -> OtherOS (lowercase s)
where
osMap = [ (name, os')
| os' <- knownOSs
, name <- showOS os' : osAliases os' ]
osMap = [ (name, os)
| os <- knownOSs
, name <- showOS os : osAliases os ]
--TODO: rename to buildOS and rename os' above to just os
os :: OS
os = readOS System.Info.os
buildOS :: OS
buildOS = readOS System.Info.os
-- ------------------------------------------------------------
-- * Machine Architecture
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment