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