diff options
author | Jason Perkins <starkos@industriousone.com> | 2012-09-28 00:59:20 +0400 |
---|---|---|
committer | Jason Perkins <starkos@industriousone.com> | 2012-09-28 00:59:20 +0400 |
commit | c538fd7d3969d1c5f2a4502eb20703ca5c25ed3e (patch) | |
tree | 1893eea18ea8edc0b92b7f4c6e8946674a8f9b0c /src/host | |
parent | 445d3176dd172a46d064efd89492c22274adf2ce (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.c | 2 | ||||
-rwxr-xr-x | src/host/premake.c | 20 |
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; } |