Commit 316a06a1 by Tom Tromey Committed by Tom Tromey

jvspec.c (lang_specific_driver): Recognize -MF and -MT.

	* jvspec.c (lang_specific_driver): Recognize -MF and -MT.
	* lang-specs.h: Added %{MA}, %{MF*}, %{MT*}.
	* lang-options.h: Added -MA, -MT, -MF..
	* lang.c (lang_decode_option): Recognize -MA, -MT, -MF.
	(DEPEND_TARGET_SET): New macro.
	(DEPEND_FILE_ALREADY_SET): Likewise.
	(init_parse): Handle new flags.
	* jcf.h (jcf_dependency_print_dummies): Declare.
	* Make-lang.in (s-java): Added mkdeps.o.
	* Makefile.in (BACKEND): Added mkdeps.o.
	(../gcjh$(exeext)): Added mkdeps.o.
	(../jcf-dump$(exeext)): Added mkdeps.o.
	* jcf-depend.c: Include mkdeps.h.
	(struct entry, dependencies, targets, MAX_OUTPUT_COLUMNS,
	add_entry): Removed.
	(jcf_dependency_reset): Rewrote.
	(dependencies): New global.
	(jcf_dependency_set_target): Rewrote.
	(jcf_dependency_add_target): Likewise.
	(jcf_dependency_add_file): Likewise.
	(munge): Removed.
	(print_ents): Removed.
	(jcf_dependency_write): Rewrote.
	(print_dummies): New global.
	(jcf_dependency_print_dummies): New function
	(jcf_dependency_write): Call deps_dummy_targets if required.

From-SVN: r36981
parent 3f568531
2000-10-16 Tom Tromey <tromey@cygnus.com>
* jvspec.c (lang_specific_driver): Recognize -MF and -MT.
* lang-specs.h: Added %{MA}, %{MF*}, %{MT*}.
* lang-options.h: Added -MA, -MT, -MF..
* lang.c (lang_decode_option): Recognize -MA, -MT, -MF.
(DEPEND_TARGET_SET): New macro.
(DEPEND_FILE_ALREADY_SET): Likewise.
(init_parse): Handle new flags.
* jcf.h (jcf_dependency_print_dummies): Declare.
* Make-lang.in (s-java): Added mkdeps.o.
* Makefile.in (BACKEND): Added mkdeps.o.
(../gcjh$(exeext)): Added mkdeps.o.
(../jcf-dump$(exeext)): Added mkdeps.o.
* jcf-depend.c: Include mkdeps.h.
(struct entry, dependencies, targets, MAX_OUTPUT_COLUMNS,
add_entry): Removed.
(jcf_dependency_reset): Rewrote.
(dependencies): New global.
(jcf_dependency_set_target): Rewrote.
(jcf_dependency_add_target): Likewise.
(jcf_dependency_add_file): Likewise.
(munge): Removed.
(print_ents): Removed.
(jcf_dependency_write): Rewrote.
(print_dummies): New global.
(jcf_dependency_print_dummies): New function
(jcf_dependency_write): Call deps_dummy_targets if required.
2000-10-12 Tom Tromey <tromey@cygnus.com>
* lex.c (java_new_lexer): Initialize new fields.
(java_read_char): Swap bytes if required.
* lex.h (java_lexer): New fields read_anything and byte_swap.
Made out_buffer unsigned.
2000-10-18 Alexandre Petit-Bianco <apbianco@cygnus.com>
* gjavah.c (add_class_decl): Removed unused variables `tname',
......
......@@ -141,7 +141,7 @@ JCF_DUMP_SOURCES = $(srcdir)/java/jcf-dump.c $(srcdir)/java/jcf-io.c \
jc1$(exeext) gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext): s-java
s-java: $(P) $(JAVA_SRCS) $(LIBDEPS) $(BACKEND) \
s-java: $(P) $(JAVA_SRCS) $(LIBDEPS) $(BACKEND) mkdeps.o \
$(GCJH_SOURCES) $(LIBDEPS) $(TREE_H) \
$(JV_SCAN_SOURCES) $(BACKEND) $(LIBDEPS) \
$(JCF_DUMP_SOURCES)
......
......@@ -181,7 +181,7 @@ JAVA_OBJS = parse.o class.o decl.o expr.o constants.o lang.o typeck.o \
JAVA_OBJS_LITE = parse-scan.o jv-scan.o
# Language-independent object files.
BACKEND = ../toplev.o ../libbackend.a
BACKEND = ../toplev.o ../mkdeps.o ../libbackend.a
compiler: ../jc1$(exeext) ../jv-scan$(exeext)
../jc1$(exeext): $(P) $(JAVA_OBJS) $(BACKEND) $(LIBDEPS)
......@@ -192,18 +192,20 @@ compiler: ../jc1$(exeext) ../jv-scan$(exeext)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JAVA_OBJS_LITE) ../version.o $(LIBS)
../jcf-dump$(exeext): jcf-dump.o jcf-io.o jcf-depend.o jcf-path.o \
zextract.o ../version.o $(LIBDEPS)
zextract.o ../version.o ../mkdeps.o $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ jcf-dump.o jcf-io.o \
jcf-depend.o jcf-path.o zextract.o ../errors.o ../version.o $(LIBS)
jcf-depend.o jcf-path.o zextract.o ../errors.o ../version.o \
../mkdeps.o $(LIBS)
# Dependencies here must be kept in sync with dependencies in Make-lang.in.
../jvgenmain$(exeext): jvgenmain.o mangle.o $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ jvgenmain.o mangle.o $(LIBS)
../gcjh$(exeext): gjavah.o jcf-io.o jcf-depend.o jcf-path.o \
zextract.o ../version.o $(LIBDEPS)
zextract.o ../version.o ../mkdeps.o $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ gjavah.o jcf-io.o \
jcf-depend.o jcf-path.o zextract.o ../errors.o ../version.o $(LIBS)
jcf-depend.o jcf-path.o zextract.o ../errors.o ../version.o \
../mkdeps.o $(LIBS)
Makefile: $(srcdir)/Makefile.in $(srcdir)/../configure
cd ..; $(SHELL) config.status
......
......@@ -25,6 +25,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "config.h"
#include "system.h"
#include "mkdeps.h"
#include <assert.h>
......@@ -32,27 +33,8 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
/* We keep a linked list of all the files we've already read. */
struct entry
{
char *file;
struct entry *next;
};
static void free_entry PARAMS ((struct entry **));
static void add_entry PARAMS ((struct entry **, const char *));
static const char *munge PARAMS ((const char *));
static int print_ents PARAMS ((struct entry *, int));
/* List of files. */
static struct entry *dependencies = NULL;
/* Name of targets. We support multiple targets when writing .class
files. */
static struct entry *targets = NULL;
/* Number of columns in output. */
#define MAX_OUTPUT_COLUMNS 72
/* The dependency structure used for this invocation. */
struct deps *dependencies;
/* The output file, or NULL if we aren't doing dependency tracking. */
static FILE *dep_out = NULL;
......@@ -60,81 +42,47 @@ static FILE *dep_out = NULL;
/* Nonzero if system files should be added. */
static int system_files;
/* Helper to free an entry list. */
static void
free_entry (entp)
struct entry **entp;
{
struct entry *ent, *next;
for (ent = *entp; ent != NULL; ent = next)
{
next = ent->next;
free (ent->file);
free (ent);
}
*entp = NULL;
}
/* Helper to add to the end of the entry list. */
static void
add_entry (entp, name)
struct entry **entp;
const char *name;
{
struct entry *ent, *last;
for (last = ent = *entp; ent != NULL; last = ent, ent = ent->next)
if (! strcmp (ent->file, name))
return;
ent = (struct entry *) xmalloc (sizeof (struct entry));
ent->file = xstrdup (name);
ent->next = NULL;
/* Nonzero if we are dumping out dummy dependencies. */
static int print_dummies;
if (last == NULL)
{
/* This is only true the first time through, when the entry list
is empty. */
*entp = ent;
}
else
last->next = ent;
}
/* Call this to reset the dependency module. This is required if
multiple dependency files are being generated from a single tool
invocation. */
invocation. FIXME: we should change our API or just completely use
the one in mkdeps.h. */
void
jcf_dependency_reset ()
{
free_entry (&dependencies);
free_entry (&targets);
if (dep_out != NULL)
{
if (dep_out != stdout)
fclose (dep_out);
dep_out = NULL;
}
if (dependencies != NULL)
{
deps_free (dependencies);
dependencies = NULL;
}
}
void
jcf_dependency_set_target (name)
const char *name;
{
free_entry (&targets);
if (name != NULL)
add_entry (&targets, name);
/* We just handle this the same as an `add_target'. */
if (dependencies != NULL && name != NULL)
deps_add_target (dependencies, name);
}
void
jcf_dependency_add_target (name)
const char *name;
{
add_entry (&targets, name);
if (dependencies != NULL)
deps_add_target (dependencies, name);
}
void
......@@ -155,122 +103,41 @@ jcf_dependency_add_file (filename, system_p)
const char *filename;
int system_p;
{
if (! dependencies)
return;
/* Just omit system files. */
if (system_p && ! system_files)
return;
add_entry (&dependencies, filename);
deps_add_dep (dependencies, filename);
}
void
jcf_dependency_init (system_p)
int system_p;
{
assert (! dependencies);
system_files = system_p;
dependencies = deps_init ();
}
/* FIXME: this is taken almost directly from cccp.c. Such duplication
is bad. */
static const char *
munge (filename)
const char *filename;
{
static char *buffer = NULL;
static int buflen = 0;
int len = 2 * strlen (filename) + 1;
const char *p;
char *dst;
if (buflen < len)
{
buflen = len;
buffer = xrealloc (buffer, buflen);
}
dst = buffer;
for (p = filename; *p; ++p)
{
switch (*p)
{
case ' ':
case '\t':
{
/* GNU make uses a weird quoting scheme for white space.
A space or tab preceded by 2N+1 backslashes represents
N backslashes followed by space; a space or tab
preceded by 2N backslashes represents N backslashes at
the end of a file name; and backslashes in other
contexts should not be doubled. */
const char *q;
for (q = p - 1; filename < q && q[-1] == '\\'; q--)
*dst++ = '\\';
}
*dst++ = '\\';
goto ordinary_char;
case '$':
*dst++ = '$';
/* Fall through. This can mishandle things like "$(" but
there's no easy fix. */
default:
ordinary_char:
/* This can mishandle characters in the string "\0\n%*?[\\~";
exactly which chars are mishandled depends on the `make' version.
We know of no portable solution for this;
even GNU make 3.76.1 doesn't solve the problem entirely.
(Also, '\0' is mishandled due to our calling conventions.) */
*dst++ = *p;
break;
}
}
*dst++ = '\0';
return buffer;
}
/* Helper to print list of files. */
static int
print_ents (ent, column)
struct entry *ent;
int column;
void
jcf_dependency_print_dummies ()
{
int first = 1;
for (; ent != NULL; ent = ent->next)
{
const char *depname = munge (ent->file);
int len = strlen (depname);
if (column + len + 2 > MAX_OUTPUT_COLUMNS)
{
fprintf (dep_out, " \\\n ");
column = 1;
}
if (! first)
fputs (" ", dep_out);
fputs (depname, dep_out);
first = 0;
column += len + 1;
}
return column;
print_dummies = 1;
}
void
jcf_dependency_write ()
{
int column = 0;
if (! dep_out)
return;
assert (targets);
column = print_ents (targets, 0);
fputs (" : ", dep_out);
assert (dependencies);
print_ents (dependencies, column);
fputs ("\n", dep_out);
deps_write (dependencies, dep_out, 72);
if (print_dummies)
deps_dummy_targets (dependencies, dep_out);
fflush (dep_out);
}
......@@ -264,6 +264,7 @@ extern void jcf_dependency_set_dep_file PARAMS ((const char *));
extern void jcf_dependency_add_file PARAMS ((const char *, int));
extern void jcf_dependency_write PARAMS ((void));
extern void jcf_dependency_init PARAMS ((int));
extern void jcf_dependency_print_dummies PARAMS ((void));
/* Declarations for path handling code. */
extern void jcf_path_init PARAMS ((void));
......
......@@ -262,9 +262,11 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
saw_g = 1;
else if (argv[i][1] == 'O')
saw_O = 1;
else if (((argv[i][2] == '\0'
&& (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
|| strcmp (argv[i], "-Tdata") == 0))
else if ((argv[i][2] == '\0'
&& (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
|| strcmp (argv[i], "-Tdata") == 0
|| strcmp (argv[i], "-MT") == 0
|| strcmp (argv[i], "-MF") == 0)
{
if (strcmp (argv[i], "-o") == 0)
saw_o = 1;
......
......@@ -41,6 +41,9 @@ DEFINE_LANG_NAME ("Java")
{ "-MMD", "Print dependencies to FILE.d" },
{ "-M", "Print dependencies to stdout" },
{ "-MM", "Print dependencies to stdout" },
{ "-MA", "Print dummy rules for included files" },
{ "-MF", "Print dependencies to FILE" },
{ "-MT", "Use TARGET as name of target in dependency file" },
#endif /* ! USE_CPPLIB */
{ "--classpath", "Set class path and suppress system path" },
{ "--CLASSPATH", "Set class path" },
......
......@@ -32,6 +32,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
{"@java",
"%{fjni:%{femit-class-files:%e-fjni and -femit-class-files are incompatible}}\
%{fjni:%{femit-class-file:%e-fjni and -femit-class-file are incompatible}}\
%{!E:jc1 %i %(jc1) %(cc1_options) %{+e*} %{I*} %{MD} %{MMD} %{M} %{MM}\
%{!E:jc1 %i %(jc1) %(cc1_options) %{+e*} %{I*}\
%{MD} %{MMD} %{M} %{MM} %{MA} %{MT*} %{MF*}\
%{!fsyntax-only:%(invoke_as)}}"},
......@@ -159,6 +159,8 @@ static int dependency_tracking = 0;
/* Flag values for DEPENDENCY_TRACKING. */
#define DEPEND_SET_FILE 1
#define DEPEND_ENABLE 2
#define DEPEND_TARGET_SET 4
#define DEPEND_FILE_ALREADY_SET 8
/*
* process java-specific compiler command-line options
......@@ -316,6 +318,23 @@ lang_decode_option (argc, argv)
dependency_tracking |= DEPEND_ENABLE;
return 1;
}
else if (strcmp (p, "-MA") == 0)
{
jcf_dependency_print_dummies ();
return 1;
}
else if (strcmp (p, "-MT") == 0)
{
jcf_dependency_set_target (argv[1]);
dependency_tracking |= DEPEND_TARGET_SET;
return 2;
}
else if (strcmp (p, "-MF") == 0)
{
jcf_dependency_set_dep_file (argv[1]);
dependency_tracking |= DEPEND_FILE_ALREADY_SET;
return 2;
}
return 0;
}
......@@ -342,36 +361,48 @@ init_parse (filename)
if (dependency_tracking)
{
char *dot;
dot = strrchr (filename, '.');
if (dot == NULL)
error ("couldn't determine target name for dependency tracking");
else
/* If the target is set and the output filename is set, then
there's no processing to do here. Otherwise we must
compute one or the other. */
if (! ((dependency_tracking & DEPEND_TARGET_SET)
&& (dependency_tracking & DEPEND_FILE_ALREADY_SET)))
{
char *buf = (char *) xmalloc (dot - filename +
3 + sizeof (OBJECT_SUFFIX));
strncpy (buf, filename, dot - filename);
/* If emitting class files, we might have multiple
targets. The class generation code takes care of
registering them. Otherwise we compute the target
name here. */
if (flag_emit_class_files)
jcf_dependency_set_target (NULL);
dot = strrchr (filename, '.');
if (dot == NULL)
error ("couldn't determine target name for dependency tracking");
else
{
strcpy (buf + (dot - filename), OBJECT_SUFFIX);
jcf_dependency_set_target (buf);
}
if ((dependency_tracking & DEPEND_SET_FILE))
{
strcpy (buf + (dot - filename), ".d");
jcf_dependency_set_dep_file (buf);
char *buf = (char *) xmalloc (dot - filename +
3 + sizeof (OBJECT_SUFFIX));
strncpy (buf, filename, dot - filename);
/* If emitting class files, we might have multiple
targets. The class generation code takes care of
registering them. Otherwise we compute the
target name here. */
if ((dependency_tracking & DEPEND_TARGET_SET))
; /* Nothing. */
else if (flag_emit_class_files)
jcf_dependency_set_target (NULL);
else
{
strcpy (buf + (dot - filename), OBJECT_SUFFIX);
jcf_dependency_set_target (buf);
}
if ((dependency_tracking & DEPEND_FILE_ALREADY_SET))
; /* Nothing. */
else if ((dependency_tracking & DEPEND_SET_FILE))
{
strcpy (buf + (dot - filename), ".d");
jcf_dependency_set_dep_file (buf);
}
else
jcf_dependency_set_dep_file ("-");
free (buf);
}
else
jcf_dependency_set_dep_file ("-");
free (buf);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment