Author: leo
Date: Sun Aug 14 05:43:09 2005
New Revision: 8954

Modified:
   trunk/imcc/docs/running.pod
   trunk/imcc/main.c
   trunk/src/library.c
Log:
Runtime prefix override

* PARROT_RUNTIME=/foo/bar parrot
  The env var overrides the builtin runtime prefix.
* parrot --runtime-prefix
  print current runtime prefix and exit
* update imcc/docs/running.pod


Modified: trunk/imcc/docs/running.pod
==============================================================================
--- trunk/imcc/docs/running.pod (original)
+++ trunk/imcc/docs/running.pod Sun Aug 14 05:43:09 2005
@@ -33,6 +33,17 @@ This document describes parrot's command
 
  parrot [-options] <file> [arguments ...]
 
+=head1 ENVIRONMENT
+
+=over 4
+
+=item PARROT_RUNTIME
+
+If this environment variable is set, parrot will use this path as runtime
+prefix instead of the compiled in path.
+
+=back
+
 =head1 OPTIONS
 
 =head2 Assembler options
@@ -73,6 +84,12 @@ it has to start with a number.
 
 =item -h, --help
 
+Print commandline option summary.
+
+=item --help-debug
+
+Print debugging and tracing flag bits summary.
+
 =item -o outputfile, --output=outputfile
 
 Act like an assembler. Don't run code, unless B<-r> is given too. If the
@@ -163,6 +180,7 @@ Prederefernce opcode function arguments 
 =item -t, --trace
 
 Run with the slow core and print trace information to B<stderr>.
+See 'parrot --help-debug' for aviable flag bits.
 
 =back
 
@@ -172,7 +190,11 @@ Run with the slow core and print trace i
 
 =item -w, --warnings
 
-Turn on warnings.
+Turn on warnings. See 'parrot --help-debug' for aviable flag bits.
+
+=item -D, --parrot-debug
+
+Turn on interpreter debug flag. See 'parrot --help-debug' for aviable flag 
bits.
 
 =item --gc-debug
 
@@ -181,7 +203,7 @@ GC subsystem and can slow down execution
 
 =item -G, --no-gc
 
-This turns off DOD (Dead Object Detection) and GC. This may be useful to find 
+This turns off DOD (Dead Object Detection) and GC. This may be useful to find
 GC related bugs. Don't use this option for longer running programs: as memory
 is no longer recycled, it may quickly become exhausted.
 
@@ -193,6 +215,10 @@ Free all memory of the last interpreter,
 
 Read a keystroke before starting.
 
+=item --runtime-prefix
+
+Print the runtime prefix path and exit.
+
 =back
 
 =head1 <file>

Modified: trunk/imcc/main.c
==============================================================================
--- trunk/imcc/main.c   (original)
+++ trunk/imcc/main.c   Sun Aug 14 05:43:09 2005
@@ -89,6 +89,7 @@ help(void)
     "       --gc-debug\n"
     "       --leak-test|--destroy-at-end\n"
     "    -. --wait    Read a keystroke before starting\n"
+    "       --runtime-prefix\n"
     "   <Compiler options>\n"
     "    -d --imcc_debug[=HEXFLAGS]\n"
     "    -v --verbose\n"
@@ -144,10 +145,12 @@ the GNU General Public License or the Ar
 #define OPT_DESTROY_FLAG 129
 #define OPT_HELP_DEBUG   130
 #define OPT_PBC_OUTPUT   131
+#define OPT_RUNTIME_PREFIX  132
+
 static struct longopt_opt_decl options[] = {
     { '.', '.', 0, { "--wait" } },
     { 'C', 'C', 0, { "--CGP-core" } },
-    { 'D', 'D', OPTION_optional_FLAG, { "---parrot-debug" } },
+    { 'D', 'D', OPTION_optional_FLAG, { "--parrot-debug" } },
     { 'E', 'E', 0, { "--pre-process-only" } },
     { 'G', 'G', 0, { "--no-gc" } },
     { 'O', 'O', OPTION_optional_FLAG, { "--optimize" } },
@@ -168,6 +171,7 @@ static struct longopt_opt_decl options[]
     { '\0', OPT_PBC_OUTPUT, 0, { "--output-pbc" } },
     { 'p', 'p', 0, { "--profile" } },
     { 'r', 'r', 0, { "--run-pbc" } },
+    { '\0', OPT_RUNTIME_PREFIX, 0, { "--runtime-prefix" } },
     { 't', 't', OPTION_optional_FLAG, { "--trace" } },
     { 'v', 'v', 0, { "--verbose" } },
     { 'w', 'w', 0, { "--warnings" } },
@@ -263,6 +267,10 @@ parseflags(Parrot_Interp interp, int *ar
                 help_debug();
                 exit(EX_USAGE);
                 break;
+            case OPT_RUNTIME_PREFIX:
+                printf("%s\n", Parrot_get_runtime_prefix(interp, NULL));
+                exit(0);
+                break;
             case 'V':
                 imcc_version();
                 break;

Modified: trunk/src/library.c
==============================================================================
--- trunk/src/library.c (original)
+++ trunk/src/library.c Sun Aug 14 05:43:09 2005
@@ -367,6 +367,17 @@ Parrot_get_runtime_prefix(Interp *interp
 {
     STRING *s, *key;
     PMC *config_hash;
+    int free_it;
+    char *env;
+
+    env = Parrot_getenv("PARROT_RUNTIME", &free_it);
+    if (env) {
+        if (!free_it)
+            env = strdup(env);
+        if (prefix_str)
+            *prefix_str = string_from_cstring(interpreter, env, 0);
+        return env;
+    }
 
     config_hash = VTABLE_get_pmc_keyed_int(interpreter, interpreter->iglobals,
             (INTVAL) IGLOBALS_CONFIG_HASH);

Reply via email to