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