[ovs-dev] [PATCH 1/2] soexpand: enable dpdk specific blocks

Aaron Conole aconole at redhat.com
Wed Mar 29 19:25:19 UTC 2017


Normally, in C code, pre-processing macros can be used to enable/disable
specific functionality based on switches passed to configure.  This works
for DPDK using the --with-dpdk flag, which sets the DPDK_NETDEV define to
the appropriate value.

However, not all files are processed with the C pre-processor.  For those
files which are not, the soexpand utility grows a new feature to simply
filter out those stanzas which aren't dpdk relevant.

Signed-off-by: Aaron Conole <aconole at redhat.com>
---
 Makefile.am           |  6 +++++-
 build-aux/soexpand.pl | 25 ++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c853085..e0c5b0c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,6 +35,9 @@ AM_CFLAGS += $(OVS_CFLAGS)
 
 if DPDK_NETDEV
 AM_CFLAGS += -D_FILE_OFFSET_BITS=64
+SOEXPAND_DPDK_BLOCKS = "--dpdk"
+else
+SOEXPAND_DPDK_BLOCKS = "--nodpdk"
 endif
 
 if NDEBUG
@@ -136,7 +139,8 @@ ro_shell = printf '\043 Generated automatically -- do not modify!    -*- buffer-
 
 SUFFIXES += .in
 .in:
-	$(AM_V_GEN)$(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) < $< | \
+	$(AM_V_GEN)$(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) \
+	$(SOEXPAND_DPDK_BLOCKS) < $< | \
 	  sed \
 	    -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
 	    -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
diff --git a/build-aux/soexpand.pl b/build-aux/soexpand.pl
index 2162564..cb4938b 100644
--- a/build-aux/soexpand.pl
+++ b/build-aux/soexpand.pl
@@ -18,15 +18,26 @@ use Getopt::Long;
 
 my ($exit_code) = 0;
 my (@include_dirs);
+my ($check_dpdk) = 0;
+my ($disabled_print) = 0;
+
 Getopt::Long::Configure ("bundling");
-GetOptions("I|include=s" => \@include_dirs) or exit(1);
+GetOptions("I|include=s" => \@include_dirs,
+           'dpdk!' => \$check_dpdk) or exit(1);
+
 @include_dirs = ('.') if !@include_dirs;
 OUTER: while (<STDIN>) {
     if (my ($name) = /^\.so (\S+)$/) {
 	foreach my $dir (@include_dirs, '.') {
 	    if (open(INNER, "$dir/$name")) {
 		while (<INNER>) {
-		    print $_;
+		    if (/@(begin|end)_dpdk@/) {
+			if (!$check_dpdk) {
+			    $disabled_print = ! $disabled_print;
+			}
+			next;
+		    }
+		    print $_ unless $disabled_print;
 		}
 		close(INNER);
 		next OUTER;
@@ -35,6 +46,14 @@ OUTER: while (<STDIN>) {
 	print STDERR "$name not found in: ", join(' ', @include_dirs), "\n";
 	$exit_code = 1;
     }
-    print $_;
+
+    if (/@(begin|end)_dpdk@/) {
+	if (!$check_dpdk) {
+	    $disabled_print = ! $disabled_print;
+	}
+	next;
+    }
+
+    print $_ unless $disabled_print;
 }
 exit $exit_code;
-- 
2.9.3



More information about the dev mailing list