Revision: 34407
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34407
Author:   campbellbarton
Date:     2011-01-19 21:30:23 +0000 (Wed, 19 Jan 2011)
Log Message:
-----------
Command line options to set blender system environment variables.
Added because CTest has no convenient way to set environment vars for commands 
it runs.

 --env-system-config -> BLENDER_SYSTEM_CONFIG
 --env-system-datafiles -> BLENDER_SYSTEM_DATAFILES
 --env-system-scripts -> BLENDER_SYSTEM_SCRIPTS
 --env-system-plugins -> BLENDER_SYSTEM_PLUGINS
 --env-system-python -> BLENDER_SYSTEM_PYTHON

Modified Paths:
--------------
    trunk/blender/doc/manpage/blender.1
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/doc/manpage/blender.1
===================================================================
(Binary files differ)

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c      2011-01-19 21:13:49 UTC (rev 
34406)
+++ trunk/blender/source/creator/creator.c      2011-01-19 21:30:23 UTC (rev 
34407)
@@ -245,10 +245,15 @@
        printf ("Misc Options:\n");
        BLI_argsPrintArgDoc(ba, "--debug");
        BLI_argsPrintArgDoc(ba, "--debug-fpe");
+       printf("\n");
        BLI_argsPrintArgDoc(ba, "--factory-startup");
-
        printf("\n");
-
+       BLI_argsPrintArgDoc(ba, "--env-system-config");
+       BLI_argsPrintArgDoc(ba, "--env-system-datafiles");
+       BLI_argsPrintArgDoc(ba, "--env-system-scripts");
+       BLI_argsPrintArgDoc(ba, "--env-system-plugins");
+       BLI_argsPrintArgDoc(ba, "--env-system-python");
+       printf("\n");
        BLI_argsPrintArgDoc(ba, "-nojoystick");
        BLI_argsPrintArgDoc(ba, "-noglsl");
        BLI_argsPrintArgDoc(ba, "-noaudio");
@@ -399,6 +404,28 @@
        return 0;
 }
 
+static int set_env(int argc, char **argv, void *UNUSED(data))
+{
+       /* "--env-system-scripts" --> "BLENDER_SYSTEM_SCRIPTS" */
+
+       char env[64]= "BLENDER";
+       char *ch_dst= env + 7; /* skip BLENDER */
+       char *ch_src= argv[0] + 5; /* skip --env */
+
+       if (argc < 2) {
+               printf("%s requires one argument\n", argv[0]);
+               exit(1);
+       }
+
+       for(; *ch_src; ch_src++, ch_dst++) {
+               *ch_dst= (*ch_src == '-') ? '_' : (*ch_src)-32; /* toupper() */
+       }
+
+       *ch_dst= '\0';
+       BLI_setenv(env, argv[1]);
+       return 1;
+}
+
 static int playback_mode(int UNUSED(argc), char **UNUSED(argv), void 
*UNUSED(data))
 {
        /* not if -b was given first */
@@ -1017,6 +1044,13 @@
 
        BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the 
"STRINGIFY(BLENDER_STARTUP_FILE)" in the users home directory", 
set_factory_startup, NULL);
 
+       /* TODO, add user env vars? */
+       BLI_argsAdd(ba, 1, NULL, "--env-system-config",         "\n\tSet the 
"STRINGIFY_ARG(BLENDER_SYSTEM_CONFIG)" environment variable", set_env, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--env-system-datafiles",      "\n\tSet the 
"STRINGIFY_ARG(BLENDER_SYSTEM_DATAFILES)" environment variable", set_env, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--env-system-scripts",        "\n\tSet the 
"STRINGIFY_ARG(BLENDER_SYSTEM_SCRIPTS)" environment variable", set_env, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--env-system-plugins",        "\n\tSet the 
"STRINGIFY_ARG(BLENDER_SYSTEM_PLUGINS)" environment variable", set_env, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--env-system-python",         "\n\tSet the 
"STRINGIFY_ARG(BLENDER_SYSTEM_PYTHON)" environment variable", set_env, NULL);
+
        /* second pass: custom window stuff */
        BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> 
<h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, 
<h>", prefsize, NULL);
        BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with 
borders (default)", with_borders, NULL);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to