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:
|
if installInstructions == 0 and pkgInfo.bin.len > 0:
|
||||||
pkgInfo.skipExt.add("nim")
|
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,
|
proc readPackageInfo(nf: NimbleFile, options: Options,
|
||||||
onlyMinimalInfo=false): PackageInfo =
|
onlyMinimalInfo=false): PackageInfo =
|
||||||
## Reads package info from the specified Nimble file.
|
## Reads package info from the specified Nimble file.
|
||||||
|
|
@ -360,12 +370,12 @@ proc readPackageInfo(nf: NimbleFile, options: Options,
|
||||||
if version.kind == verSpecial:
|
if version.kind == verSpecial:
|
||||||
result.specialVersion = minimalInfo.version
|
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.
|
# Apply rules to infer which files should/shouldn't be installed. See #469.
|
||||||
inferInstallRules(result, options)
|
inferInstallRules(result, options)
|
||||||
|
|
||||||
|
if not result.isMinimal:
|
||||||
|
options.pkgInfoCache[nf] = result
|
||||||
|
|
||||||
# Validate the rest of the package info last.
|
# Validate the rest of the package info last.
|
||||||
if not options.disableValidation:
|
if not options.disableValidation:
|
||||||
validateVersion(result.version)
|
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 "can validate package structure (#144)":
|
||||||
# Test that no warnings are produced for correctly structured packages.
|
# 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:
|
cd "packageStructure/" & package:
|
||||||
let (output, exitCode) = execNimble(["install", "-y"])
|
let (output, exitCode) = execNimble(["install", "-y"])
|
||||||
check exitCode == QuitSuccess
|
check exitCode == QuitSuccess
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue