Skip to content

Commit e13816c

Browse files
authored
Merge branch 'master' into nimsusedtest
2 parents f72af01 + 3b119f6 commit e13816c

File tree

12 files changed

+7
-114
lines changed

12 files changed

+7
-114
lines changed

.github/workflows/binaries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
builder: ubuntu-20.04
4343
- target:
4444
os: macosx
45-
builder: macos-11
45+
builder: macos-12
4646
- target:
4747
os: windows
4848
builder: windows-2019

src/nimblepkg/packageparser.nim

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -90,65 +90,6 @@ proc validateVersion*(ver: string) =
9090
"Version may only consist of numbers and the '.' character " &
9191
"but found '" & c & "'.", false)
9292

93-
proc validatePackageStructure(pkgInfo: PackageInfo, options: Options) =
94-
## This ensures that a package's source code does not leak into
95-
## another package's namespace.
96-
## https://github.com/nim-lang/nimble/issues/144
97-
let
98-
realDir = pkgInfo.getRealDir()
99-
correctDir = pkgInfo.basicInfo.name
100-
101-
proc onFile(path: string) =
102-
# Remove the root to leave only the package subdirectories.
103-
# ~/package-0.1/package/utils.nim -> package/utils.nim.
104-
var trailPath = changeRoot(realDir, "", path)
105-
if trailPath.startsWith(DirSep): trailPath = trailPath[1 .. ^1]
106-
let (dir, file, ext) = trailPath.splitFile
107-
# We're only interested in nim files, because only they can pollute our
108-
# namespace.
109-
if ext != (ExtSep & "nim"):
110-
return
111-
112-
if dir.len == 0:
113-
if file != pkgInfo.basicInfo.name:
114-
# A source file was found in the top level of srcDir that doesn't share
115-
# a name with the package.
116-
let
117-
msg = ("Package '$1' has an incorrect structure. " &
118-
"The top level of the package source directory " &
119-
"should contain at most one module, " &
120-
"named '$2', but a file named '$3' was found. This " &
121-
"will be an error in the future.") %
122-
[pkgInfo.basicInfo.name, pkgInfo.basicInfo.name & ext, file & ext]
123-
hint = ("If this is the primary source file in the package, " &
124-
"rename it to '$1'. If it's a source file required by " &
125-
"the main module, or if it is one of several " &
126-
"modules exposed by '$4', then move it into a '$2' subdirectory. " &
127-
"If it's a test file or otherwise not required " &
128-
"to build the package '$1', prevent its installation " &
129-
"by adding `skipFiles = @[\"$3\"]` to the .nimble file. See " &
130-
"https://github.com/nim-lang/nimble#libraries for more info.") %
131-
[pkgInfo.basicInfo.name & ext, correctDir & DirSep, file & ext, pkgInfo.basicInfo.name]
132-
raise validationError(msg, true, hint, true)
133-
else:
134-
assert(not pkgInfo.isMinimal)
135-
# On Windows `pkgInfo.bin` has a .exe extension, so we need to normalize.
136-
if not (dir.startsWith(correctDir & DirSep) or dir == correctDir):
137-
let
138-
msg = ("Package '$2' has an incorrect structure. " &
139-
"It should contain a single directory hierarchy " &
140-
"for source files, named '$3', but file '$1' " &
141-
"is in a directory named '$4' instead. " &
142-
"This will be an error in the future.") %
143-
[file & ext, pkgInfo.basicInfo.name, correctDir, dir]
144-
hint = ("If '$1' contains source files for building '$2', rename it " &
145-
"to '$3'. Otherwise, prevent its installation " &
146-
"by adding `skipDirs = @[\"$1\"]` to the .nimble file.") %
147-
[dir, pkgInfo.basicInfo.name, correctDir]
148-
raise validationError(msg, true, hint, true)
149-
150-
iterInstallFiles(realDir, pkgInfo, options, onFile)
151-
15293
proc validatePackageInfo(pkgInfo: PackageInfo, options: Options) =
15394
let path = pkgInfo.myPath
15495
if pkgInfo.basicInfo.name == "":
@@ -176,10 +117,6 @@ proc validatePackageInfo(pkgInfo: PackageInfo, options: Options) =
176117
if pkgInfo.backend notin ["c", "cc", "objc", "cpp", "js"]:
177118
raise validationError("'" & pkgInfo.backend &
178119
"' is an invalid backend.", false)
179-
if options.action.typ in {actionInstall, actionBuild, actionDevelop, actionCompile, actionCheck}:
180-
# nim is used for building the project, thus no need to validate its structure.
181-
if not pkgInfo.basicInfo.name.isNim:
182-
validatePackageStructure(pkginfo, options)
183120

184121
proc nimScriptHint*(pkgInfo: PackageInfo) =
185122
if not pkgInfo.isNimScript:

tests/packageStructure/validBinary/y.nimble

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/packageStructure/y/y.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
version = "0.1.0"
44
author = "Dominik Picheta"
5-
description = "Incorrectly structured package Y"
5+
description = "Correctly structured package Y"
66
license = "MIT"
77

88
installExt = @["nim"]

tests/packageStructure/y/yWrong/foobar.nim

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/packageStructure/z/incorrect.nim

Whitespace-only changes.

tests/packageStructure/z/z.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
version = "0.1.0"
44
author = "Dominik Picheta"
5-
description = "Incorrect package structure Z."
5+
description = "Correct package structure Z."
66
license = "MIT"
77

88
# Dependencies

0 commit comments

Comments
 (0)