2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / gcc / java / jcf-depend.c
blobc93c73bf915fd79e86266910057cfd53584626d2
1 /* Functions for handling dependency tracking when reading .class files.
3 Copyright (C) 1998, 1999, 2000, 2001, 2003, 2006, 2007
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>.
22 Java and all Java-based marks are trademarks or registered trademarks
23 of Sun Microsystems, Inc. in the United States and other countries.
24 The Free Software Foundation is independent of Sun Microsystems, Inc. */
26 /* Written by Tom Tromey <tromey@cygnus.com>, October 1998. */
28 #include "config.h"
29 #include "system.h"
30 #include "coretypes.h"
31 #include "mkdeps.h"
33 #include <assert.h>
35 #include "jcf.h"
39 /* The dependency structure used for this invocation. */
40 struct deps *dependencies;
42 /* The output file, or NULL if we aren't doing dependency tracking. */
43 static FILE *dep_out = NULL;
45 /* Nonzero if system files should be added. */
46 static int system_files;
48 /* Nonzero if we are dumping out dummy dependencies. */
49 static int print_dummies;
53 /* Call this to reset the dependency module. This is required if
54 multiple dependency files are being generated from a single tool
55 invocation. FIXME: we should change our API or just completely use
56 the one in mkdeps.h. */
57 void
58 jcf_dependency_reset (void)
60 if (dep_out != NULL)
62 if (dep_out != stdout)
63 fclose (dep_out);
64 dep_out = NULL;
67 if (dependencies != NULL)
69 deps_free (dependencies);
70 dependencies = NULL;
74 void
75 jcf_dependency_set_target (const char *name)
77 /* We just handle this the same as an `add_target'. */
78 if (dependencies != NULL && name != NULL)
79 deps_add_target (dependencies, name, 1);
82 void
83 jcf_dependency_add_target (const char *name)
85 if (dependencies != NULL)
86 deps_add_target (dependencies, name, 1);
89 void
90 jcf_dependency_set_dep_file (const char *name)
92 assert (dep_out != stdout);
93 if (dep_out)
94 fclose (dep_out);
95 if (! strcmp (name, "-"))
96 dep_out = stdout;
97 else
98 dep_out = fopen (name, "w");
101 void
102 jcf_dependency_add_file (const char *filename ATTRIBUTE_UNUSED, int system_p)
104 if (! dependencies)
105 return;
107 /* Just omit system files. */
108 if (system_p && ! system_files)
109 return;
112 /* FIXME: Don't emit any dependencies. In many cases we'll just see
113 temporary files emitted by ecj... */
114 /* deps_add_dep (dependencies, filename); */
117 void
118 jcf_dependency_init (int system_p)
120 assert (! dependencies);
121 system_files = system_p;
122 dependencies = deps_init ();
125 void
126 jcf_dependency_print_dummies (void)
128 print_dummies = 1;
131 void
132 jcf_dependency_write (void)
134 if (! dep_out)
135 return;
137 assert (dependencies);
139 deps_write (dependencies, dep_out, 72);
140 if (print_dummies)
141 deps_phony_targets (dependencies, dep_out);
142 fflush (dep_out);