Commit 46076a52 authored by Michael Hanus 's avatar Michael Hanus
Browse files

CPM updated

parent ecd19442
......@@ -7,7 +7,7 @@
module CPM.Config
( Config ( Config, packageInstallDir, binInstallDir, repositoryDir
, appPackageDir, packageIndexRepository, curryExec
, compilerVersion, baseVersion )
, compilerVersion, compilerBaseVersion, baseVersion )
, readConfigurationWith, defaultConfig
, showConfiguration, showCompilerVersion ) where
......@@ -50,6 +50,8 @@ data Config = Config {
--- The compiler version (name,major,minor) used to compile packages
, compilerVersion :: (String,Int,Int)
--- The version of the base libraries used by the compiler
, compilerBaseVersion :: String
--- The version of the base libraries to be used for package installations
, baseVersion :: String
}
......@@ -66,20 +68,22 @@ defaultConfig = Config
, compilerVersion = ( Dist.curryCompiler
, Dist.curryCompilerMajorVersion
, Dist.curryCompilerMinorVersion )
, baseVersion = Dist.baseVersion
, compilerBaseVersion = Dist.baseVersion
, baseVersion = ""
}
--- Shows the configuration.
showConfiguration :: Config -> String
showConfiguration cfg = unlines
[ "Current configuration:"
, "Compiler version : " ++ showCompilerVersion cfg
, "Base version : " ++ baseVersion cfg
, "CURRYBIN : " ++ curryExec cfg
, "REPOSITORYPATH : " ++ repositoryDir cfg
, "PACKAGEINSTALLPATH: " ++ packageInstallDir cfg
, "BININSTALLPATH : " ++ binInstallDir cfg
, "APPPACKAGEPATH : " ++ appPackageDir cfg
, "Compiler version : " ++ showCompilerVersion cfg
, "Compiler base version : " ++ compilerBaseVersion cfg
, "Base version : " ++ baseVersion cfg
, "CURRYBIN : " ++ curryExec cfg
, "REPOSITORYPATH : " ++ repositoryDir cfg
, "PACKAGEINSTALLPATH : " ++ packageInstallDir cfg
, "BININSTALLPATH : " ++ binInstallDir cfg
, "APPPACKAGEPATH : " ++ appPackageDir cfg
]
--- Shows the compiler version in the configuration.
......@@ -108,9 +112,13 @@ setCompilerExecutable cfg = do
setCompilerVersion :: Config -> IO Config
setCompilerVersion cfg0 = do
cfg <- setCompilerExecutable cfg0
let initbase = baseVersion cfg
if curryExec cfg == Dist.installDir </> "bin" </> Dist.curryCompiler
then return cfg { compilerVersion = currVersion
, baseVersion = Dist.baseVersion }
, compilerBaseVersion = Dist.baseVersion
, baseVersion = if null initbase
then Dist.baseVersion
else initbase }
else do (c1,sname,e1) <- evalCmd (curryExec cfg) ["--compiler-name"] ""
(c2,svers,e2) <- evalCmd (curryExec cfg) ["--numeric-version"] ""
(c3,sbver,e3) <- evalCmd (curryExec cfg) ["--base-version"] ""
......@@ -124,7 +132,10 @@ setCompilerVersion cfg0 = do
debugMessage $ "Compiler version: " ++ cname ++ " " ++ cvers
debugMessage $ "Base lib version: " ++ bvers
return cfg { compilerVersion = (cname, readInt majs, readInt mins)
, baseVersion = bvers }
, compilerBaseVersion = bvers
, baseVersion = if null initbase
then bvers
else initbase }
where
currVersion = (Dist.curryCompiler, Dist.curryCompilerMajorVersion,
Dist.curryCompilerMinorVersion)
......@@ -201,6 +212,7 @@ keySetters =
, ("BININSTALLPATH" , \v c -> c { binInstallDir = v })
, ("APPPACKAGEPATH" , \v c -> c { appPackageDir = v })
, ("CURRYBIN" , \v c -> c { curryExec = v })
, ("BASEVERSION" , \v c -> c { baseVersion = v })
]
--- Sequentially applies a list of functions that transform a value to a value
......
......@@ -49,7 +49,7 @@ cpmBanner :: String
cpmBanner = unlines [bannerLine,bannerText,bannerLine]
where
bannerText =
"Curry Package Manager <curry-language.org/tools/cpm> (version of 14/11/2017)"
"Curry Package Manager <curry-language.org/tools/cpm> (version of 28/11/2017)"
bannerLine = take (length bannerText) (repeat '-')
main :: IO ()
......@@ -1353,11 +1353,16 @@ computePackageLoadPath cfg pkgdir getRepoGC =
debugMessage "Computing load path for package..." >>
getRepoGC >>= \ (repo,gc) ->
loadPackageSpec pkgdir |>= \pkg ->
resolveAndCopyDependenciesForPackage cfg repo gc pkgdir pkg |>= \pkgs ->
resolveAndCopyDependenciesForPackage cfg repo gc pkgdir pkg |>= \allpkgs ->
getAbsolutePath pkgdir >>= \abs -> succeedIO () |>
let srcdirs = map (abs </>) (sourceDirsOf pkg)
-- remove 'base' package if it is the same as in current config:
pkgs = filter notCurrentBase allpkgs
currypath = joinSearchPath (srcdirs ++ dependencyPathsSeparate pkgs abs)
in saveCurryPathToCache cfg pkgdir currypath >> succeedIO currypath
where
notCurrentBase pkg = name pkg /= "base" ||
showVersion (version pkg) /= compilerBaseVersion cfg
-- Clean auxiliary files in the current package
cleanPackage :: LogLevel -> IO (ErrorLogger ())
......@@ -1443,7 +1448,7 @@ compatPackageNotFoundFailure cfg pkgname helpcmt =
-- The file `.cpm/CURRYPATH_CACHE` contains the following lines:
-- * The CURRYPATH used to load the package
-- * The compiler name and major/minor version
-- * The version of the base libraries
-- * The version of the base libraries required during package install
--- The name of the cache file in a package directory.
curryPathCacheFile :: String -> String
......
......@@ -43,6 +43,7 @@ import CPM.Package ( Package (..)
, readPackageSpec, packageId, readVersion, Version
, showVersion, PackageSource (..), showDependency
, showCompilerDependency, showPackageSource
, VersionConstraint (..)
, Dependency (..), GitRevision (..), PackageExecutable (..)
, PackageTest (..), PackageDocumentation (..)
, packageIdEq, loadPackageSpec)
......@@ -54,7 +55,7 @@ resolveDependenciesForPackageCopy :: Config -> Package -> Repository
-> IO (ErrorLogger ResolutionResult)
resolveDependenciesForPackageCopy cfg pkg repo gc dir =
lookupSetForPackageCopy cfg pkg repo gc dir |>= \lookupSet ->
resolveDependenciesFromLookupSet cfg (deleteBaseDependency cfg pkg) lookupSet
resolveDependenciesFromLookupSet cfg (setBaseDependency cfg pkg) lookupSet
--- Calculates the lookup set needed for dependency resolution on a package
--- copy.
......@@ -86,7 +87,7 @@ resolveDependenciesForPackage :: Config -> Package -> Repository
-> GC.GlobalCache
-> IO (ErrorLogger ResolutionResult)
resolveDependenciesForPackage cfg pkg repo gc =
resolveDependenciesFromLookupSet cfg (deleteBaseDependency cfg pkg) lookupSet
resolveDependenciesFromLookupSet cfg (setBaseDependency cfg pkg) lookupSet
where
lsRepo = addPackagesWOBase cfg LS.emptySet (allPackages repo)
LS.FromRepository
......@@ -135,7 +136,7 @@ upgradeSinglePackage :: Config -> Repository -> GC.GlobalCache -> String
upgradeSinglePackage cfg repo gc dir pkgName = loadPackageSpec dir |>=
\pkgSpec -> lookupSetForPackageCopy cfg pkgSpec repo gc dir |>=
\originalLS -> let transitiveDeps = pkgName : allTransitiveDependencies originalLS pkgName in
resolveDependenciesFromLookupSet cfg (deleteBaseDependency cfg pkgSpec)
resolveDependenciesFromLookupSet cfg (setBaseDependency cfg pkgSpec)
(LS.setLocallyIgnored originalLS transitiveDeps) |>=
\result -> GC.installMissingDependencies cfg gc (resolvedPackages result) |>
log Info (showDependencies result) |>
......@@ -201,10 +202,10 @@ resolveAndCopyDependenciesForPackage cfg repo gc dir pkgSpec =
failMsg = "Missing dependencies "
++ (intercalate "," $ map packageId missingDeps)
++ "\nUse `cypm install` to install missing dependencies."
in if length missingDeps > 0
then failIO failMsg
else copyDependencies cfg gc pkgSpec deps dir |>= \_ ->
in if null missingDeps
then copyDependencies cfg gc pkgSpec deps dir |>= \_ ->
succeedIO deps
else failIO failMsg
--- Resolves the dependencies for a package copy.
resolveDependencies :: Config -> Repository -> GC.GlobalCache -> String
......@@ -341,22 +342,25 @@ renderPackageInfo allinfos plain mbinstalled pkg = pPrint doc
indent 4 (fillSep (map text (words s)))
------------------------------------------------------------------------------
--- Deletes `base` package dependency in a package if this dependency
--- is compatible with the base package of the current compiler.
deleteBaseDependency :: Config -> Package -> Package
deleteBaseDependency cfg pkg =
pkg { dependencies = filter (not . isCompatBase) (dependencies pkg) }
--- Sets `base` package dependency in a package to the current `baseVersion`
--- if this dependency is compatible with the current `baseVersion`.
--- Hence, a conflict occurs if some package requires a different version
--- of the `base` package.
setBaseDependency :: Config -> Package -> Package
setBaseDependency cfg pkg =
pkg { dependencies = map setBase (dependencies pkg) }
where
isCompatBase (Dependency n disj) =
n=="base" &&
maybe False
(\bv -> isDisjunctionCompatible bv disj)
(readVersion (baseVersion cfg))
--- Same as `LS.addPackages` but remove `base` package dependencies.
bv = maybe (0,0,0,Nothing) id (readVersion (baseVersion cfg))
setBase (Dependency n disj) =
Dependency n $ if n == "base" && isDisjunctionCompatible bv disj
then [[VExact bv]]
else disj
--- Same as `LS.addPackages` but set the `base` package dependency.
addPackagesWOBase :: Config -> LS.LookupSet -> [Package] -> LS.LookupSource
-> LS.LookupSet
addPackagesWOBase cfg ls pkgs src =
LS.addPackages ls (map (deleteBaseDependency cfg) pkgs) src
LS.addPackages ls (map (setBaseDependency cfg) pkgs) src
------------------------------------------------------------------------------
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