@@ -90,65 +90,6 @@ proc validateVersion*(ver: string) =
90
90
" Version may only consist of numbers and the '.' character " &
91
91
" but found '" & c & " '." , false )
92
92
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
-
152
93
proc validatePackageInfo(pkgInfo: PackageInfo, options: Options) =
153
94
let path = pkgInfo.myPath
154
95
if pkgInfo.basicInfo.name == " " :
@@ -176,10 +117,6 @@ proc validatePackageInfo(pkgInfo: PackageInfo, options: Options) =
176
117
if pkgInfo.backend notin [" c" , " cc" , " objc" , " cpp" , " js" ]:
177
118
raise validationError(" '" & pkgInfo.backend &
178
119
" ' 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)
183
120
184
121
proc nimScriptHint* (pkgInfo: PackageInfo) =
185
122
if not pkgInfo.isNimScript:
0 commit comments