PageRenderTime 25ms CodeModel.GetById 20ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/src/luarocks/build/command.lua

http://github.com/keplerproject/luarocks
Lua | 41 lines | 26 code | 8 blank | 7 comment | 5 complexity | 1fd81ed9f3fafee8b87c1d0de1583b38 MD5 | raw file
 1
 2--- Build back-end for raw listing of commands in rockspec files.
 3local command = {}
 4
 5local fs = require("luarocks.fs")
 6local util = require("luarocks.util")
 7local cfg = require("luarocks.core.cfg")
 8
 9--- Driver function for the "command" build back-end.
10-- @param rockspec table: the loaded rockspec.
11-- @return boolean or (nil, string): true if no errors occurred,
12-- nil and an error message otherwise.
13function command.run(rockspec)
14   assert(rockspec:type() == "rockspec")
15
16   local build = rockspec.build
17   
18   util.variable_substitutions(build, rockspec.variables)
19
20   local env = {
21      CC = cfg.variables.CC,
22      --LD = cfg.variables.LD,
23      --CFLAGS = cfg.variables.CFLAGS,
24   }
25
26   if build.build_command then
27      util.printout(build.build_command)
28      if not fs.execute_env(env, build.build_command) then
29         return nil, "Failed building."
30      end
31   end
32   if build.install_command then
33      util.printout(build.install_command)
34      if not fs.execute_env(env, build.install_command) then
35         return nil, "Failed installing."
36      end
37   end
38   return true
39end
40
41return command