diff options
-rw-r--r-- | install.bat | 85 | ||||
-rw-r--r-- | win32/bin/objdump.exe | bin | 0 -> 2247694 bytes |
2 files changed, 75 insertions, 10 deletions
diff --git a/install.bat b/install.bat index 2150d2c3..e1e7cb76 100644 --- a/install.bat +++ b/install.bat | |||
@@ -18,6 +18,7 @@ vars.LUA_LIBNAME = nil | |||
18 | vars.LUA_VERSION = "5.1" | 18 | vars.LUA_VERSION = "5.1" |
19 | vars.LUA_SHORTV = nil | 19 | vars.LUA_SHORTV = nil |
20 | vars.LUA_LIB_NAMES = "lua5.1.lib lua51.dll liblua.dll.a" | 20 | vars.LUA_LIB_NAMES = "lua5.1.lib lua51.dll liblua.dll.a" |
21 | vars.LUA_RUNTIME = nil | ||
21 | 22 | ||
22 | local P_SET = false | 23 | local P_SET = false |
23 | local FORCE = false | 24 | local FORCE = false |
@@ -263,6 +264,66 @@ local function look_for_headers (directory) | |||
263 | return false | 264 | return false |
264 | end | 265 | end |
265 | 266 | ||
267 | -- Checks a binary file for the runtime dll used by it. If nu runtime is found, it returns an | ||
268 | -- array of dll's is depends upon. | ||
269 | -- result: string = runtime used, table = list of dll's depended upon, nil = nothing found. | ||
270 | local function get_file_runtime(p,f) -- path, filename | ||
271 | local infile = p.."\\"..f | ||
272 | local outfile = "output.txt" | ||
273 | local content | ||
274 | -- analyze binary | ||
275 | if exec([[.\bin\objdump -x "]]..infile..[[" > ]]..outfile) then | ||
276 | -- read temp file | ||
277 | local fh = io.open(outfile) | ||
278 | content = fh:read("*a") | ||
279 | fh:close() | ||
280 | end | ||
281 | -- delete temp file | ||
282 | os.remove(outfile) | ||
283 | if not content then | ||
284 | print(" Failed to analyze "..infile.." for the runtime used") | ||
285 | return nil | ||
286 | end | ||
287 | |||
288 | -- lookup | ||
289 | content = content:upper() | ||
290 | local result = content:match('DLL NAME%: (MSVCR%d*)%.DLL') | ||
291 | if not result then | ||
292 | result = content:match('DLL NAME%: (MSVCRT)%.DLL') | ||
293 | end | ||
294 | |||
295 | if result then | ||
296 | print(" "..f.." uses "..tostring(result)..".DLL as runtime") | ||
297 | else | ||
298 | print(" No runtime found for "..f) | ||
299 | -- so; create a list of dll's this file is depending upon, next level of the tree | ||
300 | result = {} | ||
301 | for name in content:gmatch("DLL NAME%: (.-%.DLL)") do | ||
302 | --print("found dll:", name) | ||
303 | table.insert(result, name) | ||
304 | end | ||
305 | end | ||
306 | return result | ||
307 | end | ||
308 | |||
309 | local function get_runtime() | ||
310 | -- first check interpreter | ||
311 | vars.LUA_RUNTIME = get_file_runtime(vars.LUA_BINDIR, vars.LUA_INTERPRETER) | ||
312 | if type(vars.LUA_RUNTIME) == "table" then | ||
313 | -- a table with dll's depended upon was returned, check this list | ||
314 | -- note: we only check 1 level deep | ||
315 | for _,dll in ipairs(vars.LUA_RUNTIME) do | ||
316 | local t = get_file_runtime(vars.LUA_BINDIR, dll) | ||
317 | if type(t) == "string" then | ||
318 | -- found it | ||
319 | vars.LUA_RUNTIME = t | ||
320 | break | ||
321 | end | ||
322 | end | ||
323 | end | ||
324 | return (type(vars.LUA_RUNTIME) == "string") | ||
325 | end | ||
326 | |||
266 | local function look_for_lua_install () | 327 | local function look_for_lua_install () |
267 | print("Looking for Lua interpreter") | 328 | print("Looking for Lua interpreter") |
268 | local directories = { [[c:\lua5.1.2]], [[c:\lua]], [[c:\kepler\1.1]] } | 329 | local directories = { [[c:\lua5.1.2]], [[c:\lua]], [[c:\kepler\1.1]] } |
@@ -275,7 +336,7 @@ local function look_for_lua_install () | |||
275 | look_for_headers(vars.LUA_INCDIR) | 336 | look_for_headers(vars.LUA_INCDIR) |
276 | then | 337 | then |
277 | if exec(S"$LUA_BINDIR\\$LUA_INTERPRETER -v 2>NUL") then | 338 | if exec(S"$LUA_BINDIR\\$LUA_INTERPRETER -v 2>NUL") then |
278 | print(" Ok") | 339 | print(" Ok") |
279 | return true | 340 | return true |
280 | end | 341 | end |
281 | end | 342 | end |
@@ -290,12 +351,15 @@ local function look_for_lua_install () | |||
290 | if look_for_link_libraries(directory) then | 351 | if look_for_link_libraries(directory) then |
291 | print("Link library found, now looking for headers...") | 352 | print("Link library found, now looking for headers...") |
292 | if look_for_headers(directory) then | 353 | if look_for_headers(directory) then |
293 | print("Headers found, now testing interpreter...") | 354 | print("Headers found, checking runtime to use...") |
294 | if exec(S[[$LUA_BINDIR\$LUA_INTERPRETER -v 2>NUL]]) then | 355 | if get_runtime() then |
295 | print(" Ok") | 356 | print("Runtime found, now testing interpreter...") |
296 | return true | 357 | if exec(S[[$LUA_BINDIR\$LUA_INTERPRETER -v 2>NUL]]) then |
358 | print(" Ok") | ||
359 | return true | ||
360 | end | ||
361 | print(" Interpreter returned an error, not ok") | ||
297 | end | 362 | end |
298 | print(" Interpreter returned an error, not ok") | ||
299 | end | 363 | end |
300 | end | 364 | end |
301 | end | 365 | end |
@@ -358,6 +422,7 @@ if not look_for_lua_install() then | |||
358 | vars.LUA_LIBDIR = vars.LIBDIR | 422 | vars.LUA_LIBDIR = vars.LIBDIR |
359 | vars.LUA_INCDIR = vars.INCDIR | 423 | vars.LUA_INCDIR = vars.INCDIR |
360 | vars.LUA_LIBNAME = "lua5.1.lib" | 424 | vars.LUA_LIBNAME = "lua5.1.lib" |
425 | vars.LUA_RUNTIME = "MSVCR80" | ||
361 | else | 426 | else |
362 | print(S[[ | 427 | print(S[[ |
363 | 428 | ||
@@ -367,7 +432,7 @@ Lua interpreter: $LUA_BINDIR\$LUA_INTERPRETER | |||
367 | Lua binaries : $LUA_BINDIR | 432 | Lua binaries : $LUA_BINDIR |
368 | Lua libraries : $LUA_LIBDIR | 433 | Lua libraries : $LUA_LIBDIR |
369 | Lua includes : $LUA_INCDIR | 434 | Lua includes : $LUA_INCDIR |
370 | Binaries will be linked against: $LUA_LIBNAME | 435 | Binaries will be linked against: $LUA_LIBNAME with runtime $LUA_RUNTIME |
371 | 436 | ||
372 | ]]) | 437 | ]]) |
373 | end | 438 | end |
@@ -521,10 +586,10 @@ rocks_trees = { | |||
521 | f:write(S"scripts_dir=[[$SCRIPTS_DIR]]\n") | 586 | f:write(S"scripts_dir=[[$SCRIPTS_DIR]]\n") |
522 | end | 587 | end |
523 | f:write("variables = {\n") | 588 | f:write("variables = {\n") |
524 | if USE_MINGW then | 589 | if USE_MINGW and vars.LUA_RUNTIME == "MSVCRT" then |
525 | f:write(" MSVCRT = 'm',\n") | 590 | f:write(" MSVCRT = 'm', -- make MinGW use MSVCRT.DLL as runtime\n") |
526 | else | 591 | else |
527 | f:write(" MSVCRT = 'msvcr80',\n") | 592 | f:write(" MSVCRT = '"..vars.LUA_RUNTIME.."',\n") |
528 | end | 593 | end |
529 | f:write(S" LUALIB = '$LUA_LIBNAME'\n") | 594 | f:write(S" LUALIB = '$LUA_LIBNAME'\n") |
530 | f:write("}\n") | 595 | f:write("}\n") |
diff --git a/win32/bin/objdump.exe b/win32/bin/objdump.exe new file mode 100644 index 00000000..4429d103 --- /dev/null +++ b/win32/bin/objdump.exe | |||
Binary files differ | |||