aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-03-19 17:11:36 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-03-19 17:13:22 -0300
commit51ea074d9886995a649f2f2251832c2741e6d4cd (patch)
treeb2d3423653f65211e93d05d401d8cb7c8a3abb51 /src
parenta02a53a8f433dae109e224a49624cec5e6d699c1 (diff)
downloadluarocks-51ea074d9886995a649f2f2251832c2741e6d4cd.tar.gz
luarocks-51ea074d9886995a649f2f2251832c2741e6d4cd.tar.bz2
luarocks-51ea074d9886995a649f2f2251832c2741e6d4cd.zip
Expose platform and processor to home config files.
platform is a {string:boolean} table, with things such as platform.unix = true and platform.linux = true. processor is the same machine arch string you get when packing a binary rock (eg. "x86", "x86_64", "powerpc"). Closes #296.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/cfg.lua16
-rw-r--r--src/luarocks/util.lua4
2 files changed, 14 insertions, 6 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index b4781840..45dbdd1b 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -158,17 +158,25 @@ if (not sys_config_ok) and errcode ~= "open" then
158 os.exit(cfg.errorcodes.CONFIGFILE) 158 os.exit(cfg.errorcodes.CONFIGFILE)
159end 159end
160 160
161local env_for_config_file = {
162 home = cfg.home,
163 lua_version = cfg.lua_version,
164 platform = util.make_shallow_copy(detected),
165 processor = proc,
166}
167
161if not site_config.LUAROCKS_FORCE_CONFIG then 168if not site_config.LUAROCKS_FORCE_CONFIG then
169
162 local home_overrides, err, errcode 170 local home_overrides, err, errcode
163 home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") 171 home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG")
164 if home_config_file then 172 if home_config_file then
165 home_overrides, err, errcode = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version }) 173 home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file)
166 else 174 else
167 home_config_file = home_config_dir.."/config-"..cfg.lua_version..".lua" 175 home_config_file = home_config_dir.."/config-"..cfg.lua_version..".lua"
168 home_overrides, err, errcode = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version }) 176 home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file)
169 if (not home_overrides) and (not errcode == "run") then 177 if (not home_overrides) and (not errcode == "run") then
170 home_config_file = home_config_dir.."/config.lua" 178 home_config_file = home_config_dir.."/config.lua"
171 home_overrides, err, errcode = persist.load_into_table(home_config_file, { home = cfg.home, lua_version = cfg.lua_version }) 179 home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file)
172 end 180 end
173 end 181 end
174 if home_overrides then 182 if home_overrides then
@@ -447,7 +455,7 @@ if detected.macosx then
447 if version >= 10 then 455 if version >= 10 then
448 version = 8 456 version = 8
449 elseif version >= 5 then 457 elseif version >= 5 then
450 version = 5 458 version = 5
451 else 459 else
452 defaults.gcc_rpath = false 460 defaults.gcc_rpath = false
453 end 461 end
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 8772883b..40af35bd 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -177,7 +177,7 @@ local var_format_pattern = "%$%((%a[%a%d_]+)%)"
177-- the original table (ie, does not copy recursively). 177-- the original table (ie, does not copy recursively).
178-- @param tbl table: the input table 178-- @param tbl table: the input table
179-- @return table: a new table with the same contents. 179-- @return table: a new table with the same contents.
180local function make_shallow_copy(tbl) 180function util.make_shallow_copy(tbl)
181 local copy = {} 181 local copy = {}
182 for k,v in pairs(tbl) do 182 for k,v in pairs(tbl) do
183 copy[k] = v 183 copy[k] = v
@@ -196,7 +196,7 @@ end
196-- needed variables. 196-- needed variables.
197-- @param msg string: the warning message to display. 197-- @param msg string: the warning message to display.
198function util.warn_if_not_used(var_defs, needed_set, msg) 198function util.warn_if_not_used(var_defs, needed_set, msg)
199 needed_set = make_shallow_copy(needed_set) 199 needed_set = util.make_shallow_copy(needed_set)
200 for _, val in pairs(var_defs) do 200 for _, val in pairs(var_defs) do
201 for used in val:gmatch(var_format_pattern) do 201 for used in val:gmatch(var_format_pattern) do
202 needed_set[used] = nil 202 needed_set[used] = nil