From e02cfdd9b86511fcb2081484c1e58d47a0298a3b Mon Sep 17 00:00:00 2001
From: Thomas Debesse <dev@illwieckz.net>
Date: Sun, 7 Mar 2021 04:35:37 +0100
Subject: [PATCH] macos: just restart the build when it failed

Sometime linking fails on macOS with this message:

	ld: symbol(s) not found for architecture x86_64

and restarting the build process just work.
---
 easy-builder | 67 ++++++++++++++++++++++++++++++++++------------------
 1 file changed, 44 insertions(+), 23 deletions(-)

diff --git a/easy-builder b/easy-builder
index d2ff3da6..6d1d9718 100755
--- a/easy-builder
+++ b/easy-builder
@@ -92,28 +92,49 @@ case "$(uname -s)" in
 		;;
 esac
 
+task_enter_build_dir () {
+	mkdir -pv "${build_dir}"
+	cd "${build_dir}"
+}
+
+task_fetch_submodules () {
+	"${fetch_submodules_cmd[@]}"
+}
+
+task_configure () {
+	cmake \
+		-G'Unix Makefiles' \
+		-D'CMAKE_INSTALL_PREFIX'="${install_dir}" \
+		-D'CMAKE_BUILD_TYPE'="${build_type}" \
+		"${cmake_user_opts[@]}" \
+		"${project_source_dir}"
+}
+
+task_build_builtins () {
+	cmake \
+		--build "${build_dir}" \
+		-- \
+		-j"${job_count}" \
+		'builtins'
+}
+
+task_build () {
+	cmake \
+		--build "${build_dir}" \
+		-- \
+		-j"${job_count}" \
+		"${install_target}"
+}
+
 set -x
 
-"${fetch_submodules_cmd[@]}"
-
-mkdir -pv "${build_dir}"
-cd "${build_dir}"
-
-cmake \
-	-G'Unix Makefiles' \
-	-D'CMAKE_INSTALL_PREFIX'="${install_dir}" \
-	-D'CMAKE_BUILD_TYPE'="${build_type}" \
-	"${cmake_user_opts[@]}" \
-	"${project_source_dir}"
-
-cmake \
-	--build "${build_dir}" \
-	-- \
-	-j"${job_count}" \
-	'builtins'
-
-cmake \
-	--build "${build_dir}" \
-	-- \
-	-j"${job_count}" \
-	"${install_target}"
+task_enter_build_dir
+
+task_configure
+
+task_build_builtins
+
+# Sometime linking fails on macOS with this message:
+#   ld: symbol(s) not found for architecture x86_64
+# and restarting the build process just work.
+task_build || task_build
-- 
2.39.5