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