Implement .nimble-link files in the compiler and add tests for them.
This commit is contained in:
parent
9b465a2361
commit
90fa64501f
6 changed files with 29 additions and 4 deletions
|
|
@ -77,9 +77,20 @@ iterator chosen(packages: StringTableRef): string =
|
||||||
yield res
|
yield res
|
||||||
|
|
||||||
proc addNimblePath(p: string, info: TLineInfo) =
|
proc addNimblePath(p: string, info: TLineInfo) =
|
||||||
if not contains(options.searchPaths, p):
|
var path = p
|
||||||
message(info, hintPath, p)
|
let nimbleLinks = toSeq(walkPattern(p / "*.nimble-link"))
|
||||||
options.lazyPaths.insert(p, 0)
|
if nimbleLinks.len > 0:
|
||||||
|
# If the user has more than one .nimble-link file then... we just ignore it.
|
||||||
|
# Spec for these files is available in Nimble's readme:
|
||||||
|
# https://github.com/nim-lang/nimble#nimble-link
|
||||||
|
let nimbleLinkLines = readFile(nimbleLinks[0]).splitLines()
|
||||||
|
path = nimbleLinkLines[1]
|
||||||
|
if not path.isAbsolute():
|
||||||
|
path = p / path
|
||||||
|
|
||||||
|
if not contains(options.searchPaths, path):
|
||||||
|
message(info, hintPath, path)
|
||||||
|
options.lazyPaths.insert(path, 0)
|
||||||
|
|
||||||
proc addPathRec(dir: string, info: TLineInfo) =
|
proc addPathRec(dir: string, info: TLineInfo) =
|
||||||
var packages = newStringTable(modeStyleInsensitive)
|
var packages = newStringTable(modeStyleInsensitive)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
../../simplePkgs/pkgA-0.1.0/pkgA.nimble
|
||||||
|
../../simplePkgs/pkgA-0.1.0/
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
../../simplePkgs/pkgB-#head/pkgB.nimble
|
||||||
|
../../simplePkgs/pkgB-#head/
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
../../simplePkgs/pkgB-0.1.0/pkgB.nimble
|
||||||
|
../../simplePkgs/pkgB-0.1.0/
|
||||||
9
tests/nimble/tnimblepathlink.nim
Normal file
9
tests/nimble/tnimblepathlink.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
discard """
|
||||||
|
action: run
|
||||||
|
cmd: "nim $target --nimblePath:$fileDir/nimbleDir/linkedPkgs $options $file"
|
||||||
|
"""
|
||||||
|
import pkgA/module as A
|
||||||
|
import pkgB/module as B
|
||||||
|
|
||||||
|
doAssert pkgATest() == 1, "Simple linked pkgA-0.1.0 wasn't added to path correctly."
|
||||||
|
doAssert pkgBTest() == 0xDEADBEEF, "linked pkgB-#head wasn't picked over pkgB-0.1.0"
|
||||||
|
|
@ -80,7 +80,6 @@ proc callCompiler(cmdTemplate, filename, options: string,
|
||||||
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||||
"options", options, "file", filename.quoteShell,
|
"options", options, "file", filename.quoteShell,
|
||||||
"filedir", filename.getFileDir()])
|
"filedir", filename.getFileDir()])
|
||||||
echo(c)
|
|
||||||
var p = startProcess(command=c[0], args=c[1.. ^1],
|
var p = startProcess(command=c[0], args=c[1.. ^1],
|
||||||
options={poStdErrToStdOut, poUsePath})
|
options={poStdErrToStdOut, poUsePath})
|
||||||
let outp = p.outputStream
|
let outp = p.outputStream
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue