Skip to content

Commit

Permalink
Various changed needed by hackage/cabal-get.
Browse files Browse the repository at this point in the history
* Exporting Distribution.Compat.FilePath and Distribution.GetOpt.
  I'm using GetOpt from Cabal 'cause I fixed a bug in it which I haven't commited to CVS yet.
In Distribution.Simple.Config:
* Made 'getInstalledPackagesAux' and 'configCompilerAux' which aren't using ConfigFlags
  since cabal-get defines it own ConfigFlags.
* Changed 'configCompilerVersion' to take a verbose argument instead of a ConfigFlags.
* Exported those functions.
  • Loading branch information
lemmih committed Apr 21, 2005
1 parent 23ca704 commit f62b5eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Cabal.cabal
Expand Up @@ -38,11 +38,11 @@ Exposed-Modules:
Distribution.Simple.Register,
Distribution.Simple.SrcDist,
Distribution.Simple.Utils,
Distribution.Compat.FilePath,
Distribution.GetOpt,
Distribution.Version
Other-Modules:
Distribution.GetOpt,
Distribution.Compat.Directory,
Distribution.Compat.Exception,
Distribution.Compat.FilePath,
Distribution.Compat.RawSystem
Extensions: CPP
37 changes: 14 additions & 23 deletions Distribution/Simple/Configure.hs
Expand Up @@ -223,16 +223,13 @@ configDependency ps (Dependency pkgname vrange) = do
": using " ++ showPackageId pkg)
return pkg

getInstalledPackagesAux :: Compiler -> ConfigFlags -> IO [PackageIdentifier]
getInstalledPackagesAux comp cfg = getInstalledPackages comp (configUser cfg) (configVerbose cfg)

getInstalledPackages :: Compiler -> Bool -> Int -> IO [PackageIdentifier]
getInstalledPackages comp user verbose = do
when (verbose > 0) $ message "Reading installed packages..."
getInstalledPackages :: Compiler -> ConfigFlags -> IO [PackageIdentifier]
getInstalledPackages comp cfg = do
message "Reading installed packages..."
withTempFile "." "" $ \tmp -> do
let user_flag = if user then " --user" else " --global"
let user_flag = if configUser cfg then " --user" else " --global"
cmd_line = compilerPkgTool comp ++ user_flag ++ " list >" ++ tmp
when (verbose > 0) $
when (configVerbose cfg > 0) $
putStrLn cmd_line
res <- system cmd_line
case res of
Expand Down Expand Up @@ -274,26 +271,20 @@ system_default_prefix _ =
-- -----------------------------------------------------------------------------
-- Determining the compiler details

configCompilerAux :: ConfigFlags -> IO Compiler
configCompilerAux cfg = configCompiler (configHcFlavor cfg)
(configHcPath cfg)
(configHcPkg cfg)
(configVerbose cfg)

configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> Maybe FilePath -> Int -> IO Compiler
configCompiler hcFlavor hcPath hcPkg verbose
= do let flavor = case hcFlavor of
configCompiler :: ConfigFlags -> IO Compiler
configCompiler cfg
= do let flavor = case configHcFlavor cfg of
Just f -> f
Nothing -> defaultCompilerFlavor
comp <-
case hcPath of
case configHcPath cfg of
Just path -> return path
Nothing -> findCompiler verbose flavor

ver <- configCompilerVersion flavor comp verbose
ver <- configCompilerVersion flavor comp cfg

pkgtool <-
case hcPkg of
case configHcPkg cfg of
Just path -> return path
Nothing -> guessPkgToolFromHCPath verbose flavor comp

Expand Down Expand Up @@ -337,11 +328,11 @@ compilerPkgToolName NHC = "hmake" -- FIX: nhc98-pkg Does not yet exist
compilerPkgToolName Hugs = "hugs" -- FIX (HUGS): hugs-pkg does not yet exist
compilerPkgToolName cmp = error $ "Unsupported compiler: " ++ (show cmp)

configCompilerVersion :: CompilerFlavor -> FilePath -> Int -> IO Version
configCompilerVersion GHC compilerP verbose =
configCompilerVersion :: CompilerFlavor -> FilePath -> ConfigFlags -> IO Version
configCompilerVersion GHC compilerP cfg =
withTempFile "." "" $ \tmp -> do
let cmd_line = compilerP ++ " --version >" ++ tmp
when (verbose > 0) $
when (configVerbose cfg > 0) $
putStrLn cmd_line
maybeExit $ system cmd_line
str <- readFile tmp
Expand Down

0 comments on commit f62b5eb

Please sign in to comment.