Switch to cli in processDeps.

This commit is contained in:
Dominik Picheta 2016-12-20 22:46:07 +01:00
commit 3791f8a09a
2 changed files with 13 additions and 7 deletions

View file

@ -274,24 +274,30 @@ proc processDeps(pkginfo: PackageInfo, options: Options): seq[string] =
## Returns the list of paths to pass to the compiler during build phase. ## Returns the list of paths to pass to the compiler during build phase.
result = @[] result = @[]
assert(not pkginfo.isMinimal, "processDeps needs pkginfo.requires") assert(not pkginfo.isMinimal, "processDeps needs pkginfo.requires")
display("Verifying",
"dependencies for $1 v$2" % [pkginfo.name, pkginfo.version],
priority = HighPriority)
let pkglist = getInstalledPkgs(options.getPkgsDir(), options) let pkglist = getInstalledPkgs(options.getPkgsDir(), options)
var reverseDeps: seq[tuple[name, version: string]] = @[] var reverseDeps: seq[tuple[name, version: string]] = @[]
for dep in pkginfo.requires: for dep in pkginfo.requires:
if dep.name == "nimrod" or dep.name == "nim": if dep.name == "nimrod" or dep.name == "nim":
let nimVer = getNimrodVersion() let nimVer = getNimrodVersion()
if not withinRange(nimVer, dep.ver): if not withinRange(nimVer, dep.ver):
quit("Unsatisfied dependency: " & dep.name & " (" & $dep.ver & ")") let msg = "Unsatisfied dependency: " & dep.name & " (" & $dep.ver & ")"
raise newException(NimbleError, msg)
else: else:
echo("Looking for ", dep.name, " (", $dep.ver, ")...") let depDesc = "$1 ($2)" % [dep.name, $dep.ver]
display("Checking", "for $1" % depDesc, priority = MediumPriority)
var pkg: PackageInfo var pkg: PackageInfo
if not findPkg(pkglist, dep, pkg): if not findPkg(pkglist, dep, pkg):
echo("None found, installing...") display("Installing", depDesc, priority = HighPriority)
let (paths, installedPkg) = install(@[(dep.name, dep.ver)], options) let (paths, installedPkg) = install(@[(dep.name, dep.ver)], options)
result.add(paths) result.add(paths)
pkg = installedPkg # For addRevDep pkg = installedPkg # For addRevDep
else: else:
echo("Dependency already satisfied.") display("Info", "Dependency already satisfied", priority = HighPriority)
result.add(pkg.mypath.splitFile.dir) result.add(pkg.mypath.splitFile.dir)
# Process the dependencies of this dependency. # Process the dependencies of this dependency.
result.add(processDeps(pkg, options)) result.add(processDeps(pkg, options))

View file

@ -3,7 +3,7 @@
# #
# Various miscellaneous utility functions reside here. # Various miscellaneous utility functions reside here.
import osproc, pegs, strutils, os, uri, sets, json, parseutils import osproc, pegs, strutils, os, uri, sets, json, parseutils
import version, common import version, common, cli
proc extractBin(cmd: string): string = proc extractBin(cmd: string): string =
if cmd[0] == '"': if cmd[0] == '"':
@ -75,14 +75,14 @@ proc changeRoot*(origRoot, newRoot, path: string): string =
proc copyFileD*(fro, to: string): string = proc copyFileD*(fro, to: string): string =
## Returns the destination (``to``). ## Returns the destination (``to``).
echo(fro, " -> ", to) display("Copying", "file $# to $#" % [fro, to], priority = LowPriority)
copyFileWithPermissions(fro, to) copyFileWithPermissions(fro, to)
result = to result = to
proc copyDirD*(fro, to: string): seq[string] = proc copyDirD*(fro, to: string): seq[string] =
## Returns the filenames of the files in the directory that were copied. ## Returns the filenames of the files in the directory that were copied.
result = @[] result = @[]
echo("Copying directory: ", fro, " -> ", to) display("Copying", "directory $# to $#" % [fro, to], priority = LowPriority)
for path in walkDirRec(fro): for path in walkDirRec(fro):
createDir(changeRoot(fro, to, path.splitFile.dir)) createDir(changeRoot(fro, to, path.splitFile.dir))
result.add copyFileD(path, changeRoot(fro, to, path)) result.add copyFileD(path, changeRoot(fro, to, path))