From: green Date: Fri, 12 Apr 2002 14:28:50 +0000 (+0000) Subject: Add --extdirs support. X-Git-Tag: upstream/4.9.2~87348 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a80ddca002da1f499be515482f673679363f39d;p=platform%2Fupstream%2Flinaro-gcc.git Add --extdirs support. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52227 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 8fc2ce7..4a22366 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,31 @@ +2002-04-10 Andreas Jaeger + + * gcj.texi (Input Options): Fix extdirs patch. + +2002-04-10 Anthony Green + + * jcf-path.c (jcf_path_init) : Clean up local extdirs declaration. + +2002-04-09 Anthony Green + + * gcj.texi (Input Options): Add --extdirs documentation. + * jcf-dump.c (OPT_extdirs): New macro. + (options): Add extdirs option. + (help): Describe --extdirs. + (main): Handle OPT_extdirs. + * gjavah.c (OPT_extdirs): New macro. + (options): Add extdirs option. + (help): Describe --extdirs. + (main): Handle OPT_extdirs. + * jcf-path.c (jcf_path_init): Add extdirs support. + (jcf_path_extdirs_arg): New function. + (extensions): New variable to hold extensions path entries. + * jvspec.c: Remove -fextdirs= when compiling main(). + * lang.c (java_decode_option): Handle -fextdirs=. + * jcf.h (jcf_path_extdirs_arg): Declare new function. + * Make-lang.in: Compile jcf-path with version info for use in + identifying the appropriate libgcj.jar. + 2002-04-08 Tom Tromey For PR libgcj/5303: diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in index 935479a..e814a10 100644 --- a/gcc/java/Make-lang.in +++ b/gcc/java/Make-lang.in @@ -315,7 +315,8 @@ java/jcf-io.o: java/jcf-io.c $(CONFIG_H) $(SYSTEM_H) $(JAVA_TREE_H) # jcf-path.o needs a -D. java/jcf-path.o: java/jcf-path.c $(CONFIG_H) $(SYSTEM_H) java/jcf.h $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ - -DLIBGCJ_ZIP_FILE='"$(prefix)/share/libgcj.jar"' \ + -DLIBGCJ_ZIP_FILE='"$(prefix)/share/java/libgcj-$(version).jar"' \ + -DDEFAULT_TARGET_VERSION=\"$(version)\" \ $(srcdir)/java/jcf-path.c $(OUTPUT_OPTION) # Documentation diff --git a/gcc/java/gcj.texi b/gcc/java/gcj.texi index 1395b11..814c182 100644 --- a/gcc/java/gcj.texi +++ b/gcc/java/gcj.texi @@ -257,6 +257,10 @@ Deprecated synonym for @code{--classpath}. @item --bootclasspath=@var{path} Where to find the standard builtin classes, such as @code{java.lang.String}. +@item --extdirs=@var{path} +For each directory in the @var{path}, place the contents of that +directory at the end of the class path. + @item CLASSPATH This is an environment variable which holds a list of paths. @end table @@ -274,8 +278,13 @@ then its value is appended. Otherwise, the current directory (@code{"."}) is appended. @item -Finally, if @code{--bootclasspath} was specified, append its value. +If @code{--bootclasspath} was specified, append its value. Otherwise, append the built-in system directory, @file{libgcj.jar}. + +@item +Finaly, if @code{--extdirs} was specified, append the contents of the +specified directories at the end of the class path. Otherwise, append +the contents of the built-in extdirs at @code{$(prefix)/share/java/ext}. @end itemize The classfile built by @command{gcj} for the class @code{java.lang.Object} diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c index b88ca8c..4daaa2b 100644 --- a/gcc/java/gjavah.c +++ b/gcc/java/gjavah.c @@ -2104,23 +2104,25 @@ DEFUN(process_file, (jcf, out), #define OPT_classpath LONG_OPT (0) #define OPT_CLASSPATH OPT_classpath #define OPT_bootclasspath LONG_OPT (1) -#define OPT_HELP LONG_OPT (2) -#define OPT_TEMP LONG_OPT (3) -#define OPT_VERSION LONG_OPT (4) -#define OPT_PREPEND LONG_OPT (5) -#define OPT_FRIEND LONG_OPT (6) -#define OPT_ADD LONG_OPT (7) -#define OPT_APPEND LONG_OPT (8) -#define OPT_M LONG_OPT (9) -#define OPT_MM LONG_OPT (10) -#define OPT_MG LONG_OPT (11) -#define OPT_MD LONG_OPT (12) -#define OPT_MMD LONG_OPT (13) +#define OPT_extdirs LONG_OPT (2) +#define OPT_HELP LONG_OPT (3) +#define OPT_TEMP LONG_OPT (4) +#define OPT_VERSION LONG_OPT (5) +#define OPT_PREPEND LONG_OPT (6) +#define OPT_FRIEND LONG_OPT (7) +#define OPT_ADD LONG_OPT (8) +#define OPT_APPEND LONG_OPT (9) +#define OPT_M LONG_OPT (10) +#define OPT_MM LONG_OPT (11) +#define OPT_MG LONG_OPT (12) +#define OPT_MD LONG_OPT (13) +#define OPT_MMD LONG_OPT (14) static const struct option options[] = { { "classpath", required_argument, NULL, OPT_classpath }, { "bootclasspath", required_argument, NULL, OPT_bootclasspath }, + { "extdirs", required_argument, NULL, OPT_extdirs }, { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, { "help", no_argument, NULL, OPT_HELP }, { "stubs", no_argument, &stubs, 1 }, @@ -2163,6 +2165,7 @@ help () printf (" --classpath PATH Set path to find .class files\n"); printf (" -IDIR Append directory to class path\n"); printf (" --bootclasspath PATH Override built-in class path\n"); + printf (" --extdirs PATH Set extensions directory path\n"); printf (" -d DIRECTORY Set output directory name\n"); printf (" -o FILE Set output file name\n"); printf (" -td DIRECTORY Set temporary directory name\n"); @@ -2246,6 +2249,10 @@ DEFUN(main, (argc, argv), jcf_path_bootclasspath_arg (optarg); break; + case OPT_extdirs: + jcf_path_extdirs_arg (optarg); + break; + case OPT_HELP: help (); break; diff --git a/gcc/java/jcf-dump.c b/gcc/java/jcf-dump.c index cf063ac..8c4052d 100644 --- a/gcc/java/jcf-dump.c +++ b/gcc/java/jcf-dump.c @@ -776,14 +776,16 @@ DEFUN(process_class, (jcf), #define OPT_classpath LONG_OPT (0) #define OPT_CLASSPATH OPT_classpath #define OPT_bootclasspath LONG_OPT (1) -#define OPT_HELP LONG_OPT (2) -#define OPT_VERSION LONG_OPT (3) -#define OPT_JAVAP LONG_OPT (4) +#define OPT_extdirs LONG_OPT (2) +#define OPT_HELP LONG_OPT (3) +#define OPT_VERSION LONG_OPT (4) +#define OPT_JAVAP LONG_OPT (5) static const struct option options[] = { { "classpath", required_argument, NULL, OPT_classpath }, { "bootclasspath", required_argument, NULL, OPT_bootclasspath }, + { "extdirs", required_argument, NULL, OPT_extdirs }, { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH }, { "help", no_argument, NULL, OPT_HELP }, { "verbose", no_argument, NULL, 'v' }, @@ -811,6 +813,7 @@ help () printf (" --classpath PATH Set path to find .class files\n"); printf (" -IDIR Append directory to class path\n"); printf (" --bootclasspath PATH Override built-in class path\n"); + printf (" --extdirs PATH Set extensions directory path\n"); printf (" -o FILE Set output file name\n"); printf ("\n"); printf (" --help Print this help, then exit\n"); @@ -881,6 +884,10 @@ DEFUN(main, (argc, argv), jcf_path_bootclasspath_arg (optarg); break; + case OPT_extdirs: + jcf_path_extdirs_arg (optarg); + break; + case OPT_HELP: help (); break; 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 + #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) { diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h index ea09639..c683e2b 100644 --- a/gcc/java/jcf.h +++ b/gcc/java/jcf.h @@ -273,6 +273,7 @@ extern void jcf_dependency_print_dummies PARAMS ((void)); extern void jcf_path_init PARAMS ((void)); extern void jcf_path_classpath_arg PARAMS ((const char *)); extern void jcf_path_bootclasspath_arg PARAMS ((const char *)); +extern void jcf_path_extdirs_arg PARAMS ((const char *)); extern void jcf_path_include_arg PARAMS ((const char *)); extern void jcf_path_seal PARAMS ((int)); extern void *jcf_path_start PARAMS ((void)); diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c index 58aa1c6..74ca9d4 100644 --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c @@ -68,6 +68,7 @@ static const char jvgenmain_spec[] = %{