From f97f5ff4bffac88f61bdc43651cd658ba4fd71d0 Mon Sep 17 00:00:00 2001 From: Eloy Coto Date: Mon, 2 Mar 2020 12:12:47 +0100 Subject: [PATCH] ADD a option to specified custom CFLAGS on install. APIcast has a issue that a custom CFLAGS need to be sent to gcc, in luarocks we can use: ``` luarocks install XXX CFLAGS="XX" ``` But in this case we can't, so I added this new env variable to be able to set custom CFLAGS Signed-off-by: Eloy Coto --- src/rover/cli/install.lua | 1 + src/rover/install.lua | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/rover/cli/install.lua b/src/rover/cli/install.lua index 90f1b44..1f3c13e 100644 --- a/src/rover/cli/install.lua +++ b/src/rover/cli/install.lua @@ -17,6 +17,7 @@ local function format_status(status) end function mt:__call(options) + install.set_extra_cflags(os.getenv("EXTRA_CFLAGS")) local lock = options.roverfile .. '.lock' local lockfile = assert(rover_lock.read(lock)) diff --git a/src/rover/install.lua b/src/rover/install.lua index aa84684..b4ff57f 100644 --- a/src/rover/install.lua +++ b/src/rover/install.lua @@ -4,6 +4,7 @@ local next = next local fs = require('luarocks.fs') local build = require("luarocks.build") +local cfg = require("luarocks.cfg") local repos = require("luarocks.repos") local search = require('luarocks.search') @@ -80,6 +81,13 @@ local function should_install(dep, desired_groups) return false end +function _M.set_extra_cflags(flag) + if not flag then + return + end + + cfg.variables.CFLAGS = cfg.variables.CFLAGS .. " " .. flag +end function _M:call(lock, force, groups) local status = {}