diff options
author | Ben Pfaff <blp@nicira.com> | 2010-07-16 10:53:14 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-07-21 15:47:09 -0700 |
commit | 480ce8abca4ae262a4148fe757aebe3e0ddba6f6 (patch) | |
tree | cea1143781be3a75aab5c02c516a22fc7ca3d546 /build-aux | |
parent | 5136ce492c414f377f7be9ae32b259abb9f76580 (diff) |
vlog: Make the vlog module catalog program-specific.
Until now, the collection of vlog modules supported by a given OVS program
was not specific to that program. That means that, for example, even
though ovs-dpctl does not have anything to do with jsonrpc, it still has
a vlog module for it. This is confusing, at best.
This commit fixes the problem on some systems, in particular on ones that
use GCC and the GNU linker. It uses the feature of the GNU linker
described in its manual as:
If an orphaned section's name is representable as a C identifier then
the linker will automatically see PROVIDE two symbols: __start_SECNAME
and __end_SECNAME, where SECNAME is the name of the section. These
indicate the start address and end address of the orphaned section
respectively.
Systems that don't support these features retain the earlier behavior.
This commit also fixes the annoyance that modifying lib/vlog-modules.def
causes all sources files that #include "vlog.h" to recompile.
Diffstat (limited to 'build-aux')
-rwxr-xr-x | build-aux/check-vlog-modules | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/build-aux/check-vlog-modules b/build-aux/check-vlog-modules new file mode 100755 index 00000000..d40c048e --- /dev/null +++ b/build-aux/check-vlog-modules @@ -0,0 +1,66 @@ +#! /bin/sh + +if test "$1" = --help; then + cat <<EOF +$0: cross-check declared and defined vlog modules +usage: $0 [--help] + +Must be run from the top-level source directory. + +On systems that don't support user-defined section names, the 'vlog' +logging subsystem requires the list of modules in lib/vlog-modules.def +to match the set of vlog modules actually used by the source files. +However, most Open vSwitch development happens on systems that do +support user-defined section names and don't have this requirement. +This utility runs automatically at build time to check this +requirement "by hand", so that Open vSwitch developers don't +accidentally break the build for others. +EOF + exit 0 +elif test "$#" != 0; then + echo "no arguments accepted (use --help for help)" + exit 1 +elif test ! -e lib/vlog-modules.def; then + echo "must run from the top-level source directory (use --help for help)" + exit 1 +fi + +# We can only get a list of source files if this is a Git checkout. +if test -e .git && (git --version) >/dev/null 2>&1; then + : +else + exit 0 +fi + +# Get the list of modules declared in lib/vlog-modules.def. +vlog_modules=` + sed -n 's/^VLOG_MODULE(\([_a-zA-Z0-9]\{1,\}\)).*$/\1/p' \ + lib/vlog-modules.def \ + | LC_ALL=C sort -u | xargs echo` + +# Get the list of modules defined in some source file. +src_modules=` + git grep -h -E '^[ ]*VLOG_DEFINE(_THIS)?_MODULE\([_a-zA-Z0-9]+\)[ ]*$' \ + | sed 's/.*(\([_a-zA-Z0-9]\{1,\}\)).*/\1/' \ + | LC_ALL=C sort -u \ + | xargs echo` + +rc=0 + +for module in $vlog_modules; do + case " $src_modules " in + *" $module "*) ;; + *) echo "vlog module $module is declared in lib/vlog-modules.def but not defined by any source file"; + rc=1 ;; + esac +done + +for module in $src_modules; do + case " $vlog_modules " in + *" $module "*) ;; + *) echo "vlog module $module is defined in a source file but not declared in lib/vlog-modules.def"; + rc=1 ;; + esac +done + +exit $rc |