From patchwork Wed Sep 18 06:19:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francois Perrad X-Patchwork-Id: 1163762 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VDJkTqrk"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Y8vw4Ylvz9sNf for ; Wed, 18 Sep 2019 16:19:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 07F428646F; Wed, 18 Sep 2019 06:19:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ui+701Dd8gum; Wed, 18 Sep 2019 06:19:31 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 8342986473; Wed, 18 Sep 2019 06:19:31 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 268FC1BF5F6 for ; Wed, 18 Sep 2019 06:19:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 23D058506D for ; Wed, 18 Sep 2019 06:19:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3jTmnvz5lgLl for ; Wed, 18 Sep 2019 06:19:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by whitealder.osuosl.org (Postfix) with ESMTPS id 874D6841D5 for ; Wed, 18 Sep 2019 06:19:27 +0000 (UTC) Received: by mail-wr1-f45.google.com with SMTP id o18so5458270wrv.13 for ; Tue, 17 Sep 2019 23:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wR6rvbnI0iIPMKnrDZKuc9iaxllve+KEAeyZE1w0cvM=; b=VDJkTqrkVQhAc00yJRePG7orpt3be9aICD20/po+nwisBtxWm/XT6/2gVPMwMDdhCt RLqhQo2JHkckiI8KL4rsEsZzCz5kevWkUy4yqdRlbdcsNUShYpgAYB0WCFWiXR6KxILG YfroL5RNBoyv2AhNekPt6qS1cM/aHLEoEr5d8j/i3wNMcjhZ7dgNLFhSTYnRLfNAXXW4 k8VDTMYiRqOMtmSaia6lA2+VJVHUZceSAV3h+uL6MGPonBeXCiF+FqupZxlhRUSB7jTG tpiny1+BO0Kclgs9lW+v7mrLtQPii0k1O56ZuVjrUmRdDjnvO0OECcFtspx2Cnj8OJ2d THAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wR6rvbnI0iIPMKnrDZKuc9iaxllve+KEAeyZE1w0cvM=; b=jnc+I2FMBtWlB5TEXHr9nXsdJHXnB3IPZEd/bT4Sms68hRa9FTFThkaF3erJL/Wief 0xCWrivicJ/9sxiTFtGxkObUZ8bUt8eYN+dRCwBt/Ju0WzgemiUK8e+qn4tx4xpxLl8L J/coApPI4bhNNSZ00ooK3WP2r5UTv9XezMuk9AMLXGWwIE8Cy7wiwfJcufPxiU5jXjUH 5HlvBaXuZHXE+9sVL5xtoO50PDqaE+XuAXbYBc0VpTqORL8NpCnp3+XTrbM8Oo962Ktp 8PxBV8Ee3dDIOHTVbwkJBxKKcF+0JCthFJpY1y6jL/b+7rRNiFHCOHqYZmTbUZSMzwaM xQ9w== X-Gm-Message-State: APjAAAVWlwowSMUoybWx26j2oxtChtcj2CGYdhc0GFRi08UNf7YheGql EbvX0ITIJ/IUzkccYJCNpKlsPWUz X-Google-Smtp-Source: APXvYqzfAVhPvuCzY1kHQ+DmmYPL0fJ515SHsihF+xGd6r04mslaOmIgENw72oq3rOVKEIrCKxUWZQ== X-Received: by 2002:adf:fd10:: with SMTP id e16mr1654436wrr.17.1568787565773; Tue, 17 Sep 2019 23:19:25 -0700 (PDT) Received: from localhost.localdomain (254.7.19.109.rev.sfr.net. [109.19.7.254]) by smtp.gmail.com with ESMTPSA id y3sm5329512wmg.2.2019.09.17.23.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2019 23:19:25 -0700 (PDT) From: Francois Perrad X-Google-Original-From: Francois Perrad To: buildroot@busybox.net Date: Wed, 18 Sep 2019 08:19:11 +0200 Message-Id: <20190918061915.31250-2-francois.perrad@gadz.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190918061915.31250-1-francois.perrad@gadz.org> References: <20190918061915.31250-1-francois.perrad@gadz.org> MIME-Version: 1.0 Subject: [Buildroot] [pkg-luarocks 2/6] pkg-luarocks: refactor infra X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" all variables containing BR data (except external_deps_dirs) are now options of the command `luarocks make` paths for external dependencies are now handled by the BR addon which generates the variable _BUILD_OPTS with the content excepted by `luarocks make` and the remaining content of luarocks-br-config.lua is now inlined in luarocks.mk here, the config file is usable for host-luarocks Signed-off-by: Francois Perrad --- docs/manual/adding-packages-luarocks.txt | 12 ++++++------ package/luarocks/buildroot.lua | 21 ++++++++++++++++++++- package/luarocks/luarocks-br-config.lua | 13 ------------- package/luarocks/luarocks.mk | 17 +++-------------- package/pkg-luarocks.mk | 16 +++++++++++++++- 5 files changed, 44 insertions(+), 35 deletions(-) delete mode 100644 package/luarocks/luarocks-br-config.lua diff --git a/docs/manual/adding-packages-luarocks.txt b/docs/manual/adding-packages-luarocks.txt index df97cdd50..f7104f373 100644 --- a/docs/manual/adding-packages-luarocks.txt +++ b/docs/manual/adding-packages-luarocks.txt @@ -19,10 +19,10 @@ with an example : 06: 07: LUA_FOO_VERSION = 1.0.2-1 08: LUA_FOO_NAME_UPSTREAM = foo -09: LUA_FOO_DEPENDENCIES = bar -10: -11: LUA_FOO_BUILD_OPTS += BAR_INCDIR=$(STAGING_DIR)/usr/include -12: LUA_FOO_BUILD_OPTS += BAR_LIBDIR=$(STAGING_DIR)/usr/lib +09: +10: LUA_FOO_DEPENDENCIES = bar +11: LUA_FOO_BUILD_OPTS = BAR_DIR=$(STAGING_DIR)/usr +12: 13: LUA_FOO_LICENSE = luaFoo license 14: LUA_FOO_LICENSE_FILES = $(LUA_FOO_SUBDIR)/COPYING 15: @@ -38,10 +38,10 @@ Buildroot, we give Lua-related packages a name that starts with "lua", so the Buildroot name is different from the upstream name. +LUA_FOO_NAME_UPSTREAM+ makes the link between the two names. -On line 9, we declare our dependencies against native libraries, so that they +On line 10, we declare our dependencies against native libraries, so that they are built before the build process of our package starts. -On lines 11-12, we tell Buildroot to pass custom options to LuaRocks when it is +On line 11, we tell Buildroot to pass custom options to LuaRocks when it is building the package. On lines 13-14, we specify the licensing terms for the package. diff --git a/package/luarocks/buildroot.lua b/package/luarocks/buildroot.lua index e829b6db0..e3ab3f7f1 100644 --- a/package/luarocks/buildroot.lua +++ b/package/luarocks/buildroot.lua @@ -94,9 +94,18 @@ local function get_main_modules (rockspec) return t end -local function get_external_dependencies (rockspec) +local function get_raw_external_dependencies (rockspec) local t = {} for k in pairs(rockspec.external_dependencies or {}) do + t[#t+1] = k + end + table.sort(t) + return t +end + +local function get_external_dependencies (rockspec) + local t = {} + for _, k in ipairs(get_raw_external_dependencies(rockspec)) do k = k:lower() if fs.is_dir('package/' .. k) then t[#t+1] = k @@ -254,6 +263,16 @@ local function generate_mk (rockspec, lcname, licenses) end if #external_dependencies > 0 then f:write(ucname .. '_DEPENDENCIES = ' .. table.concat(external_dependencies, ' ') .. '\n') + local deps = get_raw_external_dependencies(rockspec) + if #deps == 1 then + f:write(ucname .. '_BUILD_OPTS = ' .. deps[1] .. '_DIR="$(STAGING_DIR)/usr"\n') + else + f:write(ucname .. '_BUILD_OPTS =') + for i = 1, #deps do + f:write(' \\\n\t' .. deps[i] .. '_DIR="$(STAGING_DIR)/usr"') + end + f:write('\n') + end end f:write('\n$(eval $(luarocks-package))\n') f:close() diff --git a/package/luarocks/luarocks-br-config.lua b/package/luarocks/luarocks-br-config.lua deleted file mode 100644 index 32d71e1e2..000000000 --- a/package/luarocks/luarocks-br-config.lua +++ /dev/null @@ -1,13 +0,0 @@ --- 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]] diff --git a/package/luarocks/luarocks.mk b/package/luarocks/luarocks.mk index 9cf5aba8a..27fb753d5 100644 --- a/package/luarocks/luarocks.mk +++ b/package/luarocks/luarocks.mk @@ -13,10 +13,6 @@ HOST_LUAROCKS_DEPENDENCIES = host-luainterpreter LUAROCKS_CONFIG_DIR = $(HOST_DIR)/etc LUAROCKS_CONFIG_FILE = $(LUAROCKS_CONFIG_DIR)/luarocks/config-$(LUAINTERPRETER_ABIVER).lua -LUAROCKS_CFLAGS = $(TARGET_CFLAGS) -fPIC -ifeq ($(BR2_PACKAGE_LUA_5_3),y) -LUAROCKS_CFLAGS += -DLUA_COMPAT_5_2 -endif define LUAROCKS_ADDON_EXTRACT mkdir $(@D)/src/luarocks/cmd/external @@ -33,23 +29,16 @@ define HOST_LUAROCKS_CONFIGURE_CMDS cd $(@D) && ./configure $(HOST_LUAROCKS_CONF_OPTS) endef -ifeq ($(BR2_PACKAGE_LUAJIT),y) -define LUAROCKS_CONFIGURE_INTERPRETER_LUAJIT - echo "lua_interpreter = [[luajit]]" >> $(LUAROCKS_CONFIG_FILE) -endef -endif - define HOST_LUAROCKS_INSTALL_CMDS rm -f $(LUAROCKS_CONFIG_FILE) $(MAKE1) -C $(@D) install - cat $(HOST_LUAROCKS_PKGDIR)/luarocks-br-config.lua >> $(LUAROCKS_CONFIG_FILE) - $(LUAROCKS_CONFIGURE_INTERPRETER_LUAJIT) + echo "-- BR tricks" >> $(LUAROCKS_CONFIG_FILE) + echo "gcc_rpath = false" >> $(LUAROCKS_CONFIG_FILE) + echo "wrap_bin_scripts = false" >> $(LUAROCKS_CONFIG_FILE) endef $(eval $(host-generic-package)) -LUAROCKS_RUN_CMD = $(LUA_RUN) $(HOST_DIR)/bin/luarocks - define LUAROCKS_FINALIZE_TARGET rm -rf $(TARGET_DIR)/usr/lib/luarocks endef diff --git a/package/pkg-luarocks.mk b/package/pkg-luarocks.mk index ede9b2c83..23906f4a8 100644 --- a/package/pkg-luarocks.mk +++ b/package/pkg-luarocks.mk @@ -17,6 +17,12 @@ # ################################################################################ +LUAROCKS_RUN_CMD = $(HOST_DIR)/bin/luarocks +LUAROCKS_CFLAGS = $(TARGET_CFLAGS) -fPIC +ifeq ($(BR2_PACKAGE_LUA_5_3),y) +LUAROCKS_CFLAGS += -DLUA_COMPAT_5_2 +endif + ################################################################################ # inner-luarocks-package -- defines how the configuration, compilation and # installation of a LuaRocks package should be done, implements a few hooks to @@ -64,7 +70,15 @@ endif ifndef $(2)_INSTALL_TARGET_CMDS define $(2)_INSTALL_TARGET_CMDS cd $$($(2)_SRCDIR) && \ - $$(LUAROCKS_RUN_CMD) make --keep $$($(2)_ROCKSPEC) $$($(2)_BUILD_OPTS) + $$(LUAROCKS_RUN_CMD) make --keep --deps-mode none \ + --tree "$$(TARGET_DIR)/usr" \ + LUA_INCDIR="$$(STAGING_DIR)/usr/include" \ + LUA_LIBDIR="$$(STAGING_DIR)/usr/lib" \ + CC=$$(TARGET_CC) \ + LD=$$(TARGET_CC) \ + CFLAGS="$$(LUAROCKS_CFLAGS)" \ + LIBFLAG="-shared $$(TARGET_LDFLAGS)" \ + $$($(2)_BUILD_OPTS) $$($(2)_ROCKSPEC) endef endif