From 908e4ba7f0d09fafb35272e021605404261f4432 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sat, 19 Dec 2015 19:22:37 +0300 Subject: Fix extension splitting in builting backend Fixes incorrect gcc command and error message when a file name doesn't contain a dot: Error: Build error: Failed compiling object .o becomes Error: Build error: Failed compiling object dotlessname --- src/luarocks/build/builtin.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 00fd09ea..ffdc9450 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -202,7 +202,7 @@ function builtin.run(rockspec) for name, info in pairs(build.modules) do local moddir = path.module_to_path(name) if type(info) == "string" then - local ext = info:match(".([^.]+)$") + local ext = info:match("%.([^.]+)$") if ext == "lua" then local filename = dir.base_name(info) if info:match("init%.lua$") and not name:match("%.init$") then @@ -226,7 +226,7 @@ function builtin.run(rockspec) if info[1] then sources = info end if type(sources) == "string" then sources = {sources} end for _, source in ipairs(sources) do - local object = source:gsub(".[^.]*$", "."..cfg.obj_extension) + local object = source:gsub("%.[^.]*$", "."..cfg.obj_extension) if not object then object = source.."."..cfg.obj_extension end -- cgit v1.2.3-55-g6feb From d62622aa2502cf9d100723ad9232fd72b7e75b9b Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sat, 19 Dec 2015 19:30:29 +0300 Subject: Improve error handling in builtin backend Show error message from fs.copy when failed to install a file. Nice for Lua module files, since their existence is not checked beforehand. Also remove extra 'local ok, err' declarations. --- src/luarocks/build/builtin.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index ffdc9450..afd05954 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -174,7 +174,7 @@ function builtin.run(rockspec) --TODO EXEWRAPPER end - local ok = true + local ok, err local built_modules = {} local luadir = path.lua_dir(rockspec.name, rockspec.version) local libdir = path.lib_dir(rockspec.name, rockspec.version) @@ -236,11 +236,10 @@ function builtin.run(rockspec) end table.insert(objects, object) end - if not ok then break end local module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.lib_extension) if moddir ~= "" then module_name = dir.path(moddir, module_name) - local ok, err = fs.make_dir(moddir) + ok, err = fs.make_dir(moddir) if not ok then return nil, err end end built_modules[module_name] = dir.path(libdir, module_name) @@ -252,13 +251,13 @@ function builtin.run(rockspec) end for name, dest in pairs(built_modules) do fs.make_dir(dir.dir_name(dest)) - ok = fs.copy(name, dest) + ok, err = fs.copy(name, dest) if not ok then - return nil, "Failed installing "..name.." in "..dest + return nil, "Failed installing "..name.." in "..dest..": "..err end end if fs.is_dir("lua") then - local ok, err = fs.copy_contents("lua", luadir) + ok, err = fs.copy_contents("lua", luadir) if not ok then return nil, "Failed copying contents of 'lua' directory: "..err end -- cgit v1.2.3-55-g6feb