diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-06-25 22:04:57 +0200 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-06-25 22:04:57 +0200 |
| commit | d065a9588324e96731df651d855286b2b8475a74 (patch) | |
| tree | fa153f5b74a474327fec25258a6d4cf88a193ddf /src | |
| parent | 30d869c3d9691576f2e8bef9a2a2140043f46239 (diff) | |
| download | luarocks-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.lua | 94 |
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" | |||
| 37 | cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series | 37 | cfg.major_version = (cfg.program_version:match("([^.]%.[^.])")) or cfg.program_series |
| 38 | cfg.variables = {} | 38 | cfg.variables = {} |
| 39 | cfg.rocks_trees = {} | 39 | cfg.rocks_trees = {} |
| 40 | cfg.platform = {} | 40 | cfg.platforms = {} |
| 41 | 41 | ||
| 42 | local persist = require("luarocks.persist") | 42 | local persist = require("luarocks.persist") |
| 43 | 43 | ||
| @@ -89,37 +89,39 @@ elseif proc:match("Power Macintosh") then | |||
| 89 | end | 89 | end |
| 90 | 90 | ||
| 91 | if system == "FreeBSD" then | 91 | if 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 |
| 95 | elseif system == "OpenBSD" then | 95 | elseif 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 |
| 99 | elseif system == "NetBSD" then | 99 | elseif 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 |
| 103 | elseif system == "Darwin" then | 103 | elseif 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 |
| 107 | elseif system == "Linux" then | 107 | elseif system == "Linux" then |
| 108 | cfg.platform.unix = true | 108 | cfg.platforms.unix = true |
| 109 | cfg.platform.linux = true | 109 | cfg.platforms.linux = true |
| 110 | elseif system == "SunOS" then | 110 | elseif system == "SunOS" then |
| 111 | cfg.platform.unix = true | 111 | cfg.platforms.unix = true |
| 112 | cfg.platform.solaris = true | 112 | cfg.platforms.solaris = true |
| 113 | elseif system and system:match("^CYGWIN") then | 113 | elseif 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 |
| 116 | elseif system and system:match("^Windows") then | 116 | elseif system and system:match("^Windows") then |
| 117 | cfg.platform.windows = true | 117 | cfg.platforms.windows = true |
| 118 | cfg.platforms.win32 = true | ||
| 118 | elseif system and system:match("^MINGW") then | 119 | elseif 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 | ||
| 121 | else | 123 | else |
| 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. |
| 124 | end | 126 | end |
| 125 | 127 | ||
| @@ -130,7 +132,7 @@ local sys_config_dir, home_config_dir | |||
| 130 | local sys_config_ok, home_config_ok = false, false | 132 | local sys_config_ok, home_config_ok = false, false |
| 131 | local extra_luarocks_module_dir | 133 | local extra_luarocks_module_dir |
| 132 | sys_config_dir = site_config.LUAROCKS_SYSCONFDIR | 134 | sys_config_dir = site_config.LUAROCKS_SYSCONFDIR |
| 133 | if cfg.platform.windows then | 135 | if 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 |
| 232 | end | 234 | end |
| 233 | 235 | ||
| 234 | -- Configure defaults: | ||
| 235 | 236 | ||
| 237 | -- update platforms list; keyed -> array | ||
| 238 | do | ||
| 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) | ||
| 242 | end | ||
| 243 | |||
| 244 | -- Configure defaults: | ||
| 236 | local defaults = { | 245 | local 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 | ||
| 335 | if cfg.platform.windows then | 344 | if 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" |
| 393 | end | 401 | end |
| 394 | 402 | ||
| 395 | if cfg.platform.mingw32 then | 403 | if 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 | ||
| 418 | end | 425 | end |
| 419 | 426 | ||
| 420 | if cfg.platform.unix then | 427 | if 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" |
| 455 | end | 461 | end |
| 456 | 462 | ||
| 457 | if cfg.platform.cygwin then | 463 | if 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" |
| 465 | end | 470 | end |
| 466 | 471 | ||
| 467 | if cfg.platform.bsd then | 472 | if 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'" |
| 470 | end | 475 | end |
| 471 | 476 | ||
| 472 | if cfg.platform.macosx then | 477 | if 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" |
| 492 | end | 496 | end |
| 493 | 497 | ||
| 494 | if cfg.platform.linux then | 498 | if cfg.platforms.linux then |
| 495 | defaults.arch = "linux-"..cfg.target_cpu | 499 | defaults.arch = "linux-"..cfg.target_cpu |
| 496 | defaults.platforms = {"unix", "linux"} | ||
| 497 | end | 500 | end |
| 498 | 501 | ||
| 499 | if cfg.platform.freebsd then | 502 | if 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" |
| 505 | end | 507 | end |
| 506 | 508 | ||
| 507 | if cfg.platform.openbsd then | 509 | if cfg.platforms.openbsd then |
| 508 | defaults.arch = "openbsd-"..cfg.target_cpu | 510 | defaults.arch = "openbsd-"..cfg.target_cpu |
| 509 | defaults.platforms = {"unix", "bsd", "openbsd"} | ||
| 510 | end | 511 | end |
| 511 | 512 | ||
| 512 | if cfg.platform.netbsd then | 513 | if cfg.platforms.netbsd then |
| 513 | defaults.arch = "netbsd-"..cfg.target_cpu | 514 | defaults.arch = "netbsd-"..cfg.target_cpu |
| 514 | defaults.platforms = {"unix", "bsd", "netbsd"} | ||
| 515 | end | 515 | end |
| 516 | 516 | ||
| 517 | if cfg.platform.solaris then | 517 | if 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" |
| 521 | end | 521 | end |
| 522 | 522 | ||
