From dcfa509347541cf4a44f7e5be5fc74398d8a8199 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 19 Dec 2009 15:27:58 +0100 Subject: [PATCH] New module attribute 'Applicability'. --- ChangeLog | 12 ++++++++++++ gnulib-tool | 43 ++++++++++++++++++++++++++++++++++++++----- modules/TEMPLATE-EXTENDED | 2 ++ modules/arg-nonnull | 8 ++++++++ modules/link-warning | 8 ++++++++ 5 files changed, 68 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d97d2118c..d0673a93c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-12-19 Bruno Haible + + New module attribute 'Applicability'. + * modules/TEMPLATE-EXTENDED: New field 'Applicability'. + * gnulib-tool: New option --extract-applicability. + (func_usage): Document it. + (sed_extract_prog): Recognize it. + (func_get_applicability): New function. + (func_import): Generalize handling of 'link-warning' module. + * modules/link-warning (Applicability): New section. + * modules/arg-nonnull (Applicability): New section. + Repoted by Simon Josefsson . 2009-12-19 Bruno Haible diff --git a/gnulib-tool b/gnulib-tool index 5bc68936c..d8734167a 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -115,6 +115,7 @@ Usage: gnulib-tool --list gnulib-tool --extract-description module gnulib-tool --extract-status module gnulib-tool --extract-notice module + gnulib-tool --extract-applicability module gnulib-tool --extract-filelist module gnulib-tool --extract-dependencies module gnulib-tool --extract-autoconf-snippet module @@ -1347,6 +1348,7 @@ sed_extract_prog=':[ ]*$/ { s/^Description:[ ]*$// s/^Status:[ ]*$// s/^Notice:[ ]*$// + s/^Applicability:[ ]*$// s/^Files:[ ]*$// s/^Depends-on:[ ]*$// s/^configure\.ac-early:[ ]*$// @@ -1389,6 +1391,22 @@ func_get_notice () sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file" } +# func_get_applicability module +# Input: +# - local_gnulib_dir from --local-dir +# The expected result (on stdout) is either 'main', or 'tests', or 'all'. +func_get_applicability () +{ + func_lookup_file "modules/$1" + { sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file" + # The default is 'main' or 'tests', depending on the module's name. + case "$1" in + *-tests) echo "tests";; + *) echo "main";; + esac + } | sed -e 's,^ *$,,' | sed -e 1q +} + # func_get_filelist module # Input: # - local_gnulib_dir from --local-dir @@ -2745,9 +2763,9 @@ func_import () # is specified, it will consist only of LGPLed source. # The tests-related module list is the transitive closure of the specified # modules, including tests modules, minus the main module list excluding - # 'link-warning'. Its lib/* sources (brought in through dependencies of - # *-tests modules) go into $testsbase/. It may contain GPLed source, even if - # --lgpl is specified. + # modules of applicability 'all'. Its lib/* sources (brought in through + # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed + # source, even if --lgpl is specified. # Determine main module list. saved_inctests="$inctests" inctests="" @@ -2761,8 +2779,13 @@ func_import () fi # Determine tests-related module list. echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules - sed_remove_link_warning='/^link-warning$/d' - testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | sed -e "$sed_remove_link_warning" | LC_ALL=C join -v 2 - "$tmp"/final-modules` + testsrelated_modules=`func_reset_sigpipe + for module in $main_modules; do + if test \`func_get_applicability $module\` = main; then + echo $module + fi + done \ + | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules` if test $verbose -ge 1; then echo "Tests-related module list:" echo "$testsrelated_modules" | sed -e 's/^/ /' @@ -4639,6 +4662,16 @@ case $mode in done ;; + extract-applicability ) + for module + do + func_verify_module + if test -n "$module"; then + func_get_applicability "$module" + fi + done + ;; + extract-filelist ) for module do diff --git a/modules/TEMPLATE-EXTENDED b/modules/TEMPLATE-EXTENDED index d765e201f..88897363f 100644 --- a/modules/TEMPLATE-EXTENDED +++ b/modules/TEMPLATE-EXTENDED @@ -6,6 +6,8 @@ Notice: Files: +Applicability: + Depends-on: configure.ac-early: diff --git a/modules/arg-nonnull b/modules/arg-nonnull index ed224bf7d..d4e4d1366 100644 --- a/modules/arg-nonnull +++ b/modules/arg-nonnull @@ -1,6 +1,9 @@ Description: A C macro for declaring that specific arguments must not be NULL. +Applicability: +all + Files: build-aux/arg-nonnull.h @@ -9,6 +12,11 @@ Depends-on: configure.ac: Makefile.am: +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. + BUILT_SOURCES += arg-nonnull.h # The arg-nonnull.h that gets inserted into generated .h files is the same as # build-aux/arg-nonnull.h, except that it has the copyright header cut off. diff --git a/modules/link-warning b/modules/link-warning index 6b998f533..935f66a39 100644 --- a/modules/link-warning +++ b/modules/link-warning @@ -1,6 +1,9 @@ Description: A C macro for emitting link time warnings. +Applicability: +all + Files: build-aux/link-warning.h @@ -9,6 +12,11 @@ Depends-on: configure.ac: Makefile.am: +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. + BUILT_SOURCES += link-warning.h # The link-warning.h that gets inserted into generated .h files is the same as # build-aux/link-warning.h, except that it has the copyright header cut off. -- 2.11.0