aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2013-04-15 20:22:26 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2013-04-15 20:22:26 +0200
commite38a055f8dd076cc8cc3db4d56f1171d274e36b9 (patch)
treedbfac13680b22018962bad6eef3ae73235dff3dd
parent6cc2c255777d77a73197ed6b960f898391dabfe6 (diff)
downloadluarocks-e38a055f8dd076cc8cc3db4d56f1171d274e36b9.tar.gz
luarocks-e38a055f8dd076cc8cc3db4d56f1171d274e36b9.tar.bz2
luarocks-e38a055f8dd076cc8cc3db4d56f1171d274e36b9.zip
refactored error handling, less error prone
-rw-r--r--src/luarocks/build/builtin.lua33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua
index 3d179b34..9d97d58b 100644
--- a/src/luarocks/build/builtin.lua
+++ b/src/luarocks/build/builtin.lua
@@ -217,8 +217,7 @@ function run(rockspec)
217 end 217 end
218 ok = compile_object(object, source, info.defines, info.incdirs) 218 ok = compile_object(object, source, info.defines, info.incdirs)
219 if not ok then 219 if not ok then
220 err = "Failed compiling object "..object 220 return nil, "Failed compiling object "..object
221 break
222 end 221 end
223 table.insert(objects, object) 222 table.insert(objects, object)
224 end 223 end
@@ -231,30 +230,22 @@ function run(rockspec)
231 built_modules[module_name] = dest 230 built_modules[module_name] = dest
232 ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) 231 ok = compile_library(module_name, objects, info.libraries, info.libdirs, name)
233 if not ok then 232 if not ok then
234 err = "Failed compiling module "..module_name 233 return nil, "Failed compiling module "..module_name
235 break
236 end 234 end
237 end 235 end
238 end 236 end
239 if ok then 237 for name, dest in pairs(built_modules) do
240 for name, dest in pairs(built_modules) do 238 fs.make_dir(dest)
241 fs.make_dir(dest) 239 ok = fs.copy(name, dest)
242 ok = fs.copy(name, dest) 240 if not ok then
243 if not ok then 241 return nil, "Failed installing "..name.." in "..dest
244 err = "Failed installing "..name.." in "..dest
245 break
246 end
247 end 242 end
248 end 243 end
249 if ok then 244 if fs.is_dir("lua") then
250 if fs.is_dir("lua") then 245 ok, err = fs.copy_contents("lua", luadir)
251 ok, err = fs.copy_contents("lua", luadir) 246 if not ok then
252 if not ok then err = "Failed copying contents of 'lua' directory: "..err end 247 return nil, "Failed copying contents of 'lua' directory: "..err
253 end 248 end
254 end 249 end
255 if ok then 250 return true
256 return true
257 else
258 return nil, err
259 end
260end 251end