annotate share/lua/5.2/luarocks/make.lua @ 12246:f3be034784d0 draft

<b_jonas> addwhatis brachylog(1egobot) - Brachylog, a Prolog-like golf language
author HackEso <hackeso@esolangs.org>
date Thu, 05 Dec 2019 23:44:34 +0000
parents d137f631bad5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1132
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
1
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
2 --- Module implementing the LuaRocks "make" command.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
3 -- Builds sources in the current directory, but unlike "build",
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
4 -- it does not fetch sources, etc., assuming everything is
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
5 -- available in the current directory.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
6 module("luarocks.make", package.seeall)
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
7
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
8 local build = require("luarocks.build")
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
9 local fs = require("luarocks.fs")
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
10 local util = require("luarocks.util")
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
11 local cfg = require("luarocks.cfg")
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
12 local fetch = require("luarocks.fetch")
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
13 local pack = require("luarocks.pack")
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
14 local deps = require("luarocks.deps")
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
15
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
16 help_summary = "Compile package in current directory using a rockspec."
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
17 help_arguments = "[--pack-binary-rock] [<rockspec>]"
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
18 help = [[
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
19 Builds sources in the current directory, but unlike "build",
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
20 it does not fetch sources, etc., assuming everything is
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
21 available in the current directory. If no argument is given,
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
22 look for a rockspec in the current directory. If more than one
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
23 is found, you must specify which to use, through the command-line.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
24
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
25 This command is useful as a tool for debugging rockspecs.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
26 To install rocks, you'll normally want to use the "install" and
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
27 "build" commands. See the help on those for details.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
28
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
29 If --pack-binary-rock is passed, the rock is not installed;
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
30 instead, a .rock file with the contents of compilation is produced
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
31 in the current directory.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
32 ]]
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
33
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
34 --- Driver function for "make" command.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
35 -- @param name string: A local rockspec.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
36 -- @return boolean or (nil, string): True if build was successful; nil and an
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
37 -- error message otherwise.
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
38 function run(...)
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
39 local flags, rockspec = util.parse_flags(...)
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
40 assert(type(rockspec) == "string" or not rockspec)
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
41
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
42 if not rockspec then
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
43 local files = fs.list_dir(fs.current_dir())
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
44 for _, file in pairs(files) do
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
45 if file:match("rockspec$") then
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
46 if rockspec then
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
47 return nil, "Please specify which rockspec file to use."
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
48 else
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
49 rockspec = file
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
50 end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
51 end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
52 end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
53 if not rockspec then
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
54 return nil, "Argument missing: please specify a rockspec to use on current directory."
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
55 end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
56 end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
57 if not rockspec:match("rockspec$") then
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
58 return nil, "Invalid argument: 'make' takes a rockspec as a parameter. See help."
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
59 end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
60
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
61 if flags["pack-binary-rock"] then
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
62 local rspec, err, errcode = fetch.load_rockspec(rockspec)
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
63 if not rspec then
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
64 return nil, err
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
65 end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
66 return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true, deps.get_deps_mode(flags))
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
67 else
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
68 local ok, err = fs.check_command_permissions(flags)
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
69 if not ok then return nil, err end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
70 return build.build_rockspec(rockspec, false, true, deps.get_deps_mode(flags))
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
71 end
d137f631bad5 <GreyKnight> (cd luabuild/luarocks-2.0.12; make install)
HackBot
parents:
diff changeset
72 end