Mercurial > gnulib
comparison gnulib-tool @ 7320:9349ee4e633c
Speed up func_modules_transitive_closure.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 18 Sep 2006 12:55:35 +0000 |
parents | 1726cc39709b |
children | 3bf1b669d1e1 |
comparison
equal
deleted
inserted
replaced
7319:1726cc39709b | 7320:9349ee4e633c |
---|---|
20 # This program is meant for authors or maintainers which want to import | 20 # This program is meant for authors or maintainers which want to import |
21 # modules from gnulib into their packages. | 21 # modules from gnulib into their packages. |
22 | 22 |
23 progname=$0 | 23 progname=$0 |
24 package=gnulib | 24 package=gnulib |
25 cvsdatestamp='$Date: 2006-09-18 12:54:13 $' | 25 cvsdatestamp='$Date: 2006-09-18 12:55:35 $' |
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` | 26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` |
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` | 27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` |
28 | 28 |
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH. | 29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH. |
30 AUTOCONFPATH= | 30 AUTOCONFPATH= |
921 # Input: | 921 # Input: |
922 # - local_gnulib_dir from --local-dir | 922 # - local_gnulib_dir from --local-dir |
923 # - modules list of specified modules | 923 # - modules list of specified modules |
924 # - inctests true if tests should be included, blank otherwise | 924 # - inctests true if tests should be included, blank otherwise |
925 # - avoidlist list of modules to avoid | 925 # - avoidlist list of modules to avoid |
926 # - tmp pathname of a temporary directory | |
926 # Output: | 927 # Output: |
927 # - modules list of modules, including dependencies | 928 # - modules list of modules, including dependencies |
928 func_modules_transitive_closure () | 929 func_modules_transitive_closure () |
929 { | 930 { |
930 while true; do | 931 # In order to process every module only once (for speed), process an "input |
931 xmodules= | 932 # list" of modules, producing an "output list" of modules. During each round, |
932 for module in $modules; do | 933 # more modules can be queued in the input list. Once a module on the input |
934 # list has been processed, it is added to the "handled list", so we can avoid | |
935 # to process it again. | |
936 handledmodules= | |
937 inmodules="$modules" | |
938 outmodules= | |
939 while test -n "$inmodules"; do | |
940 inmodules_this_round="$inmodules" | |
941 inmodules= # Accumulator, queue for next round | |
942 for module in $inmodules_this_round; do | |
933 func_verify_module | 943 func_verify_module |
934 if test -n "$module"; then | 944 if test -n "$module"; then |
935 # Duplicate dependencies are harmless, but Jim wants a warning. | |
936 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d` | |
937 if test -n "$duplicated_deps"; then | |
938 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2 | |
939 fi | |
940 if func_acceptable $module; then | 945 if func_acceptable $module; then |
941 xmodules="$xmodules $module" | 946 outmodules="$outmodules $module" |
942 for depmodule in `func_get_dependencies $module`; do | 947 deps=`func_get_dependencies $module` |
943 if func_acceptable $depmodule; then | 948 # Duplicate dependencies are harmless, but Jim wants a warning. |
944 xmodules="$xmodules $depmodule" | 949 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d` |
945 fi | 950 if test -n "$duplicated_deps"; then |
946 done | 951 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2 |
952 fi | |
953 inmodules="$inmodules $deps" | |
947 if test -n "$inctests"; then | 954 if test -n "$inctests"; then |
948 testsmodule=`func_get_tests_module $module` | 955 testsmodule=`func_get_tests_module $module` |
949 if test -n "$testsmodule"; then | 956 if test -n "$testsmodule"; then |
950 if func_acceptable $testsmodule; then | 957 inmodules="$inmodules $testsmodule" |
951 xmodules="$xmodules $testsmodule" | |
952 for depmodule in `func_get_dependencies $testsmodule`; do | |
953 if func_acceptable $depmodule; then | |
954 xmodules="$xmodules $depmodule" | |
955 fi | |
956 done | |
957 fi | |
958 fi | 958 fi |
959 fi | 959 fi |
960 fi | 960 fi |
961 fi | 961 fi |
962 done | 962 done |
963 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq` | 963 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u` |
964 if test "$xmodules" = "$modules"; then | 964 # Remove $handledmodules from $inmodules. |
965 break | 965 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules |
966 fi | 966 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules` |
967 modules="$xmodules" | |
968 done | 967 done |
968 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u` | |
969 rm -f "$tmp"/queued-modules | |
969 } | 970 } |
970 | 971 |
971 # func_modules_add_dummy | 972 # func_modules_add_dummy |
972 # Input: | 973 # Input: |
973 # - local_gnulib_dir from --local-dir | 974 # - local_gnulib_dir from --local-dir |