aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/build/builtin.lua29
-rw-r--r--src/luarocks/cfg.lua8
-rw-r--r--src/luarocks/path.lua5
3 files changed, 41 insertions, 1 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua
index 47aa71fc..c855f48a 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.
51function builtin.run(rockspec) 51function 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(fullname, name) return true, name end 191 compile_wrapper_binary = function(fullname, name) return true, name end
174 --TODO EXEWRAPPER 192 --TODO EXEWRAPPER
175 end 193 end
@@ -246,6 +264,15 @@ function builtin.run(rockspec)
246 if not ok then 264 if not ok then
247 return nil, "Failed compiling module "..module_name 265 return nil, "Failed compiling module "..module_name
248 end 266 end
267 module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.static_lib_extension)
268 if moddir ~= "" then
269 module_name = dir.path(moddir, module_name)
270 end
271 built_modules[module_name] = dir.path(libdir, module_name)
272 ok = compile_static_library(module_name, objects, info.libraries, info.libdirs, name)
273 if not ok then
274 return nil, "Failed compiling static library "..module_name
275 end
249 end 276 end
250 end 277 end
251 for name, dest in pairs(built_modules) do 278 for name, dest in pairs(built_modules) do
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index a96d610f..8f73bec1 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -236,6 +236,8 @@ local defaults = {
236 MAKE = "make", 236 MAKE = "make",
237 CC = "cc", 237 CC = "cc",
238 LD = "ld", 238 LD = "ld",
239 AR = "ar",
240 RANLIB = "ranlib",
239 241
240 CVS = "cvs", 242 CVS = "cvs",
241 GIT = "git", 243 GIT = "git",
@@ -301,6 +303,7 @@ if detected.windows then
301 defaults.platforms = {"win32", "windows" } 303 defaults.platforms = {"win32", "windows" }
302 defaults.lib_extension = "dll" 304 defaults.lib_extension = "dll"
303 defaults.external_lib_extension = "dll" 305 defaults.external_lib_extension = "dll"
306 defaults.static_lib_extension = "lib"
304 defaults.obj_extension = "obj" 307 defaults.obj_extension = "obj"
305 defaults.external_deps_dirs = { "c:/external/" } 308 defaults.external_deps_dirs = { "c:/external/" }
306 defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" 309 defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin"
@@ -314,6 +317,7 @@ if detected.windows then
314 defaults.variables.WRAPPER = full_prefix.."\\rclauncher.c" 317 defaults.variables.WRAPPER = full_prefix.."\\rclauncher.c"
315 defaults.variables.LD = "link" 318 defaults.variables.LD = "link"
316 defaults.variables.MT = "mt" 319 defaults.variables.MT = "mt"
320 defaults.variables.AR = "lib"
317 defaults.variables.LUALIB = "lua"..cfg.lua_version..".lib" 321 defaults.variables.LUALIB = "lua"..cfg.lua_version..".lib"
318 defaults.variables.CFLAGS = "/MD /O2" 322 defaults.variables.CFLAGS = "/MD /O2"
319 defaults.variables.LIBFLAG = "/dll" 323 defaults.variables.LIBFLAG = "/dll"
@@ -354,11 +358,14 @@ end
354if detected.mingw32 then 358if detected.mingw32 then
355 defaults.platforms = { "win32", "mingw32", "windows" } 359 defaults.platforms = { "win32", "mingw32", "windows" }
356 defaults.obj_extension = "o" 360 defaults.obj_extension = "o"
361 defaults.static_lib_extension = "a"
357 defaults.cmake_generator = "MinGW Makefiles" 362 defaults.cmake_generator = "MinGW Makefiles"
358 defaults.variables.MAKE = "mingw32-make" 363 defaults.variables.MAKE = "mingw32-make"
359 defaults.variables.CC = "mingw32-gcc" 364 defaults.variables.CC = "mingw32-gcc"
360 defaults.variables.RC = "windres" 365 defaults.variables.RC = "windres"
361 defaults.variables.LD = "mingw32-gcc" 366 defaults.variables.LD = "mingw32-gcc"
367 defaults.variables.AR = "ar"
368 defaults.variables.RANLIB = "ranlib"
362 defaults.variables.CFLAGS = "-O2" 369 defaults.variables.CFLAGS = "-O2"
363 defaults.variables.LIBFLAG = "-shared" 370 defaults.variables.LIBFLAG = "-shared"
364 defaults.external_deps_patterns = { 371 defaults.external_deps_patterns = {
@@ -378,6 +385,7 @@ end
378 385
379if detected.unix then 386if detected.unix then
380 defaults.lib_extension = "so" 387 defaults.lib_extension = "so"
388 defaults.static_lib_extension = "a"
381 defaults.external_lib_extension = "so" 389 defaults.external_lib_extension = "so"
382 defaults.obj_extension = "o" 390 defaults.obj_extension = "o"
383 defaults.external_deps_dirs = { "/usr/local", "/usr" } 391 defaults.external_deps_dirs = { "/usr/local", "/usr" }
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index 598e51d9..519f32b0 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