adding-packages-luarocks.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. === Infrastructure for LuaRocks-based packages
  4. [[luarocks-package-tutorial]]
  5. ==== +luarocks-package+ tutorial
  6. First, let's see how to write a +.mk+ file for a LuaRocks-based package,
  7. with an example :
  8. ------------------------
  9. 01: ################################################################################
  10. 02: #
  11. 03: # lua-foo
  12. 04: #
  13. 05: ################################################################################
  14. 06:
  15. 07: LUA_FOO_VERSION = 1.0.2-1
  16. 08: LUA_FOO_NAME_UPSTREAM = foo
  17. 09: LUA_FOO_DEPENDENCIES = bar
  18. 10:
  19. 11: LUA_FOO_BUILD_OPTS += BAR_INCDIR=$(STAGING_DIR)/usr/include
  20. 12: LUA_FOO_BUILD_OPTS += BAR_LIBDIR=$(STAGING_DIR)/usr/lib
  21. 13: LUA_FOO_LICENSE = luaFoo license
  22. 14: LUA_FOO_LICENSE_FILES = $(LUA_FOO_SUBDIR)/COPYING
  23. 15:
  24. 16: $(eval $(luarocks-package))
  25. ------------------------
  26. On line 7, we declare the version of the package (the same as in the rockspec,
  27. which is the concatenation of the upstream version and the rockspec revision,
  28. separated by a hyphen '-').
  29. On line 8, we declare that the package is called "foo" on LuaRocks. In
  30. Buildroot, we give Lua-related packages a name that starts with "lua", so the
  31. Buildroot name is different from the upstream name. +LUA_FOO_NAME_UPSTREAM+
  32. makes the link between the two names.
  33. On line 9, we declare our dependencies against native libraries, so that they
  34. are built before the build process of our package starts.
  35. On lines 11-12, we tell Buildroot to pass custom options to LuaRocks when it is
  36. building the package.
  37. On lines 13-14, we specify the licensing terms for the package.
  38. Finally, on line 16, we invoke the +luarocks-package+
  39. macro that generates all the Makefile rules that actually allows the
  40. package to be built.
  41. [[luarocks-package-reference]]
  42. ==== +luarocks-package+ reference
  43. LuaRocks is a deployment and management system for Lua modules, and supports
  44. various +build.type+: +builtin+, +make+ and +cmake+. In the context of
  45. Buildroot, the +luarocks-package+ infrastructure only supports the +builtin+
  46. mode. LuaRocks packages that use the +make+ or +cmake+ build mechanisms
  47. should instead be packaged using the +generic-package+ and +cmake-package+
  48. infrastructures in Buildroot, respectively.
  49. The main macro of the LuaRocks package infrastructure is +luarocks-package+:
  50. like +generic-package+ it works by defining a number of variables providing
  51. metadata information about the package, and then calling +luarocks-package+. It
  52. is worth mentioning that building LuaRocks packages for the host is not
  53. supported, so the macro +host-luarocks-package+ is not implemented.
  54. Just like the generic infrastructure, the LuaRocks infrastructure works
  55. by defining a number of variables before calling the +luarocks-package+
  56. macro.
  57. First, all the package metadata information variables that exist in
  58. the generic infrastructure also exist in the LuaRocks infrastructure:
  59. +LUA_FOO_VERSION+, +LUA_FOO_SOURCE+, +LUA_FOO_SITE+,
  60. +LUA_FOO_DEPENDENCIES+, +LUA_FOO_LICENSE+, +LUA_FOO_LICENSE_FILES+.
  61. Two of them are populated by the LuaRocks infrastructure (for the
  62. +download+ step). If your package is not hosted on the LuaRocks mirror
  63. +$(BR2_LUAROCKS_MIRROR)+, you can override them:
  64. * +LUA_FOO_SITE+, which defaults to +$(BR2_LUAROCKS_MIRROR)+
  65. * +LUA_FOO_SOURCE+, which defaults to
  66. +$(lowercase LUA_FOO_NAME_UPSTREAM)-$(LUA_FOO_VERSION).src.rock+
  67. A few additional variables, specific to the LuaRocks infrastructure, are
  68. also defined. They can be overridden in specific cases.
  69. * +LUA_FOO_NAME_UPSTREAM+, which defaults to +lua-foo+, i.e. the Buildroot
  70. package name
  71. * +LUA_FOO_ROCKSPEC+, which defaults to
  72. +$(lowercase LUA_FOO_NAME_UPSTREAM)-$(LUA_FOO_VERSION).rockspec+
  73. * +LUA_FOO_SUBDIR+, which defaults to
  74. +$(LUA_FOO_NAME_UPSTREAM)-$(LUA_FOO_VERSION_WITHOUT_ROCKSPEC_REVISION)+
  75. * +LUA_FOO_BUILD_OPTS+ contains additional build options for the
  76. +luarocks build+ call.