aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2015-06-25 22:04:57 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2015-06-25 22:04:57 +0200
commitd065a9588324e96731df651d855286b2b8475a74 (patch)
treefa153f5b74a474327fec25258a6d4cf88a193ddf /src
parent30d869c3d9691576f2e8bef9a2a2140043f46239 (diff)
downloadluarocks-d065a9588324e96731df651d855286b2b8475a74.tar.gz
luarocks-d065a9588324e96731df651d855286b2b8475a74.tar.bz2
luarocks-d065a9588324e96731df651d855286b2b8475a74.zip
integrated cfg.platform and cfg.platforms
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/cfg.lua94
1 files changed, 47 insertions, 47 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 6ff2fcf0..8368ee7e 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -37,7 +37,7 @@ cfg.program_series = "2.2"
37cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series 37cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series
38cfg.variables = {} 38cfg.variables = {}
39cfg.rocks_trees = {} 39cfg.rocks_trees = {}
40cfg.platform = {} 40cfg.platforms = {}
41 41
42local persist = require("luarocks.persist") 42local persist = require("luarocks.persist")
43 43
@@ -89,37 +89,39 @@ elseif proc:match("Power Macintosh") then
89end 89end
90 90
91if system == "FreeBSD" then 91if system == "FreeBSD" then
92 cfg.platform.unix = true 92 cfg.platforms.unix = true
93 cfg.platform.freebsd = true 93 cfg.platforms.freebsd = true
94 cfg.platform.bsd = true 94 cfg.platforms.bsd = true
95elseif system == "OpenBSD" then 95elseif system == "OpenBSD" then
96 cfg.platform.unix = true 96 cfg.platforms.unix = true
97 cfg.platform.openbsd = true 97 cfg.platforms.openbsd = true
98 cfg.platform.bsd = true 98 cfg.platforms.bsd = true
99elseif system == "NetBSD" then 99elseif system == "NetBSD" then
100 cfg.platform.unix = true 100 cfg.platforms.unix = true
101 cfg.platform.netbsd = true 101 cfg.platforms.netbsd = true
102 cfg.platform.bsd = true 102 cfg.platforms.bsd = true
103elseif system == "Darwin" then 103elseif system == "Darwin" then
104 cfg.platform.unix = true 104 cfg.platforms.unix = true
105 cfg.platform.macosx = true 105 cfg.platforms.macosx = true
106 cfg.platform.bsd = true 106 cfg.platforms.bsd = true
107elseif system == "Linux" then 107elseif system == "Linux" then
108 cfg.platform.unix = true 108 cfg.platforms.unix = true
109 cfg.platform.linux = true 109 cfg.platforms.linux = true
110elseif system == "SunOS" then 110elseif system == "SunOS" then
111 cfg.platform.unix = true 111 cfg.platforms.unix = true
112 cfg.platform.solaris = true 112 cfg.platforms.solaris = true
113elseif system and system:match("^CYGWIN") then 113elseif system and system:match("^CYGWIN") then
114 cfg.platform.unix = true 114 cfg.platforms.unix = true
115 cfg.platform.cygwin = true 115 cfg.platforms.cygwin = true
116elseif system and system:match("^Windows") then 116elseif system and system:match("^Windows") then
117 cfg.platform.windows = true 117 cfg.platforms.windows = true
118 cfg.platforms.win32 = true
118elseif system and system:match("^MINGW") then 119elseif system and system:match("^MINGW") then
119 cfg.platform.windows = true 120 cfg.platforms.windows = true
120 cfg.platform.mingw32 = true 121 cfg.platforms.mingw32 = true
122 cfg.platforms.win32 = true
121else 123else
122 cfg.platform.unix = true 124 cfg.platforms.unix = true
123 -- Fall back to Unix in unknown systems. 125 -- Fall back to Unix in unknown systems.
124end 126end
125 127
@@ -130,7 +132,7 @@ local sys_config_dir, home_config_dir
130local sys_config_ok, home_config_ok = false, false 132local sys_config_ok, home_config_ok = false, false
131local extra_luarocks_module_dir 133local extra_luarocks_module_dir
132sys_config_dir = site_config.LUAROCKS_SYSCONFDIR 134sys_config_dir = site_config.LUAROCKS_SYSCONFDIR
133if cfg.platform.windows then 135if cfg.platforms.windows then
134 cfg.home = os.getenv("APPDATA") or "c:" 136 cfg.home = os.getenv("APPDATA") or "c:"
135 sys_config_dir = sys_config_dir or "c:/luarocks" 137 sys_config_dir = sys_config_dir or "c:/luarocks"
136 home_config_dir = cfg.home.."/luarocks" 138 home_config_dir = cfg.home.."/luarocks"
@@ -148,7 +150,7 @@ local env_for_config_file = function()
148 e = { 150 e = {
149 home = cfg.home, 151 home = cfg.home,
150 lua_version = cfg.lua_version, 152 lua_version = cfg.lua_version,
151 platform = util.make_shallow_copy(cfg.platform), 153 platforms = util.make_shallow_copy(cfg.platforms),
152 processor = cfg.target_cpu, -- remains for compat reasons 154 processor = cfg.target_cpu, -- remains for compat reasons
153 target_cpu = cfg.target_cpu, -- replaces `processor` 155 target_cpu = cfg.target_cpu, -- replaces `processor`
154 os_getenv = os.getenv, 156 os_getenv = os.getenv,
@@ -231,8 +233,15 @@ if not next(cfg.rocks_trees) then
231 end 233 end
232end 234end
233 235
234-- Configure defaults:
235 236
237-- update platforms list; keyed -> array
238do
239 local lst = {} -- use temp array to not confuse `pairs` in loop
240 for plat in pairs(cfg.platforms) do table.insert(lst, plat) end
241 util.deep_merge(cfg.platforms, lst)
242end
243
244-- Configure defaults:
236local defaults = { 245local defaults = {
237 246
238 local_by_default = false, 247 local_by_default = false,
@@ -332,14 +341,13 @@ local defaults = {
332 rocks_provided = {} 341 rocks_provided = {}
333} 342}
334 343
335if cfg.platform.windows then 344if cfg.platforms.windows then
336 local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version 345 local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version
337 extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" 346 extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua"
338 347
339 home_config_file = home_config_file and home_config_file:gsub("\\","/") 348 home_config_file = home_config_file and home_config_file:gsub("\\","/")
340 defaults.fs_use_modules = false 349 defaults.fs_use_modules = false
341 defaults.arch = "win32-"..cfg.target_cpu 350 defaults.arch = "win32-"..cfg.target_cpu
342 defaults.platforms = {"win32", "windows" }
343 defaults.lib_extension = "dll" 351 defaults.lib_extension = "dll"
344 defaults.external_lib_extension = "dll" 352 defaults.external_lib_extension = "dll"
345 defaults.obj_extension = "obj" 353 defaults.obj_extension = "obj"
@@ -392,8 +400,7 @@ if cfg.platform.windows then
392 defaults.web_browser = "start" 400 defaults.web_browser = "start"
393end 401end
394 402
395if cfg.platform.mingw32 then 403if cfg.platforms.mingw32 then
396 defaults.platforms = { "win32", "mingw32", "windows" }
397 defaults.obj_extension = "o" 404 defaults.obj_extension = "o"
398 defaults.cmake_generator = "MinGW Makefiles" 405 defaults.cmake_generator = "MinGW Makefiles"
399 defaults.variables.MAKE = "mingw32-make" 406 defaults.variables.MAKE = "mingw32-make"
@@ -417,7 +424,7 @@ if cfg.platform.mingw32 then
417 424
418end 425end
419 426
420if cfg.platform.unix then 427if cfg.platforms.unix then
421 defaults.lib_extension = "so" 428 defaults.lib_extension = "so"
422 defaults.external_lib_extension = "so" 429 defaults.external_lib_extension = "so"
423 defaults.obj_extension = "o" 430 defaults.obj_extension = "o"
@@ -427,7 +434,6 @@ if cfg.platform.unix then
427 defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR or "/usr/local/lib" 434 defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR or "/usr/local/lib"
428 defaults.variables.CFLAGS = "-O2" 435 defaults.variables.CFLAGS = "-O2"
429 defaults.cmake_generator = "Unix Makefiles" 436 defaults.cmake_generator = "Unix Makefiles"
430 defaults.platforms = { "unix" }
431 defaults.variables.CC = "gcc" 437 defaults.variables.CC = "gcc"
432 defaults.variables.LD = "gcc" 438 defaults.variables.LD = "gcc"
433 defaults.gcc_rpath = true 439 defaults.gcc_rpath = true
@@ -454,26 +460,24 @@ if cfg.platform.unix then
454 defaults.web_browser = "xdg-open" 460 defaults.web_browser = "xdg-open"
455end 461end
456 462
457if cfg.platform.cygwin then 463if cfg.platforms.cygwin then
458 defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds 464 defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds
459 defaults.arch = "cygwin-"..cfg.target_cpu 465 defaults.arch = "cygwin-"..cfg.target_cpu
460 defaults.platforms = {"unix", "cygwin"}
461 defaults.cmake_generator = "Unix Makefiles" 466 defaults.cmake_generator = "Unix Makefiles"
462 defaults.variables.CC = "echo -llua | xargs gcc" 467 defaults.variables.CC = "echo -llua | xargs gcc"
463 defaults.variables.LD = "echo -llua | xargs gcc" 468 defaults.variables.LD = "echo -llua | xargs gcc"
464 defaults.variables.LIBFLAG = "-shared" 469 defaults.variables.LIBFLAG = "-shared"
465end 470end
466 471
467if cfg.platform.bsd then 472if cfg.platforms.bsd then
468 defaults.variables.MAKE = "gmake" 473 defaults.variables.MAKE = "gmake"
469 defaults.variables.STATFLAG = "-f '%OLp'" 474 defaults.variables.STATFLAG = "-f '%OLp'"
470end 475end
471 476
472if cfg.platform.macosx then 477if cfg.platforms.macosx then
473 defaults.variables.MAKE = "make" 478 defaults.variables.MAKE = "make"
474 defaults.external_lib_extension = "dylib" 479 defaults.external_lib_extension = "dylib"
475 defaults.arch = "macosx-"..cfg.target_cpu 480 defaults.arch = "macosx-"..cfg.target_cpu
476 defaults.platforms = {"unix", "bsd", "macosx"}
477 defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" 481 defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load"
478 defaults.variables.STAT = "/usr/bin/stat" 482 defaults.variables.STAT = "/usr/bin/stat"
479 defaults.variables.STATFLAG = "-f '%A'" 483 defaults.variables.STATFLAG = "-f '%A'"
@@ -491,32 +495,28 @@ if cfg.platform.macosx then
491 defaults.web_browser = "open" 495 defaults.web_browser = "open"
492end 496end
493 497
494if cfg.platform.linux then 498if cfg.platforms.linux then
495 defaults.arch = "linux-"..cfg.target_cpu 499 defaults.arch = "linux-"..cfg.target_cpu
496 defaults.platforms = {"unix", "linux"}
497end 500end
498 501
499if cfg.platform.freebsd then 502if cfg.platforms.freebsd then
500 defaults.arch = "freebsd-"..cfg.target_cpu 503 defaults.arch = "freebsd-"..cfg.target_cpu
501 defaults.platforms = {"unix", "bsd", "freebsd"}
502 defaults.gcc_rpath = false 504 defaults.gcc_rpath = false
503 defaults.variables.CC = "cc" 505 defaults.variables.CC = "cc"
504 defaults.variables.LD = "cc" 506 defaults.variables.LD = "cc"
505end 507end
506 508
507if cfg.platform.openbsd then 509if cfg.platforms.openbsd then
508 defaults.arch = "openbsd-"..cfg.target_cpu 510 defaults.arch = "openbsd-"..cfg.target_cpu
509 defaults.platforms = {"unix", "bsd", "openbsd"}
510end 511end
511 512
512if cfg.platform.netbsd then 513if cfg.platforms.netbsd then
513 defaults.arch = "netbsd-"..cfg.target_cpu 514 defaults.arch = "netbsd-"..cfg.target_cpu
514 defaults.platforms = {"unix", "bsd", "netbsd"}
515end 515end
516 516
517if cfg.platform.solaris then 517if cfg.platforms.solaris then
518 defaults.arch = "solaris-"..cfg.target_cpu 518 defaults.arch = "solaris-"..cfg.target_cpu
519 defaults.platforms = {"unix", "solaris"} 519 --defaults.platforms = {"unix", "solaris"}
520 defaults.variables.MAKE = "gmake" 520 defaults.variables.MAKE = "gmake"
521end 521end
522 522