diff options
-rw-r--r-- | src/luarocks/cmd/make.tl (renamed from src/luarocks/cmd/make.lua) | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.tl index ffec8c5d..13b1d66b 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.tl | |||
@@ -3,7 +3,9 @@ | |||
3 | -- Builds sources in the current directory, but unlike "build", | 3 | -- Builds sources in the current directory, but unlike "build", |
4 | -- it does not fetch sources, etc., assuming everything is | 4 | -- it does not fetch sources, etc., assuming everything is |
5 | -- available in the current directory. | 5 | -- available in the current directory. |
6 | local make = {} | 6 | local record make |
7 | needs_lock: function(Args): boolean | ||
8 | end | ||
7 | 9 | ||
8 | local build = require("luarocks.build") | 10 | local build = require("luarocks.build") |
9 | local util = require("luarocks.util") | 11 | local util = require("luarocks.util") |
@@ -12,11 +14,16 @@ local fetch = require("luarocks.fetch") | |||
12 | local pack = require("luarocks.pack") | 14 | local pack = require("luarocks.pack") |
13 | local remove = require("luarocks.remove") | 15 | local remove = require("luarocks.remove") |
14 | local deps = require("luarocks.deps") | 16 | local deps = require("luarocks.deps") |
15 | local writer = require("luarocks.manif.writer") | ||
16 | local dir = require("luarocks.dir") | 17 | local dir = require("luarocks.dir") |
17 | local fs = require("luarocks.fs") | 18 | local fs = require("luarocks.fs") |
18 | 19 | ||
19 | function make.cmd_options(parser) | 20 | local type Parser = require("luarocks.vendor.argparse").Parser |
21 | |||
22 | local type Args = require("luarocks.core.types.args").Args | ||
23 | |||
24 | local type BOpts = require("luarocks.core.types.bopts").BOpts | ||
25 | |||
26 | function make.cmd_options(parser: Parser) | ||
20 | parser:flag("--no-install", "Do not install the rock.") | 27 | parser:flag("--no-install", "Do not install the rock.") |
21 | parser:flag("--no-doc", "Install the rock without its documentation.") | 28 | parser:flag("--no-doc", "Install the rock without its documentation.") |
22 | parser:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. | 29 | parser:flag("--pack-binary-rock", "Do not install rock. Instead, produce a ".. |
@@ -33,7 +40,7 @@ function make.cmd_options(parser) | |||
33 | "built. If the rockspec or src.rock is being downloaded, LuaRocks will ".. | 40 | "built. If the rockspec or src.rock is being downloaded, LuaRocks will ".. |
34 | "attempt to download the signature as well. Otherwise, the signature ".. | 41 | "attempt to download the signature as well. Otherwise, the signature ".. |
35 | "file should be already available locally in the same directory.\n".. | 42 | "file should be already available locally in the same directory.\n".. |
36 | "You need the signer’s public key in your local keyring for this ".. | 43 | "You need the signer's public key in your local keyring for this ".. |
37 | "option to work properly.") | 44 | "option to work properly.") |
38 | parser:flag("--sign", "To be used with --pack-binary-rock. Also produce a ".. | 45 | parser:flag("--sign", "To be used with --pack-binary-rock. Also produce a ".. |
39 | "signature file for the generated .rock file.") | 46 | "signature file for the generated .rock file.") |
@@ -46,7 +53,7 @@ function make.cmd_options(parser) | |||
46 | util.deps_mode_option(parser) | 53 | util.deps_mode_option(parser) |
47 | end | 54 | end |
48 | 55 | ||
49 | function make.add_to_parser(parser) | 56 | function make.add_to_parser(parser: Parser) |
50 | -- luacheck: push ignore 431 | 57 | -- luacheck: push ignore 431 |
51 | local cmd = parser:command("make", [[ | 58 | local cmd = parser:command("make", [[ |
52 | Builds sources in the current directory, but unlike "build", it does not fetch | 59 | Builds sources in the current directory, but unlike "build", it does not fetch |
@@ -71,16 +78,17 @@ overrides and recreates this file scanning dependency based on ranges. | |||
71 | cmd:argument("rockspec", "Rockspec for the rock to build.") | 78 | cmd:argument("rockspec", "Rockspec for the rock to build.") |
72 | :args("?") | 79 | :args("?") |
73 | 80 | ||
74 | make.cmd_options(cmd) | 81 | make.cmd_options(cmd as Parser) |
75 | end | 82 | end |
76 | 83 | ||
77 | --- Driver function for "make" command. | 84 | --- Driver function for "make" command. |
78 | -- @return boolean or (nil, string, exitcode): True if build was successful; nil and an | 85 | -- @return boolean or (nil, string, exitcode): True if build was successful; nil and an |
79 | -- error message otherwise. exitcode is optionally returned. | 86 | -- error message otherwise. exitcode is optionally returned. |
80 | function make.command(args) | 87 | function make.command(args: Args): boolean, string |
88 | local name, namespace, version: string, string, string | ||
81 | local rockspec_filename = args.rockspec | 89 | local rockspec_filename = args.rockspec |
82 | if not rockspec_filename then | 90 | if not rockspec_filename then |
83 | local err | 91 | local err: string |
84 | rockspec_filename, err = util.get_default_rockspec() | 92 | rockspec_filename, err = util.get_default_rockspec() |
85 | if not rockspec_filename then | 93 | if not rockspec_filename then |
86 | return nil, err | 94 | return nil, err |
@@ -96,10 +104,10 @@ function make.command(args) | |||
96 | return nil, err | 104 | return nil, err |
97 | end | 105 | end |
98 | 106 | ||
99 | local name, namespace = util.split_namespace(rockspec.name) | 107 | name, namespace = util.split_namespace(rockspec.name) |
100 | namespace = namespace or args.namespace | 108 | namespace = namespace or args.namespace |
101 | 109 | ||
102 | local opts = build.opts({ | 110 | local opts: BOpts = { |
103 | need_to_fetch = false, | 111 | need_to_fetch = false, |
104 | minimal_mode = true, | 112 | minimal_mode = true, |
105 | deps_mode = deps.get_deps_mode(args), | 113 | deps_mode = deps.get_deps_mode(args), |
@@ -111,17 +119,22 @@ function make.command(args) | |||
111 | pin = not not args.pin, | 119 | pin = not not args.pin, |
112 | rebuild = true, | 120 | rebuild = true, |
113 | no_install = not not args.no_install | 121 | no_install = not not args.no_install |
114 | }) | 122 | } |
115 | 123 | ||
116 | if args.sign and not args.pack_binary_rock then | 124 | if args.sign and not args.pack_binary_rock then |
117 | return nil, "In the make command, --sign is meant to be used only with --pack-binary-rock" | 125 | return nil, "In the make command, --sign is meant to be used only with --pack-binary-rock" |
118 | end | 126 | end |
119 | 127 | ||
120 | if args.no_install then | 128 | if args.no_install then |
121 | return build.build_rockspec(rockspec, opts, cwd) | 129 | name, version = build.build_rockspec(rockspec, opts, cwd) |
130 | if name then | ||
131 | return true | ||
132 | else | ||
133 | return nil, version | ||
134 | end | ||
122 | elseif args.pack_binary_rock then | 135 | elseif args.pack_binary_rock then |
123 | return pack.pack_binary_rock(name, namespace, rockspec.version, args.sign, function() | 136 | return pack.pack_binary_rock(name, namespace, rockspec.version, args.sign, function(): string, string |
124 | local name, version = build.build_rockspec(rockspec, opts, cwd) -- luacheck: ignore 431 | 137 | name, version = build.build_rockspec(rockspec, opts, cwd) -- luacheck: ignore 431 |
125 | if name and args.no_doc then | 138 | if name and args.no_doc then |
126 | util.remove_doc_dir(name, version) | 139 | util.remove_doc_dir(name, version) |
127 | end | 140 | end |
@@ -130,12 +143,12 @@ function make.command(args) | |||
130 | else | 143 | else |
131 | local ok, err = build.build_rockspec(rockspec, opts, cwd) | 144 | local ok, err = build.build_rockspec(rockspec, opts, cwd) |
132 | if not ok then return nil, err end | 145 | if not ok then return nil, err end |
133 | local name, version = ok, err -- luacheck: ignore 421 | 146 | name, version = ok, err -- luacheck: ignore 421 |
134 | 147 | ||
135 | if opts.build_only_deps then | 148 | if opts.build_only_deps then |
136 | util.printout("Stopping after installing dependencies for " ..name.." "..version) | 149 | util.printout("Stopping after installing dependencies for " ..name.." "..version) |
137 | util.printout() | 150 | util.printout() |
138 | return name, version | 151 | return name ~= nil, version |
139 | end | 152 | end |
140 | 153 | ||
141 | if args.no_doc then | 154 | if args.no_doc then |
@@ -151,12 +164,12 @@ function make.command(args) | |||
151 | end | 164 | end |
152 | end | 165 | end |
153 | 166 | ||
154 | writer.check_dependencies(nil, deps.get_deps_mode(args)) | 167 | deps.check_dependencies(nil, deps.get_deps_mode(args)) |
155 | return name, version | 168 | return name ~= nil, version |
156 | end | 169 | end |
157 | end | 170 | end |
158 | 171 | ||
159 | make.needs_lock = function(args) | 172 | make.needs_lock = function(args: Args): boolean |
160 | if args.pack_binary_rock or args.no_install then | 173 | if args.pack_binary_rock or args.no_install then |
161 | return false | 174 | return false |
162 | end | 175 | end |