Added some code for dependency generator
This commit is contained in:
parent
94b3467079
commit
ae3e9716f5
8 changed files with 84 additions and 6 deletions
|
@ -62,7 +62,7 @@ GSRC = char.c symbol2str.c
|
|||
GHSRC = errout.h idfsize.h ifdepth.h lapbuf.h \
|
||||
nparams.h numsize.h obufsize.h \
|
||||
parbufsize.h pathlength.h strsize.h textsize.h \
|
||||
botch_free.h debug.h inputtype.h dobits.h line_prefix.h
|
||||
botch_free.h debug.h inputtype.h dobits.h line_prefix.h mkdep.h
|
||||
|
||||
# Other generated files, for 'make clean' only
|
||||
GENERATED = tokenfile.g Lpars.h LLfiles LL.output lint.out \
|
||||
|
@ -172,6 +172,7 @@ domacro.o: input.h
|
|||
domacro.o: inputtype.h
|
||||
domacro.o: interface.h
|
||||
domacro.o: macro.h
|
||||
domacro.o: mkdep.h
|
||||
domacro.o: nparams.h
|
||||
domacro.o: parbufsize.h
|
||||
domacro.o: textsize.h
|
||||
|
@ -188,7 +189,10 @@ input.o: file_info.h
|
|||
input.o: input.h
|
||||
input.o: inputtype.h
|
||||
main.o: file_info.h
|
||||
main.o: idf.h
|
||||
main.o: idfsize.h
|
||||
main.o: macro.h
|
||||
main.o: mkdep.h
|
||||
options.o: charoffset.h
|
||||
options.o: class.h
|
||||
options.o: idf.h
|
||||
|
@ -205,6 +209,7 @@ preprocess.o: idfsize.h
|
|||
preprocess.o: input.h
|
||||
preprocess.o: inputtype.h
|
||||
preprocess.o: line_prefix.h
|
||||
preprocess.o: mkdep.h
|
||||
preprocess.o: obufsize.h
|
||||
replace.o: LLlex.h
|
||||
replace.o: charoffset.h
|
||||
|
|
|
@ -66,3 +66,12 @@
|
|||
#define LINE_PREFIX "#" /* prefix for generated line directives,
|
||||
either "#" or "#line"
|
||||
*/
|
||||
|
||||
|
||||
!File: mkdep.h
|
||||
#undef MKDEP 1 /* if defined, preprocessor only outputs
|
||||
names of files included (not finished yet)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "class.h"
|
||||
#include "macro.h"
|
||||
#include "bits.h"
|
||||
#include "mkdep.h"
|
||||
|
||||
IMPORT char **inctable; /* list of include directories */
|
||||
IMPORT char *getwdir();
|
||||
|
@ -273,9 +274,17 @@ do_include()
|
|||
inctable[0] = WorkingDir;
|
||||
if (filenm) {
|
||||
if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){
|
||||
#ifndef MKDEP
|
||||
error("cannot find include file \"%s\"", filenm);
|
||||
#else
|
||||
warning("cannot find include file \"%s\"", filenm);
|
||||
add_file(filenm);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#ifdef MKDEP
|
||||
add_file(result);
|
||||
#endif
|
||||
WorkingDir = getwdir(result);
|
||||
svnestlevel[++nestcount] = nestlevel;
|
||||
FileName = result;
|
||||
|
|
|
@ -4,13 +4,17 @@
|
|||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
struct id_usr {
|
||||
struct macro *idu_macro;
|
||||
union {
|
||||
struct macro *idu_macro;
|
||||
struct idf *idu_file;
|
||||
} idu_x;
|
||||
int idu_resmac;
|
||||
};
|
||||
|
||||
#define IDF_TYPE struct id_usr
|
||||
#define IDF_HSIZE 6
|
||||
#define id_macro id_user.idu_macro
|
||||
#define id_macro id_user.idu_x.idu_macro
|
||||
#define id_file id_user.idu_x.idu_file
|
||||
#define id_resmac id_user.idu_resmac
|
||||
|
||||
#include <idf_pkg.spec>
|
||||
|
|
|
@ -75,3 +75,4 @@ extern char *std_alloc();
|
|||
#define K_LINE 9
|
||||
#define K_UNDEF 10
|
||||
#define K_PRAGMA 11
|
||||
#define K_FILE 100 /* for dependency generator */
|
||||
|
|
|
@ -7,13 +7,20 @@
|
|||
|
||||
#include <alloc.h>
|
||||
#include <em_arith.h>
|
||||
#include <assert.h>
|
||||
#include "file_info.h"
|
||||
#include "idfsize.h"
|
||||
#include "mkdep.h"
|
||||
#ifdef MKDEP
|
||||
#include "idf.h"
|
||||
#include "macro.h"
|
||||
#endif
|
||||
|
||||
extern char *symbol2str();
|
||||
extern char *getwdir();
|
||||
extern int err_occurred;
|
||||
int idfsize = IDFSIZE;
|
||||
extern char options[];
|
||||
|
||||
arith ifval;
|
||||
|
||||
|
@ -49,6 +56,9 @@ main(argc, argv)
|
|||
do_option(par);
|
||||
argc--, argv++;
|
||||
}
|
||||
#ifdef MKDEP
|
||||
options['P'] = 1;
|
||||
#endif
|
||||
compile(argc - 1, &argv[1]);
|
||||
exit(err_occurred);
|
||||
}
|
||||
|
@ -79,4 +89,34 @@ compile(argc, argv)
|
|||
source ? source : "stdin");
|
||||
if (source) WorkingDir = getwdir(dummy);
|
||||
preprocess(source);
|
||||
#ifdef MKDEP
|
||||
list_files();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MKDEP
|
||||
struct idf *file_head;
|
||||
|
||||
list_files()
|
||||
{
|
||||
register struct idf *p = file_head;
|
||||
|
||||
while (p) {
|
||||
assert(p->id_resmac == K_FILE);
|
||||
print("%s\n", p->id_text);
|
||||
p = p->id_file;
|
||||
}
|
||||
}
|
||||
|
||||
add_file(s)
|
||||
char *s;
|
||||
{
|
||||
register struct idf *p = str2idf(s, 0);
|
||||
|
||||
if (! p->id_resmac) {
|
||||
p->id_resmac = K_FILE;
|
||||
p->id_file = file_head;
|
||||
file_head = p;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -14,31 +14,42 @@
|
|||
#include "idfsize.h"
|
||||
#include "bits.h"
|
||||
#include "line_prefix.h"
|
||||
|
||||
char _obuf[OBUFSIZE];
|
||||
#include "mkdep.h"
|
||||
|
||||
#ifdef DOBITS
|
||||
char bits[128];
|
||||
#endif
|
||||
|
||||
#ifndef MKDEP
|
||||
char _obuf[OBUFSIZE];
|
||||
|
||||
Xflush()
|
||||
{
|
||||
sys_write(STDOUT, _obuf, OBUFSIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
preprocess(fn)
|
||||
char *fn;
|
||||
{
|
||||
register int c;
|
||||
#ifndef MKDEP
|
||||
register char *op = _obuf;
|
||||
register char *ob = &_obuf[OBUFSIZE];
|
||||
#endif
|
||||
char Xbuf[256];
|
||||
int lineno = 0;
|
||||
extern char options[];
|
||||
|
||||
#ifndef MKDEP
|
||||
#define flush(X) (sys_write(STDOUT,_obuf,X))
|
||||
#define echo(ch) if (op == ob) { Xflush(); op = _obuf; } *op++ = (ch);
|
||||
#define newline() echo('\n')
|
||||
#else
|
||||
#define flush(X)
|
||||
#define echo(ch) (ch)
|
||||
#define newline()
|
||||
#endif
|
||||
|
||||
if (! options['P']) {
|
||||
/* Generate a line directive communicating the
|
||||
|
|
|
@ -78,7 +78,6 @@ replace(idef)
|
|||
struct idf *param;
|
||||
char *nam;
|
||||
extern char *GetIdentifier();
|
||||
extern struct idf *str2idf();
|
||||
|
||||
UnknownIdIsZero = 0;
|
||||
nam = GetIdentifier();
|
||||
|
|
Loading…
Reference in a new issue