From d90c3c918a2555eff8776e1acabab7a777f13c31 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 19 Jun 2018 00:07:03 -0300 Subject: fs.win32.pe-parser: copy get_architecture from install.bat --- src/luarocks/fs/win32/pe-parser.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/luarocks/fs/win32/pe-parser.lua b/src/luarocks/fs/win32/pe-parser.lua index 9cd36ffc..34556812 100644 --- a/src/luarocks/fs/win32/pe-parser.lua +++ b/src/luarocks/fs/win32/pe-parser.lua @@ -550,4 +550,19 @@ function M.msvcrt(infile) return nil, "No msvcrt found" end +function M.get_architecture(program) + -- detect processor arch interpreter was compiled for + local proc = (M.parse(program) or {}).Machine + if not proc then + return nil, "Could not detect processor architecture used in "..program + end + proc = M.const.Machine[proc] -- collect name from constant value + if proc == "IMAGE_FILE_MACHINE_I386" then + proc = "x86" + else + proc = "x86_64" + end + return proc +end + return M -- cgit v1.2.3-55-g6feb