From 1f98b0ae3661958b8886eaea796cfb2d69bbe2a5 Mon Sep 17 00:00:00 2001
From: Sebastian Fricke <sebastian.fricke@collabora.com>
Date: Mon, 27 Nov 2023 15:12:20 +0100
Subject: [PATCH] funcs.sh: Wrapper for smatch install

Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
---
 build.sh | 10 +---------
 funcs.sh | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/build.sh b/build.sh
index 80a6b61..7f94a22 100755
--- a/build.sh
+++ b/build.sh
@@ -270,15 +270,7 @@ set_doc_headers
 cd $top
 
 if [ $sparse == 1 -o $smatch == 1 -o ! -d smatch ]; then
-	if [ ! -d smatch ]; then
-		echo 'Smatch missing, run prepare_build.sh first'
-		exit 1
-	fi
-	cd smatch
-	git remote update
-	git reset --hard origin/master
-	make -j HAVE_LLVM=no
-	cd ..
+	build_smatch origin/master
 fi
 
 export CCACHE_MAXSIZE=512M
diff --git a/funcs.sh b/funcs.sh
index a0095a5..a71c9c0 100755
--- a/funcs.sh
+++ b/funcs.sh
@@ -78,6 +78,19 @@ function strip_top()
 	sed "s;$top/media-git/;;g"
 }
 
+function build_smatch()
+{
+	if [ ! -d smatch ]; then
+		echo '`smatch` folder missing, run prepare_build.sh first'
+		exit 1
+	fi
+	cd smatch
+	git remote update
+	git reset --hard $1
+	make -j HAVE_LLVM=no
+	cd ..
+	return 0
+}
 function setup()
 {
 	if [ ! -d media-git ]; then
@@ -98,9 +111,7 @@ function setup()
 	git remote update
 	git checkout -b build-test media_stage/master
 	cd ..
-	git clone $smatch_git
-	cd smatch
-	make -j HAVE_LLVM=no
+	build_smatch origin/master
 
 	exit 0
 }
-- 
GitLab