added define _CRT_SECURE_NO_DEPRECATE for visual studio build in premake4.lua. Old versions of vs2005 use this define.
added host.c for detecting if the process is running under wow, uses code provided on msdn where we lookup the function at runtime, which fails gracefully if a 32 bit machine. add host.is_64bit function in host.lua
This commit is contained in:
parent
33b9dfe543
commit
ecd8d1ae34
@ -7,6 +7,7 @@
|
|||||||
* Patch 2963313: Enable setting .NET framework version (Justen Hyde)
|
* Patch 2963313: Enable setting .NET framework version (Justen Hyde)
|
||||||
* Switched PS3 builds from GCC to SNC
|
* Switched PS3 builds from GCC to SNC
|
||||||
* Ignore NoRTTI flag for Managed C++ projects (Nick Darnell)
|
* Ignore NoRTTI flag for Managed C++ projects (Nick Darnell)
|
||||||
|
* Added host.is_64bit
|
||||||
|
|
||||||
|
|
||||||
-------
|
-------
|
||||||
|
@ -49,6 +49,9 @@
|
|||||||
configuration "vs*"
|
configuration "vs*"
|
||||||
defines { "_CRT_SECURE_NO_WARNINGS" }
|
defines { "_CRT_SECURE_NO_WARNINGS" }
|
||||||
|
|
||||||
|
configuration "vs2005"
|
||||||
|
defines {"_CRT_SECURE_NO_DEPRECATE" }
|
||||||
|
|
||||||
configuration "linux"
|
configuration "linux"
|
||||||
defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
|
defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
|
||||||
links { "m", "dl" }
|
links { "m", "dl" }
|
||||||
|
67
src/base/host.lua
Executable file
67
src/base/host.lua
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
|
||||||
|
--
|
||||||
|
--Windows
|
||||||
|
--AMD64 or IA64 or x86 according to --http://msdn.microsoft.com/en-us/library/aa384274(VS.85).aspx
|
||||||
|
--
|
||||||
|
local function windows_is_64_bit()
|
||||||
|
--works on 64 bit windows running a 32 bit binary
|
||||||
|
local arch = os.getenv("PROCESSOR_ARCHITECTURE")
|
||||||
|
if string.find(arch,'AMD64') or string.find(arch,'IA64') then
|
||||||
|
--64 bit executable running on 64 bit windows
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
--if running under wow then the above returns X86, so check using this
|
||||||
|
--function defined in host.c
|
||||||
|
return host.windows_is_64bit_running_under_wow()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_result_of_command(cmd)
|
||||||
|
local pipe = io.popen(cmd)
|
||||||
|
local result = pipe:read('*a')
|
||||||
|
pipe:close()
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local function linux_is_64_bit()
|
||||||
|
--works on 64bit Debian running a 32 bit binary
|
||||||
|
local contents= get_result_of_command('uname -m')
|
||||||
|
local t64 =
|
||||||
|
{
|
||||||
|
'x86_64'
|
||||||
|
,'ia64'
|
||||||
|
,'amd64'
|
||||||
|
,'powerpc64'
|
||||||
|
,'sparc64'
|
||||||
|
}
|
||||||
|
for _,v in ipairs(t64) do
|
||||||
|
if contents:find(v) then return true end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function macosx_is_64_bit()
|
||||||
|
--works on mac mini 10.6 as well as others
|
||||||
|
local contents= get_result_of_command('echo $HOSTTYPE')
|
||||||
|
--PPC64 is this correct?
|
||||||
|
if string.find(contents,'x86_64') or string.find(contents,'PPC64') then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
host.is_64bit = function()
|
||||||
|
local host_os = _OS
|
||||||
|
|
||||||
|
if host_os == 'linux' or host_os == 'bsd' or host_os == 'solaris' or host_os == 'haiku' then
|
||||||
|
--I assume these are correct only tested with 'linux'
|
||||||
|
return linux_is_64_bit()
|
||||||
|
elseif host_os == 'macosx' then
|
||||||
|
return macosx_is_64_bit()
|
||||||
|
elseif host_os == 'windows' then
|
||||||
|
return windows_is_64_bit()
|
||||||
|
else
|
||||||
|
error('unknown host platform, please contact premake')
|
||||||
|
end
|
||||||
|
end
|
19
src/host/host.c
Executable file
19
src/host/host.c
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
#include "premake.h"
|
||||||
|
|
||||||
|
int windows_is_64bit_running_under_wow(struct lua_State* l)
|
||||||
|
{
|
||||||
|
#if PLATFORM_WINDOWS == 1
|
||||||
|
typedef BOOL (WINAPI * wow_func_sig)(HANDLE,PBOOL);
|
||||||
|
|
||||||
|
BOOL is_wow = FALSE;
|
||||||
|
wow_func_sig func = (wow_func_sig)GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
|
||||||
|
if(func)
|
||||||
|
if(! func(GetCurrentProcess(),&is_wow))
|
||||||
|
luaL_error(l,"IsWow64Process returned an error");
|
||||||
|
#else
|
||||||
|
int is_wow = 0;
|
||||||
|
#endif
|
||||||
|
lua_pushboolean(l,is_wow);
|
||||||
|
return 1;
|
||||||
|
}
|
7
src/host/premake.c
Normal file → Executable file
7
src/host/premake.c
Normal file → Executable file
@ -56,7 +56,11 @@ static const luaL_Reg string_functions[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const luaL_Reg host_functions[] =
|
||||||
|
{
|
||||||
|
{ "windows_is_64bit_running_under_wow", windows_is_64bit_running_under_wow },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Program entry point.
|
* Program entry point.
|
||||||
@ -72,6 +76,7 @@ int main(int argc, const char** argv)
|
|||||||
luaL_register(L, "path", path_functions);
|
luaL_register(L, "path", path_functions);
|
||||||
luaL_register(L, "os", os_functions);
|
luaL_register(L, "os", os_functions);
|
||||||
luaL_register(L, "string", string_functions);
|
luaL_register(L, "string", string_functions);
|
||||||
|
luaL_register(L, "host", host_functions);
|
||||||
|
|
||||||
/* push the application metadata */
|
/* push the application metadata */
|
||||||
lua_pushstring(L, LUA_COPYRIGHT);
|
lua_pushstring(L, LUA_COPYRIGHT);
|
||||||
|
6
src/host/premake.h
Normal file → Executable file
6
src/host/premake.h
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file premake.h
|
* \file premake.h
|
||||||
* \brief Program-wide constants and definitions.
|
* \brief Program-wide constants and definitions.
|
||||||
* \author Copyright (c) 2002-2011 Jason Perkins and the Premake project
|
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define lua_c
|
#define lua_c
|
||||||
@ -24,9 +24,6 @@
|
|||||||
#elif defined(__sun__) && defined(__svr4__)
|
#elif defined(__sun__) && defined(__svr4__)
|
||||||
#define PLATFORM_SOLARIS (1)
|
#define PLATFORM_SOLARIS (1)
|
||||||
#define PLATFORM_STRING "solaris"
|
#define PLATFORM_STRING "solaris"
|
||||||
#elif defined(__HAIKU__)
|
|
||||||
#define PLATFORM_HAIKU (1)
|
|
||||||
#define PLATFORM_STRING "haiku"
|
|
||||||
#else
|
#else
|
||||||
#define PLATFORM_WINDOWS (1)
|
#define PLATFORM_WINDOWS (1)
|
||||||
#define PLATFORM_STRING "windows"
|
#define PLATFORM_STRING "windows"
|
||||||
@ -67,4 +64,5 @@ int os_pathsearch(lua_State* L);
|
|||||||
int os_rmdir(lua_State* L);
|
int os_rmdir(lua_State* L);
|
||||||
int os_uuid(lua_State* L);
|
int os_uuid(lua_State* L);
|
||||||
int string_endswith(lua_State* L);
|
int string_endswith(lua_State* L);
|
||||||
|
int windows_is_64bit_running_under_wow(struct lua_State* l);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user