diff options
author | Anthony Green <green@gcc.gnu.org> | 2002-04-12 14:28:50 +0000 |
---|---|---|
committer | Anthony Green <green@gcc.gnu.org> | 2002-04-12 14:28:50 +0000 |
commit | 9fef1fe3e4efbd44157c8796db3909097fab7e27 (patch) | |
tree | c805c665a66c87dca37b7dfcf03d737017b9baf0 /gcc/java/jcf-path.c | |
parent | 395cb211416da7def56ca50868c8f1379f99fcda (diff) | |
download | gcc-9fef1fe3e4efbd44157c8796db3909097fab7e27.zip gcc-9fef1fe3e4efbd44157c8796db3909097fab7e27.tar.gz gcc-9fef1fe3e4efbd44157c8796db3909097fab7e27.tar.bz2 |
Add --extdirs support.
From-SVN: r52227
Diffstat (limited to 'gcc/java/jcf-path.c')
-rw-r--r-- | gcc/java/jcf-path.c | 108 |
1 files changed, 105 insertions, 3 deletions
diff --git a/gcc/java/jcf-path.c b/gcc/java/jcf-path.c index 0976705..a87703e 100644 --- a/gcc/java/jcf-path.c +++ b/gcc/java/jcf-path.c @@ -26,6 +26,8 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "config.h" #include "system.h" +#include <dirent.h> + #include "jcf.h" /* Some boilerplate that really belongs in a header. */ @@ -74,6 +76,7 @@ static void add_path PARAMS ((struct entry **, const char *, int)); -classpath option overrides $CLASSPATH -CLASSPATH option is a synonym for -classpath (for compatibility) -bootclasspath overrides built-in + -extdirs sets the extensions directory path (overrides built-in) -I prepends path to list We implement this by keeping several path lists, and then simply @@ -92,6 +95,9 @@ static struct entry *classpath_user; "system" flag set. */ static struct entry *sys_dirs; +/* This holds the extensions path entries. */ +static struct entry *extensions; + /* This is the sealed list. It is just a combination of other lists. */ static struct entry *sealed; @@ -244,7 +250,7 @@ jcf_path_init () try = alloca (strlen (cp) + 50); /* The exec prefix can be something like /usr/local/bin/../lib/gcc-lib/. We want to change this - into a pointer to the share directory. We support two + into a pointer to the share/java directory. We support two configurations: one where prefix and exec-prefix are the same, and one where exec-prefix is `prefix/SOMETHING'. */ strcpy (try, cp); @@ -256,11 +262,20 @@ jcf_path_init () strcpy (try + len, "share"); strcat (try, sep); - strcat (try, "libgcj.jar"); + strcat (try, "java"); + strcat (try, sep); + strcat (try, "libgcj-" DEFAULT_TARGET_VERSION ".jar"); if (! stat (try, &stat_b)) { add_entry (&sys_dirs, try, 1); found = 1; + strcpy (&try[strlen (try) + - strlen ("libgcj-" DEFAULT_TARGET_VERSION ".jar")], + sep); + strcat (try, "ext"); + strcat (try, sep); + if (! stat (try, &stat_b)) + jcf_path_extdirs_arg (try); } else { @@ -268,18 +283,36 @@ jcf_path_init () strcat (try, sep); strcat (try, "share"); strcat (try, sep); - strcat (try, "libgcj.jar"); + strcat (try, "java"); + strcat (try, sep); + strcat (try, "libgcj-" DEFAULT_TARGET_VERSION ".jar"); if (! stat (try, &stat_b)) { add_entry (&sys_dirs, try, 1); found = 1; + strcpy (&try[strlen (try) + - strlen ("libgcj-" DEFAULT_TARGET_VERSION ".jar")], + sep); + strcat (try, "ext"); + strcat (try, sep); + if (! stat (try, &stat_b)) + jcf_path_extdirs_arg (try); } } } if (! found) { /* Desperation: use the installed one. */ + char *extdirs; add_entry (&sys_dirs, LIBGCJ_ZIP_FILE, 1); + extdirs = (char *) alloca (strlen (LIBGCJ_ZIP_FILE)); + strcpy (extdirs, LIBGCJ_ZIP_FILE); + strcpy (&extdirs[strlen (LIBGCJ_ZIP_FILE) + - strlen ("libgcj-" DEFAULT_TARGET_VERSION ".jar")], + "ext"); + strcat (extdirs, sep); + if (! stat (extdirs, &stat_b)) + jcf_path_extdirs_arg (extdirs); } GET_ENV_PATH_LIST (cp, "CLASSPATH"); @@ -307,6 +340,73 @@ jcf_path_bootclasspath_arg (path) add_path (&sys_dirs, path, 1); } +/* Call this when -extdirs is seen on the command line. + */ +void +jcf_path_extdirs_arg (cp) + const char *cp; +{ + const char *startp, *endp; + + free_entry (&extensions); + + if (cp) + { + char *buf = (char *) alloca (strlen (cp) + 3); + startp = endp = cp; + while (1) + { + if (! *endp || *endp == PATH_SEPARATOR) + { + if (endp == startp) + return; + + strncpy (buf, startp, endp - startp); + buf[endp - startp] = '\0'; + + { + DIR *dirp = NULL; + int dirname_length = strlen (buf); + + dirp = opendir (buf); + if (dirp == NULL) + return; + + for (;;) + { + struct dirent *direntp = readdir (dirp); + + if (!direntp) + break; + + if (direntp->d_name[0] != '.') + { + char *name = + (char *) alloca (dirname_length + + strlen (direntp->d_name) + 2); + strcpy (name, buf); + if (name[dirname_length-1] != DIR_SEPARATOR) + { + name[dirname_length] = DIR_SEPARATOR; + name[dirname_length+1] = 0; + } + strcat (name, direntp->d_name); + add_entry (&extensions, name, 0); + } + } + } + + if (! *endp) + break; + ++endp; + startp = endp; + } + else + ++endp; + } + } +} + /* Call this when -I is seen on the command line. */ void jcf_path_include_arg (path) @@ -347,7 +447,9 @@ jcf_path_seal (print) append_entry (&sealed, secondary); append_entry (&sealed, sys_dirs); + append_entry (&sealed, extensions); sys_dirs = NULL; + extensions = NULL; if (print) { |