Simplify implementation of path for Nimble links.
This commit is contained in:
parent
596d17804f
commit
a02a1431e2
2 changed files with 10 additions and 22 deletions
|
|
@ -615,28 +615,13 @@ proc listPaths(options: Options) =
|
|||
if kind != pcDir or not path.startsWith(options.getPkgsDir / name):
|
||||
continue
|
||||
|
||||
var nimbleFile = path / name.addFileExt("nimble")
|
||||
var nimbleLinkTargetPath: string
|
||||
if not nimbleFile.existsFile:
|
||||
let nimbleLinkFile = path / name.addFileExt("nimble-link")
|
||||
if fileExists(nimbleLinkFile):
|
||||
let lnk = readNimbleLink(nimbleLinkFile)
|
||||
nimbleFile = lnk.nimbleFilePath
|
||||
nimbleLinkTargetPath = lnk.packageDir
|
||||
|
||||
var nimbleFile = findNimbleFile(path, false)
|
||||
if nimbleFile.existsFile:
|
||||
var pkgInfo = getPkgInfo(path, options)
|
||||
var v: VersionAndPath
|
||||
v.version = newVersion(pkgInfo.specialVersion)
|
||||
if nimbleLinkTargetPath.len == 0:
|
||||
v.path = options.getPkgsDir / (pkgInfo.name & '-' & pkgInfo.specialVersion)
|
||||
installed.add(v)
|
||||
else:
|
||||
# If we have a nimble-developed package, this is really the path we're
|
||||
# looking for.
|
||||
v.path = nimbleLinkTargetPath
|
||||
installed = @[v]
|
||||
break
|
||||
v.path = pkgInfo.getRealDir()
|
||||
installed = @[v]
|
||||
else:
|
||||
display("Warning:", "No .nimble file found for " & path, Warning,
|
||||
MediumPriority)
|
||||
|
|
@ -878,8 +863,11 @@ proc developFromDir(dir: string, options: Options) =
|
|||
# `nimble develop` if they change their `srcDir` but I think it's a worthy
|
||||
# compromise.
|
||||
let nimbleLinkPath = pkgDestDir / pkgInfo.name.addFileExt("nimble-link")
|
||||
writeNimbleLink(nimbleLinkPath,
|
||||
NimbleLink(nimbleFilePath: pkgInfo.myPath, packageDir: pkgInfo.getRealDir()))
|
||||
let nimbleLink = NimbleLink(
|
||||
nimbleFilePath: pkgInfo.myPath,
|
||||
packageDir: pkgInfo.getRealDir()
|
||||
)
|
||||
writeNimbleLink(nimbleLinkPath, nimbleLink)
|
||||
|
||||
# Save a nimblemeta.json file.
|
||||
saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir),
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ const path = "../src/nimble"
|
|||
removeDir(installDir)
|
||||
createDir(installDir)
|
||||
|
||||
test "can compile nimble":
|
||||
check execCmdEx("nim c " & path).exitCode == QuitSuccess
|
||||
# Always recompile.
|
||||
doAssert execCmdEx("nim c " & path).exitCode == QuitSuccess
|
||||
|
||||
test "can compile with --os:windows":
|
||||
check execCmdEx("nim check --os:windows " & path).exitCode == QuitSuccess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue