diff options
author | Xpol Wan <xpolife@gmail.com> | 2015-03-18 15:20:37 +0800 |
---|---|---|
committer | Xpol Wan <xpolife@gmail.com> | 2015-03-18 15:20:37 +0800 |
commit | b5e25391beece55da27777af6bb81b877f77da52 (patch) | |
tree | ca20e29c8e99f1e165f631d5a687feaa634c5c81 | |
parent | 463ee893b29c94b91e19d9a684ac4914d67c29a7 (diff) | |
download | luarocks-b5e25391beece55da27777af6bb81b877f77da52.tar.gz luarocks-b5e25391beece55da27777af6bb81b877f77da52.tar.bz2 luarocks-b5e25391beece55da27777af6bb81b877f77da52.zip |
Better cmake support.
1. Let cmake choose the generator.
2. use `cmake --build` to build without needs of make (nmake mingwin-make ...)
-rw-r--r-- | src/luarocks/build/cmake.lua | 14 | ||||
-rw-r--r-- | src/luarocks/cfg.lua | 9 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index ed2af3ff..5891cda9 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua | |||
@@ -15,7 +15,7 @@ function cmake.run(rockspec) | |||
15 | assert(type(rockspec) == "table") | 15 | assert(type(rockspec) == "table") |
16 | local build = rockspec.build | 16 | local build = rockspec.build |
17 | local variables = build.variables or {} | 17 | local variables = build.variables or {} |
18 | 18 | ||
19 | -- Pass Env variables | 19 | -- Pass Env variables |
20 | variables.CMAKE_MODULE_PATH=os.getenv("CMAKE_MODULE_PATH") | 20 | variables.CMAKE_MODULE_PATH=os.getenv("CMAKE_MODULE_PATH") |
21 | variables.CMAKE_LIBRARY_PATH=os.getenv("CMAKE_LIBRARY_PATH") | 21 | variables.CMAKE_LIBRARY_PATH=os.getenv("CMAKE_LIBRARY_PATH") |
@@ -26,7 +26,7 @@ function cmake.run(rockspec) | |||
26 | if not fs.execute_quiet(rockspec.variables.CMAKE, "--help") then | 26 | if not fs.execute_quiet(rockspec.variables.CMAKE, "--help") then |
27 | return nil, "'"..rockspec.variables.CMAKE.."' program not found. Is cmake installed? You may want to edit variables.CMAKE" | 27 | return nil, "'"..rockspec.variables.CMAKE.."' program not found. Is cmake installed? You may want to edit variables.CMAKE" |
28 | end | 28 | end |
29 | 29 | ||
30 | -- If inline cmake is present create CMakeLists.txt from it. | 30 | -- If inline cmake is present create CMakeLists.txt from it. |
31 | if type(build.cmake) == "string" then | 31 | if type(build.cmake) == "string" then |
32 | local cmake_handler = assert(io.open(fs.current_dir().."/CMakeLists.txt", "w")) | 32 | local cmake_handler = assert(io.open(fs.current_dir().."/CMakeLists.txt", "w")) |
@@ -38,21 +38,21 @@ function cmake.run(rockspec) | |||
38 | -- Execute cmake with variables. | 38 | -- Execute cmake with variables. |
39 | local args = "" | 39 | local args = "" |
40 | if cfg.cmake_generator then | 40 | if cfg.cmake_generator then |
41 | args = args .. ' -G"'..cfg.cmake_generator.. '"' | 41 | --args = args .. ' -G"'..cfg.cmake_generator.. '"' |
42 | end | 42 | end |
43 | for k,v in pairs(variables) do | 43 | for k,v in pairs(variables) do |
44 | args = args .. ' -D' ..k.. '="' ..v.. '"' | 44 | args = args .. ' -D' ..k.. '="' ..v.. '"' |
45 | end | 45 | end |
46 | 46 | ||
47 | if not fs.execute_string(rockspec.variables.CMAKE.." . " ..args) then | 47 | if not fs.execute_string(rockspec.variables.CMAKE.." -H. -Bbuild.luarocks "..args) then |
48 | return nil, "Failed cmake." | 48 | return nil, "Failed cmake." |
49 | end | 49 | end |
50 | 50 | ||
51 | if not fs.execute_string(rockspec.variables.MAKE.." -fMakefile") then | 51 | if not fs.execute_string(rockspec.variables.CMAKE.." --build build.luarocks --config Release") then |
52 | return nil, "Failed building." | 52 | return nil, "Failed building." |
53 | end | 53 | end |
54 | 54 | ||
55 | if not fs.execute_string(rockspec.variables.MAKE.." -fMakefile install") then | 55 | if not fs.execute_string(rockspec.variables.CMAKE.." --build build.luarocks --target install --config Release") then |
56 | return nil, "Failed installing." | 56 | return nil, "Failed installing." |
57 | end | 57 | end |
58 | return true | 58 | return true |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 50d247b5..ea80e5b5 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -227,7 +227,7 @@ local defaults = { | |||
227 | } | 227 | } |
228 | }, | 228 | }, |
229 | disabled_servers = {}, | 229 | disabled_servers = {}, |
230 | 230 | ||
231 | upload = { | 231 | upload = { |
232 | server = "https://rocks.moonscript.org", | 232 | server = "https://rocks.moonscript.org", |
233 | tool_version = "1.0.0", | 233 | tool_version = "1.0.0", |
@@ -315,7 +315,7 @@ if detected.windows then | |||
315 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" | 315 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin" |
316 | defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/include" | 316 | defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/include" |
317 | defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/lib" | 317 | defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/lib" |
318 | defaults.cmake_generator = "MinGW Makefiles" | 318 | |
319 | defaults.makefile = "Makefile.win" | 319 | defaults.makefile = "Makefile.win" |
320 | defaults.variables.MAKE = "nmake" | 320 | defaults.variables.MAKE = "nmake" |
321 | defaults.variables.CC = "cl" | 321 | defaults.variables.CC = "cl" |
@@ -363,7 +363,6 @@ end | |||
363 | if detected.mingw32 then | 363 | if detected.mingw32 then |
364 | defaults.platforms = { "win32", "mingw32", "windows" } | 364 | defaults.platforms = { "win32", "mingw32", "windows" } |
365 | defaults.obj_extension = "o" | 365 | defaults.obj_extension = "o" |
366 | defaults.cmake_generator = "MinGW Makefiles" | ||
367 | defaults.variables.MAKE = "mingw32-make" | 366 | defaults.variables.MAKE = "mingw32-make" |
368 | defaults.variables.CC = "mingw32-gcc" | 367 | defaults.variables.CC = "mingw32-gcc" |
369 | defaults.variables.RC = "windres" | 368 | defaults.variables.RC = "windres" |
@@ -394,7 +393,6 @@ if detected.unix then | |||
394 | defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR or "/usr/local/include" | 393 | defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR or "/usr/local/include" |
395 | defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR or "/usr/local/lib" | 394 | defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR or "/usr/local/lib" |
396 | defaults.variables.CFLAGS = "-O2" | 395 | defaults.variables.CFLAGS = "-O2" |
397 | defaults.cmake_generator = "Unix Makefiles" | ||
398 | defaults.platforms = { "unix" } | 396 | defaults.platforms = { "unix" } |
399 | defaults.variables.CC = "gcc" | 397 | defaults.variables.CC = "gcc" |
400 | defaults.variables.LD = "gcc" | 398 | defaults.variables.LD = "gcc" |
@@ -426,7 +424,6 @@ if detected.cygwin then | |||
426 | defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds | 424 | defaults.lib_extension = "so" -- can be overridden in the config file for mingw builds |
427 | defaults.arch = "cygwin-"..proc | 425 | defaults.arch = "cygwin-"..proc |
428 | defaults.platforms = {"unix", "cygwin"} | 426 | defaults.platforms = {"unix", "cygwin"} |
429 | defaults.cmake_generator = "Unix Makefiles" | ||
430 | defaults.variables.CC = "echo -llua | xargs gcc" | 427 | defaults.variables.CC = "echo -llua | xargs gcc" |
431 | defaults.variables.LD = "echo -llua | xargs gcc" | 428 | defaults.variables.LD = "echo -llua | xargs gcc" |
432 | defaults.variables.LIBFLAG = "-shared" | 429 | defaults.variables.LIBFLAG = "-shared" |
@@ -569,7 +566,7 @@ function cfg.package_paths() | |||
569 | table.insert(new_cpath, lib_path.."/?."..cfg.lib_extension) | 566 | table.insert(new_cpath, lib_path.."/?."..cfg.lib_extension) |
570 | table.insert(new_bin, bin_path) | 567 | table.insert(new_bin, bin_path) |
571 | end | 568 | end |
572 | if extra_luarocks_module_dir then | 569 | if extra_luarocks_module_dir then |
573 | table.insert(new_path, extra_luarocks_module_dir) | 570 | table.insert(new_path, extra_luarocks_module_dir) |
574 | end | 571 | end |
575 | return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, cfg.export_path_separator) | 572 | return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, cfg.export_path_separator) |