adding-packages-luarocks.txt 3.4 KB

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