/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. --- Build back-end for raw listing of commands in rockspec files.
  2. local command = {}
  3. local fs = require("luarocks.fs")
  4. local util = require("luarocks.util")
  5. local cfg = require("luarocks.core.cfg")
  6. --- Driver function for the "command" build back-end.
  7. -- @param rockspec table: the loaded rockspec.
  8. -- @return boolean or (nil, string): true if no errors occurred,
  9. -- nil and an error message otherwise.
  10. function command.run(rockspec)
  11. assert(rockspec:type() == "rockspec")
  12. local build = rockspec.build
  13. util.variable_substitutions(build, rockspec.variables)
  14. local env = {
  15. CC = cfg.variables.CC,
  16. --LD = cfg.variables.LD,
  17. --CFLAGS = cfg.variables.CFLAGS,
  18. }
  19. if build.build_command then
  20. util.printout(build.build_command)
  21. if not fs.execute_env(env, build.build_command) then
  22. return nil, "Failed building."
  23. end
  24. end
  25. if build.install_command then
  26. util.printout(build.install_command)
  27. if not fs.execute_env(env, build.install_command) then
  28. return nil, "Failed installing."
  29. end
  30. end
  31. return true
  32. end
  33. return command