diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-04-20 03:10:17 -0700 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-04-20 03:10:17 -0700 |
| commit | 4a13290379eb5f112720f248936229c67558fcfe (patch) | |
| tree | 96591eb489c8a7304c89f2113fdf6250f72b246d | |
| parent | 800c2fe268481d6dc60f95005032a72d8cbe82db (diff) | |
| parent | e38a055f8dd076cc8cc3db4d56f1171d274e36b9 (diff) | |
| download | luarocks-4a13290379eb5f112720f248936229c67558fcfe.tar.gz luarocks-4a13290379eb5f112720f248936229c67558fcfe.tar.bz2 luarocks-4a13290379eb5f112720f248936229c67558fcfe.zip | |
Merge pull request #124 from Tieske/refactor_builtin_error
refactored error handling, less error prone
| -rw-r--r-- | src/luarocks/build/builtin.lua | 33 |
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 | ||
| 260 | end | 251 | end |
