[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21752] branches/blender2.5/blender/source : BLI_setenv, use instead of copying ifdefs about for setting env vars.
Campbell Barton
ideasman42 at gmail.com
Tue Jul 21 11:26:29 CEST 2009
Revision: 21752
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21752
Author: campbellbarton
Date: 2009-07-21 11:26:28 +0200 (Tue, 21 Jul 2009)
Log Message:
-----------
BLI_setenv, use instead of copying ifdefs about for setting env vars.
set PYTHONHOME as well as PYTHONPATH, quiets some warnings.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenlib/BLI_util.h
branches/blender2.5/blender/source/blender/blenlib/intern/util.c
branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c
branches/blender2.5/blender/source/creator/creator.c
Modified: branches/blender2.5/blender/source/blender/blenlib/BLI_util.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/BLI_util.h 2009-07-21 08:39:58 UTC (rev 21751)
+++ branches/blender2.5/blender/source/blender/blenlib/BLI_util.h 2009-07-21 09:26:28 UTC (rev 21752)
@@ -43,6 +43,7 @@
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);
Modified: branches/blender2.5/blender/source/blender/blenlib/intern/util.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/util.c 2009-07-21 08:39:58 UTC (rev 21751)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/util.c 2009-07-21 09:26:28 UTC (rev 21752)
@@ -951,7 +951,25 @@
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)
{
if(path==0) return;
Modified: branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c 2009-07-21 08:39:58 UTC (rev 21751)
+++ branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c 2009-07-21 09:26:28 UTC (rev 21752)
@@ -160,28 +160,8 @@
/* 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);
}
Modified: branches/blender2.5/blender/source/creator/creator.c
===================================================================
--- branches/blender2.5/blender/source/creator/creator.c 2009-07-21 08:39:58 UTC (rev 21751)
+++ branches/blender2.5/blender/source/creator/creator.c 2009-07-21 09:26:28 UTC (rev 21752)
@@ -501,25 +501,11 @@
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
}
More information about the Bf-blender-cvs
mailing list