From d44ff4fd917d850afecbb19d80b77e076c7ba2c7 Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 28 May 2002 02:25:03 +0000 Subject: [PATCH] Pass library paths through -Cfile instead of command line. --- driver/build_string.c | 21 +++------------- driver/main.c | 58 +++++++++++++++++-------------------------- iverilog.conf | 21 ++++++++-------- main.cc | 18 +++++++++++++- 4 files changed, 54 insertions(+), 64 deletions(-) diff --git a/driver/build_string.c b/driver/build_string.c index 98fb1048c..9bffc64be 100644 --- a/driver/build_string.c +++ b/driver/build_string.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: build_string.c,v 1.9 2002/05/28 00:50:39 steve Exp $" +#ident "$Id: build_string.c,v 1.10 2002/05/28 02:25:03 steve Exp $" #endif # include "config.h" @@ -150,22 +150,6 @@ int build_string(char*output, size_t olen, const char*pattern) olen -= strlen(warning_flags); break; - case 'y': - if (library_flags) { - strcpy(output, library_flags); - output += strlen(library_flags); - olen -= strlen(library_flags); - } - break; - - case 'Y': - if (library_flags2) { - strcpy(output, library_flags2); - output += strlen(library_flags2); - olen -= strlen(library_flags2); - } - break; - } pattern += 1; @@ -181,6 +165,9 @@ int build_string(char*output, size_t olen, const char*pattern) /* * $Log: build_string.c,v $ + * Revision 1.10 2002/05/28 02:25:03 steve + * Pass library paths through -Cfile instead of command line. + * * Revision 1.9 2002/05/28 00:50:39 steve * Add the ivl -C flag for bulk configuration * from the driver, and use that to run library diff --git a/driver/main.c b/driver/main.c index adc27d592..9f9382fa7 100644 --- a/driver/main.c +++ b/driver/main.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ident "$Id: main.c,v 1.39 2002/05/28 00:50:40 steve Exp $" +#ident "$Id: main.c,v 1.40 2002/05/28 02:25:03 steve Exp $" # include "config.h" @@ -92,8 +92,6 @@ const char*depfile = 0; const char*generation = "-g3.0"; char warning_flags[16] = ""; -char *library_flags = 0; -char *library_flags2 = 0; char*inc_list = 0; char*def_list = 0; @@ -304,28 +302,12 @@ static void process_warning_switch(const char*name) void process_library_switch(const char *name) { - if (library_flags) { - library_flags = realloc(library_flags, - strlen(library_flags) + strlen(name) + 5); - strcat(library_flags, " -y "); - } else { - library_flags = malloc(strlen(name) + 4); - strcpy(library_flags, "-y "); - } - strcat(library_flags, name); + fprintf(iconfig_file, "-y:%s\n", name); } void process_library2_switch(const char *name) { - if (library_flags2) { - library_flags2 = realloc(library_flags2, - strlen(library_flags2) + strlen(name) + 5); - strcat(library_flags2, " -Y "); - } else { - library_flags2 = malloc(strlen(name) + 4); - strcpy(library_flags2, "-Y "); - } - strcat(library_flags2, name); + fprintf(iconfig_file, "-Y:%s\n", name); } void process_include_dir(const char *name) @@ -447,6 +429,20 @@ int main(int argc, char **argv) return 1; } + /* Create another temporary file for passing configuration + information to ivl. */ + iconfig_path = strdup(tempnam(NULL, "ivrlh")); + assert(iconfig_path); + iconfig_file = fopen(iconfig_path, "w"); + if (NULL == iconfig_file) { + fprintf(stderr, "%s: Error opening temporary file %s\n", + argv[0], iconfig_path); + fprintf(stderr, "%s: Please check TMP or TMPDIR.\n", argv[0]); + fclose(source_file); + remove(source_path); + return 1; + } + while ((opt = getopt(argc, argv, "B:C:c:D:Ef:g:hI:M:m:N::o:p:Ss:T:t:vVW:y:Y:")) != EOF) { switch (opt) { @@ -682,6 +678,9 @@ int main(int argc, char **argv) rc = system(cmd); remove(source_path); + fclose(iconfig_file); + remove(iconfig_path); + if (rc != 0) { if (WIFEXITED(rc)) { fprintf(stderr, "errors preprocessing Verilog program.\n"); @@ -695,20 +694,6 @@ int main(int argc, char **argv) return 0; } - /* Create another temporary file for passing configuration - information to ivl. */ - iconfig_path = strdup(tempnam(NULL, "ivrlh")); - assert(iconfig_path); - iconfig_file = fopen(iconfig_path, "w"); - if (NULL == iconfig_file) { - fprintf(stderr, "%s: Error opening temporary file %s\n", - argv[0], iconfig_path); - fprintf(stderr, "%s: Please check TMP or TMPDIR.\n", argv[0]); - fclose(source_file); - remove(source_path); - return 1; - } - /* Write the preprocessor command needed to preprocess a single file. This may be used to preprocess library files. */ @@ -731,6 +716,9 @@ int main(int argc, char **argv) /* * $Log: main.c,v $ + * Revision 1.40 2002/05/28 02:25:03 steve + * Pass library paths through -Cfile instead of command line. + * * Revision 1.39 2002/05/28 00:50:40 steve * Add the ivl -C flag for bulk configuration * from the driver, and use that to run library diff --git a/iverilog.conf b/iverilog.conf index 212e6107e..695ea6760 100644 --- a/iverilog.conf +++ b/iverilog.conf @@ -28,6 +28,8 @@ # # %B Substitute the base libdir, -B flag of iverilog. # +# %C Substitute the path to the temporary config file. +# # %f Substitute the -f flags from the command line. # # %g Substitule the -g flag @@ -47,9 +49,6 @@ # # %W Substitute the ivl warning flags. # -# %y Substitute all the -y flags here. -# %Y Substitute all the -Y flags here. -# # %[] # This substitution pattern is magical, and is the only # multicharacter pattern. This tests the code , and @@ -63,20 +62,20 @@ # be useful and interesting if the -N flag is included. [-tnull -S] -%B/ivl %[v-v] -C%C %g %y %Y %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -Fsynth -Fsyn-rules -- - +%B/ivl %[v-v] -C%C %g %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -Fsynth -Fsyn-rules -- - [-tnull] -%B/ivl %[v-v] -C%C %g %y %Y %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -- - +%B/ivl %[v-v] -C%C %g %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -- - # -- # The vvp target generates code that the vvp simulation engine can execute. # These rules support synthesized and non-synthesized variants. [-tvvp -S] -%B/ivl %[v-v] -C%C %g %y %Y %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fsynth -Fsyn-rules -Fcprop -Fnodangle %f %m -o%o -- - +%B/ivl %[v-v] -C%C %g %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fsynth -Fsyn-rules -Fcprop -Fnodangle %f %m -o%o -- - [-tvvp] -%B/ivl %[v-v] -C%C %g %y %Y %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fcprop -Fnodangle %f %m -o%o -- - +%B/ivl %[v-v] -C%C %g %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fcprop -Fnodangle %f %m -o%o -- - # -- # The vvm target uses the string to take the preprocessed code from @@ -85,20 +84,20 @@ # on the result. [-tvvm] -%B/ivl %[v-v] -C%C %g %y %Y %W %s %[N-N%N] %[T-T%T] -tvvm -Fcprop -Fnodangle -fVPI_MODULE_PATH=%B %f %m -o%o.cc -- - +%B/ivl %[v-v] -C%C %g %W %s %[N-N%N] %[T-T%T] -tvvm -Fcprop -Fnodangle -fVPI_MODULE_PATH=%B %f %m -o%o.cc -- - # This is the XNF code generator. [-txnf] -%B/ivl -C%C %y %Y %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] -txnf -Fsynth -Fsyn-rules -Fxnfio -Fcprop -Fnodangle -o%o -- - +%B/ivl -C%C %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] -txnf -Fsynth -Fsyn-rules -Fxnfio -Fcprop -Fnodangle -o%o -- - # And this is another XNF code generator, under development. [-tfpga] -%B/ivl -C%C %y %Y %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/fpga.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - +%B/ivl -C%C %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/fpga.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - # -- # This is the pal code generator. The target module requires the -fpart= # flag to specify the part type. [-tpal] -%B/ivl -C%C %y %Y %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/pal.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - +%B/ivl -C%C %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/pal.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - diff --git a/main.cc b/main.cc index 33d43e231..465d7e5ae 100644 --- a/main.cc +++ b/main.cc @@ -19,7 +19,7 @@ const char COPYRIGHT[] = * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: main.cc,v 1.56 2002/05/28 00:50:39 steve Exp $" +#ident "$Id: main.cc,v 1.57 2002/05/28 02:25:03 steve Exp $" #endif # include "config.h" @@ -99,6 +99,12 @@ bool error_implicit = false; */ bool verbose_flag = false; +/* + * Read the contents of a config file. This file is a temporary + * configuration file made by the compiler driver to carry the bulky + * flags generated from the user. This reduces the size of the command + * line needed to invoke ivl + */ static void read_iconfig_file(const char*ipath) { char buf[8*1024]; @@ -130,6 +136,13 @@ static void read_iconfig_file(const char*ipath) if (strcmp(buf, "ivlpp") == 0) { ivlpp_string = strdup(cp); + + } else if (strcmp(buf, "-y") == 0) { + library_dirs.push_back(strdup(cp)); + + } else if (strcmp(buf, "-Y") == 0) { + library_suff.push_back(strdup(cp)); + } } } @@ -570,6 +583,9 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.57 2002/05/28 02:25:03 steve + * Pass library paths through -Cfile instead of command line. + * * Revision 1.56 2002/05/28 00:50:39 steve * Add the ivl -C flag for bulk configuration * from the driver, and use that to run library