diff mbox series

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

Message ID 20211027170256.18223-2-iwj@xenproject.org (mailing list archive)
State New, archived
Headers show
Series ts-xen-build: explicitly enable/disable configure features | expand

Commit Message

Ian Jackson Oct. 27, 2021, 5:02 p.m. UTC
Replace the repeated pattern with a function to generate that code.
No significant functional change.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
CC: Juergen Gross <jgross@suse.com>
---
 ts-xen-build | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
diff mbox series

Patch

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