Patch: gcj extensions directory support
Anthony Green
green@redhat.com
Mon Apr 8 11:12:00 GMT 2002
This patch does the following...
- libgcj.jar is now installed as $(prefix)/share/java/libgcj-VERSION.jar
where VERSION is the version number of the compiler.
- gcj now has an --extdirs flag for specifiying a list of directories.
The contents of this directory are placed at the very tail end of the
class path.
- $(prefix)/share/java/ext is the default extensions directory. --extdirs
overrides this.
There is a corresponding libjava patch to install libgcj.jar in the new location.
Tested on x86 Linux. Discussed in the java list. Ok for trunk and branch?
Thanks,
AG
2002-04-08 Anthony Green <green@redhat.com>
* 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.
Index: Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Make-lang.in,v
retrieving revision 1.80
diff -c -r1.80 Make-lang.in
*** Make-lang.in 22 Jan 2002 20:23:45 -0000 1.80
--- Make-lang.in 7 Apr 2002 19:30:06 -0000
***************
*** 309,315 ****
# 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"' \
$(srcdir)/java/jcf-path.c $(OUTPUT_OPTION)
# Documentation
--- 309,316 ----
# 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/java/libgcj-$(version).jar"' \
! -DDEFAULT_TARGET_VERSION=\"$(version)\" \
$(srcdir)/java/jcf-path.c $(OUTPUT_OPTION)
# Documentation
Index: gcj.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gcj.texi,v
retrieving revision 1.22.2.3
diff -c -r1.22.2.3 gcj.texi
*** gcj.texi 5 Apr 2002 12:20:03 -0000 1.22.2.3
--- gcj.texi 7 Apr 2002 19:30:11 -0000
***************
*** 251,256 ****
--- 251,260 ----
@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
***************
*** 268,276 ****
Otherwise, the current directory (@code{"."}) is appended.
@item
! Finally, if @code{--bootclasspath} was specified, append its value.
Otherwise, append the built-in system directory, @file{libgcj.jar}.
@end itemize
The classfile built by @command{gcj} for the class @code{java.lang.Object}
(and placed in @code{libgcj.jar}) contains a special zero length
--- 272,285 ----
Otherwise, the current directory (@code{"."}) is appended.
@item
! If @code{--bootclasspath} was specified, append its value.
Otherwise, append the built-in system directory, @file{libgcj.jar}.
@end itemize
+
+ @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}.
The classfile built by @command{gcj} for the class @code{java.lang.Object}
(and placed in @code{libgcj.jar}) contains a special zero length
Index: gjavah.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gjavah.c,v
retrieving revision 1.84.2.1
diff -c -r1.84.2.1 gjavah.c
*** gjavah.c 3 Mar 2002 08:38:37 -0000 1.84.2.1
--- gjavah.c 7 Apr 2002 19:30:16 -0000
***************
*** 2104,2126 ****
#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)
static const struct option options[] =
{
{ "classpath", required_argument, NULL, OPT_classpath },
{ "bootclasspath", required_argument, NULL, OPT_bootclasspath },
{ "CLASSPATH", required_argument, NULL, OPT_CLASSPATH },
{ "help", no_argument, NULL, OPT_HELP },
{ "stubs", no_argument, &stubs, 1 },
--- 2104,2128 ----
#define OPT_classpath LONG_OPT (0)
#define OPT_CLASSPATH OPT_classpath
#define OPT_bootclasspath LONG_OPT (1)
! #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,2168 ****
--- 2165,2171 ----
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");
***************
*** 2244,2249 ****
--- 2247,2256 ----
case OPT_bootclasspath:
jcf_path_bootclasspath_arg (optarg);
+ break;
+
+ case OPT_extdirs:
+ jcf_path_extdirs_arg (optarg);
break;
case OPT_HELP:
Index: jcf-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-dump.c,v
retrieving revision 1.42.2.1
diff -c -r1.42.2.1 jcf-dump.c
*** jcf-dump.c 3 Mar 2002 08:38:37 -0000 1.42.2.1
--- jcf-dump.c 7 Apr 2002 19:30:19 -0000
***************
*** 776,789 ****
#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)
static const struct option options[] =
{
{ "classpath", required_argument, NULL, OPT_classpath },
{ "bootclasspath", required_argument, NULL, OPT_bootclasspath },
{ "CLASSPATH", required_argument, NULL, OPT_CLASSPATH },
{ "help", no_argument, NULL, OPT_HELP },
{ "verbose", no_argument, NULL, 'v' },
--- 776,791 ----
#define OPT_classpath LONG_OPT (0)
#define OPT_CLASSPATH OPT_classpath
#define OPT_bootclasspath LONG_OPT (1)
! #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,816 ****
--- 813,819 ----
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");
***************
*** 879,884 ****
--- 882,891 ----
case OPT_bootclasspath:
jcf_path_bootclasspath_arg (optarg);
+ break;
+
+ case OPT_extdirs:
+ jcf_path_extdirs_arg (optarg);
break;
case OPT_HELP:
Index: jcf-path.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-path.c,v
retrieving revision 1.18.2.1
diff -c -r1.18.2.1 jcf-path.c
*** jcf-path.c 3 Mar 2002 08:38:37 -0000 1.18.2.1
--- jcf-path.c 7 Apr 2002 19:30:21 -0000
***************
*** 26,31 ****
--- 26,33 ----
#include "config.h"
#include "system.h"
+ #include <dirent.h>
+
#include "jcf.h"
/* Some boilerplate that really belongs in a header. */
***************
*** 74,79 ****
--- 76,82 ----
-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,97 ****
--- 95,103 ----
"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,250 ****
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
configurations: one where prefix and exec-prefix are the
same, and one where exec-prefix is `prefix/SOMETHING'. */
strcpy (try, cp);
--- 250,256 ----
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/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,266 ****
strcpy (try + len, "share");
strcat (try, sep);
! strcat (try, "libgcj.jar");
if (! stat (try, &stat_b))
{
add_entry (&sys_dirs, try, 1);
found = 1;
}
else
{
--- 262,281 ----
strcpy (try + len, "share");
strcat (try, sep);
! 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,278 ****
strcat (try, sep);
strcat (try, "share");
strcat (try, sep);
! strcat (try, "libgcj.jar");
if (! stat (try, &stat_b))
{
add_entry (&sys_dirs, try, 1);
found = 1;
}
}
}
--- 283,302 ----
strcat (try, sep);
strcat (try, "share");
strcat (try, sep);
! 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);
}
}
}
***************
*** 280,285 ****
--- 304,317 ----
{
/* Desperation: use the installed one. */
add_entry (&sys_dirs, LIBGCJ_ZIP_FILE, 1);
+ char *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,312 ****
--- 339,411 ----
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,353 ****
--- 446,454 ----
append_entry (&sealed, secondary);
append_entry (&sealed, sys_dirs);
+ append_entry (&sealed, extensions);
sys_dirs = NULL;
+ extensions = NULL;
if (print)
{
Index: jcf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf.h,v
retrieving revision 1.28.2.1
diff -c -r1.28.2.1 jcf.h
*** jcf.h 3 Mar 2002 08:38:37 -0000 1.28.2.1
--- jcf.h 7 Apr 2002 19:30:21 -0000
***************
*** 273,278 ****
--- 273,279 ----
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));
Index: jvspec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jvspec.c,v
retrieving revision 1.52.2.2
diff -c -r1.52.2.2 jvspec.c
*** jvspec.c 3 Mar 2002 08:38:37 -0000 1.52.2.2
--- jvspec.c 7 Apr 2002 19:30:21 -0000
***************
*** 68,73 ****
--- 68,74 ----
%{<findirect-dispatch} \
%{<fno-store-check} %{<foutput-class-dir}\
%{<fclasspath*} %{<fCLASSPATH*} %{<fbootclasspath*}\
+ %{<fextdirs*}\
%{<fuse-divide-subroutine} %{<fno-use-divide-subroutine}\
%{<fcheck-references} %{<fno-check-references}\
%{<ffilelist-file}\
Index: lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.85.2.2
diff -c -r1.85.2.2 lang.c
*** lang.c 3 Mar 2002 08:38:37 -0000 1.85.2.2
--- lang.c 7 Apr 2002 19:30:23 -0000
***************
*** 326,331 ****
--- 326,338 ----
return 1;
}
#undef CLARG
+ #define CLARG "-fextdirs="
+ if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
+ {
+ jcf_path_extdirs_arg (p + sizeof (CLARG) - 1);
+ return 1;
+ }
+ #undef CLARG
else if (strncmp (p, "-I", 2) == 0)
{
jcf_path_include_arg (p + 2);
More information about the Gcc-patches
mailing list