aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2015-06-24 17:03:10 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2015-06-24 17:03:10 +0200
commit8757d35dc25785d1d9bb6f66e8d8e9d596265ee2 (patch)
tree5a5a78fa63a27ec777e75539c3bdd145b4c9ccb1
parenta0315b7bc2432ea517bb90ce39df0cc8b1cd2f65 (diff)
downloadluarocks-8757d35dc25785d1d9bb6f66e8d8e9d596265ee2.tar.gz
luarocks-8757d35dc25785d1d9bb6f66e8d8e9d596265ee2.tar.bz2
luarocks-8757d35dc25785d1d9bb6f66e8d8e9d596265ee2.zip
- site_config remains local, not exposed
- added field 'target_cpu' to `cfg` and config file environments
-rw-r--r--src/luarocks/cfg.lua31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 48623765..ab7bc4ed 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -32,8 +32,6 @@ if not ok then
32 site_config = {} 32 site_config = {}
33end 33end
34 34
35cfg.site_config = site_config
36
37cfg.program_version = "scm" 35cfg.program_version = "scm"
38cfg.program_series = "2.2" 36cfg.program_series = "2.2"
39cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series 37cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series
@@ -87,6 +85,7 @@ elseif proc:match("amd64") or proc:match("x86_64") then
87elseif proc:match("Power Macintosh") then 85elseif proc:match("Power Macintosh") then
88 proc = "powerpc" 86 proc = "powerpc"
89end 87end
88cfg.target_cpu = proc
90 89
91if system == "FreeBSD" then 90if system == "FreeBSD" then
92 detected.unix = true 91 detected.unix = true
@@ -151,7 +150,8 @@ env_for_config_file = {
151 home = cfg.home, 150 home = cfg.home,
152 lua_version = cfg.lua_version, 151 lua_version = cfg.lua_version,
153 platform = util.make_shallow_copy(detected), 152 platform = util.make_shallow_copy(detected),
154 processor = proc, 153 processor = cfg.target_cpu, -- remains for compat reasons
154 target_cpu = cfg.target_cpu, -- replaces `processor`
155 os_getenv = os.getenv, 155 os_getenv = os.getenv,
156 dump_env = function() 156 dump_env = function()
157 -- debug function, calling it from a config file will show all 157 -- debug function, calling it from a config file will show all
@@ -323,7 +323,7 @@ if detected.windows then
323 323
324 home_config_file = home_config_file and home_config_file:gsub("\\","/") 324 home_config_file = home_config_file and home_config_file:gsub("\\","/")
325 defaults.fs_use_modules = false 325 defaults.fs_use_modules = false
326 defaults.arch = "win32-"..proc 326 defaults.arch = "win32-"..cfg.target_cpu
327 defaults.platforms = {"win32", "windows" } 327 defaults.platforms = {"win32", "windows" }
328 defaults.lib_extension = "dll" 328 defaults.lib_extension = "dll"
329 defaults.external_lib_extension = "dll" 329 defaults.external_lib_extension = "dll"
@@ -441,7 +441,7 @@ end
441 441
442if detected.cygwin then 442if detected.cygwin then
443 defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds 443 defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds
444 defaults.arch = "cygwin-"..proc 444 defaults.arch = "cygwin-"..cfg.target_cpu
445 defaults.platforms = {"unix", "cygwin"} 445 defaults.platforms = {"unix", "cygwin"}
446 defaults.cmake_generator = "Unix Makefiles" 446 defaults.cmake_generator = "Unix Makefiles"
447 defaults.variables.CC = "echo -llua | xargs gcc" 447 defaults.variables.CC = "echo -llua | xargs gcc"
@@ -457,7 +457,7 @@ end
457if detected.macosx then 457if detected.macosx then
458 defaults.variables.MAKE = "make" 458 defaults.variables.MAKE = "make"
459 defaults.external_lib_extension = "dylib" 459 defaults.external_lib_extension = "dylib"
460 defaults.arch = "macosx-"..proc 460 defaults.arch = "macosx-"..cfg.target_cpu
461 defaults.platforms = {"unix", "bsd", "macosx"} 461 defaults.platforms = {"unix", "bsd", "macosx"}
462 defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" 462 defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load"
463 defaults.variables.STAT = "/usr/bin/stat" 463 defaults.variables.STAT = "/usr/bin/stat"
@@ -477,12 +477,12 @@ if detected.macosx then
477end 477end
478 478
479if detected.linux then 479if detected.linux then
480 defaults.arch = "linux-"..proc 480 defaults.arch = "linux-"..cfg.target_cpu
481 defaults.platforms = {"unix", "linux"} 481 defaults.platforms = {"unix", "linux"}
482end 482end
483 483
484if detected.freebsd then 484if detected.freebsd then
485 defaults.arch = "freebsd-"..proc 485 defaults.arch = "freebsd-"..cfg.target_cpu
486 defaults.platforms = {"unix", "bsd", "freebsd"} 486 defaults.platforms = {"unix", "bsd", "freebsd"}
487 defaults.gcc_rpath = false 487 defaults.gcc_rpath = false
488 defaults.variables.CC = "cc" 488 defaults.variables.CC = "cc"
@@ -490,17 +490,17 @@ if detected.freebsd then
490end 490end
491 491
492if detected.openbsd then 492if detected.openbsd then
493 defaults.arch = "openbsd-"..proc 493 defaults.arch = "openbsd-"..cfg.target_cpu
494 defaults.platforms = {"unix", "bsd", "openbsd"} 494 defaults.platforms = {"unix", "bsd", "openbsd"}
495end 495end
496 496
497if detected.netbsd then 497if detected.netbsd then
498 defaults.arch = "netbsd-"..proc 498 defaults.arch = "netbsd-"..cfg.target_cpu
499 defaults.platforms = {"unix", "bsd", "netbsd"} 499 defaults.platforms = {"unix", "bsd", "netbsd"}
500end 500end
501 501
502if detected.solaris then 502if detected.solaris then
503 defaults.arch = "solaris-"..proc 503 defaults.arch = "solaris-"..cfg.target_cpu
504 defaults.platforms = {"unix", "solaris"} 504 defaults.platforms = {"unix", "solaris"}
505 defaults.variables.MAKE = "gmake" 505 defaults.variables.MAKE = "gmake"
506end 506end
@@ -630,4 +630,13 @@ function cfg.is_platform(query)
630 end 630 end
631end 631end
632 632
633--[[
634function cfg.dump()
635 for k,v in pairs(defaults) do
636 if cfg[k] then end -- nothing todo, just touch it and the __index will make a local copy in `cfg`
637 end
638 print(util.show_table(cfg, "Dump of `cfg` table:"))
639end
640cfg.dump() --]]
641
633return cfg 642return cfg