Version and ebug options.

This commit is contained in:
steve 1999-12-30 04:59:39 +00:00
parent b6d1bb1fa7
commit b7409d98ff
1 changed files with 72 additions and 87 deletions

View File

@ -30,8 +30,8 @@
# define INCLUDEDIR "/usr/local/include" # define INCLUDEDIR "/usr/local/include"
#endif #endif
#define REMOVE "rm -f" const char VERSION[] = "$Name: $ $State: Exp $";
#define MOVE "mv"
#define P_IF_SET(var) var.set ? var.name : "" #define P_IF_SET(var) var.set ? var.name : ""
@ -85,8 +85,9 @@ struct compileinfo {
int pform; int pform;
int execute; int execute;
int elabnetlist; int elabnetlist;
int debug;
}; };
struct compileinfo compileinfo = {0, 0, 0}; struct compileinfo compileinfo = {0, 0, 0, 0};
void sorry(char optelem) void sorry(char optelem)
@ -145,17 +146,16 @@ void preprocess(void)
P_IF_SET(ivlppincdir), P_IF_SET(ivlppincdir),
tmpPPfile, tmpPPfile,
verilogfiles); verilogfiles);
#if DEBUG if (compileinfo.debug) {
printf("Executing command : \n%s\n", argument); printf("Executing command : \n%s\n", argument);
#else } else {
if (system(argument)) { if (system(argument)) {
fprintf(stderr, "Preprocessing failed. Terminating compilation\n"); fprintf(stderr, "Preprocessing failed. Terminating compilation\n");
sprintf(argument, "%s %s", REMOVE, tmpPPfile); unlink(tmpPPfile);
system(argument);
free(argument); free(argument);
exit(1); exit(1);
} }
#endif }
free(argument); free(argument);
return; return;
@ -168,33 +168,28 @@ void compile(void)
argument = (char *)malloc(256); argument = (char *)malloc(256);
sprintf(argument, "ivl %s %s %s -o %s %s", /* VPI_MODULE_PATH should be better integrated. */
/* HACK */
sprintf(argument, "ivl %s %s %s %sVPI_MODULE_PATH=%s -o %s %s",
P_IF_SET(topmodule), P_IF_SET(topmodule),
target.targetinfo.compsw, target.targetinfo.compsw, target.targetinfo.name,
target.targetinfo.name, VPImodpath.compsw, VPImodpath.name,
/* compileinfo.pform ? "-P whatever_pform" : "", /* compileinfo.pform ? "-P whatever_pform" : "",
compileinfo.elabnetlist ? "-E whatever_netlist" : "", */ compileinfo.elabnetlist ? "-E whatever_netlist" : "", */
tmpCCfile, tmpCCfile,
tmpPPfile); tmpPPfile);
#if DEBUG if (compileinfo.debug) {
printf("Executing command : \n%s\n", argument); printf("Executing command : \n%s\n", argument);
#else printf("Removing file %s\n", tmpPPfile);
} else {
if (system(argument)) { if (system(argument)) {
fprintf(stderr, "Compilation failed. Terminating compilation\n"); fprintf(stderr, "Compilation failed. Terminating compilation\n");
sprintf(argument, "%s %s", REMOVE, tmpCCfile); unlink(tmpCCfile);
system(argument);
free(argument); free(argument);
exit(1); exit(1);
} }
#endif unlink(tmpPPfile);
}
sprintf(argument, "%s %s", REMOVE, tmpPPfile);
#if DEBUG
printf("Executing command:\n %s\n", argument);
#else
system(argument);
#endif
free(argument); free(argument);
return; return;
@ -216,44 +211,32 @@ void postprocess(void)
cpplibdir.compsw, cpplibdir.name, /* Library dir */ cpplibdir.compsw, cpplibdir.name, /* Library dir */
tmpCCfile, tmpCCfile,
outputfile.name); outputfile.name);
#if DEBUG if (compileinfo.debug) {
printf("Executing command :\n%s\n", argument); printf("Executing command :\n%s\n", argument);
#else } else {
if (system(argument)) { if (system(argument)) {
fprintf(stderr, "g++ compilation failed. Terminating compilation\n"); fprintf(stderr, "g++ compilation failed. Terminating compilation\n");
sprintf(argument, "%s %s", REMOVE, tmpCCfile); unlink(tmpCCfile);
system(argument);
free(argument); free(argument);
exit(1); exit(1);
} }
#endif }
unlink(tmpCCfile);
sprintf(argument, "%s %s", REMOVE, tmpCCfile);
#if DEBUG
printf("Executing command :\n%s\n", argument);
#else
system(argument);
#endif
break; break;
case XNF: /* Just move file as is */ case XNF: /* Just move file as is */
sprintf(argument, "%s %s %s.xnf", MOVE, tmpCCfile, outputfile.name); if (compileinfo.debug) {
#if DEBUG printf("Moving file %s to %s\n", tmpCCfile, outputfile.name);
printf("Executing command :\n%s\n", argument); } else {
#else rename(tmpCCfile, outputfile.name);
system(argument); }
#endif
break; break;
case OTHER: /* Just move file as is */ case OTHER: /* Just move file as is */
sprintf(argument, "mv %s %s.%s", sprintf(outputfile.name, "%s.%s", outputfile.name, target.targetinfo.name);
tmpCCfile, if (compileinfo.debug) {
outputfile.name, printf("Moving file %s to %s\n", tmpCCfile, outputfile.name);
target.targetinfo.name); } else {
#if DEBUG rename(tmpCCfile, outputfile.name);
printf("Executing command :\n%s\n", argument); }
#else
system(argument);
#endif
break; break;
default: default:
fprintf(stderr, "Illegal target. This should never happen.\n"); fprintf(stderr, "Illegal target. This should never happen.\n");
@ -261,11 +244,11 @@ void postprocess(void)
} }
if (compileinfo.execute) { if (compileinfo.execute) {
#if DEBUG if (compileinfo.debug) {
printf("Executing command :\n%s\n", outputfile.name); printf("Executing command :\n%s\n", outputfile.name);
#else } else {
system(outputfile.name); system(outputfile.name);
#endif }
} }
@ -275,19 +258,13 @@ void postprocess(void)
void main(int argc, char **argv) int main(int argc, char **argv)
{ {
const char optstring[] = "D:I:Xxf:o:s:t:EP"; const char optstring[] = "D:I:Xxf:o:s:t:EPvd";
int optelem = 0; int optelem = 0;
while ((optelem = getopt(argc, argv, optstring)) != EOF) { while ((optelem = getopt(argc, argv, optstring)) != EOF) {
/*#if DEBUG
if (optarg == NULL)
printf("Option element %c\n", (char)optelem);
else
printf("Option element %c %s\n", (char)optelem, optarg);
#endif*/
switch ((char)optelem) { switch ((char)optelem) {
case 'D': /* defines */ case 'D': /* defines */
@ -347,8 +324,19 @@ void main(int argc, char **argv)
case 'P': /* dump pform */ case 'P': /* dump pform */
compileinfo.pform = 1; compileinfo.pform = 1;
break; break;
case 'v':
printf("gverilog version %s\n", VERSION);
system("ivlpp -v");
printf("*****\n");
system("ivl -v");
printf("*****\n");
system("g++ -v");
return(0);
case 'd':
compileinfo.debug = 1;
break;
case '?': case '?':
fprintf(stderr, "Not defined commandswitch\n", argv[optind]); fprintf(stderr, "Not defined commandswitch %s\n", argv[optind]);
error_exit(); error_exit();
default: default:
fprintf(stderr, "Not handled commandswitch %s\n", argv[optind]); fprintf(stderr, "Not handled commandswitch %s\n", argv[optind]);
@ -365,9 +353,6 @@ void main(int argc, char **argv)
/* Resolve temporary file storage */ /* Resolve temporary file storage */
sprintf(tmpPPfile, "/tmp/ivl%d.pp", (int)getpid()); sprintf(tmpPPfile, "/tmp/ivl%d.pp", (int)getpid());
sprintf(tmpCCfile, "/tmp/ivl%d.cc", (int)getpid()); sprintf(tmpCCfile, "/tmp/ivl%d.cc", (int)getpid());
/*#if DEBUG
printf("Temporary files are %s and %s\n", tmpPPfile, tmpCCfile);
#endif */
/* Build list of verilog files */ /* Build list of verilog files */
for(; optind != argc; optind++) { for(; optind != argc; optind++) {
@ -386,5 +371,5 @@ void main(int argc, char **argv)
postprocess(); postprocess();
return; return(0);
} }