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

[OSSTEST PATCH 1/2] ts-xen-build: Refactor enable/disable configure options



Replace the repeated pattern with a function to generate that code.
No significant functional change.

Signed-off-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
CC: Juergen Gross <jgross@xxxxxxxx>
---
 ts-xen-build | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/ts-xen-build b/ts-xen-build
index ccb2aba23..d6f6bfacb 100755
--- a/ts-xen-build
+++ b/ts-xen-build
@@ -142,9 +142,21 @@ END
 }
 
 sub build () {
-    my $xend_opt= $r{enable_xend} =~ m/true/ ? "--enable-xend" : 
"--disable-xend";
-    my $ovmf_opt= $r{enable_ovmf} =~ m/true/ ? "--enable-ovmf" : 
"--disable-ovmf";
-    my $qemutrad_opt = $r{arch} =~ m/amd64|i386/ ? "--enable-qemu-traditional" 
: "--disable-qemu-traditional";
+    my $enable_opts = ''; # shell script to set "enable_opts" shell var
+    my $enable_disable = sub {
+       my ($subdir, $feat, $enable) = @_;
+       my $opt = "--".($enable ? 'enable' : 'disable')."-$feat";
+       $enable_opts .= <<END;
+                if grep -q -- $opt \\
+                               ${subdir}configure ; then
+                   enable_opts="\$enable_opts $opt"
+                fi
+END
+    };
+    
+    $enable_disable->("tools/", "xend", $r{enable_xend} =~ m/true/);
+    $enable_disable->("tools/", "ovmf", $r{enable_ovmf} =~ m/true/);
+    $enable_disable->("tools/", "qemu-traditional", $r{arch} =~ m/amd64|i386/);
 
     my $configure_prefix = $r{cmdprefix_configure} // '';
     my $configure_suffix = $r{cmdsuffix_configure} // '';
@@ -152,17 +164,9 @@ sub build () {
 
     buildcmd_stamped_logged(600, 'xen', 'configure', <<END,<<END,<<END);
             if test -f configure; then
-                if grep -q -- $xend_opt tools/configure ; then
-                   xend=$xend_opt
-                fi
-                if grep -q -- $ovmf_opt tools/configure ; then
-                    ovmf=$ovmf_opt
-                fi
-                if grep -q -- $qemutrad_opt tools/configure ; then
-                    qemutrad=$qemutrad_opt
-                fi
+$enable_opts
 END
-               $configure_prefix ./configure --sysconfdir=/etc \$xend \$ovmf 
\$qemutrad $configure_suffix @configure_args
+               $configure_prefix ./configure --sysconfdir=/etc \$enable_opts 
$configure_suffix @configure_args
 END
             fi
 END
-- 
2.20.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.