Convert --scripts argument to absolute path on startup

This commit is contained in:
Jason Perkins 2014-10-16 19:09:14 -04:00
parent df6ff7c86c
commit aaa3052db4
2 changed files with 17 additions and 7 deletions

View File

@ -41,6 +41,11 @@ int os_locate(lua_State* L)
/* ...relative to the CWD */
lua_pushstring(L, ".");
/* ...on the paths specified by --scripts, if set */
if (scripts_path) {
lua_pushstring(L, scripts_path);
}
/* ... relative to ~/.premake */
if (vars) {
lua_getglobal(L, "_USER_HOME_DIR");
@ -48,11 +53,6 @@ int os_locate(lua_State* L)
lua_concat(L, 2);
}
/* ...on the paths specified by --scripts, if set */
if (scripts_path) {
lua_pushstring(L, scripts_path);
}
/* ...on the PREMAKE_PATH environment variable, if set */
if (premake_path) {
lua_pushstring(L, premake_path);

View File

@ -246,6 +246,16 @@ int premake_locate(lua_State* L, const char* argv0)
const char* set_scripts_path(const char* relativePath)
{
char* path = (char*)malloc(PATH_MAX);
do_getabsolute(path, relativePath, NULL);
scripts_path = path;
return scripts_path;
}
/**
* Copy all command line arguments into the script-side _ARGV global, and
* check for the presence of a /scripts=<path> argument to help locate
@ -267,11 +277,11 @@ int process_arguments(lua_State* L, int argc, const char** argv)
* manifest and scripts later if necessary */
if (strncmp(argv[i], "/scripts=", 9) == 0)
{
scripts_path = argv[i] + 9;
argv[i] = set_scripts_path(argv[i] + 9);
}
else if (strncmp(argv[i], "--scripts=", 10) == 0)
{
scripts_path = argv[i] + 10;
argv[i] = set_scripts_path(argv[i] + 10);
}
}
lua_setglobal(L, "_ARGV");