From 5ed517551730424477547d7482829388789392ee Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 22 Jan 2023 11:03:31 +0000 Subject: [PATCH] Replace --make with --print-deps --- NEWS.md | 3 ++ lib/ieee.08/Makemodule.am | 2 +- lib/ieee.19/Makemodule.am | 2 +- lib/ieee/Makemodule.am | 2 +- lib/nvc.08/Makemodule.am | 2 +- lib/nvc.19/Makemodule.am | 2 +- lib/nvc/Makemodule.am | 2 +- lib/std.08/Makemodule.am | 2 +- lib/std.19/Makemodule.am | 2 +- lib/std/Makemodule.am | 2 +- lib/synopsys/Makemodule.am | 2 +- src/nvc.c | 76 +++++++++++++++++++++++++++++--------- src/option.c | 1 - src/option.h | 1 - test/regress/cmdline5.sh | 9 +++++ test/regress/testlist.txt | 1 + 16 files changed, 82 insertions(+), 29 deletions(-) create mode 100644 test/regress/cmdline5.sh diff --git a/NEWS.md b/NEWS.md index a9a4d315..e225dafd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -25,6 +25,9 @@ - `case .. generate` statements are now supported in VHDL-2008. - Coverage implementation was reworked and now collects statement, branch, expression and toggle metrics (from @Blebowski). +- The `--make` command is deprecated and will be repurposed in a later + release. Use the new `--print-deps` command instead to generate + Makefile dependencies. ## Version 1.7.2 - 2022-10-16 - Fixed build on FreeBSD/arm (#534). diff --git a/lib/ieee.08/Makemodule.am b/lib/ieee.08/Makemodule.am index 9f7d6b4b..fab6fbd5 100644 --- a/lib/ieee.08/Makemodule.am +++ b/lib/ieee.08/Makemodule.am @@ -130,7 +130,7 @@ lib/ieee.08/IEEE.IEEE_BIT_CONTEXT: $(srcdir)/lib/ieee.08/ieee_bit_context.vhdl @ $(nvc) --std=2008 -L lib/ --work=lib/ieee.08 -a $(srcdir)/lib/ieee.08/ieee_bit_context.vhdl gen-deps-ieee-08: - $(nvc) --std=2008 -L lib/ --work=lib/ieee.08 --make --posix --deps-only \ + $(nvc) --std=2008 -L lib/ --work=lib/ieee.08 --print-deps \ | $(deps_pp) > $(srcdir)/lib/ieee.08/deps.mk include lib/ieee.08/deps.mk diff --git a/lib/ieee.19/Makemodule.am b/lib/ieee.19/Makemodule.am index 2b540685..9f5c5249 100644 --- a/lib/ieee.19/Makemodule.am +++ b/lib/ieee.19/Makemodule.am @@ -108,7 +108,7 @@ lib/ieee.19/IEEE.IEEE_BIT_CONTEXT: $(srcdir)/lib/ieee.08/ieee_bit_context.vhdl @ $(nvc) --std=2019 -L lib/ --work=lib/ieee.19 -a $(srcdir)/lib/ieee.08/ieee_bit_context.vhdl gen-deps-ieee-19: - $(nvc) --std=2019 -L lib/ --work=lib/ieee.19 --make --posix --deps-only \ + $(nvc) --std=2019 -L lib/ --work=lib/ieee.19 --print-deps \ | $(deps_pp) > $(srcdir)/lib/ieee.19/deps.mk include lib/ieee.19/deps.mk diff --git a/lib/ieee/Makemodule.am b/lib/ieee/Makemodule.am index b97f3d56..0ae63cfd 100644 --- a/lib/ieee/Makemodule.am +++ b/lib/ieee/Makemodule.am @@ -64,7 +64,7 @@ lib/ieee/IEEE.MATH_COMPLEX-body: $(srcdir)/lib/ieee/math_complex-body.vhdl @ifGN $(nvc) -L lib/ --work=lib/ieee -a $(srcdir)/lib/ieee/math_complex-body.vhdl gen-deps-ieee: - $(nvc) -L lib/ --work=lib/ieee --make --posix --deps-only \ + $(nvc) -L lib/ --work=lib/ieee --print-deps \ | $(deps_pp) > $(srcdir)/lib/ieee/deps.mk include lib/ieee/deps.mk diff --git a/lib/nvc.08/Makemodule.am b/lib/nvc.08/Makemodule.am index 1bce25b3..3573e727 100644 --- a/lib/nvc.08/Makemodule.am +++ b/lib/nvc.08/Makemodule.am @@ -33,7 +33,7 @@ lib/nvc.08/NVC.IEEE_SUPPORT-body: $(srcdir)/lib/nvc.08/ieee_support-body.vhd @if $(nvc) --std=2008 -L lib/ --work=lib/nvc.08 -a $(srcdir)/lib/nvc.08/ieee_support-body.vhd gen-deps-nvc-08: - $(nvc) --std=2008 -L lib/ --work=lib/nvc.08 --make --posix --deps-only | \ + $(nvc) --std=2008 -L lib/ --work=lib/nvc.08 --print-deps | \ $(deps_pp) > $(srcdir)/lib/nvc.08/deps.mk include lib/nvc.08/deps.mk diff --git a/lib/nvc.19/Makemodule.am b/lib/nvc.19/Makemodule.am index 580e5403..586ee2ef 100644 --- a/lib/nvc.19/Makemodule.am +++ b/lib/nvc.19/Makemodule.am @@ -28,7 +28,7 @@ lib/nvc.19/NVC.IEEE_SUPPORT-body: $(srcdir)/lib/nvc.08/ieee_support-body.vhd @if $(nvc) --std=2019 -L lib/ --work=lib/nvc.19 -a $(srcdir)/lib/nvc.08/ieee_support-body.vhd gen-deps-nvc-19: - $(nvc) --std=2019 -L lib/ --work=lib/nvc.19 --make --posix --deps-only | \ + $(nvc) --std=2019 -L lib/ --work=lib/nvc.19 --print-deps | \ $(deps_pp) > $(srcdir)/lib/nvc.19/deps.mk include lib/nvc.19/deps.mk diff --git a/lib/nvc/Makemodule.am b/lib/nvc/Makemodule.am index c8fce24c..75109102 100644 --- a/lib/nvc/Makemodule.am +++ b/lib/nvc/Makemodule.am @@ -29,7 +29,7 @@ lib/nvc/NVC.POLYFILL-body: $(srcdir)/lib/nvc/polyfill-body.vhd @ifGNUmake@ | $(D $(nvc) -L lib/ --work=lib/nvc -a $(srcdir)/lib/nvc/polyfill-body.vhd gen-deps-nvc: - $(nvc) -L lib/ --work=lib/nvc --make --posix --deps-only | \ + $(nvc) -L lib/ --work=lib/nvc --print-deps | \ $(deps_pp) > $(srcdir)/lib/nvc/deps.mk include lib/nvc/deps.mk diff --git a/lib/std.08/Makemodule.am b/lib/std.08/Makemodule.am index 6335a15b..806254a8 100644 --- a/lib/std.08/Makemodule.am +++ b/lib/std.08/Makemodule.am @@ -39,7 +39,7 @@ lib/std.08/STD.ENV-body: $(srcdir)/lib/std.08/env-body.vhd @ifGNUmake@ | $(DRIVE $(nvc) --std=2008 -L lib/ --work=lib/std.08 -a $(srcdir)/lib/std.08/env-body.vhd gen-deps-std-08: - $(nvc) --std=2008 -L lib/ --work=lib/std.08 --make --posix --deps-only | \ + $(nvc) --std=2008 -L lib/ --work=lib/std.08 --print-deps | \ $(deps_pp) > $(srcdir)/lib/std.08/deps.mk include lib/std.08/deps.mk diff --git a/lib/std.19/Makemodule.am b/lib/std.19/Makemodule.am index c7f5e80e..cf7d7ffb 100644 --- a/lib/std.19/Makemodule.am +++ b/lib/std.19/Makemodule.am @@ -38,7 +38,7 @@ lib/std.19/STD.ENV-body: $(srcdir)/lib/std.19/env-body.vhd @ifGNUmake@ | $(DRIVE $(nvc) --std=2019 -L lib/ --work=lib/std.19 -a $(srcdir)/lib/std.19/env-body.vhd gen-deps-std-19: - $(nvc) --std=2019 -L lib/ --work=lib/std.19 --make --posix --deps-only | \ + $(nvc) --std=2019 -L lib/ --work=lib/std.19 --print-deps | \ $(deps_pp) > $(srcdir)/lib/std.19/deps.mk include lib/std.19/deps.mk diff --git a/lib/std/Makemodule.am b/lib/std/Makemodule.am index 23778f7d..a4518eee 100644 --- a/lib/std/Makemodule.am +++ b/lib/std/Makemodule.am @@ -25,7 +25,7 @@ lib/std/STD.TEXTIO-body: $(srcdir)/lib/std/textio-body.vhd @ifGNUmake@ | $(DRIVE $(nvc) -L lib/ --work=lib/std -a $(srcdir)/lib/std/textio-body.vhd gen-deps-std: - $(nvc) -L lib/ --work=lib/std --make --posix --deps-only | \ + $(nvc) -L lib/ --work=lib/std --print-deps | \ $(deps_pp) > $(srcdir)/lib/std/deps.mk include lib/std/deps.mk diff --git a/lib/synopsys/Makemodule.am b/lib/synopsys/Makemodule.am index 485876f1..0888152d 100644 --- a/lib/synopsys/Makemodule.am +++ b/lib/synopsys/Makemodule.am @@ -67,7 +67,7 @@ lib/synopsys/SYNOPSYS.ATTRIBUTES: $(srcdir)/lib/synopsys/attributes.vhd @ifGNUma $(nvc) -L lib/ --work=lib/synopsys -a $(srcdir)/lib/synopsys/attributes.vhd gen-deps-synopsys: - $(nvc) -L lib/ --work=lib/synopsys --make --posix --deps-only | \ + $(nvc) -L lib/ --work=lib/synopsys --print-deps | \ $(deps_pp) > $(srcdir)/lib/synopsys/deps.mk lib/ieee/IEEE.STD_LOGIC_MISC: lib/synopsys/SYNOPSYS.ATTRIBUTES diff --git a/src/nvc.c b/src/nvc.c index 6a9fba5a..26890ce9 100644 --- a/src/nvc.c +++ b/src/nvc.c @@ -81,8 +81,8 @@ static ident_t to_unit_name(const char *str) static int scan_cmd(int start, int argc, char **argv) { const char *commands[] = { - "-a", "-e", "-r", "-c", "--dump", "--make", "--syntax", "--list", "--init", - "--install", + "-a", "-e", "-r", "-c", "--dump", "--make", "--syntax", "--list", + "--init", "--install", "--print-deps", }; for (int i = start; i < argc; i++) { @@ -631,6 +631,47 @@ static int run(int argc, char **argv) return rc == 0 && argc > 1 ? process_command(argc, argv) : rc; } +static int print_deps_cmd(int argc, char **argv) +{ + static struct option long_options[] = { + { 0, 0, 0, 0 } + }; + + opt_set_int(OPT_MAKE_DEPS_ONLY, 1); + + const int next_cmd = scan_cmd(2, argc, argv); + int c, index = 0; + const char *spec = ""; + while ((c = getopt_long(next_cmd, argv, spec, long_options, &index)) != -1) { + switch (c) { + case 0: break; // Set a flag + default: bad_option("make", argv); + } + } + + const int count = next_cmd - optind; + tree_t *targets = xmalloc_array(count, sizeof(tree_t)); + + lib_t work = lib_work(); + + for (int i = optind; i < next_cmd; i++) { + ident_t name = to_unit_name(argv[i]); + ident_t elab = ident_prefix(name, well_known(W_ELAB), '.'); + if ((targets[i - optind] = lib_get(work, elab)) == NULL) { + if ((targets[i - optind] = lib_get(work, name)) == NULL) + fatal("cannot find unit %s in library %s", + istr(name), istr(lib_name(work))); + } + } + + make(targets, count, stdout); + + argc -= next_cmd - 1; + argv += next_cmd - 1; + + return argc > 1 ? process_command(argc, argv) : EXIT_SUCCESS; +} + static int make_cmd(int argc, char **argv) { static struct option long_options[] = { @@ -639,6 +680,10 @@ static int make_cmd(int argc, char **argv) { 0, 0, 0, 0 } }; + warnf("the $bold$--make$$ command is deprecated and may be repurposed in a " + "future release"); + notef("use $bold$--print-deps$$ to print Makefile dependencies instead"); + const int next_cmd = scan_cmd(2, argc, argv); int c, index = 0; const char *spec = ""; @@ -647,16 +692,14 @@ static int make_cmd(int argc, char **argv) case 0: // Set a flag break; - case '?': - bad_option("make", argv); case 'd': opt_set_int(OPT_MAKE_DEPS_ONLY, 1); break; case 'p': - opt_set_int(OPT_MAKE_POSIX, 1); + // Does nothing break; default: - abort(); + bad_option("make", argv); } } @@ -1055,7 +1098,7 @@ static void usage(void) " --init\t\t\t\tInitialise work library directory\n" " --install PKG\t\t\tInstall third-party packages\n" " --list\t\t\t\tPrint all units in the library\n" - " --make [OPTION]... [UNIT]...\tGenerate makefile to rebuild UNITs\n" + " --print-deps [UNIT]...\t\tPrint dependencies in Makefile format\n" " --syntax FILE...\t\tCheck FILEs for syntax errors only\n" "\n" "Global options may be placed before COMMAND:\n" @@ -1128,10 +1171,6 @@ static void usage(void) " -e, --elab\t\tDump an elaborated unit\n" " -b, --body\t\tDump package body\n" "\n" - "Make options:\n" - " --deps-only\tOutput dependencies without actions\n" - " --posix\t\tStrictly POSIX compliant makefile\n" - "\n" "Install options:\n" " --dest=DIR\t\tCompile libraries into directory DEST\n" "\n", @@ -1249,12 +1288,13 @@ static void parse_work_name(char *str, const char **name, const char **path) static int process_command(int argc, char **argv) { static struct option long_options[] = { - { "dump", no_argument, 0, 'd' }, - { "make", no_argument, 0, 'm' }, - { "syntax", no_argument, 0, 's' }, - { "list", no_argument, 0, 'l' }, - { "init", no_argument, 0, 'i' }, - { "install", no_argument, 0, 'I' }, + { "dump", no_argument, 0, 'd' }, + { "make", no_argument, 0, 'm' }, + { "syntax", no_argument, 0, 's' }, + { "list", no_argument, 0, 'l' }, + { "init", no_argument, 0, 'i' }, + { "install", no_argument, 0, 'I' }, + { "print-deps", no_argument, 0, 'P' }, { 0, 0, 0, 0 } }; @@ -1284,6 +1324,8 @@ static int process_command(int argc, char **argv) return init_cmd(argc, argv); case 'I': return install_cmd(argc, argv); + case 'P': + return print_deps_cmd(argc, argv); default: fatal("missing command, try %s --help for usage", PACKAGE); return EXIT_FAILURE; diff --git a/src/option.c b/src/option.c index 17bccae9..858e3c13 100644 --- a/src/option.c +++ b/src/option.c @@ -123,7 +123,6 @@ void set_default_options(void) opt_set_int(OPT_STOP_DELTA, 10000); opt_set_int(OPT_UNIT_TEST, 0); opt_set_int(OPT_MAKE_DEPS_ONLY, 0); - opt_set_int(OPT_MAKE_POSIX, 0); opt_set_str(OPT_DUMP_VCODE, getenv("NVC_LOWER_VERBOSE")); opt_set_int(OPT_IGNORE_TIME, 0); opt_set_int(OPT_VERBOSE, 0); diff --git a/src/option.h b/src/option.h index 041ac21f..382ab718 100644 --- a/src/option.h +++ b/src/option.h @@ -32,7 +32,6 @@ typedef enum { OPT_STOP_DELTA, OPT_UNIT_TEST, OPT_MAKE_DEPS_ONLY, - OPT_MAKE_POSIX, OPT_DUMP_VCODE, OPT_IGNORE_TIME, OPT_VERBOSE, diff --git a/test/regress/cmdline5.sh b/test/regress/cmdline5.sh new file mode 100644 index 00000000..b7b5f2ac --- /dev/null +++ b/test/regress/cmdline5.sh @@ -0,0 +1,9 @@ +set -xe + +pwd +which nvc + +nvc -a $TESTDIR/regress/ieee1.vhd + +nvc --print-deps IEEE1 IEEE1-TEST \ + | grep -E ".*WORK.IEEE1-TEST: .*test/regress/ieee1.vhd .*std/STD.STANDARD .*ieee/IEEE.STD_LOGIC_1164" diff --git a/test/regress/testlist.txt b/test/regress/testlist.txt index 84f3c81d..ee373ec4 100644 --- a/test/regress/testlist.txt +++ b/test/regress/testlist.txt @@ -709,3 +709,4 @@ issue595 normal,2008 cover9 cover,shell issue592 normal cover10 cover,shell +cmdline5 shell -- 2.39.2