From 8e2b334db91cb4c6e33a9fc52ce19d31fafd42e7 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Date: Sat, 13 Feb 2021 14:51:30 -0500
Subject: [PATCH] contrib: Use git_download to fetch the ONNX sources.

* contrib/src/main.mak (git_download): Document procedure.
* contrib/src/onnx/rules.mak (ONNX_URL): Use it.

Change-Id: Ia1759e8d10c79b1109481895dc13166440709228
---
 contrib/src/main.mak       | 4 ++++
 contrib/src/onnx/rules.mak | 5 +----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index 28c1701950..b04f001717 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -326,6 +326,10 @@ HOSTVARS := $(HOSTTOOLS) \
 	CXXFLAGS="$(CXXFLAGS) $(PIC)" \
 	LDFLAGS="$(LDFLAGS)"
 
+# git_download procedure
+# $1: The URL of the Git repository.
+# $2: The remote branch to clone.
+# $3: The git refspec to checkout.
 ifeq ($(DISABLE_CONTRIB_DOWNLOADS),TRUE)
 download_git = $(error Trying to clone $(1) but DISABLE_CONTRIB_DOWNLOADS is TRUE, aborting.)
 else
diff --git a/contrib/src/onnx/rules.mak b/contrib/src/onnx/rules.mak
index 2d7b57de8b..513c9a453b 100644
--- a/contrib/src/onnx/rules.mak
+++ b/contrib/src/onnx/rules.mak
@@ -3,10 +3,7 @@ ONNX_VERSION := v1.6.0
 ONNX_URL := https://github.com/microsoft/onnxruntime.git
 
 $(TARBALLS)/onnxruntime-$(ONNX_VERSION).tar.xz:
-	git clone $(ONNX_URL) ../../contrib/tarballs/onnxruntime-$(ONNX_VERSION)
-	cd ../../contrib/tarballs/onnxruntime-$(ONNX_VERSION) && git checkout $(ONNX_VERSION)
-	cd ../../contrib/tarballs/ && tar cJf onnxruntime-$(ONNX_VERSION).tar.xz onnxruntime-$(ONNX_VERSION)
-	rm -Rf ../../contrib/tarballs/onnxruntime-v1.6.0
+	$(call download_git,$(ONNX_URL),master,$(ONNX_VERSION))
 
 .sum-onnx: onnxruntime-$(ONNX_VERSION).tar.xz
 	$(warning $@ not implemented)
-- 
GitLab