Add -R option to print runtime paths (for now, includedir only)

This allows for, e.g., a Makefile to find the location of vpi_user.h in a portable manner. Similar to pkgconfig.
This commit is contained in:
Jevin Sweval 2022-07-02 18:05:12 -07:00
parent c7cb13d302
commit 5a90b7857a
4 changed files with 20 additions and 4 deletions

View File

@ -242,6 +242,11 @@ These flags affect the general behavior of the compiler.
version information, including version details for the various components of
the compiler.
* -R
Print the runtime paths of the compiler. This can be useful to find, e.g.,
the include path of vpi_user.h.
* -W<warning class>
Enable/disable warnings. All the warning types (other then "all") can be

View File

@ -95,7 +95,7 @@ cfparse%c cfparse%h: $(srcdir)/cfparse%y
mv $*.d dep
main.o: main.c globals.h $(srcdir)/../version_base.h ../version_tag.h Makefile
$(CC) $(CPPFLAGS) $(CFLAGS) @DEPENDENCY_FLAG@ -c -DIVL_ROOT='"@libdir@/ivl$(suffix)"' -DIVL_SUFFIX='"$(suffix)"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DDLLIB='"@DLLIB@"' $(srcdir)/main.c
$(CC) $(CPPFLAGS) $(CFLAGS) @DEPENDENCY_FLAG@ -c -DIVL_ROOT='"@libdir@/ivl$(suffix)"' -DIVL_SUFFIX='"$(suffix)"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DDLLIB='"@DLLIB@"' -DIVL_INCLUDE_INSTALL_DIR="\"$(realpath $(DESTDIR)/$(includedir))\"" $(srcdir)/main.c
mv $*.d dep
cflexor.o: cflexor.c cfparse.h

View File

@ -4,7 +4,7 @@ iverilog - Icarus Verilog compiler
.SH SYNOPSIS
.B iverilog
[\-EiSuVv] [\-Bpath] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]]
[\-EiRSuVv] [\-Bpath] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]]
[\-Pparameter=value] [\-pflag=value] [\-dname]
[\-g1995\:|\-g2001\:|\-g2005\:|\-g2005-sv\:|\-g2009\:|\-g2012\:|\-g<feature>]
[\-Iincludedir] [\-Lmoduledir] [\-mmodule] [\-M[mode=]file] [\-Nfile]
@ -271,6 +271,9 @@ indirectly execute the compiler output file.
.B -V
Print the version of the compiler, and exit.
.TP 8
.B -R
Print the runtime paths of the compiler, and exit.
.TP 8
.B -W\fIclass\fP
Turn on different classes of warnings. See the \fBWARNING TYPES\fP
section below for descriptions of the different warning groups. If

View File

@ -38,7 +38,7 @@ const char NOTICE[] =
;
const char HELP[] =
"Usage: iverilog [-EiSuvV] [-B base] [-c cmdfile|-f cmdfile]\n"
"Usage: iverilog [-EiRSuvV] [-B base] [-c cmdfile|-f cmdfile]\n"
" [-g1995|-g2001|-g2005|-g2005-sv|-g2009|-g2012] [-g<feature>]\n"
" [-D macro[=defn]] [-I includedir] [-L moduledir]\n"
" [-M [mode=]depfile] [-m module]\n"
@ -1088,6 +1088,10 @@ static void find_ivl_root(void)
strcat(ivl_root, ivl_lib_suffix);
}
static void print_runtime_paths(void) {
printf("includedir: %s\n", IVL_INCLUDE_INSTALL_DIR);
}
int main(int argc, char **argv)
{
int e_flag = 0;
@ -1157,7 +1161,7 @@ int main(int argc, char **argv)
}
}
while ((opt = getopt(argc, argv, "B:c:D:d:Ef:g:hl:I:iL:M:m:N:o:P:p:Ss:T:t:uvVW:y:Y:")) != EOF) {
while ((opt = getopt(argc, argv, "B:c:D:d:Ef:g:hl:I:iL:M:m:N:o:P:p:RSs:T:t:uvVW:y:Y:")) != EOF) {
switch (opt) {
case 'B':
@ -1244,6 +1248,10 @@ int main(int argc, char **argv)
opath = optarg;
break;
case 'R':
print_runtime_paths();
return 0;
case 'S':
synth_flag = 1;
break;