Binary packages no longer install .nim files implicitly. Refs #469.

This commit is contained in:
Dominik Picheta 2018-09-09 23:24:53 +01:00
commit fb879efb72
6 changed files with 28 additions and 1 deletions

View file

@ -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)

View file

View 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"

View file

@ -0,0 +1 @@

View file

@ -5,6 +5,7 @@ author = "Dominik Picheta"
description = "Incorrectly structured package Y"
license = "MIT"
installExt = @["nim"]
bin = @["y"]
# Dependencies

View 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"]:
for package in ["a", "b", "c", "validBinary"]:
cd "packageStructure/" & package:
let (output, exitCode) = execNimble(["install", "-y"])
check exitCode == QuitSuccess