Softened package structure rules when srcDir is not specified.
Fixes #469.
This commit is contained in:
parent
fb879efb72
commit
9f4081e888
6 changed files with 29 additions and 4 deletions
|
|
@ -286,6 +286,16 @@ proc inferInstallRules(pkgInfo: var PackageInfo, options: Options) =
|
|||
if installInstructions == 0 and pkgInfo.bin.len > 0:
|
||||
pkgInfo.skipExt.add("nim")
|
||||
|
||||
# When a package doesn't specify a `srcDir` it's fair to assume that
|
||||
# the .nim files are in the root of the package. So we can explicitly select
|
||||
# them and prevent the installation of anything else. The user can always
|
||||
# override this with `installFiles`.
|
||||
if pkgInfo.srcDir == "":
|
||||
if dirExists(pkgInfo.getRealDir() / pkgInfo.name):
|
||||
pkgInfo.installDirs.add(pkgInfo.name)
|
||||
if fileExists(pkgInfo.getRealDir() / pkgInfo.name.addFileExt("nim")):
|
||||
pkgInfo.installFiles.add(pkgInfo.name.addFileExt("nim"))
|
||||
|
||||
proc readPackageInfo(nf: NimbleFile, options: Options,
|
||||
onlyMinimalInfo=false): PackageInfo =
|
||||
## Reads package info from the specified Nimble file.
|
||||
|
|
@ -360,12 +370,12 @@ proc readPackageInfo(nf: NimbleFile, options: Options,
|
|||
if version.kind == verSpecial:
|
||||
result.specialVersion = minimalInfo.version
|
||||
|
||||
if not result.isMinimal:
|
||||
options.pkgInfoCache[nf] = result
|
||||
|
||||
# Apply rules to infer which files should/shouldn't be installed. See #469.
|
||||
inferInstallRules(result, options)
|
||||
|
||||
if not result.isMinimal:
|
||||
options.pkgInfoCache[nf] = result
|
||||
|
||||
# Validate the rest of the package info last.
|
||||
if not options.disableValidation:
|
||||
validateVersion(result.version)
|
||||
|
|
|
|||
0
tests/packageStructure/softened/myPkg.nim
Normal file
0
tests/packageStructure/softened/myPkg.nim
Normal file
15
tests/packageStructure/softened/myPkg.nimble
Normal file
15
tests/packageStructure/softened/myPkg.nimble
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Correctly structured package myPkg. See #469."
|
||||
license = "MIT"
|
||||
|
||||
# This is inferred implicitly by Nimble:
|
||||
# installDirs = @["myPkg"]
|
||||
# installFiles = @["myPkg.nim"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0"
|
||||
|
||||
0
tests/packageStructure/softened/myPkg/submodule.nim
Normal file
0
tests/packageStructure/softened/myPkg/submodule.nim
Normal file
0
tests/packageStructure/softened/tests/mytest.nim
Normal file
0
tests/packageStructure/softened/tests/mytest.nim
Normal file
|
|
@ -92,7 +92,7 @@ test "can build with #head and versioned package (#289)":
|
|||
|
||||
test "can validate package structure (#144)":
|
||||
# Test that no warnings are produced for correctly structured packages.
|
||||
for package in ["a", "b", "c", "validBinary"]:
|
||||
for package in ["a", "b", "c", "validBinary", "softened"]:
|
||||
cd "packageStructure/" & package:
|
||||
let (output, exitCode) = execNimble(["install", "-y"])
|
||||
check exitCode == QuitSuccess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue