BLI_setenv, use instead of copying ifdefs about for setting env vars.

set PYTHONHOME as well as PYTHONPATH, quiets some warnings.
This commit is contained in:
2009-07-21 09:26:28 +00:00
parent ca466dc8d8
commit 0ebf23c0b8
4 changed files with 25 additions and 40 deletions

View File

@@ -43,6 +43,7 @@ struct direntry;
char *BLI_gethome(void);
char *BLI_gethome_folder(char *folder_name);
void BLI_setenv(const char *env, const char *val);
void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file);
void BLI_make_exist(char *dir);

View File

@@ -951,6 +951,24 @@ char *BLI_gethome_folder(char *folder_name)
return NULL;
}
void BLI_setenv(const char *env, const char*val)
{
/* SGI or free windows */
#if (defined(__sgi) || ((defined(WIN32) || defined(WIN64)) && defined(FREE_WINDOWS)))
char *envstr= malloc(sizeof(char) * (strlen(env) + strlen(val) + 2)); /* one for = another for \0 */
sprintf(envstr, "%s=%s", env, val);
putenv(envstr);
free(envstr);
/* non-free windows */
#elif (defined(WIN32) || defined(WIN64)) /* not free windows */
_putenv_s(env, val);
#else
/* linux/osx/bsd */
setenv(env, val, 1);
#endif
}
void BLI_clean(char *path)
{

View File

@@ -160,28 +160,8 @@ void BPY_start_python_path(void)
/* set the environment path */
printf("found bundled python: %s\n", py_path_bundle);
#if (defined(WIN32) || defined(WIN64))
#if defined(FREE_WINDOWS)
{
char py_path[FILE_MAXDIR + 11] = "";
sprintf(py_path, "PYTHONPATH=%s", py_path_bundle);
putenv(py_path);
}
#else
_putenv_s("PYTHONPATH", py_path_bundle);
#endif
#else
#ifdef __sgi
{
char py_path[FILE_MAXDIR + 11] = "";
sprintf(py_path, "PYTHONPATH=%s", py_path_bundle);
putenv(py_path);
}
#else
setenv("PYTHONPATH", py_path_bundle, 1);
#endif
#endif
BLI_setenv("PYTHONHOME", py_path_bundle);
BLI_setenv("PYTHONPATH", py_path_bundle);
}

View File

@@ -501,25 +501,11 @@ int main(int argc, char **argv)
BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */
#ifndef DISABLE_SDL
#if (defined(WIN32) || defined(WIN64))
#if defined(FREE_WINDOWS)
putenv("SDL_VIDEODRIVER=dummy");
#else
_putenv_s("SDL_VIDEODRIVER", "dummy");
#endif
#else
#ifdef __sgi
putenv("SDL_VIDEODRIVER=dummy");
#else
setenv("SDL_VIDEODRIVER", "dummy", 1); /* initializing the video driver can cause crashes on some systems - Campbell */
#endif
#endif
BLI_setenv("SDL_VIDEODRIVER", "dummy");
#ifdef __linux__
/* On linux the default SDL driver dma often would not play
* use alsa if none is set */
if ( getenv("SDL_AUDIODRIVER") == NULL) {
setenv("SDL_AUDIODRIVER", "alsa", 1);
}
/* On linux the default SDL driver dma often would not play
* use alsa if none is set */
setenv("SDL_AUDIODRIVER", "alsa", 0);
#endif
#endif
}