diff options
author | Hisham <hisham@gobolinux.org> | 2016-05-03 16:41:01 -0300 |
---|---|---|
committer | Hisham <hisham@gobolinux.org> | 2016-05-03 16:41:01 -0300 |
commit | 42ffeb60e739c78b1b0254d24e15a617efb8101b (patch) | |
tree | 94179c3c2dbfdcc7898d60b9d6eb23bd9ee71d15 /src | |
parent | e281fea83c49e301ff7bfb4af444e68d02309f5f (diff) | |
parent | dbb63f8248eca42da4fad45c718fe7d70ec8eacc (diff) | |
download | luarocks-42ffeb60e739c78b1b0254d24e15a617efb8101b.tar.gz luarocks-42ffeb60e739c78b1b0254d24e15a617efb8101b.tar.bz2 luarocks-42ffeb60e739c78b1b0254d24e15a617efb8101b.zip |
Merge branch 'staticlibs' of https://github.com/siffiejoe/luarocks into siffiejoe-staticlibs
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 591a456a..898b0854 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", |
@@ -408,6 +410,7 @@ if cfg.platforms.windows then | |||
408 | defaults.arch = "win32-"..cfg.target_cpu | 410 | defaults.arch = "win32-"..cfg.target_cpu |
409 | defaults.lib_extension = "dll" | 411 | defaults.lib_extension = "dll" |
410 | defaults.external_lib_extension = "dll" | 412 | defaults.external_lib_extension = "dll" |
413 | defaults.static_lib_extension = "lib" | ||
411 | defaults.obj_extension = "obj" | 414 | defaults.obj_extension = "obj" |
412 | defaults.external_deps_dirs = { "c:/external/" } | 415 | defaults.external_deps_dirs = { "c:/external/" } |
413 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" | 416 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" |
@@ -421,6 +424,7 @@ if cfg.platforms.windows then | |||
421 | defaults.variables.WRAPPER = full_prefix.."\\rclauncher.c" | 424 | defaults.variables.WRAPPER = full_prefix.."\\rclauncher.c" |
422 | defaults.variables.LD = "link" | 425 | defaults.variables.LD = "link" |
423 | defaults.variables.MT = "mt" | 426 | defaults.variables.MT = "mt" |
427 | defaults.variables.AR = "lib" | ||
424 | defaults.variables.LUALIB = "lua"..cfg.lua_version..".lib" | 428 | defaults.variables.LUALIB = "lua"..cfg.lua_version..".lib" |
425 | defaults.variables.CFLAGS = "/nologo /MD /O2" | 429 | defaults.variables.CFLAGS = "/nologo /MD /O2" |
426 | defaults.variables.LIBFLAG = "/nologo /dll" | 430 | defaults.variables.LIBFLAG = "/nologo /dll" |
@@ -460,11 +464,14 @@ end | |||
460 | 464 | ||
461 | if cfg.platforms.mingw32 then | 465 | if cfg.platforms.mingw32 then |
462 | defaults.obj_extension = "o" | 466 | defaults.obj_extension = "o" |
467 | defaults.static_lib_extension = "a" | ||
463 | defaults.cmake_generator = "MinGW Makefiles" | 468 | defaults.cmake_generator = "MinGW Makefiles" |
464 | defaults.variables.MAKE = "mingw32-make" | 469 | defaults.variables.MAKE = "mingw32-make" |
465 | defaults.variables.CC = "mingw32-gcc" | 470 | defaults.variables.CC = "mingw32-gcc" |
466 | defaults.variables.RC = "windres" | 471 | defaults.variables.RC = "windres" |
467 | defaults.variables.LD = "mingw32-gcc" | 472 | defaults.variables.LD = "mingw32-gcc" |
473 | defaults.variables.AR = "ar" | ||
474 | defaults.variables.RANLIB = "ranlib" | ||
468 | defaults.variables.CFLAGS = "-O2" | 475 | defaults.variables.CFLAGS = "-O2" |
469 | defaults.variables.LIBFLAG = "-shared" | 476 | defaults.variables.LIBFLAG = "-shared" |
470 | defaults.external_deps_patterns = { | 477 | defaults.external_deps_patterns = { |
@@ -484,6 +491,7 @@ end | |||
484 | 491 | ||
485 | if cfg.platforms.unix then | 492 | if cfg.platforms.unix then |
486 | defaults.lib_extension = "so" | 493 | defaults.lib_extension = "so" |
494 | defaults.static_lib_extension = "a" | ||
487 | defaults.external_lib_extension = "so" | 495 | defaults.external_lib_extension = "so" |
488 | defaults.obj_extension = "o" | 496 | defaults.obj_extension = "o" |
489 | defaults.external_deps_dirs = { "/usr/local", "/usr" } | 497 | 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 |