diff options
| author | Hisham <hisham@gobolinux.org> | 2016-05-03 16:41:17 -0300 |
|---|---|---|
| committer | Hisham <hisham@gobolinux.org> | 2016-05-03 16:41:17 -0300 |
| commit | 9b2b548f8a5e349993355288ef6849207fe25eb1 (patch) | |
| tree | 34607f9e19c2bc5d5247c4ced75e9567114e99de /src | |
| parent | ab8c6c7926afe5ca2fcfc330de18618d9dce1059 (diff) | |
| parent | 42ffeb60e739c78b1b0254d24e15a617efb8101b (diff) | |
| download | luarocks-9b2b548f8a5e349993355288ef6849207fe25eb1.tar.gz luarocks-9b2b548f8a5e349993355288ef6849207fe25eb1.tar.bz2 luarocks-9b2b548f8a5e349993355288ef6849207fe25eb1.zip | |
Merge branch 'siffiejoe-staticlibs' into luarocks-3
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/build/builtin.lua | 29 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/path.lua | 5 |
3 files changed, 41 insertions, 1 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index afd05954..938262ef 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
| @@ -50,7 +50,7 @@ end | |||
| 50 | -- nil and an error message otherwise. | 50 | -- nil and an error message otherwise. |
| 51 | function builtin.run(rockspec) | 51 | function builtin.run(rockspec) |
| 52 | assert(type(rockspec) == "table") | 52 | assert(type(rockspec) == "table") |
| 53 | local compile_object, compile_library, compile_wrapper_binary --TODO EXEWRAPPER | 53 | local compile_object, compile_library, compile_static_library, compile_wrapper_binary --TODO EXEWRAPPER |
| 54 | 54 | ||
| 55 | local build = rockspec.build | 55 | local build = rockspec.build |
| 56 | local variables = rockspec.variables | 56 | local variables = rockspec.variables |
| @@ -83,6 +83,13 @@ function builtin.run(rockspec) | |||
| 83 | local ok = execute(variables.LD.." "..variables.LIBFLAG, "-o", library, unpack(extras)) | 83 | local ok = execute(variables.LD.." "..variables.LIBFLAG, "-o", library, unpack(extras)) |
| 84 | return ok | 84 | return ok |
| 85 | end | 85 | end |
| 86 | compile_static_library = function(library, objects, libraries, libdirs, name) | ||
| 87 | local ok = execute(variables.AR, "rc", library, unpack(objects)) | ||
| 88 | if ok then | ||
| 89 | ok = execute(variables.RANLIB, library) | ||
| 90 | end | ||
| 91 | return ok | ||
| 92 | end | ||
| 86 | compile_wrapper_binary = function(fullname, name) | 93 | compile_wrapper_binary = function(fullname, name) |
| 87 | --TODO EXEWRAPPER | 94 | --TODO EXEWRAPPER |
| 88 | local fullbasename = fullname:gsub("%.lua$", ""):gsub("/", "\\") | 95 | local fullbasename = fullname:gsub("%.lua$", ""):gsub("/", "\\") |
| @@ -129,6 +136,10 @@ function builtin.run(rockspec) | |||
| 129 | end | 136 | end |
| 130 | return ok | 137 | return ok |
| 131 | end | 138 | end |
| 139 | compile_static_library = function(library, objects, libraries, libdirs, name) | ||
| 140 | local ok = execute(variables.AR, "-out:"..library, unpack(objects)) | ||
| 141 | return ok | ||
| 142 | end | ||
| 132 | compile_wrapper_binary = function(fullname, name) | 143 | compile_wrapper_binary = function(fullname, name) |
| 133 | --TODO EXEWRAPPER | 144 | --TODO EXEWRAPPER |
| 134 | local fullbasename = fullname:gsub("%.lua$", ""):gsub("/", "\\") | 145 | local fullbasename = fullname:gsub("%.lua$", ""):gsub("/", "\\") |
| @@ -170,6 +181,13 @@ function builtin.run(rockspec) | |||
| 170 | end | 181 | end |
| 171 | return execute(variables.LD.." "..variables.LIBFLAG, "-o", library, "-L"..variables.LUA_LIBDIR, unpack(extras)) | 182 | return execute(variables.LD.." "..variables.LIBFLAG, "-o", library, "-L"..variables.LUA_LIBDIR, unpack(extras)) |
| 172 | end | 183 | end |
| 184 | compile_static_library = function(library, objects, libraries, libdirs, name) | ||
| 185 | local ok = execute(variables.AR, "rc", library, unpack(objects)) | ||
| 186 | if ok then | ||
| 187 | ok = execute(variables.RANLIB, library) | ||
| 188 | end | ||
| 189 | return ok | ||
| 190 | end | ||
| 173 | compile_wrapper_binary = function(_, name) return true, name end | 191 | compile_wrapper_binary = function(_, name) return true, name end |
| 174 | --TODO EXEWRAPPER | 192 | --TODO EXEWRAPPER |
| 175 | end | 193 | end |
| @@ -247,6 +265,15 @@ function builtin.run(rockspec) | |||
| 247 | if not ok then | 265 | if not ok then |
| 248 | return nil, "Failed compiling module "..module_name | 266 | return nil, "Failed compiling module "..module_name |
| 249 | end | 267 | end |
| 268 | module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.static_lib_extension) | ||
| 269 | if moddir ~= "" then | ||
| 270 | module_name = dir.path(moddir, module_name) | ||
| 271 | end | ||
| 272 | built_modules[module_name] = dir.path(libdir, module_name) | ||
| 273 | ok = compile_static_library(module_name, objects, info.libraries, info.libdirs, name) | ||
| 274 | if not ok then | ||
| 275 | return nil, "Failed compiling static library "..module_name | ||
| 276 | end | ||
| 250 | end | 277 | end |
| 251 | end | 278 | end |
| 252 | for name, dest in pairs(built_modules) do | 279 | for name, dest in pairs(built_modules) do |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index e7356c16..aa298b07 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -341,6 +341,8 @@ local defaults = { | |||
| 341 | MAKE = "make", | 341 | MAKE = "make", |
| 342 | CC = "cc", | 342 | CC = "cc", |
| 343 | LD = "ld", | 343 | LD = "ld", |
| 344 | AR = "ar", | ||
| 345 | RANLIB = "ranlib", | ||
| 344 | 346 | ||
| 345 | CVS = "cvs", | 347 | CVS = "cvs", |
| 346 | GIT = "git", | 348 | GIT = "git", |
| @@ -409,6 +411,7 @@ if cfg.platforms.windows then | |||
| 409 | defaults.arch = "win32-"..cfg.target_cpu | 411 | defaults.arch = "win32-"..cfg.target_cpu |
| 410 | defaults.lib_extension = "dll" | 412 | defaults.lib_extension = "dll" |
| 411 | defaults.external_lib_extension = "dll" | 413 | defaults.external_lib_extension = "dll" |
| 414 | defaults.static_lib_extension = "lib" | ||
| 412 | defaults.obj_extension = "obj" | 415 | defaults.obj_extension = "obj" |
| 413 | defaults.external_deps_dirs = { "c:/external/" } | 416 | defaults.external_deps_dirs = { "c:/external/" } |
| 414 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" | 417 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" |
| @@ -422,6 +425,7 @@ if cfg.platforms.windows then | |||
| 422 | defaults.variables.WRAPPER = full_prefix.."\\rclauncher.c" | 425 | defaults.variables.WRAPPER = full_prefix.."\\rclauncher.c" |
| 423 | defaults.variables.LD = "link" | 426 | defaults.variables.LD = "link" |
| 424 | defaults.variables.MT = "mt" | 427 | defaults.variables.MT = "mt" |
| 428 | defaults.variables.AR = "lib" | ||
| 425 | defaults.variables.LUALIB = "lua"..cfg.lua_version..".lib" | 429 | defaults.variables.LUALIB = "lua"..cfg.lua_version..".lib" |
| 426 | defaults.variables.CFLAGS = "/nologo /MD /O2" | 430 | defaults.variables.CFLAGS = "/nologo /MD /O2" |
| 427 | defaults.variables.LIBFLAG = "/nologo /dll" | 431 | defaults.variables.LIBFLAG = "/nologo /dll" |
| @@ -461,11 +465,14 @@ end | |||
| 461 | 465 | ||
| 462 | if cfg.platforms.mingw32 then | 466 | if cfg.platforms.mingw32 then |
| 463 | defaults.obj_extension = "o" | 467 | defaults.obj_extension = "o" |
| 468 | defaults.static_lib_extension = "a" | ||
| 464 | defaults.cmake_generator = "MinGW Makefiles" | 469 | defaults.cmake_generator = "MinGW Makefiles" |
| 465 | defaults.variables.MAKE = "mingw32-make" | 470 | defaults.variables.MAKE = "mingw32-make" |
| 466 | defaults.variables.CC = "mingw32-gcc" | 471 | defaults.variables.CC = "mingw32-gcc" |
| 467 | defaults.variables.RC = "windres" | 472 | defaults.variables.RC = "windres" |
| 468 | defaults.variables.LD = "mingw32-gcc" | 473 | defaults.variables.LD = "mingw32-gcc" |
| 474 | defaults.variables.AR = "ar" | ||
| 475 | defaults.variables.RANLIB = "ranlib" | ||
| 469 | defaults.variables.CFLAGS = "-O2" | 476 | defaults.variables.CFLAGS = "-O2" |
| 470 | defaults.variables.LIBFLAG = "-shared" | 477 | defaults.variables.LIBFLAG = "-shared" |
| 471 | defaults.external_deps_patterns = { | 478 | defaults.external_deps_patterns = { |
| @@ -485,6 +492,7 @@ end | |||
| 485 | 492 | ||
| 486 | if cfg.platforms.unix then | 493 | if cfg.platforms.unix then |
| 487 | defaults.lib_extension = "so" | 494 | defaults.lib_extension = "so" |
| 495 | defaults.static_lib_extension = "a" | ||
| 488 | defaults.external_lib_extension = "so" | 496 | defaults.external_lib_extension = "so" |
| 489 | defaults.obj_extension = "o" | 497 | defaults.obj_extension = "o" |
| 490 | defaults.external_deps_dirs = { "/usr/local", "/usr" } | 498 | defaults.external_deps_dirs = { "/usr/local", "/usr" } |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index bc7ab63b..37ff846a 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
| @@ -251,6 +251,11 @@ function path.path_to_module(file) | |||
| 251 | name = file:match("(.*)%."..cfg.lib_extension.."$") | 251 | name = file:match("(.*)%."..cfg.lib_extension.."$") |
| 252 | if name then | 252 | if name then |
| 253 | name = name:gsub(dir.separator, ".") | 253 | name = name:gsub(dir.separator, ".") |
| 254 | else | ||
| 255 | name = file:match("(.*)%."..cfg.static_lib_extension.."$") | ||
| 256 | if name then | ||
| 257 | name = name:gsub(dir.separator, ".") | ||
| 258 | end | ||
| 254 | end | 259 | end |
| 255 | end | 260 | end |
| 256 | if not name then name = file end | 261 | if not name then name = file end |
