adding-packages-luarocks.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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: # luafoo
  12. 04: #
  13. 05: ################################################################################
  14. 06:
  15. 07: LUAFOO_VERSION = 1.0.2-1
  16. 08: LUAFOO_DEPENDENCIES = foo
  17. 09:
  18. 10: LUAFOO_BUILD_OPTS += FOO_INCDIR=$(STAGING_DIR)/usr/include
  19. 11: LUAFOO_BUILD_OPTS += FOO_LIBDIR=$(STAGING_DIR)/usr/lib
  20. 12: LUAFOO_LICENSE = luaFoo license
  21. 13: LUAFOO_LICENSE_FILES = COPYING
  22. 14:
  23. 15: $(eval $(luarocks-package))
  24. ------------------------
  25. On line 7, we declare the version of the package (the same as in the rockspec,
  26. which is the concatenation of the upstream version and the rockspec revision,
  27. separated by a hyphen '-').
  28. On line 8, we declare our dependencies against native libraries, so that they
  29. are built before the build process of our package starts.
  30. On lines 10-11, we tell Buildroot to pass custom options to LuaRocks when it is
  31. building the package.
  32. On lines 12-13, we specify the licensing terms for the package.
  33. Finally, on line 15, we invoke the +luarocks-package+
  34. macro that generates all the Makefile rules that actually allows the
  35. package to be built.
  36. [[luarocks-package-reference]]
  37. ==== +luarocks-package+ reference
  38. LuaRocks is a deployment and management system for Lua modules, and supports
  39. various +build.type+: +builtin+, +make+ and +cmake+. In the context of
  40. Buildroot, the +luarocks-package+ infrastructure only supports the +builtin+
  41. mode. LuaRocks packages that use the +make+ or +cmake+ build mechanisms
  42. should instead be packaged using the +generic-package+ and +cmake-package+
  43. infrastructures in Buildroot, respectively.
  44. The main macro of the LuaRocks package infrastructure is +luarocks-package+:
  45. like +generic-package+ it works by defining a number of variables providing
  46. metadata information about the package, and then calling +luarocks-package+. It
  47. is worth mentioning that building LuaRocks packages for the host is not
  48. supported, so the macro +host-luarocks-package+ is not implemented.
  49. Just like the generic infrastructure, the LuaRocks infrastructure works
  50. by defining a number of variables before calling the +luarocks-package+
  51. macro.
  52. First, all the package metadata information variables that exist in
  53. the generic infrastructure also exist in the LuaRocks infrastructure:
  54. +LUAFOO_VERSION+, +LUAFOO_SOURCE+, +LUAFOO_SITE+,
  55. +LUAFOO_DEPENDENCIES+, +LUAFOO_LICENSE+, +LUAFOO_LICENSE_FILES+.
  56. Two of them are populated by the LuaRocks infrastructure (for the
  57. +download+ step). If your package is not hosted on the LuaRocks mirror
  58. +$(BR2_LUAROCKS_MIRROR)+, you can override them:
  59. * +LUAFOO_SITE+, which defaults to +$(BR2_LUAROCKS_MIRROR)+
  60. * +LUAFOO_SOURCE+, which defaults to +luafoo-$(LUAFOO_VERSION).src.rock+
  61. A few additional variables, specific to the LuaRocks infrastructure, are
  62. also defined. They can be overridden in specific cases.
  63. * +LUAFOO_ROCKSPEC+, which defaults to +luafoo-$(LUAFOO_VERSION).rockspec+
  64. * +LUAFOO_SUBDIR+, which defaults to
  65. +luafoo-$(LUAFOO_VERSION_WITHOUT_ROCKSPEC_REVISION)+
  66. * +LUAFOO_BUILD_OPTS+ contains additional build options for the
  67. +luarocks build+ call.