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

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2012-09-28 00:59:20 +0400
committerJason Perkins <starkos@industriousone.com>2012-09-28 00:59:20 +0400
commit0c0a284b18ecb86ec1a1efc71d4a18566f207835 (patch)
tree1893eea18ea8edc0b92b7f4c6e8946674a8f9b0c /src/host
parent4e8d01487d3bb90a66098d03ab5d0e8a4b29af3f (diff)
Patch 3485071: Fixed _PREMAKE_COMMAND fallback when premake4 is not in PATH (Konstantin Tokarev)
Diffstat (limited to 'src/host')
-rw-r--r--src/host/path_isabsolute.c2
-rwxr-xr-xsrc/host/premake.c20
2 files changed, 20 insertions, 2 deletions
diff --git a/src/host/path_isabsolute.c b/src/host/path_isabsolute.c
index 14942d1..961ed77 100644
--- a/src/host/path_isabsolute.c
+++ b/src/host/path_isabsolute.c
@@ -9,7 +9,7 @@
int path_isabsolute(lua_State* L)
{
- const char* path = luaL_checkstring(L, 1);
+ const char* path = luaL_checkstring(L, -1);
if (path[0] == '/' || path[0] == '\\' || path[0] == '$' || (path[0] != '\0' && path[1] == ':'))
{
lua_pushboolean(L, 1);
diff --git a/src/host/premake.c b/src/host/premake.c
index 1db66fd..41d42f9 100755
--- a/src/host/premake.c
+++ b/src/host/premake.c
@@ -160,7 +160,7 @@ int premake_locate(lua_State* L, const char* argv0)
lua_pushcfunction(L, os_pathsearch);
lua_pushstring(L, argv0);
lua_pushstring(L, getenv("PATH"));
- if (lua_pcall(L, 2, 1, 0) == OKAY)
+ if (lua_pcall(L, 2, 1, 0) == OKAY && !lua_isnil(L, -1))
{
lua_pushstring(L, "/");
lua_pushstring(L, argv0);
@@ -169,6 +169,24 @@ int premake_locate(lua_State* L, const char* argv0)
}
}
+ /* If all else fails, use argv[0] as-is and hope for the best */
+ if (!path)
+ {
+ /* make it absolute, if needed */
+ os_getcwd(L);
+ lua_pushstring(L, "/");
+ lua_pushstring(L, argv0);
+
+ if (!path_isabsolute(L)) {
+ lua_concat(L, 3);
+ }
+ else {
+ lua_pop(L, 1);
+ }
+
+ path = lua_tostring(L, -1);
+ }
+
lua_pushstring(L, path);
return 1;
}