Skip to content

Commit 66d35a5

Browse files
committed
Handle missing files.
Any .java file that isn't in our source directory must be in a different source directory and shoule be ignored. Example: src and test directories used to separate unit tests from source code. This isn't an elegant solution, but it fixes my problem. It won't work correctly if you want your unit tests to recompile when your source code has changed.
1 parent 0e99e6a commit 66d35a5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

jdep.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
Written by Chip Morningstar.
2525
*/
2626

27+
#include <unistd.h>
2728
#include <stdio.h>
2829
#include <stdlib.h>
2930
#include <string.h>
@@ -153,6 +154,7 @@ analyzeClassFile(char *name)
153154
{
154155
FILE *outfyle;
155156
char outfilename[1000];
157+
char depfilename[1000];
156158
char *deps[10000];
157159
int depCount;
158160
int i;
@@ -181,7 +183,10 @@ analyzeClassFile(char *name)
181183
fprintf(outfyle, "%s%s.class: \\\n", ClassRoot, name);
182184
for (i = 0; i < depCount; ++i) {
183185
if (index(deps[i], '$') == NULL) {
184-
fprintf(outfyle, " %s%s.java\\\n", JavaRoot, deps[i]);
186+
snprintf(depfilename, sizeof(depfilename), "%s%s.java", JavaRoot, deps[i]);
187+
if (access(depfilename, F_OK) != -1) {
188+
fprintf(outfyle, " %s%s.java\\\n", JavaRoot, deps[i]);
189+
}
185190
}
186191
}
187192
fprintf(outfyle, "\n");

0 commit comments

Comments
 (0)