Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorLiam Devine <dmail00@gmail.com>2011-03-12 20:03:10 +0300
committerLiam Devine <dmail00@gmail.com>2011-03-12 20:03:10 +0300
commitecd8d1ae34125057a39e8517a3dd24f81c20ec86 (patch)
tree350af0783e19e2443d5925a8784ca915c2e3a8b9 /src/host
parent33b9dfe543b0a270f50d95d1738348bf3fd18c60 (diff)
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
Diffstat (limited to 'src/host')
-rwxr-xr-xsrc/host/host.c19
-rwxr-xr-x[-rw-r--r--]src/host/premake.c9
-rwxr-xr-x[-rw-r--r--]src/host/premake.h138
3 files changed, 94 insertions, 72 deletions
diff --git a/src/host/host.c b/src/host/host.c
new file mode 100755
index 0000000..c245506
--- /dev/null
+++ b/src/host/host.c
@@ -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;
+} \ No newline at end of file
diff --git a/src/host/premake.c b/src/host/premake.c
index 01beb59..802b6f1 100644..100755
--- a/src/host/premake.c
+++ b/src/host/premake.c
@@ -56,7 +56,11 @@ static const luaL_Reg string_functions[] = {
{ 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.
@@ -72,7 +76,8 @@ int main(int argc, const char** argv)
luaL_register(L, "path", path_functions);
luaL_register(L, "os", os_functions);
luaL_register(L, "string", string_functions);
-
+ luaL_register(L, "host", host_functions);
+
/* push the application metadata */
lua_pushstring(L, LUA_COPYRIGHT);
lua_setglobal(L, "_COPYRIGHT");
diff --git a/src/host/premake.h b/src/host/premake.h
index 0c83571..fa77ec6 100644..100755
--- a/src/host/premake.h
+++ b/src/host/premake.h
@@ -1,70 +1,68 @@
-/**
- * \file premake.h
- * \brief Program-wide constants and definitions.
- * \author Copyright (c) 2002-2011 Jason Perkins and the Premake project
- */
-
-#define lua_c
-#include "lua.h"
-#include "lauxlib.h"
-#include "lualib.h"
-
-
-/* Identify the current platform I'm not sure how to reliably detect
- * Windows but since it is the most common I use it as the default */
-#if defined(__linux__)
-#define PLATFORM_LINUX (1)
-#define PLATFORM_STRING "linux"
-#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
-#define PLATFORM_BSD (1)
-#define PLATFORM_STRING "bsd"
-#elif defined(__APPLE__) && defined(__MACH__)
-#define PLATFORM_MACOSX (1)
-#define PLATFORM_STRING "macosx"
-#elif defined(__sun__) && defined(__svr4__)
-#define PLATFORM_SOLARIS (1)
-#define PLATFORM_STRING "solaris"
-#elif defined(__HAIKU__)
-#define PLATFORM_HAIKU (1)
-#define PLATFORM_STRING "haiku"
-#else
-#define PLATFORM_WINDOWS (1)
-#define PLATFORM_STRING "windows"
-#endif
-
-
-/* Pull in platform-specific headers required by built-in functions */
-#if PLATFORM_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#else
-#include <unistd.h>
-#endif
-
-
-/* A success return code */
-#define OKAY (0)
-
-
-/* Bootstrapping helper functions */
-int do_isfile(const char* filename);
-
-
-/* Built-in functions */
-int path_isabsolute(lua_State* L);
-int os_chdir(lua_State* L);
-int os_copyfile(lua_State* L);
-int os_getcwd(lua_State* L);
-int os_isdir(lua_State* L);
-int os_isfile(lua_State* L);
-int os_matchdone(lua_State* L);
-int os_matchisfile(lua_State* L);
-int os_matchname(lua_State* L);
-int os_matchnext(lua_State* L);
-int os_matchstart(lua_State* L);
-int os_mkdir(lua_State* L);
-int os_pathsearch(lua_State* L);
-int os_rmdir(lua_State* L);
-int os_uuid(lua_State* L);
-int string_endswith(lua_State* L);
-
+/**
+ * \file premake.h
+ * \brief Program-wide constants and definitions.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#define lua_c
+#include "lua.h"
+#include "lauxlib.h"
+#include "lualib.h"
+
+
+/* Identify the current platform I'm not sure how to reliably detect
+ * Windows but since it is the most common I use it as the default */
+#if defined(__linux__)
+#define PLATFORM_LINUX (1)
+#define PLATFORM_STRING "linux"
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#define PLATFORM_BSD (1)
+#define PLATFORM_STRING "bsd"
+#elif defined(__APPLE__) && defined(__MACH__)
+#define PLATFORM_MACOSX (1)
+#define PLATFORM_STRING "macosx"
+#elif defined(__sun__) && defined(__svr4__)
+#define PLATFORM_SOLARIS (1)
+#define PLATFORM_STRING "solaris"
+#else
+#define PLATFORM_WINDOWS (1)
+#define PLATFORM_STRING "windows"
+#endif
+
+
+/* Pull in platform-specific headers required by built-in functions */
+#if PLATFORM_WINDOWS
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
+
+/* A success return code */
+#define OKAY (0)
+
+
+/* Bootstrapping helper functions */
+int do_isfile(const char* filename);
+
+
+/* Built-in functions */
+int path_isabsolute(lua_State* L);
+int os_chdir(lua_State* L);
+int os_copyfile(lua_State* L);
+int os_getcwd(lua_State* L);
+int os_isdir(lua_State* L);
+int os_isfile(lua_State* L);
+int os_matchdone(lua_State* L);
+int os_matchisfile(lua_State* L);
+int os_matchname(lua_State* L);
+int os_matchnext(lua_State* L);
+int os_matchstart(lua_State* L);
+int os_mkdir(lua_State* L);
+int os_pathsearch(lua_State* L);
+int os_rmdir(lua_State* L);
+int os_uuid(lua_State* L);
+int string_endswith(lua_State* L);
+int windows_is_64bit_running_under_wow(struct lua_State* l);
+