bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to find out which modules have brought in a particular module


From: Gavin Smith
Subject: Re: How to find out which modules have brought in a particular module
Date: Sat, 9 Jan 2016 12:47:37 +0000

On 21 October 2015 at 02:42, Pádraig Brady <address@hidden> wrote:
> There was some work on displaying a graph previously.
> http://lists.gnu.org/archive/html/bug-gnulib/2011-03/msg00276.html
> Something like this is worth adding I think.
>
> cheers,
> Pádraig

Here's basic functionality that shows direct dependencies. Indirect
dependencies and noting conditional dependencies are a possible
extension, but I think that this output as it is could be useful for
seeing the interdependencies between modules, and potentially
eliminating some modules that make checks you don't care about. If
some code like this is included, it should of course be controlled by
a command-line option.

Anybody please feel free to suggest directions I should take this code in.

PS I was discouraged after I sent my first mail when I realised that
gnulib-tool was written in shell script (I thought it was in Perl for
some reason).

diff --git a/gnulib-tool b/gnulib-tool
index 426ace1..d0593fa 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -2885,6 +2885,9 @@ func_modules_transitive_closure ()
             done
             if $inc && func_acceptable "$dep"; then
               func_append inmodules " $dep"
+              cachevar=c_`echo "$dep" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'`
+              # fixme: should use func_cache_var $dep instead
+              func_append ${cachevar}_demanded_by " $module"
               if test "$cond_dependencies" = true; then
                 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
                 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
@@ -2940,11 +2943,20 @@ func_show_module_list ()
     bold_on=
     bold_off=
   fi
+  (for m in $modules; do
+    cachevar=c_`echo "$m" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'`
+    # fixme: should use func_cache_var $dep instead
+    eval echo \"${m}\|\" \" \[\" \$${cachevar}_demanded_by \"\]\"
+  done) >"$tmp"/modules-with-reasons
   echo "Module list with included dependencies (indented):"
-  echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' >
"$tmp"/specified-modules
-  echo "$modules" | sed -e '/^$/d' \
+  echo "$specified_modules" | sed -e '/^$/d' -e 's/$/|0/' >
"$tmp"/specified-modules
+  cat "$tmp"/modules-with-reasons \
+    | sed -e '/^$/d' \
     | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
-    | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/    /' -e 's/^    |\(.*\)$/
'"${bold_on}"'\1'"${bold_off}"'/'
+    | sed -e 's/^\(.*\)|0|.*/|\1/' \
+          -e 's/^/    /' \
+          -e 's/^    |\(.*\)$/  '"${bold_on}"'\1'"${bold_off}"'/' \
+          -e 's/|/\n    /'
 }

 # func_modules_transitive_closure_separately

===================

Sample output from "gnulib-tool --add-import --dry-run"

Module list with included dependencies (indented):
    absolute-header
      [ include_next ]
    alloca-opt
      [ regex malloca vasnprintf ]
  argz
    btowc
      [ regex ]
    configmake
      [ localcharset ]
    dosname
      [ lstat stat ]
    errno
      [ strerror vasprintf strerror-override vasnprintf ]
    error
      [ xalloc-die ]
    exitfail
      [ xalloc-die ]
    extensions
      [ gettext mbchar mbswidth memrchr mkstemp regex vasprintf
getopt-posix iswblank mbrtowc mbsinit memmem-simple mempcpy stdio
stpcpy strcasestr-simple string strndup strnlen tempname wcrtomb
wcwidth fcntl-h langinfo localcharset memchr secure_getenv locale time
]
    extern-inline
      [ mbchar mbiter xalloc mbuiter string wctype-h unistd xsize ]
    fcntl-h
      [ tempname ]
    float
      [ vasnprintf ]
  getopt-gnu
    getopt-posix
      [ getopt-gnu ]
  gettext
    gettext-h
      [ gettext regex getopt-posix xalloc-die ]
    gettimeofday
      [ tempname time ]
    havelib
      [ gettext iconv threadlib ]
  iconv
    include_next
      [ stdarg errno getopt-posix stdint stdio stdlib string wchar
wctype-h fcntl-h float langinfo stddef sys_stat sys_time sys_types
unistd locale strings time ]
    intprops
      [ strerror ]
    iswblank
      [ mbchar ]
    langinfo
      [ nl_langinfo ]
    largefile
      [ mkstemp lstat stat ]
    localcharset
      [ mbrtowc wcwidth ]
    locale
      [ localeconv ]
    localeconv
      [ nl_langinfo ]
    lock
      [ regex ]
    lstat
      [ tempname ]
    malloc-posix
      [ strdup-posix ]
    malloca
      [ mbsstr ]
  mbchar
  mbiter
    mbrtowc
      [ mbiter mbswidth regex mbsinit mbuiter mbtowc ]
  mbscasecmp
  mbschr
    mbsinit
      [ mbiter mbswidth regex mbrtowc mbuiter wcrtomb ]
  mbslen
  mbsncasecmp
  mbsstr
  mbswidth
    mbtowc
      [ btowc ]
    mbuiter
      [ mbscasecmp mbschr mbslen mbsncasecmp mbsstr ]
    memchr
      [ memmem-simple strcasestr-simple vasnprintf strnlen1 strstr-simple ]
  memmem
    memmem-simple
      [ memmem ]
    mempcpy
      [ argz ]
  memrchr
  mkstemp
    msvc-inval
      [ msvc-nothrow ]
    msvc-nothrow
      [ error ]
    multiarch
      [ stdint ]
    nl_langinfo
      [ regex ]
    nocrash
      [ getopt-gnu ]
    pathmax
      [ stat ]
  regex
    secure_getenv
      [ tempname ]
    size_max
      [ xsize ]
    snippet/_Noreturn
      [ stdlib ]
    snippet/arg-nonnull
      [ getopt-posix stdio stdlib string wchar fcntl-h sys_stat
sys_time unistd locale strings time ]
    snippet/c++defs
      [ stdio stdlib string wchar wctype-h fcntl-h langinfo sys_stat
sys_time unistd locale strings time ]
    snippet/warn-on-use
      [ stdio stdlib string wchar wctype-h fcntl-h langinfo sys_stat
sys_time unistd locale strings time ]
    ssize_t
      [ regex stdio sys_types unistd ]
    stat
      [ lstat ]
  stdarg
    stdbool
      [ mbchar mbiter mbsstr regex mbuiter strcasestr-simple
strstr-simple stat ]
    stddef
      [ stdio stdlib string wchar unistd locale time ]
    stdint
      [ regex malloca memmem-simple tempname vasnprintf unitypes ]
    stdio
      [ vasprintf error ]
    stdlib
      [ mkstemp malloc-posix exitfail mbtowc secure_getenv ]
    stpcpy
      [ argz ]
    strcase
      [ strcasestr-simple ]
  strcasestr
    strcasestr-simple
      [ strcasestr ]
  strdup-posix
    streq
      [ mbrtowc wcwidth uniwidth/width ]
  strerror
    strerror-override
      [ strerror ]
    string
      [ mbscasecmp mbschr mbslen mbsncasecmp mbsstr memrchr
strdup-posix strerror memmem-simple mempcpy stpcpy strcasestr-simple
strndup strnlen memchr strstr-simple ]
    strings
      [ strcase ]
    strndup
      [ argz ]
    strnlen
      [ argz mbsstr strndup ]
    strnlen1
      [ mbuiter ]
    strstr
      [ argz ]
    strstr-simple
      [ strstr ]
    sys_stat
      [ tempname lstat stat ]
    sys_time
      [ tempname gettimeofday ]
    sys_types
      [ stdint stdio fcntl-h sys_stat unistd strings ]
    tempname
      [ mkstemp ]
    threadlib
      [ lock ]
    time
      [ sys_stat ]
    unistd
      [ getopt-posix stdlib error fcntl-h pathmax ]
    unitypes
      [ uniwidth/base ]
    uniwidth/base
      [ uniwidth/width ]
    uniwidth/width
      [ wcwidth ]
    vasnprintf
      [ vasprintf ]
  vasprintf
    verify
      [ strerror malloca mbrtowc mbsinit vasnprintf stat ]
    wchar
      [ mbchar mbiter mbswidth regex btowc mbrtowc mbsinit mbuiter
vasnprintf wcrtomb wcwidth mbtowc ]
    wcrtomb
      [ regex ]
    wctype-h
      [ mbchar mbswidth regex iswblank wcwidth ]
    wcwidth
      [ mbchar mbswidth ]
  xalloc
    xalloc-die
      [ xalloc ]
    xalloc-oversized
      [ xalloc ]
    xsize
      [ vasnprintf ]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]