diff options
author | V1K1NGbg <victor@ilchev.com> | 2024-08-15 01:36:44 +0300 |
---|---|---|
committer | V1K1NGbg <victor@ilchev.com> | 2024-08-15 01:36:44 +0300 |
commit | 38f2dc2ab50e06d6b8be5eaec5d06f7c57e270c8 (patch) | |
tree | 222b33e8d3d331156678ed91fcc96e852e852929 | |
parent | 5345cb12dedf5b81013a77cf35d2aecb18e16e26 (diff) | |
download | luarocks-38f2dc2ab50e06d6b8be5eaec5d06f7c57e270c8.tar.gz luarocks-38f2dc2ab50e06d6b8be5eaec5d06f7c57e270c8.tar.bz2 luarocks-38f2dc2ab50e06d6b8be5eaec5d06f7c57e270c8.zip |
remove asserts and builtin and build
-rw-r--r-- | src/luarocks/build/builtin.tl | 52 | ||||
-rw-r--r-- | src/luarocks/core/cfg.d.tl | 4 | ||||
-rw-r--r-- | src/luarocks/core/dir.tl | 1 | ||||
-rw-r--r-- | src/luarocks/core/manif.tl | 1 | ||||
-rw-r--r-- | src/luarocks/core/path.tl | 3 | ||||
-rw-r--r-- | src/luarocks/core/sysdetect.tl | 1 | ||||
-rw-r--r-- | src/luarocks/core/types/build.d.tl | 9 | ||||
-rw-r--r-- | src/luarocks/core/types/installs.d.tl | 1 | ||||
-rw-r--r-- | src/luarocks/core/types/rockspec.tl | 3 | ||||
-rw-r--r-- | src/luarocks/core/util.tl | 4 | ||||
-rw-r--r-- | src/luarocks/deps.tl | 15 | ||||
-rw-r--r-- | src/luarocks/dir.tl | 2 | ||||
-rw-r--r-- | src/luarocks/fetch.tl | 1 | ||||
-rw-r--r-- | src/luarocks/fs.d.tl | 1 | ||||
-rw-r--r-- | src/luarocks/queries.tl | 6 | ||||
-rw-r--r-- | src/luarocks/results.tl | 2 | ||||
-rw-r--r-- | src/luarocks/search.tl | 1 | ||||
-rw-r--r-- | src/luarocks/test.tl | 2 | ||||
-rw-r--r-- | src/luarocks/test/command.tl | 6 | ||||
-rw-r--r-- | src/luarocks/tools/zip.tl | 4 |
20 files changed, 57 insertions, 62 deletions
diff --git a/src/luarocks/build/builtin.tl b/src/luarocks/build/builtin.tl index e26ca5a4..b0857363 100644 --- a/src/luarocks/build/builtin.tl +++ b/src/luarocks/build/builtin.tl | |||
@@ -9,6 +9,12 @@ local type Rockspec = r.Rockspec | |||
9 | 9 | ||
10 | local type i = require("luarocks.core.types.installs") | 10 | local type i = require("luarocks.core.types.installs") |
11 | local type Installs = i.Installs | 11 | local type Installs = i.Installs |
12 | local type Install = i.Install | ||
13 | |||
14 | local type b = require("luarocks.core.types.build") | ||
15 | local type Build = b.Build | ||
16 | local type BuiltinBuild = b.BuiltinBuild | ||
17 | local type Module = BuiltinBuild.Module | ||
12 | 18 | ||
13 | -- This build driver checks LUA_INCDIR and LUA_LIBDIR on demand, | 19 | -- This build driver checks LUA_INCDIR and LUA_LIBDIR on demand, |
14 | -- so that pure-Lua rocks don't need to have development headers | 20 | -- so that pure-Lua rocks don't need to have development headers |
@@ -58,8 +64,8 @@ do | |||
58 | ["tests.lua"] = true, | 64 | ["tests.lua"] = true, |
59 | } | 65 | } |
60 | 66 | ||
61 | function builtin.autodetect_modules(libs: {string}, incdirs: {string}, libdirs: {string}) | 67 | function builtin.autodetect_modules(libs: {string}, incdirs: {string}, libdirs: {string}): {string : string | Module}, Installs, {string} |
62 | local modules = {} | 68 | local modules: {string: (string | Module)} = {} |
63 | local install: Installs | 69 | local install: Installs |
64 | local copy_directories: {string} | 70 | local copy_directories: {string} |
65 | 71 | ||
@@ -102,7 +108,7 @@ do | |||
102 | if bindir then | 108 | if bindir then |
103 | install = { bin = {} } | 109 | install = { bin = {} } |
104 | for _, file in ipairs(fs.list_dir(bindir)) do | 110 | for _, file in ipairs(fs.list_dir(bindir)) do |
105 | table.insert(install.bin, dir.path(bindir, file)) --! | 111 | table.insert(install.bin, dir.path(bindir, file)) |
106 | end | 112 | end |
107 | end | 113 | end |
108 | 114 | ||
@@ -131,10 +137,12 @@ end | |||
131 | -- @param rockspec table: the loaded rockspec. | 137 | -- @param rockspec table: the loaded rockspec. |
132 | -- @return boolean or (nil, string): true if no errors occurred, | 138 | -- @return boolean or (nil, string): true if no errors occurred, |
133 | -- nil and an error message otherwise. | 139 | -- nil and an error message otherwise. |
134 | function builtin.run(rockspec: Rockspec, no_install: boolean) | 140 | function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, string |
135 | local compile_object, compile_library, compile_static_library | 141 | local compile_object: function(string, string, {string}, {string}): boolean, string, string |
142 | local compile_library: function(string, {string}, {string}, {string}, string): boolean, string, string | ||
143 | local compile_static_library: function(string, {string}, {string}, {string}, string): boolean, string, string | ||
136 | 144 | ||
137 | local build = rockspec.build | 145 | local build = rockspec.build as BuiltinBuild |
138 | local variables = rockspec.variables | 146 | local variables = rockspec.variables |
139 | local checked_lua_h = false | 147 | local checked_lua_h = false |
140 | 148 | ||
@@ -161,7 +169,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
161 | add_flags(extras, "-I%s", incdirs) | 169 | add_flags(extras, "-I%s", incdirs) |
162 | return execute(variables.CC.." "..variables.CFLAGS, "-c", "-o", object, "-I"..variables.LUA_INCDIR, source, table.unpack(extras)) | 170 | return execute(variables.CC.." "..variables.CFLAGS, "-c", "-o", object, "-I"..variables.LUA_INCDIR, source, table.unpack(extras)) |
163 | end | 171 | end |
164 | compile_library = function(library, objects, libraries, libdirs, name) | 172 | compile_library = function(library: string, objects: {string}, libraries: {string}, libdirs: {string}, name: string): boolean, string, string |
165 | local extras = { table.unpack(objects) } | 173 | local extras = { table.unpack(objects) } |
166 | add_flags(extras, "-L%s", libdirs) | 174 | add_flags(extras, "-L%s", libdirs) |
167 | add_flags(extras, "-l%s", libraries) | 175 | add_flags(extras, "-l%s", libraries) |
@@ -188,13 +196,13 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
188 | end | 196 | end |
189 | ]] | 197 | ]] |
190 | elseif cfg.is_platform("win32") then | 198 | elseif cfg.is_platform("win32") then |
191 | compile_object = function(object, source, defines, incdirs) | 199 | compile_object = function(object: string, source: string, defines: {string}, incdirs: {string}): boolean, string, string |
192 | local extras = {} | 200 | local extras = {} |
193 | add_flags(extras, "-D%s", defines) | 201 | add_flags(extras, "-D%s", defines) |
194 | add_flags(extras, "-I%s", incdirs) | 202 | add_flags(extras, "-I%s", incdirs) |
195 | return execute(variables.CC.." "..variables.CFLAGS, "-c", "-Fo"..object, "-I"..variables.LUA_INCDIR, source, table.unpack(extras)) | 203 | return execute(variables.CC.." "..variables.CFLAGS, "-c", "-Fo"..object, "-I"..variables.LUA_INCDIR, source, table.unpack(extras)) |
196 | end | 204 | end |
197 | compile_library = function(library, objects, libraries, libdirs, name) | 205 | compile_library = function(library: string, objects: {string}, libraries: {string}, libdirs: {string}, name: string): boolean, string, string |
198 | local extras = { table.unpack(objects) } | 206 | local extras = { table.unpack(objects) } |
199 | add_flags(extras, "-libpath:%s", libdirs) | 207 | add_flags(extras, "-libpath:%s", libdirs) |
200 | add_flags(extras, "%s.lib", libraries) | 208 | add_flags(extras, "%s.lib", libraries) |
@@ -226,13 +234,13 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
226 | end | 234 | end |
227 | ]] | 235 | ]] |
228 | else | 236 | else |
229 | compile_object = function(object, source, defines, incdirs) | 237 | compile_object = function(object: string, source: string, defines: {string}, incdirs: {string}): boolean, string, string |
230 | local extras = {} | 238 | local extras = {} |
231 | add_flags(extras, "-D%s", defines) | 239 | add_flags(extras, "-D%s", defines) |
232 | add_flags(extras, "-I%s", incdirs) | 240 | add_flags(extras, "-I%s", incdirs) |
233 | return execute(variables.CC.." "..variables.CFLAGS, "-I"..variables.LUA_INCDIR, "-c", source, "-o", object, table.unpack(extras)) | 241 | return execute(variables.CC.." "..variables.CFLAGS, "-I"..variables.LUA_INCDIR, "-c", source, "-o", object, table.unpack(extras)) |
234 | end | 242 | end |
235 | compile_library = function (library, objects, libraries, libdirs) | 243 | compile_library = function (library: string, objects: {string}, libraries: {string}, libdirs: {string}, name: string): boolean, string, string |
236 | local extras = { table.unpack(objects) } | 244 | local extras = { table.unpack(objects) } |
237 | add_flags(extras, "-L%s", libdirs) | 245 | add_flags(extras, "-L%s", libdirs) |
238 | if cfg.gcc_rpath then | 246 | if cfg.gcc_rpath then |
@@ -245,7 +253,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
245 | end | 253 | end |
246 | return execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, table.unpack(extras)) | 254 | return execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, table.unpack(extras)) |
247 | end | 255 | end |
248 | compile_static_library = function(library, objects, libraries, libdirs, name) -- luacheck: ignore 211 | 256 | compile_static_library = function(library: string, objects: {string}, libraries: {string}, libdirs: {string}, name: string): boolean, string, string -- luacheck: ignore 211 |
249 | local ok = execute(variables.AR, "rc", library, table.unpack(objects)) | 257 | local ok = execute(variables.AR, "rc", library, table.unpack(objects)) |
250 | if ok then | 258 | if ok then |
251 | ok = execute(variables.RANLIB, library) | 259 | ok = execute(variables.RANLIB, library) |
@@ -254,7 +262,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
254 | end | 262 | end |
255 | end | 263 | end |
256 | 264 | ||
257 | local ok, err | 265 | local ok, err: boolean, string |
258 | local lua_modules = {} | 266 | local lua_modules = {} |
259 | local lib_modules = {} | 267 | local lib_modules = {} |
260 | local luadir = path.lua_dir(rockspec.name, rockspec.version) | 268 | local luadir = path.lua_dir(rockspec.name, rockspec.version) |
@@ -264,7 +272,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
264 | 272 | ||
265 | if not build.modules then | 273 | if not build.modules then |
266 | if rockspec:format_is_at_least("3.0") then | 274 | if rockspec:format_is_at_least("3.0") then |
267 | local install, copy_directories | 275 | local install, copy_directories: Installs, {string} |
268 | build.modules, install, copy_directories = builtin.autodetect_modules(autolibs, autoincdirs, autolibdirs) | 276 | build.modules, install, copy_directories = builtin.autodetect_modules(autolibs, autoincdirs, autolibdirs) |
269 | build.install = build.install or install | 277 | build.install = build.install or install |
270 | build.copy_directories = build.copy_directories or copy_directories | 278 | build.copy_directories = build.copy_directories or copy_directories |
@@ -273,10 +281,10 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
273 | end | 281 | end |
274 | end | 282 | end |
275 | 283 | ||
276 | local compile_temp_dir | 284 | local compile_temp_dir: string |
277 | 285 | ||
278 | local mkdir_cache = {} | 286 | local mkdir_cache = {} |
279 | local function cached_make_dir(name) | 287 | local function cached_make_dir(name: string): boolean, string |
280 | if name == "" or mkdir_cache[name] then | 288 | if name == "" or mkdir_cache[name] then |
281 | return true | 289 | return true |
282 | end | 290 | end |
@@ -286,7 +294,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
286 | 294 | ||
287 | for name, info in pairs(build.modules) do | 295 | for name, info in pairs(build.modules) do |
288 | local moddir = path.module_to_path(name) | 296 | local moddir = path.module_to_path(name) |
289 | if type(info) == "string" then | 297 | if info is string then |
290 | local ext = info:match("%.([^.]+)$") | 298 | local ext = info:match("%.([^.]+)$") |
291 | if ext == "lua" then | 299 | if ext == "lua" then |
292 | local filename = dir.base_name(info) | 300 | local filename = dir.base_name(info) |
@@ -302,7 +310,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
302 | info = {info} | 310 | info = {info} |
303 | end | 311 | end |
304 | end | 312 | end |
305 | if type(info) == "table" then | 313 | if info is Module then |
306 | if not checked_lua_h then | 314 | if not checked_lua_h then |
307 | local ok, err, errcode = deps.check_lua_incdir(rockspec.variables) | 315 | local ok, err, errcode = deps.check_lua_incdir(rockspec.variables) |
308 | if not ok then | 316 | if not ok then |
@@ -320,12 +328,12 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
320 | local objects = {} | 328 | local objects = {} |
321 | local sources = info.sources | 329 | local sources = info.sources |
322 | if info[1] then sources = info end | 330 | if info[1] then sources = info end |
323 | if type(sources) == "string" then sources = {sources} end | 331 | if sources is string then sources = {sources} end |
324 | if type(sources) ~= "table" then | 332 | if not sources is {string} then |
325 | return nil, "error in rockspec: module '" .. name .. "' entry has no 'sources' list" | 333 | return nil, "error in rockspec: module '" .. name .. "' entry has no 'sources' list" |
326 | end | 334 | end |
327 | for _, source in ipairs(sources) do | 335 | for _, source in ipairs(sources) do |
328 | if type(source) ~= "string" then | 336 | if not source is string then |
329 | return nil, "error in rockspec: module '" .. name .. "' does not specify source correctly." | 337 | return nil, "error in rockspec: module '" .. name .. "' does not specify source correctly." |
330 | end | 338 | end |
331 | local object = source:gsub("%.[^.]*$", "."..cfg.obj_extension) | 339 | local object = source:gsub("%.[^.]*$", "."..cfg.obj_extension) |
@@ -354,7 +362,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean) | |||
354 | cached_make_dir(build_dir) | 362 | cached_make_dir(build_dir) |
355 | 363 | ||
356 | lib_modules[build_name] = dir.path(libdir, module_name) | 364 | lib_modules[build_name] = dir.path(libdir, module_name) |
357 | ok = compile_library(build_name, objects, info.libraries, info.libdirs or autolibdirs, name) | 365 | ok = compile_library(build_name, objects, info.libraries as {string}, info.libdirs or autolibdirs, name) |
358 | if not ok then | 366 | if not ok then |
359 | return nil, "Failed compiling module "..module_name | 367 | return nil, "Failed compiling module "..module_name |
360 | end | 368 | end |
diff --git a/src/luarocks/core/cfg.d.tl b/src/luarocks/core/cfg.d.tl index a342fe35..f87cc1e9 100644 --- a/src/luarocks/core/cfg.d.tl +++ b/src/luarocks/core/cfg.d.tl | |||
@@ -79,6 +79,10 @@ local record cfg | |||
79 | -- writer | 79 | -- writer |
80 | no_manifest: boolean | 80 | no_manifest: boolean |
81 | accepted_build_types: {boolean} | 81 | accepted_build_types: {boolean} |
82 | -- builtin | ||
83 | gcc_rpath: boolean | ||
84 | link_lua_explicitly: boolean | ||
85 | obj_extension: string | ||
82 | end | 86 | end |
83 | 87 | ||
84 | return cfg \ No newline at end of file | 88 | return cfg \ No newline at end of file |
diff --git a/src/luarocks/core/dir.tl b/src/luarocks/core/dir.tl index 87efec12..20068341 100644 --- a/src/luarocks/core/dir.tl +++ b/src/luarocks/core/dir.tl | |||
@@ -19,7 +19,6 @@ end | |||
19 | -- @param url string: an URL or a local pathname. | 19 | -- @param url string: an URL or a local pathname. |
20 | -- @return string, string: the protocol, and the pathname without the protocol. | 20 | -- @return string, string: the protocol, and the pathname without the protocol. |
21 | function dir.split_url(url: string): string, string | 21 | function dir.split_url(url: string): string, string |
22 | assert(type(url) == "string") | ||
23 | 22 | ||
24 | url = unquote(url) | 23 | url = unquote(url) |
25 | local protocol, pathname = url:match("^([^:]*)://(.*)") | 24 | local protocol, pathname = url:match("^([^:]*)://(.*)") |
diff --git a/src/luarocks/core/manif.tl b/src/luarocks/core/manif.tl index 683ec741..0b0bf9f8 100644 --- a/src/luarocks/core/manif.tl +++ b/src/luarocks/core/manif.tl | |||
@@ -70,7 +70,6 @@ end | |||
70 | -- @return table or (nil, string, string): A table representing the manifest, | 70 | -- @return table or (nil, string, string): A table representing the manifest, |
71 | -- or nil followed by an error message and an error code, see manifest_loader. | 71 | -- or nil followed by an error message and an error code, see manifest_loader. |
72 | function manif.fast_load_local_manifest(repo_url: string): Manifest, string | {any: any}, string | 72 | function manif.fast_load_local_manifest(repo_url: string): Manifest, string | {any: any}, string |
73 | assert(type(repo_url) == "string") | ||
74 | 73 | ||
75 | local cached_manifest = manif.get_cached_manifest(repo_url) | 74 | local cached_manifest = manif.get_cached_manifest(repo_url) |
76 | if cached_manifest then | 75 | if cached_manifest then |
diff --git a/src/luarocks/core/path.tl b/src/luarocks/core/path.tl index 37421445..491fe484 100644 --- a/src/luarocks/core/path.tl +++ b/src/luarocks/core/path.tl | |||
@@ -43,7 +43,6 @@ end | |||
43 | -- not a conformant module path (the function does not check if the | 43 | -- not a conformant module path (the function does not check if the |
44 | -- path actually exists). | 44 | -- path actually exists). |
45 | function path.path_to_module(file: string): string | 45 | function path.path_to_module(file: string): string |
46 | assert(type(file) == "string") | ||
47 | 46 | ||
48 | local exts = {} | 47 | local exts = {} |
49 | local paths = package.path .. ";" .. package.cpath | 48 | local paths = package.path .. ";" .. package.cpath |
@@ -75,7 +74,6 @@ function path.deploy_lua_dir(tree: string | Tree): string | |||
75 | if tree is string then | 74 | if tree is string then |
76 | return dir.path(tree, cfg.lua_modules_path) | 75 | return dir.path(tree, cfg.lua_modules_path) |
77 | else | 76 | else |
78 | assert(type(tree) == "table") | ||
79 | return tree.lua_dir or dir.path(tree.root, cfg.lua_modules_path) | 77 | return tree.lua_dir or dir.path(tree.root, cfg.lua_modules_path) |
80 | end | 78 | end |
81 | end | 79 | end |
@@ -84,7 +82,6 @@ function path.deploy_lib_dir(tree: string | Tree): string | |||
84 | if tree is string then | 82 | if tree is string then |
85 | return dir.path(tree, cfg.lib_modules_path) | 83 | return dir.path(tree, cfg.lib_modules_path) |
86 | else | 84 | else |
87 | assert(type(tree) == "table") | ||
88 | return tree.lib_dir or dir.path(tree.root, cfg.lib_modules_path) | 85 | return tree.lib_dir or dir.path(tree.root, cfg.lib_modules_path) |
89 | end | 86 | end |
90 | end | 87 | end |
diff --git a/src/luarocks/core/sysdetect.tl b/src/luarocks/core/sysdetect.tl index a19a5f24..63692e4a 100644 --- a/src/luarocks/core/sysdetect.tl +++ b/src/luarocks/core/sysdetect.tl | |||
@@ -435,7 +435,6 @@ end | |||
435 | -------------------------------------------------------------------------------- | 435 | -------------------------------------------------------------------------------- |
436 | 436 | ||
437 | function sysdetect.detect_file(file: string): System, Processor | 437 | function sysdetect.detect_file(file: string): System, Processor |
438 | assert(type(file) == "string") | ||
439 | local fd = io.open(file, "rb") | 438 | local fd = io.open(file, "rb") |
440 | if not fd then | 439 | if not fd then |
441 | return nil | 440 | return nil |
diff --git a/src/luarocks/core/types/build.d.tl b/src/luarocks/core/types/build.d.tl index 0591aa33..98707c0b 100644 --- a/src/luarocks/core/types/build.d.tl +++ b/src/luarocks/core/types/build.d.tl | |||
@@ -6,8 +6,10 @@ local record build | |||
6 | interface Build | 6 | interface Build |
7 | type: string | 7 | type: string |
8 | install: Installs | 8 | install: Installs |
9 | copy_directories: string | 9 | copy_directories: {string} |
10 | patches: {string : string} | 10 | patches: {string : string} |
11 | extra_files: {string : string} | ||
12 | macosx_deployment_target: string | ||
11 | end | 13 | end |
12 | 14 | ||
13 | record BuiltinBuild | 15 | record BuiltinBuild |
@@ -15,14 +17,15 @@ local record build | |||
15 | where self.type == "builtin" | 17 | where self.type == "builtin" |
16 | 18 | ||
17 | record Module | 19 | record Module |
20 | is {string} | ||
18 | sources: string | {string} | 21 | sources: string | {string} |
19 | libraries: {string} | 22 | libraries: string | {string} |
20 | defines: {string} | 23 | defines: {string} |
21 | incdirs: {string} | 24 | incdirs: {string} |
22 | libdirs: {string} | 25 | libdirs: {string} |
23 | end | 26 | end |
24 | 27 | ||
25 | modules: {string: (string | {string} | Module)} | 28 | modules: {string: (string | Module)} |
26 | end | 29 | end |
27 | 30 | ||
28 | record MakeBuild | 31 | record MakeBuild |
diff --git a/src/luarocks/core/types/installs.d.tl b/src/luarocks/core/types/installs.d.tl index 9e919233..1e0747fc 100644 --- a/src/luarocks/core/types/installs.d.tl +++ b/src/luarocks/core/types/installs.d.tl | |||
@@ -12,4 +12,5 @@ local record installs | |||
12 | bin: Install | 12 | bin: Install |
13 | end | 13 | end |
14 | end | 14 | end |
15 | |||
15 | return installs \ No newline at end of file | 16 | return installs \ No newline at end of file |
diff --git a/src/luarocks/core/types/rockspec.tl b/src/luarocks/core/types/rockspec.tl index ca12bf94..f1e4895d 100644 --- a/src/luarocks/core/types/rockspec.tl +++ b/src/luarocks/core/types/rockspec.tl | |||
@@ -4,9 +4,6 @@ local type Query = q.Query | |||
4 | local type b = require("luarocks.core.types.build") | 4 | local type b = require("luarocks.core.types.build") |
5 | local type Build = b.Build | 5 | local type Build = b.Build |
6 | 6 | ||
7 | local type i = require("luarocks.core.types.installs") | ||
8 | local type Installs = i.Installs | ||
9 | |||
10 | local record rockspec | 7 | local record rockspec |
11 | record Description | 8 | record Description |
12 | summary: string | 9 | summary: string |
diff --git a/src/luarocks/core/util.tl b/src/luarocks/core/util.tl index 183deaab..d8d6c1b5 100644 --- a/src/luarocks/core/util.tl +++ b/src/luarocks/core/util.tl | |||
@@ -70,7 +70,7 @@ function util.show_table(t: {any:any}, tname: string, top_indent: string): strin | |||
70 | -- the information is defined through lines | 70 | -- the information is defined through lines |
71 | return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) | 71 | return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) |
72 | end | 72 | end |
73 | elseif type(o) == "number" then | 73 | elseif o is number then |
74 | return so | 74 | return so |
75 | else | 75 | else |
76 | return ("%q"):format(so) | 76 | return ("%q"):format(so) |
@@ -110,7 +110,7 @@ function util.show_table(t: {any:any}, tname: string, top_indent: string): strin | |||
110 | end | 110 | end |
111 | 111 | ||
112 | tname = tname or "__unnamed__" | 112 | tname = tname or "__unnamed__" |
113 | if type(t) ~= "table" then | 113 | if not t is {any:any} then |
114 | return tname .. " = " .. basic_serialize(t) | 114 | return tname .. " = " .. basic_serialize(t) |
115 | end | 115 | end |
116 | cart, autoref = "", "" | 116 | cart, autoref = "", "" |
diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl index 1ce163c3..30ff8e53 100644 --- a/src/luarocks/deps.tl +++ b/src/luarocks/deps.tl | |||
@@ -17,8 +17,10 @@ local type r = require("luarocks.core.types.rockspec") | |||
17 | local type Rockspec = r.Rockspec | 17 | local type Rockspec = r.Rockspec |
18 | local type Dependencies = r.Dependencies | 18 | local type Dependencies = r.Dependencies |
19 | 19 | ||
20 | local type b = require("luarocks.core.types.build") | 20 | local type bld = require("luarocks.core.types.build") |
21 | local type Build = b.Build | 21 | local type BuiltinBuild = bld.BuiltinBuild |
22 | local type Module = BuiltinBuild.Module | ||
23 | local type Build = bld.Build | ||
22 | 24 | ||
23 | local type t = require("luarocks.core.types.tree") | 25 | local type t = require("luarocks.core.types.tree") |
24 | local type Tree = t.Tree | 26 | local type Tree = t.Tree |
@@ -592,14 +594,14 @@ end | |||
592 | 594 | ||
593 | function deps.autodetect_external_dependencies(build: Build): {string : {string : string}} | 595 | function deps.autodetect_external_dependencies(build: Build): {string : {string : string}} |
594 | -- only applies to the 'builtin' build type | 596 | -- only applies to the 'builtin' build type |
595 | if not build or not build.modules then | 597 | if not build or not (build as BuiltinBuild).modules then |
596 | return nil | 598 | return nil |
597 | end | 599 | end |
598 | 600 | ||
599 | local extdeps: {string: {string: string}} = {} | 601 | local extdeps: {string: {string: string}} = {} |
600 | local any = false | 602 | local any = false |
601 | for _, data in pairs(build.modules) do | 603 | for _, data in pairs((build as BuiltinBuild).modules) do |
602 | if data is {string : string | {string}} and data.libraries then | 604 | if data is Module and data.libraries then |
603 | local libraries: {string} | 605 | local libraries: {string} |
604 | local librariesstr: string | {string} = data.libraries | 606 | local librariesstr: string | {string} = data.libraries |
605 | if librariesstr is string then | 607 | if librariesstr is string then |
@@ -679,8 +681,6 @@ end | |||
679 | -- @param name string: Package name. | 681 | -- @param name string: Package name. |
680 | -- @param version string: Package version. | 682 | -- @param version string: Package version. |
681 | function deps.scan_deps(results: {string: string}, mdeps: {string: {string: {Query}}}, name: string, version: string, deps_mode: string) | 683 | function deps.scan_deps(results: {string: string}, mdeps: {string: {string: {Query}}}, name: string, version: string, deps_mode: string) |
682 | assert(type(results) == "table") | ||
683 | assert(type(mdeps) == "table") | ||
684 | assert(not name:match("/")) | 684 | assert(not name:match("/")) |
685 | 685 | ||
686 | local fetch = require("luarocks.fetch") | 686 | local fetch = require("luarocks.fetch") |
@@ -858,7 +858,6 @@ end | |||
858 | -- "none" for using the default dependency mode from the configuration. | 858 | -- "none" for using the default dependency mode from the configuration. |
859 | function deps.check_dependencies(repo: string, deps_mode: string) | 859 | function deps.check_dependencies(repo: string, deps_mode: string) |
860 | local rocks_dir = path.rocks_dir(repo or cfg.root_dir) | 860 | local rocks_dir = path.rocks_dir(repo or cfg.root_dir) |
861 | assert(type(deps_mode) == "string") | ||
862 | if deps_mode == "none" then deps_mode = cfg.deps_mode end | 861 | if deps_mode == "none" then deps_mode = cfg.deps_mode end |
863 | 862 | ||
864 | local manifest = manif.load_manifest(rocks_dir) | 863 | local manifest = manif.load_manifest(rocks_dir) |
diff --git a/src/luarocks/dir.tl b/src/luarocks/dir.tl index d349ac71..e9e16fbd 100644 --- a/src/luarocks/dir.tl +++ b/src/luarocks/dir.tl | |||
@@ -19,7 +19,6 @@ local dir_sep = package.config:sub(1, 1) | |||
19 | -- or "\a\b\c". | 19 | -- or "\a\b\c". |
20 | -- @return string: The filename without its path, such as "c". | 20 | -- @return string: The filename without its path, such as "c". |
21 | function dir.base_name(pathname: string): string | 21 | function dir.base_name(pathname: string): string |
22 | assert(type(pathname) == "string") | ||
23 | 22 | ||
24 | local b: string | 23 | local b: string |
25 | b = pathname:gsub("[/\\]", "/") -- canonicalize to forward slashes | 24 | b = pathname:gsub("[/\\]", "/") -- canonicalize to forward slashes |
@@ -36,7 +35,6 @@ end | |||
36 | -- For entries such as "/a/b/", "/a" is returned. If there are | 35 | -- For entries such as "/a/b/", "/a" is returned. If there are |
37 | -- no directory separators in input, "" is returned. | 36 | -- no directory separators in input, "" is returned. |
38 | function dir.dir_name(pathname: string): string | 37 | function dir.dir_name(pathname: string): string |
39 | assert(type(pathname) == "string") | ||
40 | 38 | ||
41 | local d: string | 39 | local d: string |
42 | d = pathname:gsub("[/\\]", "/") -- canonicalize to forward slashes | 40 | d = pathname:gsub("[/\\]", "/") -- canonicalize to forward slashes |
diff --git a/src/luarocks/fetch.tl b/src/luarocks/fetch.tl index 5a42645b..30c45b56 100644 --- a/src/luarocks/fetch.tl +++ b/src/luarocks/fetch.tl | |||
@@ -436,7 +436,6 @@ end | |||
436 | -- @return table or (nil, string): A table representing the rockspec | 436 | -- @return table or (nil, string): A table representing the rockspec |
437 | -- or nil followed by an error message. | 437 | -- or nil followed by an error message. |
438 | function fetch.load_local_rockspec(rel_filename: string, quick?: boolean): Rockspec, string | 438 | function fetch.load_local_rockspec(rel_filename: string, quick?: boolean): Rockspec, string |
439 | assert(type(rel_filename) == "string") | ||
440 | local abs_filename = fs.absolute_name(rel_filename) | 439 | local abs_filename = fs.absolute_name(rel_filename) |
441 | 440 | ||
442 | local basename = dir.base_name(abs_filename) | 441 | local basename = dir.base_name(abs_filename) |
diff --git a/src/luarocks/fs.d.tl b/src/luarocks/fs.d.tl index 86499bee..ce055567 100644 --- a/src/luarocks/fs.d.tl +++ b/src/luarocks/fs.d.tl | |||
@@ -61,6 +61,7 @@ local record fs | |||
61 | get_md5: function(string): string, string | 61 | get_md5: function(string): string, string |
62 | -- build | 62 | -- build |
63 | apply_patch: function(string, string, boolean): boolean, string | 63 | apply_patch: function(string, string, boolean): boolean, string |
64 | copy_contents: function(string, string): boolean, string | ||
64 | end | 65 | end |
65 | 66 | ||
66 | return fs | 67 | return fs |
diff --git a/src/luarocks/queries.tl b/src/luarocks/queries.tl index 7729ab5f..3bd0802f 100644 --- a/src/luarocks/queries.tl +++ b/src/luarocks/queries.tl | |||
@@ -57,11 +57,6 @@ end | |||
57 | -- @param operator string?: operator for version matching (default is "==") | 57 | -- @param operator string?: operator for version matching (default is "==") |
58 | -- @return table: A query in table format | 58 | -- @return table: A query in table format |
59 | function queries.new(name: string, namespace?: string, version?: string, substring?: boolean, arch?: string, operator?: string): Query | 59 | function queries.new(name: string, namespace?: string, version?: string, substring?: boolean, arch?: string, operator?: string): Query |
60 | -- assert(type(namespace) == "string" or not namespace) --! optional parameters? | ||
61 | -- assert(type(version) == "string" or not version) | ||
62 | -- assert(type(substring) == "boolean" or not substring) | ||
63 | -- assert(type(arch) == "string" or not arch) | ||
64 | -- assert(type(operator) == "string" or not operator) | ||
65 | 60 | ||
66 | operator = operator or "==" | 61 | operator = operator or "==" |
67 | 62 | ||
@@ -83,7 +78,6 @@ end | |||
83 | -- Query for all packages | 78 | -- Query for all packages |
84 | -- @param arch string (optional) | 79 | -- @param arch string (optional) |
85 | function queries.all(arch?: string): Query | 80 | function queries.all(arch?: string): Query |
86 | -- assert(type(arch) == "string" or not arch) --! optional | ||
87 | 81 | ||
88 | return queries.new("", nil, nil, true, arch) | 82 | return queries.new("", nil, nil, true, arch) |
89 | end | 83 | end |
diff --git a/src/luarocks/results.tl b/src/luarocks/results.tl index e6c849a6..cf7e109c 100644 --- a/src/luarocks/results.tl +++ b/src/luarocks/results.tl | |||
@@ -20,8 +20,6 @@ end | |||
20 | function results.new(name: string, version: string, repo: string, arch?: string, namespace?: string): Result, boolean | 20 | function results.new(name: string, version: string, repo: string, arch?: string, namespace?: string): Result, boolean |
21 | 21 | ||
22 | assert(not name:match("/")) | 22 | assert(not name:match("/")) |
23 | -- assert(type(arch) == "string" or not arch) --! arch?: string | ||
24 | -- assert(type(namespace) == "string" or not namespace) --! namespace?: string | ||
25 | 23 | ||
26 | 24 | ||
27 | if not namespace then | 25 | if not namespace then |
diff --git a/src/luarocks/search.tl b/src/luarocks/search.tl index fdeebcd8..5681fa54 100644 --- a/src/luarocks/search.tl +++ b/src/luarocks/search.tl | |||
@@ -27,7 +27,6 @@ local type Tree = t.Tree | |||
27 | -- tables with fields "arch" and "repo". | 27 | -- tables with fields "arch" and "repo". |
28 | -- @param result table: A result. | 28 | -- @param result table: A result. |
29 | function search.store_result(result_tree: {string: {string: {Result}}}, result: Result) | 29 | function search.store_result(result_tree: {string: {string: {Result}}}, result: Result) |
30 | assert(type(result_tree) == "table") | ||
31 | 30 | ||
32 | local name = result.name | 31 | local name = result.name |
33 | local version = result.version | 32 | local version = result.version |
diff --git a/src/luarocks/test.tl b/src/luarocks/test.tl index 3345a7eb..b60e3458 100644 --- a/src/luarocks/test.tl +++ b/src/luarocks/test.tl | |||
@@ -104,7 +104,7 @@ function test.run_test_suite(rockspec_arg: string | Rockspec, test_type: string, | |||
104 | end | 104 | end |
105 | else | 105 | else |
106 | local flags = rockspec.test and rockspec.test.flags | 106 | local flags = rockspec.test and rockspec.test.flags |
107 | if type(flags) == "table" then | 107 | if flags is {string} then |
108 | util.variable_substitutions(flags, rockspec.variables) | 108 | util.variable_substitutions(flags, rockspec.variables) |
109 | 109 | ||
110 | -- insert any flags given in test.flags at the front of args | 110 | -- insert any flags given in test.flags at the front of args |
diff --git a/src/luarocks/test/command.tl b/src/luarocks/test/command.tl index 843367b2..2a1e3ce9 100644 --- a/src/luarocks/test/command.tl +++ b/src/luarocks/test/command.tl | |||
@@ -29,7 +29,8 @@ function command.run_tests(test: Test, args: {string}): boolean, string | |||
29 | local ok: boolean | 29 | local ok: boolean |
30 | 30 | ||
31 | if test.script then | 31 | if test.script then |
32 | if type(test.script) ~= "string" then | 32 | local test_script = test.script |
33 | if not test_script is string then | ||
33 | return nil, "Malformed rockspec: 'script' expects a string" | 34 | return nil, "Malformed rockspec: 'script' expects a string" |
34 | end | 35 | end |
35 | if not fs.exists(test.script) then | 36 | if not fs.exists(test.script) then |
@@ -38,7 +39,8 @@ function command.run_tests(test: Test, args: {string}): boolean, string | |||
38 | local lua = fs.Q(cfg.variables["LUA"]) -- get lua interpreter configured | 39 | local lua = fs.Q(cfg.variables["LUA"]) -- get lua interpreter configured |
39 | ok = fs.execute(lua, test.script, table.unpack(args)) | 40 | ok = fs.execute(lua, test.script, table.unpack(args)) |
40 | elseif test.command then | 41 | elseif test.command then |
41 | if type(test.command) ~= "string" then | 42 | local test_command = test.command |
43 | if not test_command is string then | ||
42 | return nil, "Malformed rockspec: 'command' expects a string" | 44 | return nil, "Malformed rockspec: 'command' expects a string" |
43 | end | 45 | end |
44 | ok = fs.execute(test.command, table.unpack(args)) | 46 | ok = fs.execute(test.command, table.unpack(args)) |
diff --git a/src/luarocks/tools/zip.tl b/src/luarocks/tools/zip.tl index bbe2ecbd..82a19011 100644 --- a/src/luarocks/tools/zip.tl +++ b/src/luarocks/tools/zip.tl | |||
@@ -562,9 +562,7 @@ function zip.gzip(input_filename: string, output_filename?: string): boolean, st | |||
562 | return fs.filter_file(fn, input_filename, output_filename) | 562 | return fs.filter_file(fn, input_filename, output_filename) |
563 | end | 563 | end |
564 | 564 | ||
565 | function zip.gunzip(input_filename: string, output_filename: string): boolean, string | 565 | function zip.gunzip(input_filename: string, output_filename?: string): boolean, string |
566 | assert(type(input_filename) == "string") | ||
567 | assert(output_filename == nil or type(output_filename) == "string") | ||
568 | 566 | ||
569 | if not output_filename then | 567 | if not output_filename then |
570 | output_filename = input_filename:gsub("%.gz$", "") | 568 | output_filename = input_filename:gsub("%.gz$", "") |