Skip to contentSkip to conversation

package/luarocks: rework configuration file for per-package folders

PATCH Superseded Thomas Petazzoni 2 participants 3 messages Nov 30, 2018 – Dec 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 package/luarocks: rework configuration file for per-package folders

Currently, luarocks.mk generates a configuration file with hardcoded STAGING_DIR, TARGET_DIR, TARGET_CC, LUAROCKS_CFLAGS and TARGET_LDFLAGS values. This is not compatible with per-package folders, where the value of STAGING_DIR, TARGET_DIR, TARGET_CC and possibly TARGET_CFLAGS/TARGET_LDFLAGS may be different from one package to the other.

Based on input from Fran?ois Perrad, this commit:

- Changes the Luarocks configuration file to use os_getenv() for the appropriate variables. Since the contents of this file is not fixed, it is no longer generated by luarocks.mk using a series of 'echo' but simply concatenated with the rest of the Luarocks configuration file.

- Adjusts LUAROCKS_RUNV_ENV so that the necessary environment variables are now passed.

---
Changes since v2:
- Do not pass STAGING_DIR/TARGET_DIR in LUAROCKS_RUN_ENV, since they are already exported globally in the environment. Suggested by Arnout Vandecappelle.

Changes since v1:
- Drop the luarocks patch exporting getenv() in the sandbox, as Fran?ois explained this is not needed.
- Define a getenv() function in luarocks-br-config that returns the empty string when os_getenv() returns nothing so that luarocks can still be called without all the environment variable defined, as suggested by Fran?ois.

---
 package/luarocks/luarocks-br-config.lua | 13 +++++++++++++
 package/luarocks/luarocks.mk            | 19 ++++++-------------
 2 files changed, 19 insertions(+), 13 deletions(-)
 create mode 100644 package/luarocks/luarocks-br-config.lua
package/luarocks/luarocks-br-config.lua new file +13 -0
new file mode 100644
index 0000000000..32d71e1e21
@@ -0,0 +1,13 @@
+-- BR cross-compilation
+local function getenv (name) return os_getenv(name) or '' end
+variables.LUA_INCDIR = getenv('STAGING_DIR') .. [[/usr/include]]
+variables.LUA_LIBDIR = getenv('STAGING_DIR') .. [[/usr/lib]]
+variables.CC = getenv('TARGET_CC')
+variables.LD = getenv('TARGET_CC')
+variables.CFLAGS = getenv('TARGET_CFLAGS')
+variables.LIBFLAG = [[-shared ]] .. getenv('TARGET_LDFLAGS')
+external_deps_dirs = { getenv('STAGING_DIR') .. [[/usr]] }
+gcc_rpath = false
+rocks_trees = { getenv('TARGET_DIR') .. [[/usr]] }
+wrap_bin_scripts = false
+deps_mode = [[none]]
package/luarocks/luarocks.mk +6 -13
index cfef8f19b3..1b29a21406 100644
@@ -30,23 +30,16 @@ endef
 define HOST_LUAROCKS_INSTALL_CMDS
 	rm -f $(LUAROCKS_CONFIG_FILE)
 	$(MAKE1) -C $(@D) install
-	echo "-- BR cross-compilation"                                  >> $(LUAROCKS_CONFIG_FILE)
-	echo "variables.LUA_INCDIR = [[$(STAGING_DIR)/usr/include]]"    >> $(LUAROCKS_CONFIG_FILE)
-	echo "variables.LUA_LIBDIR = [[$(STAGING_DIR)/usr/lib]]"        >> $(LUAROCKS_CONFIG_FILE)
-	echo "variables.CC = [[$(TARGET_CC)]]"                          >> $(LUAROCKS_CONFIG_FILE)
-	echo "variables.LD = [[$(TARGET_CC)]]"                          >> $(LUAROCKS_CONFIG_FILE)
-	echo "variables.CFLAGS = [[$(LUAROCKS_CFLAGS)]]"                >> $(LUAROCKS_CONFIG_FILE)
-	echo "variables.LIBFLAG = [[-shared $(TARGET_LDFLAGS)]]"        >> $(LUAROCKS_CONFIG_FILE)
-	echo "external_deps_dirs = { [[$(STAGING_DIR)/usr]] }"          >> $(LUAROCKS_CONFIG_FILE)
-	echo "gcc_rpath = false"                                        >> $(LUAROCKS_CONFIG_FILE)
-	echo "rocks_trees = { [[$(TARGET_DIR)/usr]] }"                  >> $(LUAROCKS_CONFIG_FILE)
-	echo "wrap_bin_scripts = false"                                 >> $(LUAROCKS_CONFIG_FILE)
-	echo "deps_mode = [[none]]"                                     >> $(LUAROCKS_CONFIG_FILE)
+	cat $(HOST_LUAROCKS_PKGDIR)/luarocks-br-config.lua >> $(LUAROCKS_CONFIG_FILE)
 endef
 
 $(eval $(host-generic-package))
 
-LUAROCKS_RUN_ENV = LUA_PATH="$(HOST_DIR)/share/lua/$(LUAINTERPRETER_ABIVER)/?.lua"
+LUAROCKS_RUN_ENV = \
+	LUA_PATH="$(HOST_DIR)/share/lua/$(LUAINTERPRETER_ABIVER)/?.lua" \
+	TARGET_CC="$(TARGET_CC)" \
+	TARGET_CFLAGS="$(LUAROCKS_CFLAGS)" \
+	TARGET_LDFLAGS="$(TARGET_LDFLAGS)"
 LUAROCKS_RUN_CMD = $(LUA_RUN) $(HOST_DIR)/bin/luarocks
 
 define LUAROCKS_FINALIZE_TARGET
Signature · 1 line
2.19.2
#1 lore raw

PATCH v3 1/1 package/luarocks: rework configuration file for per-package folders

Le ven. 30 nov. 2018 ? 11:38, Thomas Petazzoni <[email protected]> a ?crit :

Quoted 15 lines

Currently, luarocks.mk generates a configuration file with hardcoded STAGING_DIR, TARGET_DIR, TARGET_CC, LUAROCKS_CFLAGS and TARGET_LDFLAGS values. This is not compatible with per-package folders, where the value of STAGING_DIR, TARGET_DIR, TARGET_CC and possibly TARGET_CFLAGS/TARGET_LDFLAGS may be different from one package to the other.

Based on input from Fran?ois Perrad, this commit:

- Changes the Luarocks configuration file to use os_getenv() for the appropriate variables. Since the contents of this file is not fixed, it is no longer generated by luarocks.mk using a series of 'echo' but simply concatenated with the rest of the Luarocks configuration file.

Quoted 5 lines

- Adjusts LUAROCKS_RUNV_ENV so that the necessary environment variables are now passed.

---

Quoted 87 lines

Changes since v2:
- Do not pass STAGING_DIR/TARGET_DIR in LUAROCKS_RUN_ENV, since they are already exported globally in the environment. Suggested by Arnout Vandecappelle.

Changes since v1:
- Drop the luarocks patch exporting getenv() in the sandbox, as Fran?ois explained this is not needed.
- Define a getenv() function in luarocks-br-config that returns the empty string when os_getenv() returns nothing so that luarocks can still be called without all the environment variable defined, as suggested by Fran?ois.

---
 package/luarocks/luarocks-br-config.lua | 13 +++++++++++++
 package/luarocks/luarocks.mk            | 19 ++++++-------------
 2 files changed, 19 insertions(+), 13 deletions(-)
 create mode 100644 package/luarocks/luarocks-br-config.lua
package/luarocks/luarocks-br-config.lua new file +13 -0
new file mode 100644
index 0000000000..32d71e1e21
@@ -0,0 +1,13 @@
+-- BR cross-compilation
+local function getenv (name) return os_getenv(name) or '' end
+variables.LUA_INCDIR = getenv('STAGING_DIR') .. [[/usr/include]]
+variables.LUA_LIBDIR = getenv('STAGING_DIR') .. [[/usr/lib]]
+variables.CC = getenv('TARGET_CC')
+variables.LD = getenv('TARGET_CC')
+variables.CFLAGS = getenv('TARGET_CFLAGS')
+variables.LIBFLAG = [[-shared ]] .. getenv('TARGET_LDFLAGS')
+external_deps_dirs = { getenv('STAGING_DIR') .. [[/usr]] }
+gcc_rpath = false
+rocks_trees = { getenv('TARGET_DIR') .. [[/usr]] }
+wrap_bin_scripts = false
+deps_mode = [[none]]
package/luarocks/luarocks.mk +0 -11
index cfef8f19b3..1b29a21406 100644
@@ -30,23 +30,16 @@ endef
 define HOST_LUAROCKS_INSTALL_CMDS
        rm -f $(LUAROCKS_CONFIG_FILE)
        $(MAKE1) -C $(@D) install
-       echo "-- BR cross-compilation"                                  >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "variables.LUA_INCDIR = [[$(STAGING_DIR)/usr/include]]"    >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "variables.LUA_LIBDIR = [[$(STAGING_DIR)/usr/lib]]"        >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "variables.CC = [[$(TARGET_CC)]]"                          >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "variables.LD = [[$(TARGET_CC)]]"                          >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "variables.CFLAGS = [[$(LUAROCKS_CFLAGS)]]"                >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "variables.LIBFLAG = [[-shared $(TARGET_LDFLAGS)]]"        >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "external_deps_dirs = { [[$(STAGING_DIR)/usr]] }"          >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "gcc_rpath = false"                                        >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "rocks_trees = { [[$(TARGET_DIR)/usr]] }"                  >>
 $(LUAROCKS_CONFIG_FILE)
-       echo "wrap_bin_scripts = false"                                 >>

$(LUAROCKS_CONFIG_FILE)
- echo "deps_mode = [[none]]" >>
$(LUAROCKS_CONFIG_FILE)
+ cat $(HOST_LUAROCKS_PKGDIR)/luarocks-br-config.lua >>
$(LUAROCKS_CONFIG_FILE)
endef

$(eval $(host-generic-package))

-LUAROCKS_RUN_ENV = LUA_PATH="$(HOST_DIR)/share/lua/$(LUAINTERPRETER_ABIVER)/?.lua"

package/luarocks/luarocks.mk +5 -1
+LUAROCKS_RUN_ENV = \
+       LUA_PATH="$(HOST_DIR)/share/lua/$(LUAINTERPRETER_ABIVER)/?.lua" \
+       TARGET_CC="$(TARGET_CC)" \
+       TARGET_CFLAGS="$(LUAROCKS_CFLAGS)" \
+       TARGET_LDFLAGS="$(TARGET_LDFLAGS)"
 LUAROCKS_RUN_CMD = $(LUA_RUN) $(HOST_DIR)/bin/luarocks
 
 define LUAROCKS_FINALIZE_TARGET
--
Quoted 3 lines

2.19.2

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20181201/c6fee140/attachment.html>

author Applied
#2 lore raw

PATCH v3 1/1 package/luarocks: rework configuration file for per-package folders

In reply to Thomas Petazzoni

Hello,

Quoted 18 lines · Thomas Petazzoni

Currently, luarocks.mk generates a configuration file with hardcoded STAGING_DIR, TARGET_DIR, TARGET_CC, LUAROCKS_CFLAGS and TARGET_LDFLAGS values. This is not compatible with per-package folders, where the value of STAGING_DIR, TARGET_DIR, TARGET_CC and possibly TARGET_CFLAGS/TARGET_LDFLAGS may be different from one package to the other.

Based on input from Fran?ois Perrad, this commit:

- Changes the Luarocks configuration file to use os_getenv() for the appropriate variables. Since the contents of this file is not fixed, it is no longer generated by luarocks.mk using a series of 'echo' but simply concatenated with the rest of the Luarocks configuration file.

- Adjusts LUAROCKS_RUNV_ENV so that the necessary environment variables are now passed.

Quoted 6 lines

---
Changes since v2:
- Do not pass STAGING_DIR/TARGET_DIR in LUAROCKS_RUN_ENV, since they are already exported globally in the environment. Suggested by Arnout Vandecappelle.

Applied to next, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com