diff options
| author | Philipp Janda <siffiejoe@gmx.net> | 2014-05-27 01:08:19 +0200 |
|---|---|---|
| committer | Philipp Janda <siffiejoe@gmx.net> | 2014-05-27 01:08:19 +0200 |
| commit | 85b8c8cc20a58a2c769ee323aa1283ad94e2b2f4 (patch) | |
| tree | 0b5c054bbc77596ef98b114b044b448aacd47abf /src | |
| parent | 0d9bc9eb541cdac6ae55c5c313a29be275cdd812 (diff) | |
| download | luarocks-85b8c8cc20a58a2c769ee323aa1283ad94e2b2f4.tar.gz luarocks-85b8c8cc20a58a2c769ee323aa1283ad94e2b2f4.tar.bz2 luarocks-85b8c8cc20a58a2c769ee323aa1283ad94e2b2f4.zip | |
build static libraries for builtin build type
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/build/builtin.lua | 29 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 8 |
2 files changed, 36 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. |
| 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(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 59a17754..c404c663 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -233,6 +233,8 @@ local defaults = { | |||
| 233 | MAKE = "make", | 233 | MAKE = "make", |
| 234 | CC = "cc", | 234 | CC = "cc", |
| 235 | LD = "ld", | 235 | LD = "ld", |
| 236 | AR = "ar", | ||
| 237 | RANLIB = "ranlib", | ||
| 236 | 238 | ||
| 237 | CVS = "cvs", | 239 | CVS = "cvs", |
| 238 | GIT = "git", | 240 | GIT = "git", |
| @@ -298,6 +300,7 @@ if detected.windows then | |||
| 298 | defaults.platforms = {"win32", "windows" } | 300 | defaults.platforms = {"win32", "windows" } |
| 299 | defaults.lib_extension = "dll" | 301 | defaults.lib_extension = "dll" |
| 300 | defaults.external_lib_extension = "dll" | 302 | defaults.external_lib_extension = "dll" |
| 303 | defaults.static_lib_extension = "lib" | ||
| 301 | defaults.obj_extension = "obj" | 304 | defaults.obj_extension = "obj" |
| 302 | defaults.external_deps_dirs = { "c:/external/" } | 305 | defaults.external_deps_dirs = { "c:/external/" } |
| 303 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" | 306 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" |
| @@ -311,6 +314,7 @@ if detected.windows then | |||
| 311 | defaults.variables.WRAPPER = full_prefix.."\\rclauncher.c" | 314 | defaults.variables.WRAPPER = full_prefix.."\\rclauncher.c" |
| 312 | defaults.variables.LD = "link" | 315 | defaults.variables.LD = "link" |
| 313 | defaults.variables.MT = "mt" | 316 | defaults.variables.MT = "mt" |
| 317 | defaults.variables.AR = "lib" | ||
| 314 | defaults.variables.LUALIB = "lua"..cfg.lua_version..".lib" | 318 | defaults.variables.LUALIB = "lua"..cfg.lua_version..".lib" |
| 315 | defaults.variables.CFLAGS = "/MD /O2" | 319 | defaults.variables.CFLAGS = "/MD /O2" |
| 316 | defaults.variables.LIBFLAG = "/dll" | 320 | defaults.variables.LIBFLAG = "/dll" |
| @@ -351,11 +355,14 @@ end | |||
| 351 | if detected.mingw32 then | 355 | if detected.mingw32 then |
| 352 | defaults.platforms = { "win32", "mingw32", "windows" } | 356 | defaults.platforms = { "win32", "mingw32", "windows" } |
| 353 | defaults.obj_extension = "o" | 357 | defaults.obj_extension = "o" |
| 358 | defaults.static_lib_extension = "a" | ||
| 354 | defaults.cmake_generator = "MinGW Makefiles" | 359 | defaults.cmake_generator = "MinGW Makefiles" |
| 355 | defaults.variables.MAKE = "mingw32-make" | 360 | defaults.variables.MAKE = "mingw32-make" |
| 356 | defaults.variables.CC = "mingw32-gcc" | 361 | defaults.variables.CC = "mingw32-gcc" |
| 357 | defaults.variables.RC = "windres" | 362 | defaults.variables.RC = "windres" |
| 358 | defaults.variables.LD = "mingw32-gcc" | 363 | defaults.variables.LD = "mingw32-gcc" |
| 364 | defaults.variables.AR = "mingw32-gcc-ar" | ||
| 365 | defaults.variables.RANLIB = "mingw32-gcc-ranlib" | ||
| 359 | defaults.variables.CFLAGS = "-O2" | 366 | defaults.variables.CFLAGS = "-O2" |
| 360 | defaults.variables.LIBFLAG = "-shared" | 367 | defaults.variables.LIBFLAG = "-shared" |
| 361 | defaults.external_deps_patterns = { | 368 | defaults.external_deps_patterns = { |
| @@ -375,6 +382,7 @@ end | |||
| 375 | 382 | ||
| 376 | if detected.unix then | 383 | if detected.unix then |
| 377 | defaults.lib_extension = "so" | 384 | defaults.lib_extension = "so" |
| 385 | defaults.static_lib_extension = "a" | ||
| 378 | defaults.external_lib_extension = "so" | 386 | defaults.external_lib_extension = "so" |
| 379 | defaults.obj_extension = "o" | 387 | defaults.obj_extension = "o" |
| 380 | defaults.external_deps_dirs = { "/usr/local", "/usr" } | 388 | defaults.external_deps_dirs = { "/usr/local", "/usr" } |
