From 0e9838907b2edfbcf8748b461a20cb0fe73061d1 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Tue, 27 Apr 2021 15:27:40 +0200
Subject: [PATCH] Add machine and flavour aware recipes from manifest

Currently machines and flavours are defined in the meta-ohos repository
but their CI pipelines are defined in the manifest repository. Move the
definitions of the various build jobs here to be included from the
manifest repository internally.

This way the public interface is unchanged but patches such as the
recent Raspberry Pi 4 support can enable a new MACHINE configuration and
a new CI job all in one go, to the extent that in-progress CI will pick
it up.

Closes: https://git.ostc-eu.org/OSTC/OHOS/meta-ohos/-/issues/44
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .ostc-ci/machines-and-flavours.yaml | 102 +++++++++++++++++++
 docs/ci/index.rst                   |  11 +++
 docs/ci/machines-and-flavours.rst   | 147 ++++++++++++++++++++++++++++
 docs/index.rst                      |   1 +
 4 files changed, 261 insertions(+)
 create mode 100644 .ostc-ci/machines-and-flavours.yaml
 create mode 100644 docs/ci/index.rst
 create mode 100644 docs/ci/machines-and-flavours.rst

diff --git a/.ostc-ci/machines-and-flavours.yaml b/.ostc-ci/machines-and-flavours.yaml
new file mode 100644
index 00000000..99e0b632
--- /dev/null
+++ b/.ostc-ci/machines-and-flavours.yaml
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: Huawei Inc.
+
+# NOTE: This file is included from the manifest repository. It is not
+# self-sufficient.  It is here only because the meta-ohos repository also
+# contains all the flavour and machine definitions and having both in one place
+# allows one to add a new MACHINE and the associated build jobs in one go.
+#
+# Please do not include this file directly.
+
+# The following jobs are documented in docs/ci/shared-jobs.rst
+
+linux-qemu-x86:
+  extends: .build-linux
+  variables:
+    MACHINE: qemux86
+    # Set OHOS_BUILD_CACHE to "pub", overriding the value defined in the
+    # .build job. This enables sharing of download and sstate-cache created
+    # during this job.
+    #
+    # This is done assuming that there are no non-redistributable or otherwise
+    # tainted build intermediate files, downloads or published artifacts. All
+    # the non-tainted builds help to populate a cache exposed at
+    # https://cache.ostc-eu.org/bitbake
+    OHOS_BUILD_CACHE: "pub"
+    OHOS_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1
+
+linux-qemu-x86_64:
+  extends: .build-linux
+  variables:
+    MACHINE: qemux86-64
+    # See the note on linux-qemu-x86.
+    OHOS_BUILD_CACHE: "pub"
+    OHOS_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1
+
+linux-qemu-arm:
+  extends: .build-linux
+  variables:
+    MACHINE: qemuarm
+    # See the note on linux-qemu-x86.
+    OHOS_BUILD_CACHE: "pub"
+    OHOS_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1
+
+linux-qemu-arm64:
+  extends: .build-linux
+  variables:
+    MACHINE: qemuarm64
+    # See the note on linux-qemu-x86.
+    OHOS_BUILD_CACHE: "pub"
+    OHOS_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1
+
+linux-seco-intel-b68:
+  extends: .build-linux
+  variables:
+    MACHINE: seco-intel-b68
+
+linux-seco-imx8mm-c61:
+  extends: .build-linux
+  variables:
+    MACHINE: seco-imx8mm-c61
+    # This platform requires proprietary resources to boot.
+    # See build-generic.yaml for explanation of OHOS_BB_LOCAL_CONF_ variables.
+    OHOS_BB_LOCAL_CONF_ACCEPT_FSL_EULA: 1
+
+linux-stm32mp1-av96:
+  extends: .build-linux
+  variables:
+    MACHINE: stm32mp1-av96
+
+zephyr-qemu-x86:
+  extends: .build-zephyr
+  variables:
+    MACHINE: qemu-x86
+    # See the note on linux-qemu-x86.
+    OHOS_BUILD_CACHE: "pub"
+    OHOS_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1
+
+zephyr-qemu-cortex-m3:
+  extends: .build-zephyr
+  variables:
+    MACHINE: qemu-cortex-m3
+    # See the note on linux-qemu-x86.
+    OHOS_BUILD_CACHE: "pub"
+    OHOS_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1
+
+zephyr-96b-nitrogen:
+  extends: .build-zephyr
+  variables:
+    MACHINE: 96b-nitrogen
+
+zephyr-96b-avenger:
+  extends: .build-zephyr
+  variables:
+    MACHINE: 96b-avenger96
+
+freertos-armv5:
+  extends: .build-freertos
+  variables:
+    MACHINE: qemuarmv5
+    # See the note on linux-qemu-x86.
+    OHOS_BUILD_CACHE: "pub"
+    OHOS_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1
diff --git a/docs/ci/index.rst b/docs/ci/index.rst
new file mode 100644
index 00000000..5a81e12a
--- /dev/null
+++ b/docs/ci/index.rst
@@ -0,0 +1,11 @@
+.. SPDX-FileCopyrightText: Huawei Inc.
+..
+.. SPDX-License-Identifier: CC-BY-4.0
+
+Continuous Integration
+======================
+
+.. toctree::
+   :maxdepth: 1
+      
+   machines-and-flavours
diff --git a/docs/ci/machines-and-flavours.rst b/docs/ci/machines-and-flavours.rst
new file mode 100644
index 00000000..b321d869
--- /dev/null
+++ b/docs/ci/machines-and-flavours.rst
@@ -0,0 +1,147 @@
+.. SPDX-FileCopyrightText: Huawei Inc.
+..
+.. SPDX-License-Identifier: CC-BY-4.0
+
+Machines and Flavours
+---------------------
+
+The following GitLab job definitions are included by the central shared
+pipelines in the manifest repository and constitute the set of supported
+combination of ``FLAVOUR`` and ``MACHINE``.
+
+.. warning::
+
+    Do not include YAML files from the meta-ohos repository directly. The
+    primary entry point for build and test pipelines is defined by the manifest
+    repository.
+
+linux-qemu-x86
+..............
+
+This job extends `.build-linux` job from the manifest repository and builds
+``allscenarios-image-base-tests`` and ``allscenarios-image-extra-tests`` using
+the Linux flavour of All Scenarios OS and ``MACHINE=qemux86``. This job checks that
+All Scenarios OS software can be built for a basic 32bit x86 virtual machine.
+
+The cache for this job is publicly available.
+
+linux-qemu-x86_64
+.................
+
+This job extends `.build-linux` job from the manifest repository and builds
+``allscenarios-image-base-tests`` and ``allscenarios-image-extra-tests`` using
+the Linux flavour of All Scenarios OS and ``MACHINE=qemux86-64``. This job checks that
+All Scenarios OS software can be built for a basic 64bit x86 virtual machine.
+
+The cache for this job is publicly available.
+
+linux-qemu-arm
+..............
+
+This job extends `.build-linux` job from the manifest repository and builds
+``allscenarios-image-base-tests`` and ``allscenarios-image-extra-tests`` using
+the Linux flavour of All Scenarios OS and ``MACHINE=qemuarm``. This job checks that
+All Scenarios OS software can be built for a basic 32bit ARMv7 virtual machine.
+
+The cache for this job is publicly available.
+
+linux-qemu-arm64
+................
+
+This job extends `.build-linux` job from the manifest repository and builds
+``allscenarios-image-base-tests`` and ``allscenarios-image-extra-tests`` using
+the Linux flavour of All Scenarios OS and ``MACHINE=qemuarm64``. This job checks that
+All Scenarios OS software can be built for a basic 64bit ARMv8 virtual machine.
+
+The cache for this job is publicly available.
+
+linux-seco-intel-b68
+....................
+
+This job extends `.build-linux` job from the manifest repository and builds
+``allscenarios-image-base-tests`` and ``allscenarios-image-extra-tests`` using
+the Linux flavour of All Scenarios OS and ``MACHINE=seco-intel-b68``. This job
+checks that All Scenarios OS software can be built for the SECO B68 development
+board, which contains an Intel x86_64 SoC.
+
+The cache for this job is not public, pending legal review of any firmware that
+may be included.
+
+linux-seco-imx8mm-c61
+.....................
+
+This job extends `.build-linux` job from the manifest repository and builds
+``allscenarios-image-base-tests`` and ``allscenarios-image-extra-tests`` using
+the Linux flavour of All Scenarios OS and ``MACHINE=seco-imx8mm-c61``. This job
+checks that All Scenarios OS software can be built for the SECO C61 development
+board, which contains the NXP i.MX 8M Mini SoC, which implements 64bit ARMv8
+architecture.
+
+The cache for this job is not public, as it contains proprietary elements that
+cannot be redistributed without an agreement with Freescale.
+
+linux-stm32mp1-av96
+...................
+
+This job extends `.build-linux` job from the manifest repository and builds
+``allscenarios-image-base-tests`` and ``allscenarios-image-extra-tests`` using
+the Linux flavour of All Scenarios OS and ``MACHINE=stm32mp1-av96``. This job checks
+that All Scenarios OS software can be built for the 96Boards Avenger development
+board, which contains the STM32MP157 SoC, which implements 32bit ARMv7
+architecture.
+
+The cache for this job is not public, pending legal review of any firmware that
+may be included.
+
+zephyr-qemu-x86
+...............
+
+This job extends `.build-zephyr` job from the manifest repository and builds
+``zephyr-philosophers`` using the Zephyr flavour of All Scenarios OS and
+``MACHINE=qemu-x86``. This job checks that Zephyr can be built for a basic
+32bit x86 virtual machine.
+
+The cache for this job is publicly available.
+
+zephyr-qemu-cortex-m3
+.....................
+
+This job extends `.build-zephyr` job from the manifest repository and builds
+``zephyr-philosophers`` using the Zephyr flavour of All Scenarios OS and
+``MACHINE=qemu-cortex-m3``. This job checks that Zephyr can be built for a
+basic 32bit ARM micro-controller virtual machine.
+
+The cache for this job is publicly available.
+
+zephyr-96b-nitrogen
+...................
+
+This job extends `.build-zephyr` job from the manifest repository and builds
+``zephyr-philosophers`` using the Zephyr flavour of All Scenarios OS and
+``MACHINE=96b-nitrogen``. This job checks that Zephyr can be built for the
+96Boards Nitrogen development board, which contains an nRF52832 SoC.
+
+The cache for this job is not public, pending legal review of any firmware that
+may be included.
+
+zephyr-96b-avenger
+..................
+
+This job extends `.build-zephyr` job from the manifest repository and builds
+``zephyr-philosophers`` using the Zephyr flavour of All Scenarios OS and
+``MACHINE=96b-avenger96``. This job checks that Zephyr can be built for the
+96Boards Avenger development board cortex-M3 core, embedded into STM32MP157
+SoC.
+
+The cache for this job is not public, pending legal review of any firmware that
+may be included.
+
+freertos-armv5
+..............
+
+This job extends `.build-freertos` job from the manifest repository and builds
+``freertos-demo`` using the FreeRTOS flavour of All Scenarios OS and
+``MACHINE=qemuarmv5``. This job checks that FreeRTOS can be built for a basic
+32bit ARMv5 micro-controller virtual machine.
+
+The cache for this job is publicly available.
diff --git a/docs/index.rst b/docs/index.rst
index f9be8f42..f5c6cbe8 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -13,5 +13,6 @@ Build system documentation
    repo-workspace
    build-flavours/index
    ohos-build/index
+   ci/index
    blueprints/index
    hardware-support/index
-- 
GitLab