From 10fba4ca1e16147ef13bafba194f04d59815c2cb Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Thu, 25 Mar 2021 17:22:10 +0100
Subject: [PATCH] .gitlab-ci.yml, Makefile: put build artifacts in
 $CI_PROJECT_DIR

GitLab CI system has a constraint that requires all artifact files to be
placed in a sub-directory of $CI_PROJECT_DIR - aka the place where the
project is automatically checked out by the GitLab runner. Since our
project is manifest-based, we use a temporary scratch directory where
the entire structure is created.

Override `make` invocation, so that it builds the project from the
scratch directory into a build sub-directory of CI_PROJECT_DIR.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .gitlab-ci.yml |  2 +-
 Makefile       | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c1d6f59..e685fbd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -58,7 +58,7 @@ build:
   stage: build
   script:
     - *doc-workspace-do
-    - make
+    - make BUILD_DIR="$CI_PROJECT_DIR/build"
   artifacts:
     paths:
       - build
diff --git a/Makefile b/Makefile
index ec6ef54..973359e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,16 @@
 # SPDX-License-Identifier: Apache-2.0
 # SPDX-FileCopyrightText: Huawei Inc.
 
+BUILD_DIR ?= build
+
 .PHONY: all
-all: build
+all: $(BUILD_DIR)
 
 .PHONY: clean
 clean:
 	rm -rf build
 
-build:
-	sphinx-build -W . build
+SRC_DIR ?= .
+# XXX: cannot add true dependencies because some file names contain spaces.
+$(BUILD_DIR):
+	sphinx-build -W $(SRC_DIR) $(BUILD_DIR)
-- 
GitLab