Binary packages no longer install .nim files implicitly. Refs #469.
This commit is contained in:
parent
5dfe81556b
commit
fb879efb72
6 changed files with 28 additions and 1 deletions
|
|
@ -277,6 +277,15 @@ proc readPackageInfoFromNimble(path: string; result: var PackageInfo) =
|
|||
else:
|
||||
raise newException(ValueError, "Cannot open package info: " & path)
|
||||
|
||||
proc inferInstallRules(pkgInfo: var PackageInfo, options: Options) =
|
||||
# Binary packages shouldn't install .nim files by default.
|
||||
# (As long as the package info doesn't explicitly specify what should be
|
||||
# installed.)
|
||||
let installInstructions =
|
||||
pkgInfo.installDirs.len + pkgInfo.installExt.len + pkgInfo.installFiles.len
|
||||
if installInstructions == 0 and pkgInfo.bin.len > 0:
|
||||
pkgInfo.skipExt.add("nim")
|
||||
|
||||
proc readPackageInfo(nf: NimbleFile, options: Options,
|
||||
onlyMinimalInfo=false): PackageInfo =
|
||||
## Reads package info from the specified Nimble file.
|
||||
|
|
@ -354,6 +363,9 @@ proc readPackageInfo(nf: NimbleFile, options: Options,
|
|||
if not result.isMinimal:
|
||||
options.pkgInfoCache[nf] = result
|
||||
|
||||
# Apply rules to infer which files should/shouldn't be installed. See #469.
|
||||
inferInstallRules(result, options)
|
||||
|
||||
# Validate the rest of the package info last.
|
||||
if not options.disableValidation:
|
||||
validateVersion(result.version)
|
||||
|
|
|
|||
0
tests/packageStructure/validBinary/y.nim
Normal file
0
tests/packageStructure/validBinary/y.nim
Normal file
13
tests/packageStructure/validBinary/y.nimble
Normal file
13
tests/packageStructure/validBinary/y.nimble
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Correctly structured package Y"
|
||||
license = "MIT"
|
||||
|
||||
bin = @["y"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0"
|
||||
|
||||
1
tests/packageStructure/validBinary/yWrong/foobar.nim
Normal file
1
tests/packageStructure/validBinary/yWrong/foobar.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -5,6 +5,7 @@ author = "Dominik Picheta"
|
|||
description = "Incorrectly structured package Y"
|
||||
license = "MIT"
|
||||
|
||||
installExt = @["nim"]
|
||||
bin = @["y"]
|
||||
|
||||
# Dependencies
|
||||
|
|
|
|||
|
|
@ -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"]:
|
||||
for package in ["a", "b", "c", "validBinary"]:
|
||||
cd "packageStructure/" & package:
|
||||
let (output, exitCode) = execNimble(["install", "-y"])
|
||||
check exitCode == QuitSuccess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue