From e419c60b97cf88c850a2a0233c01a9bff18a5b7e Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Sun, 24 Mar 2024 21:09:16 +0000 Subject: [PATCH] feat(build): Allow specifying snippets for a build. * Allow using snippets https://docs.zephyrproject.org/latest/build/snippets/using.html for user builds in a `snippets` array propertly. --- .github/workflows/build-user-config.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index d8ea057e56df..9565fc98711a 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -59,12 +59,16 @@ jobs: run: | echo "build_dir=$(mktemp -d)" >> $GITHUB_ENV + - name: Install yaml2json + run: apt-get update && apt-get install -y jq python3-pip && python3 -m pip install remarshal + - name: Prepare variables shell: sh -x {0} env: board: ${{ matrix.board }} shield: ${{ matrix.shield }} artifact_name: ${{ matrix.artifact-name }} + job_index: ${{ strategy.job-index }} run: | if [ -e zephyr/module.yml ]; then export zmk_load_arg=" -DZMK_EXTRA_MODULES='${GITHUB_WORKSPACE}'" @@ -75,7 +79,11 @@ jobs: echo "base_dir=${GITHUB_WORKSPACE}" >> $GITHUB_ENV fi + # Pull the snippets array for each matrix entry, and create a single string from it + extra_west_args=$(yaml2json "${{ inputs.build_matrix_path }}" | jq -r -c ".include[${job_index}].snippets | map(\"-S \" +.) | join(\" \")") + echo "zephyr_version=${ZEPHYR_VERSION}" >> $GITHUB_ENV + echo "extra_west_args=${extra_west_args}" >> $GITHUB_ENV echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}${zmk_load_arg}" >> $GITHUB_ENV echo "display_name=${shield:+$shield - }${board}" >> $GITHUB_ENV echo "artifact_name=${artifact_name:-${shield:+$shield-}${board}-zmk}" >> $GITHUB_ENV @@ -120,7 +128,7 @@ jobs: - name: West Build (${{ env.display_name }}) working-directory: ${{ env.base_dir }} shell: sh -x {0} - run: west build -s zmk/app -d "${{ env.build_dir }}" -b "${{ matrix.board }}" -- -DZMK_CONFIG=${{ env.base_dir }}/${{ inputs.config_path }} ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }} + run: west build -s zmk/app -d "${{ env.build_dir }}" -b "${{ matrix.board }}" ${{ env.extra_west_args }} -- -DZMK_CONFIG=${{ env.base_dir }}/${{ inputs.config_path }} ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }} - name: ${{ env.display_name }} Kconfig file run: |