Added --addon'/-A', in addition to $PLTADDONDIR from revision 17121.

svn: r17136
This commit is contained in:
Eli Barzilay 2009-12-01 15:11:45 +00:00
parent f4049e8c63
commit 3d9c4b0ac5
5 changed files with 59 additions and 6 deletions

View File

@ -57,6 +57,13 @@ Sets the path to be returned by @scheme[(find-system-path
'collects-dir)].}
@function[(void scheme_set_addon_path
[Scheme_Object* path])]{
Sets the path to be returned by @scheme[(find-system-path
'addon-dir)].}
@function[(void scheme_init_collection_paths_post
[Scheme_Env* env]
[Scheme_Object* pre_extra_paths]

View File

@ -80,10 +80,15 @@ by @scheme[kind], which must be one of the following:
]}
@item{@indexed-scheme['addon-dir] --- a directory for installing PLT Scheme
extensions. It's the same as @scheme['pref-dir], except under Mac OS
X, where it is @filepath{Library/PLT Scheme} in the user's home
directory. This directory might not exist.}
@item{@indexed-scheme['addon-dir] --- a directory for installing PLT
Scheme extensions. This directory is specified by the
@indexed-envvar{PLTADDONDIR} environment variable, and it can be
overridden by the @DFlag{addon} or @Flag{A} command-line flag. If no
environment variable or flag is specified, or if the value is not a
legal path name, then this directory defaults to
@filepath{Library/PLT Scheme} in the user's home directory under Mac
OS X and @scheme['pref-dir] otherwise. This directory might not
exist.}
@item{@indexed-scheme['doc-dir] --- the standard directory for
storing the current user's documents. Under Unix, it's the same as

View File

@ -456,7 +456,9 @@ static int run_from_cmd_line(int argc, char *_argv[],
GC_CAN_IGNORE char **argv = _argv;
Scheme_Env *global_env;
char *prog, *sprog = NULL;
Scheme_Object *sch_argv, *collects_path = NULL, *collects_extra = NULL;
Scheme_Object *sch_argv,
*collects_path = NULL, *collects_extra = NULL,
*addon_dir = NULL;
int i;
#ifndef DONT_PARSE_COMMAND_LINE
char **evals_and_loads, *real_switch = NULL, specific_switch[2];
@ -693,6 +695,8 @@ static int run_from_cmd_line(int argc, char *_argv[],
argv[0] = "-X";
else if (!strcmp("--search", argv[0]))
argv[0] = "-S";
else if (!strcmp("--addon", argv[0]))
argv[0] = "-A";
# ifdef CMDLINE_STDIO_FLAG
else if (!strcmp("--stdio", argv[0]))
argv[0] = "-z";
@ -738,6 +742,17 @@ static int run_from_cmd_line(int argc, char *_argv[],
collects_path = scheme_make_path(argv[0]);
was_config_flag = 1;
break;
case 'A':
if (argc < 2) {
PRINTF("%s: missing path after %s switch\n",
prog, real_switch);
goto show_need_help;
}
argv++;
--argc;
addon_dir = scheme_make_path(argv[0]);
was_config_flag = 1;
break;
case 'U':
scheme_set_ignore_user_paths(1);
was_config_flag = 1;
@ -1041,6 +1056,20 @@ static int run_from_cmd_line(int argc, char *_argv[],
}
#ifndef NO_FILE_SYSTEM_UTILS
/* Setup path for "addon" directory: */
{
#ifdef GETENV_FUNCTION
if (!addon_dir) {
char *s;
s = getenv("PLTADDONDIR");
if (s) {
s = scheme_expand_filename(s, -1, NULL, NULL, 0);
if (s) addon_dir = scheme_make_path(s);
}
}
#endif
if (addon_dir) scheme_set_addon_dir(addon_dir);
}
/* Setup path for "collects" collection directory: */
{
Scheme_Object *l, *r;
@ -1149,6 +1178,7 @@ static int run_from_cmd_line(int argc, char *_argv[],
" -I <path> : Set <init-lib> to <path>\n"
" -X <dir>, --collects <dir> : Main collects at <dir>\n"
" -S <dir>, --search <dir> : More collects at <dir> (after main collects)\n"
" -A <dir>, --addon <dir> : Addon directory at <dir>\n"
" -U, --no-user-path : Ignore user-specific collects, etc.\n"
" -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to <file>\n"
# ifdef MZ_USE_JIT

View File

@ -1745,6 +1745,7 @@ MZ_EXTERN Scheme_Object *scheme_set_exec_cmd(char *s);
MZ_EXTERN Scheme_Object *scheme_set_run_cmd(char *s);
MZ_EXTERN void scheme_set_collects_path(Scheme_Object *p);
MZ_EXTERN void scheme_set_original_dir(Scheme_Object *d);
MZ_EXTERN void scheme_set_addon_dir(Scheme_Object *p);
MZ_EXTERN void scheme_init_collection_paths(Scheme_Env *global_env, Scheme_Object *extra_dirs);
MZ_EXTERN void scheme_init_collection_paths_post(Scheme_Env *global_env, Scheme_Object *extra_dirs, Scheme_Object *extra_post_dirs);

View File

@ -227,7 +227,8 @@ static Scheme_Object *init_dir_symbol, *init_file_symbol, *sys_dir_symbol;
static Scheme_Object *exec_file_symbol, *run_file_symbol, *collects_dir_symbol;
static Scheme_Object *pref_file_symbol, *orig_dir_symbol, *addon_dir_symbol;
static Scheme_Object *exec_cmd, *run_cmd, *collects_path, *original_pwd;
static Scheme_Object *exec_cmd, *run_cmd;
static Scheme_Object *collects_path, *original_pwd = NULL, *addon_dir = NULL;
#endif
static Scheme_Object *windows_symbol, *unix_symbol;
@ -5734,6 +5735,7 @@ find_system_path(int argc, Scheme_Object **argv)
} else if (argv[0] == orig_dir_symbol) {
return original_pwd;
} else if (argv[0] == addon_dir_symbol) {
if (addon_dir) return addon_dir;
which = id_addon_dir;
} else {
scheme_wrong_type("find-system-path", "system-path-symbol",
@ -6023,6 +6025,14 @@ void scheme_set_original_dir(Scheme_Object *d)
original_pwd = d;
}
void scheme_set_addon_dir(Scheme_Object *p)
{
if (!addon_dir) {
REGISTER_SO(addon_dir);
}
addon_dir = p;
}
/********************************************************************************/
#ifdef DOS_FILE_SYSTEM