Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
curry-tools
Commits
dd94d576
Commit
dd94d576
authored
Nov 13, 2017
by
Michael Hanus
Browse files
CPM updated
parent
5ddf47dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
cpm/src/CPM/Config.curry
View file @
dd94d576
...
...
@@ -7,14 +7,13 @@
module CPM.Config
( Config ( Config, packageInstallDir, binInstallDir, repositoryDir
, appPackageDir, packageIndexRepository, curryExec
, compilerVersion )
, compilerVersion
, baseVersion
)
, readConfigurationWith, defaultConfig
, showConfiguration, showCompilerVersion ) where
import Char ( toUpper )
import Directory ( getHomeDirectory, createDirectoryIfMissing )
import Distribution ( installDir, curryCompiler, curryCompilerMinorVersion
, curryCompilerMajorVersion )
import qualified Distribution as Dist
import FilePath ( (</>), isAbsolute )
import Function ( (***) )
import IOExts ( evalCmd )
...
...
@@ -50,6 +49,8 @@ data Config = Config {
, curryExec :: String
--- The compiler version (name,major,minor) used to compile packages
, compilerVersion :: (String,Int,Int)
--- The version of the base libraries used by the compiler
, baseVersion :: String
}
--- CPM's default configuration values. These are used if no .cpmrc file is found
...
...
@@ -61,9 +62,11 @@ defaultConfig = Config
, repositoryDir = "$HOME/.cpm/index"
, appPackageDir = "$HOME/.cpm/app_packages"
, packageIndexRepository = packageIndexURI
, curryExec = installDir </> "bin" </> curryCompiler
, compilerVersion = (curryCompiler, curryCompilerMajorVersion,
curryCompilerMinorVersion)
, curryExec = Dist.installDir </> "bin" </> Dist.curryCompiler
, compilerVersion = ( Dist.curryCompiler
, Dist.curryCompilerMajorVersion
, Dist.curryCompilerMinorVersion )
, baseVersion = Dist.baseVersion
}
--- Shows the configuration.
...
...
@@ -71,11 +74,12 @@ showConfiguration :: Config -> String
showConfiguration cfg = unlines
[ "Current configuration:"
, "Compiler version : " ++ showCompilerVersion cfg
, "CURRYBIN : " ++ curryExec cfg
, "REPOSITORYPATH : " ++ repositoryDir cfg
, "PACKAGEINSTALLPATH: " ++ packageInstallDir cfg
, "BININSTALLPATH : " ++ binInstallDir cfg
, "APPPACKAGEPATH : " ++ appPackageDir 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.
...
...
@@ -104,21 +108,26 @@ setCompilerExecutable cfg = do
setCompilerVersion :: Config -> IO Config
setCompilerVersion cfg0 = do
cfg <- setCompilerExecutable cfg0
if curryExec cfg == installDir </> "bin" </> curryCompiler
then return cfg { compilerVersion = currVersion }
if curryExec cfg == Dist.installDir </> "bin" </> Dist.curryCompiler
then return cfg { compilerVersion = currVersion
, baseVersion = Dist.baseVersion }
else do (c1,sname,e1) <- evalCmd (curryExec cfg) ["--compiler-name"] ""
(c2,svers,e2) <- evalCmd (curryExec cfg) ["--numeric-version"] ""
when (c1 > 0 || c2 > 0) $
(c3,sbver,e3) <- evalCmd (curryExec cfg) ["--base-version"] ""
when (c1 > 0 || c2 > 0 || c3 > 0) $
error $ "Cannot determine compiler version:\n" ++
unlines (filter (not . null) [e1,e2])
unlines (filter (not . null) [e1,e2
,e3
])
let cname = strip sname
cvers = strip svers
bvers = strip sbver
(majs:mins:_) = split (=='.') cvers
debugMessage $ "Compiler version: " ++ cname ++ " " ++ cvers
return cfg { compilerVersion = (cname, readInt majs, readInt mins) }
debugMessage $ "Base lib version: " ++ bvers
return cfg { compilerVersion = (cname, readInt majs, readInt mins)
, baseVersion = bvers }
where
currVersion = (curryCompiler, curryCompilerMajorVersion,
curryCompilerMinorVersion)
currVersion = (
Dist.
curryCompiler,
Dist.
curryCompilerMajorVersion,
Dist.
curryCompilerMinorVersion)
--- Reads the .cpmrc file from the user's home directory (if present) and
--- merges its contents and some given default settings (first argument)
...
...
cpm/src/CPM/Main.curry
View file @
dd94d576
...
...
@@ -49,7 +49,7 @@ cpmBanner :: String
cpmBanner = unlines [bannerLine,bannerText,bannerLine]
where
bannerText =
"Curry Package Manager <curry-language.org/tools/cpm> (version of
09
/11/2017)"
"Curry Package Manager <curry-language.org/tools/cpm> (version of
13
/11/2017)"
bannerLine = take (length bannerText) (repeat '-')
main :: IO ()
...
...
@@ -694,7 +694,7 @@ depsCmd opts cfg getRepoGC =
loadPackageSpec specDir |>= \pkg ->
checkCompiler cfg pkg >>
if depsPath opts -- show CURRYPATH only?
then loadCurryPathFromCache specDir |>=
then loadCurryPathFromCache
cfg
specDir |>=
maybe (computePackageLoadPath cfg specDir getRepoGC)
succeedIO |>= \currypath ->
putStrLn currypath >> succeedIO ()
...
...
@@ -1330,7 +1330,7 @@ execCmd o cfg getRepoGC =
execWithPkgDir :: ExecOptions -> Config -> IO (Repository,GlobalCache)
-> String -> IO (ErrorLogger ())
execWithPkgDir o cfg getRepoGC specDir =
loadCurryPathFromCache specDir |>=
loadCurryPathFromCache
cfg
specDir |>=
maybe (computePackageLoadPath cfg specDir getRepoGC)
succeedIO |>= \currypath ->
log Debug ("Setting CURRYPATH to " ++ currypath) |>
...
...
@@ -1343,14 +1343,19 @@ execWithPkgDir o cfg getRepoGC specDir =
computePackageLoadPath :: Config -> String -> IO (Repository,GlobalCache)
-> IO (ErrorLogger String)
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 |>= \
all
pkgs ->
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 pkgdir currypath >> succeedIO currypath
in saveCurryPathToCache cfg pkgdir currypath >> succeedIO currypath
where
notCurrentBase pkg = name pkg /= "base" ||
showVersion (version pkg) /= baseVersion cfg
-- Clean auxiliary files in the current package
cleanPackage :: LogLevel -> IO (ErrorLogger ())
...
...
@@ -1419,23 +1424,28 @@ newPackage (NewOptions pname) = do
---------------------------------------------------------------------------
-- Caching the current CURRYPATH of a package for faster startup.
-- 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 name of the cache file in a package directory.
curryPathCacheFile :: String -> String
curryPathCacheFile pkgdir = pkgdir </> ".cpm" </> "CURRYPATH_CACHE"
--- Saves package CURRYPATH in local cache file in the given package dir.
saveCurryPathToCache :: String -> String -> IO ()
saveCurryPathToCache pkgdir path = do
saveCurryPathToCache ::
Config ->
String -> String -> IO ()
saveCurryPathToCache
cfg
pkgdir path = do
let cpmdir = pkgdir </> ".cpm"
createDirectoryIfMissing False cpmdir
writeFile (curryPathCacheFile pkgdir) (path ++ "\n")
writeFile (curryPathCacheFile pkgdir)
(unlines [path, showCompilerVersion cfg, baseVersion cfg])
--- Restores package CURRYPATH from local cache file in the given package dir,
--- if it is still up-to-date, i.e., it exists and is newer than the package
--- specification.
loadCurryPathFromCache :: String -> IO (ErrorLogger (Maybe String))
loadCurryPathFromCache pkgdir = do
loadCurryPathFromCache ::
Config ->
String -> IO (ErrorLogger (Maybe String))
loadCurryPathFromCache
cfg
pkgdir = do
let cachefile = curryPathCacheFile pkgdir
excache <- doesFileExist cachefile
if excache
...
...
@@ -1445,10 +1455,14 @@ loadCurryPathFromCache pkgdir = do
if cftime > pftime
then do cnt <- safeReadFile cachefile
let ls = either (const []) lines cnt
succeedIO $ if
null ls then Nothing
else Just (head ls)
succeedIO $ if
consistentCache ls then Just (head ls)
else Nothing
else succeedIO Nothing
else succeedIO Nothing
where
consistentCache cls =
length cls > 2 && cls!!1 == showCompilerVersion cfg
&& cls!!2 == baseVersion cfg
--- Cleans the local cache file for CURRYPATH. This might be necessary
--- for upgrade/install/link commands.
...
...
cpm/vendor/abstract-curry/src/AbstractCurry/Files.curry
View file @
dd94d576
...
...
@@ -6,8 +6,8 @@
--- Assumption: an abstract Curry program is stored in file with
--- extension `.acy` in the subdirectory `.curry`
---
--- @author Michael Hanus, Bjoern Peemoeller
--- @version
Octo
ber 201
6
--- @author Michael Hanus, Bjoern Peemoeller
, Jan Tikovsky
--- @version
Novem
ber 201
7
--- @category meta
-- ---------------------------------------------------------------------------
...
...
@@ -15,7 +15,7 @@ module AbstractCurry.Files where
import AbstractCurry.Select (imports)
import AbstractCurry.Types
import Char (isSpace)
import Char (isSpace
, toUpper
)
import Directory (doesFileExist, getModificationTime)
import Distribution
import FileGoodies (getFileInPath, lookupFileInPath)
...
...
@@ -30,7 +30,7 @@ import ReadShowTerm
--- or ".lcurry") and the result is a Curry term representing this
--- program.
readCurry :: String -> IO CurryProg
readCurry prog = readCurryWithParseOptions prog
(setQuiet True default
Params
)
readCurry prog = readCurryWithParseOptions prog
cc
Params
--- Read an AbstractCurry file with all its imports.
--- @param modname - Module name or file name of Curry module
...
...
@@ -66,7 +66,7 @@ tryReadCurryFile m = do
case mbSrc of
Nothing -> cancel $ "Source module '" ++ m ++ "' not found"
Just (_,srcFile) -> do
callFrontendWithParams ACY
(setQuiet True default
Params
)
m
callFrontendWithParams ACY
cc
Params m
mbFn <- getLoadPathForModule m >>=
lookupFileInPath (abstractCurryFileName m) [""]
case mbFn of
...
...
@@ -116,7 +116,7 @@ tryParse fn = do
--- the function declaration contains the type `(CTCons ("Prelude","untyped")`.
readUntypedCurry :: String -> IO CurryProg
readUntypedCurry prog =
readUntypedCurryWithParseOptions prog
(setQuiet True default
Params
)
readUntypedCurryWithParseOptions prog
cc
Params
--- I/O action which reads a typed Curry program from a file (with extension
--- ".acy") with respect to some parser options.
...
...
@@ -234,4 +234,11 @@ tryReadACYFile fn = do
writeAbstractCurryFile :: String -> CurryProg -> IO ()
writeAbstractCurryFile file prog = writeFile file (showTerm prog)
--- frontend params (quiet and definition for conditional compiling set)
ccParams :: FrontendParams
ccParams = setQuiet True $ setDefinitions defs defaultParams
where
defs = [( "__" ++ map toUpper curryCompiler ++ "__"
, curryCompilerMajorVersion * 100 + curryCompilerMinorVersion )]
------------------------------------------------------------------------------
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment