From 5946d0a3076b273a360fbcf48d575873b860422e Mon Sep 17 00:00:00 2001 From: magi-arun <110526558+magi-arun@users.noreply.github.com> Date: Tue, 21 Nov 2023 16:48:17 +0100 Subject: [PATCH] feat: add targets in order upgrade pack (#476) * build(deps): bump github/codeql-action from 2.21.6 to 2.21.7 (#417) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.6 to 2.21.7. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/701f152f28d4350ad289a5e31435e9ab6169a7ca...04daf014b50eaf774287bf3f0f1869d4b4c4b913) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ci: consolidate configurations (#411) * ci: consolidate configurations * Change Package config into Host-Single-MinSizeRel, split Windows/MacOS workflows * Add Host-Single-Debug, use for MacOS ci * Disable sccache for Windows build * Consolidate Windows and MacOS builds * Explicitly enable tests * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Use the correct configuration for the test preset * Presets now start with a lower case character * Presets now start with a lower case character * Presets now start with a lower case character * Update CMakePresets.json Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * .github/workflows/ci.yml: small improvements --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * build(deps): bump actions/checkout from 4.0.0 to 4.1.0 (#420) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.0.0 to 4.1.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/3df4ab11eba7bda6032a0b82a6bb43b11571feac...8ade135a41bc03ea155e62e844d188df1ea18608) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump actions/first-interaction from 1.1.1 to 1.2.0 (#421) Bumps [actions/first-interaction](https://github.com/actions/first-interaction) from 1.1.1 to 1.2.0. - [Release notes](https://github.com/actions/first-interaction/releases) - [Commits](https://github.com/actions/first-interaction/compare/1d8459ca65b335265f1285568221e229d45a995e...1dbfe1ba5525b8257e1f259b09745bee346d62d8) --- updated-dependencies: - dependency-name: actions/first-interaction dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github/codeql-action from 2.21.7 to 2.21.9 (#422) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.7 to 2.21.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/04daf014b50eaf774287bf3f0f1869d4b4c4b913...ddccb873888234080b77e9bc2d4764d5ccaaccf9) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: switch static analysis to container (#423) * chore: update devcontainer * chore: switch static analysis to container * chore: use correct configurations * chore: remove workaround for missing symlinks When running into issues using mutation testing, please update your local devcontainer. * chore: use correct mutation-testing preset * chore: update CMakePresets.json * chore: update googletest * chore: use nproc for -j parameters * chore: revert version update in CMakePresets.json * deps: update mbedtls to 3.4.1 to silence warning See: https://github.com/Mbed-TLS/mbedtls/pull/7098 * chore: fix compilation with clang-15 * chore: fix remaining issues * feat: add order to pack upg supported targets * resolve review comments * refactor: resolved review comments * refactor: resolved review comments * style: fix build * refactor: resolved review comments * Update upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * review comments resolved * fix review comments * Update upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp Co-authored-by: Richard Peters * refactor: fix review comments --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Richard Peters Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Ron <45816308+rjaegers@users.noreply.github.com> --- .clusterfuzzlite/build.sh | 6 +- .devcontainer/devcontainer.json | 2 +- .github/workflows/ci.yml | 35 ++-- .github/workflows/dependency-scanner.yml | 4 +- .github/workflows/documentation.yml | 6 +- .github/workflows/linting-formatting.yml | 6 +- .github/workflows/release-please.yml | 6 +- .github/workflows/security.yml | 4 +- .github/workflows/social-interaction.yml | 2 +- .github/workflows/static-analysis.yml | 51 +++-- CMakePresets.json | 177 +++++++++--------- cmake/emil_test_helpers.cmake | 37 ++-- external/crypto/mbedtls/CMakeLists.txt | 4 + upgrade/pack_builder/SupportedTargets.cpp | 22 +++ upgrade/pack_builder/SupportedTargets.hpp | 11 ++ .../test/TestSupportedTargets.cpp | 37 ++++ .../UpgradePackBuilderFacade.cpp | 40 ++++ .../UpgradePackBuilderFacade.hpp | 6 + 18 files changed, 282 insertions(+), 174 deletions(-) diff --git a/.clusterfuzzlite/build.sh b/.clusterfuzzlite/build.sh index 5cfed44fe..b185aec90 100644 --- a/.clusterfuzzlite/build.sh +++ b/.clusterfuzzlite/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -eu -cmake --preset Fuzzing -cmake --build --preset Fuzzing +cmake --preset fuzzing +cmake --build --preset fuzzing -cp build/Fuzzing/infra/syntax/fuzz/infra.syntax_json_fuzzer $OUT/infra-syntax_json_fuzzer +cp build/fuzzing/infra/syntax/fuzz/infra.syntax_json_fuzzer $OUT/infra-syntax_json_fuzzer diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index df9f970f3..b91420f74 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ // This devcontainer has been set-up to run docker-from-docker scenarios as per // https://github.com/microsoft/vscode-dev-containers/tree/main/containers/docker-from-docker "name": "amp-devcontainer", - "image": "ghcr.io/philips-software/amp-devcontainer:2.2.0", + "image": "ghcr.io/philips-software/amp-devcontainer:2.5.0", "runArgs": ["--add-host=host.docker.internal:host-gateway"], "remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" }, "mounts": [ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6c8f95ff..485e695a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,30 +22,31 @@ jobs: name: Host Build & Test (ubuntu-latest) runs-on: ubuntu-latest steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: persist-credentials: false - uses: hendrikmuhs/ccache-action@6d1841ec156c39a52b1b23a810da917ab98da1f4 # v1.2.10 with: key: ${{ github.job }}-ubuntu-latest variant: sccache + - uses: seanmiddleditch/gha-setup-ninja@16b940825621068d98711680b6c3ff92201f8fc0 # v3 - uses: lukka/run-cmake@c2b72aff009141774c5a5fabe74ea46c8c04d9c4 # v10.6 with: - configurePreset: "ContinuousIntegration" - buildPreset: "ContinuousIntegrationWithPackage" - testPreset: "ContinuousIntegration" + configurePreset: "host" + buildPreset: "host-Debug-WithPackage" + testPreset: "host" configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache']" - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 with: name: emil - path: build/ContinuousIntegration/emil-*-Linux.tar.gz + path: build/host/emil-*-Linux.tar.gz if-no-files-found: error - name: Upload test logs if: ${{ failure() }} uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 with: name: test-logs - path: build/ContinuousIntegration/Testing/Temporary/ + path: build/host/Testing/Temporary/ host_build_test: name: Host Build & Test runs-on: ${{ matrix.os }} @@ -53,7 +54,7 @@ jobs: matrix: os: [macos-latest, windows-latest, windows-2019] steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: persist-credentials: false - uses: hendrikmuhs/ccache-action@6d1841ec156c39a52b1b23a810da917ab98da1f4 # v1.2.10 @@ -62,16 +63,16 @@ jobs: variant: sccache - uses: lukka/run-cmake@c2b72aff009141774c5a5fabe74ea46c8c04d9c4 # v10.6 with: - configurePreset: "ContinuousIntegration" - buildPreset: "ContinuousIntegration" - testPreset: "ContinuousIntegration" + configurePreset: "host-single-Debug" + buildPreset: "host-single-Debug" + testPreset: "host-single-Debug" configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache']" - name: Upload test logs if: ${{ failure() }} uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 with: name: test-logs - path: build/ContinuousIntegration/Testing/Temporary/ + path: build/host/Testing/Temporary/ embedded_build: name: Embedded Build runs-on: ubuntu-latest @@ -81,7 +82,7 @@ jobs: gcc: ["7-2018-q2", "8-2019-q3", "9-2020-q2", "10.3-2021.10"] configuration: ["RelWithDebInfo"] steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: persist-credentials: false - name: Install GNU Arm Embedded Toolchain ${{ matrix.gcc }} @@ -99,8 +100,8 @@ jobs: - run: mkdir install && mv emil-*/* install/ - uses: lukka/run-cmake@c2b72aff009141774c5a5fabe74ea46c8c04d9c4 # v10.6 with: - configurePreset: "Embedded" - buildPreset: "Embedded-${{ matrix.configuration }}" + configurePreset: "embedded" + buildPreset: "embedded-${{ matrix.configuration }}" configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']" rtos: name: Embedded Build - RTOS @@ -110,7 +111,7 @@ jobs: matrix: rtos: ["FreeRTOS", "ThreadX"] steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: persist-credentials: false - name: Install GNU Arm Embedded Toolchain "10.3-2021.10" @@ -128,6 +129,6 @@ jobs: - run: mkdir install && mv emil-*/* install/ - uses: lukka/run-cmake@c2b72aff009141774c5a5fabe74ea46c8c04d9c4 # v10.6 with: - configurePreset: "Embedded-${{ matrix.rtos }}" - buildPreset: "Embedded-${{ matrix.rtos }}-RelWithDebInfo" + configurePreset: "embedded-${{ matrix.rtos }}" + buildPreset: "embedded-${{ matrix.rtos }}-RelWithDebInfo" configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']" diff --git a/.github/workflows/dependency-scanner.yml b/.github/workflows/dependency-scanner.yml index 36efe6a3c..1f584aaa8 100644 --- a/.github/workflows/dependency-scanner.yml +++ b/.github/workflows/dependency-scanner.yml @@ -16,7 +16,7 @@ jobs: contents: write pull-requests: write steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - uses: philips-forks/cmake-dependency-submission@72880580a7cafc16145d82268f1892c0ece3da2a # main dependency-review: runs-on: ubuntu-latest @@ -25,7 +25,7 @@ jobs: permissions: pull-requests: write steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - uses: actions/dependency-review-action@6c5ccdad469c9f8a2996bfecaec55a631a347034 # v3.1.0 with: comment-summary-in-pr: true diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 7da7a10ac..7bd5a63db 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -16,7 +16,7 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} steps: - name: Checkout - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: fetch-depth: 0 persist-credentials: false @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: fetch-depth: 0 persist-credentials: false @@ -69,7 +69,7 @@ jobs: name: Publish to GitHub Pages steps: - name: Checkout - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - name: Retrieve Antora Site uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 with: diff --git a/.github/workflows/linting-formatting.yml b/.github/workflows/linting-formatting.yml index a68c358f9..8c5a4c61d 100644 --- a/.github/workflows/linting-formatting.yml +++ b/.github/workflows/linting-formatting.yml @@ -21,7 +21,7 @@ jobs: contents: read pull-requests: write steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: persist-credentials: false - uses: DoozyX/clang-format-lint-action@a83a8fb7d371f66da7dd1c4f33a193023899494b # v0.16 @@ -42,7 +42,7 @@ jobs: pull-requests: write security-events: write steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: fetch-depth: 0 persist-credentials: false @@ -51,7 +51,7 @@ jobs: APPLY_FIXES: all VALIDATE_ALL_CODEBASE: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: github/codeql-action/upload-sarif@701f152f28d4350ad289a5e31435e9ab6169a7ca # v2.21.6 + - uses: github/codeql-action/upload-sarif@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9 if: ${{ success() }} || ${{ failure() }} with: sarif_file: megalinter-reports/megalinter-report.sarif diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 0778da3c1..9714fc9cc 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -43,7 +43,7 @@ jobs: matrix: os: [macos-latest, ubuntu-latest, windows-latest] steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: persist-credentials: false - uses: hendrikmuhs/ccache-action@6d1841ec156c39a52b1b23a810da917ab98da1f4 # v1.2.10 @@ -52,8 +52,8 @@ jobs: variant: sccache - uses: lukka/run-cmake@c2b72aff009141774c5a5fabe74ea46c8c04d9c4 # v10.6 with: - configurePreset: "Package" - buildPreset: "Package" + configurePreset: "host-single-MinSizeRel" + buildPreset: "release-package" configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache']" - run: gh release upload ${{ needs.release_please.outputs.tag_name }} build/**/emil-*.zip --clobber shell: bash diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index a47c33359..858a8e9bd 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -21,7 +21,7 @@ jobs: actions: read contents: read steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: persist-credentials: false - name: Analysis @@ -31,6 +31,6 @@ jobs: results_format: sarif repo_token: ${{ secrets.SCORECARD_READ_TOKEN }} publish_results: true - - uses: github/codeql-action/upload-sarif@701f152f28d4350ad289a5e31435e9ab6169a7ca # v2.21.6 + - uses: github/codeql-action/upload-sarif@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9 with: sarif_file: scorecards.sarif diff --git a/.github/workflows/social-interaction.yml b/.github/workflows/social-interaction.yml index f03c75c26..ab77aaa8c 100644 --- a/.github/workflows/social-interaction.yml +++ b/.github/workflows/social-interaction.yml @@ -14,7 +14,7 @@ jobs: pull-requests: write if: ${{ github.actor != 'dependabot[bot]' }} steps: - - uses: actions/first-interaction@1d8459ca65b335265f1285568221e229d45a995e + - uses: actions/first-interaction@1dbfe1ba5525b8257e1f259b09745bee346d62d8 continue-on-error: true with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 6853e071e..e6af0dae3 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -18,47 +18,42 @@ jobs: sonar: name: SonarCloud runs-on: ubuntu-latest + container: ghcr.io/philips-software/amp-devcontainer:2.5.0 env: - SONAR_SCANNER_VERSION: 4.7.0.2747 + SONAR_SCANNER_VERSION: 5.0.1.3006 SONAR_SERVER_URL: "https://sonarcloud.io" steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: fetch-depth: 0 # Disable shallow clone to enable blame information persist-credentials: false - - run: sudo apt-get update && sudo apt-get install --no-install-recommends jq ninja-build xsltproc - - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 - - uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 - with: - packages: gcovr==5.2 - - name: Install Sonar Scanner & Mull + - name: Install Sonar Scanner run: | wget -qN "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip" unzip -qqo "sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip" echo "${PWD}/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> "$GITHUB_PATH" - wget -qN https://github.com/mull-project/mull/releases/download/0.18.0/Mull-12-0.18.0-LLVM-12.0-ubuntu-20.04.deb - sudo dpkg -i Mull-12-0.18.0-LLVM-12.0-ubuntu-20.04.deb - uses: hendrikmuhs/ccache-action@6d1841ec156c39a52b1b23a810da917ab98da1f4 # v1.2.10 with: key: ${{ github.job }} max-size: 2G - name: Build & Collect Coverage run: | - cmake --preset Coverage -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - cmake --build --preset Coverage - GTEST_OUTPUT="xml:${PWD}/testresults/" ctest --preset Coverage - gcovr --sonarqube=coverage.xml --exclude-lines-by-pattern '.*assert\(.*\);|.*really_assert\(.*\);|.*std::abort();' --exclude-unreachable-branches --exclude-throw-branches -j 2 --exclude=.*/generated/.* --exclude=.*/examples/.* --exclude=.*/external/.* --exclude=.*/lwip/.* --exclude=.*/tracing/.* --exclude=.*/test/.* - - name: Build & Run Mutation Tests - run: | - cmake --preset MutationTesting -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - cmake --build --preset MutationTesting - ctest --preset MutationTesting + cmake --preset coverage -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build --preset coverage + GTEST_OUTPUT="xml:${PWD}/testresults/" ctest --preset coverage + gcovr --sonarqube=coverage.xml --exclude-lines-by-pattern '.*assert\(.*\);|.*really_assert\(.*\);|.*std::abort();' --exclude-unreachable-branches --exclude-throw-branches -j "$(nproc)" --exclude=.*/generated/.* --exclude=.*/examples/.* --exclude=.*/external/.* --exclude=.*/lwip/.* --exclude=.*/tracing/.* --exclude=.*/test/.* + - uses: lukka/run-cmake@c2b72aff009141774c5a5fabe74ea46c8c04d9c4 # v10.6 + with: + configurePreset: "mutation-testing" + buildPreset: "mutation-testing" + testPreset: "mutation-testing" + configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']" - name: Convert Results run: | { echo ''; xsltproc .github/formatters/gtest-to-generic-execution.xslt testresults/*.xml; echo ''; } | tee execution.xml > /dev/null jq -s 'reduce .[] as $item ({}; . * $item)' reports/mull/*.json > reports/mull/merged-mutation.json jq --arg workspace "$GITHUB_WORKSPACE" -f .github/formatters/mutation-report-to-generic-issue.jq reports/mull/merged-mutation.json > mutation-sonar.json - cp build/Coverage/compile_commands.json compile_commands.json + cp build/coverage/compile_commands.json compile_commands.json - name: Run Analysis # skip the analysis step for dependabot PRs since dependabot does not have access to secrets if: ${{ github.actor != 'dependabot[bot]' }} @@ -70,20 +65,22 @@ jobs: codeql: name: CodeQL runs-on: ubuntu-latest + container: ghcr.io/philips-software/amp-devcontainer:2.5.0 permissions: security-events: write steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: persist-credentials: false - - run: sudo apt-get update && sudo apt-get install ninja-build - uses: hendrikmuhs/ccache-action@6d1841ec156c39a52b1b23a810da917ab98da1f4 # v1.2.10 with: key: ${{ github.job }} - - uses: github/codeql-action/init@701f152f28d4350ad289a5e31435e9ab6169a7ca # v2.21.6 + - uses: github/codeql-action/init@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9 with: languages: cpp - - run: | - cmake --preset ContinuousIntegration -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - cmake --build --preset ContinuousIntegration - - uses: github/codeql-action/analyze@701f152f28d4350ad289a5e31435e9ab6169a7ca # v2.21.6 + - uses: lukka/run-cmake@c2b72aff009141774c5a5fabe74ea46c8c04d9c4 # v10.6 + with: + configurePreset: "host" + buildPreset: "host-Debug" + configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']" + - uses: github/codeql-action/analyze@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9 diff --git a/CMakePresets.json b/CMakePresets.json index 99cdfaf78..1442446cf 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,51 +12,57 @@ } }, { - "name": "ContinuousIntegration", - "displayName": "Configuration for Continuous Integration", + "name": "host", + "displayName": "Configuration for Host Tooling and Tests", + "inherits": "defaults", + "cacheVariables": { + "CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel" + }, + "generator": "Ninja Multi-Config" + }, + { + "name": "host-single-Debug", + "displayName": "Configuration for Host Tooling and Tests, Single Config Generator, Debug", "inherits": "defaults", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "EMIL_ENABLE_DOCKER_TOOLS": "Off", - "EMIL_BUILD_EXAMPLES": "On" + "EMIL_ENABLE_DOCKER_TOOLS": "Off" } }, { - "name": "Package", - "displayName": "Configuration for CPack package generation", + "name": "host-single-MinSizeRel", + "displayName": "Configuration for Host Tooling and Tests, Single Config Generator, MinSizeRel", "inherits": "defaults", "cacheVariables": { "CMAKE_BUILD_TYPE": "MinSizeRel", - "EMIL_ENABLE_DOCKER_TOOLS": "Off", - "EMIL_BUILD_TESTS": "Off", - "EMIL_BUILD_EXAMPLES": "Off" + "EMIL_ENABLE_DOCKER_TOOLS": "Off" } }, { - "name": "Coverage", + "name": "coverage", "displayName": "Configuration for Code Coverage", - "inherits": "ContinuousIntegration", + "inherits": "host", "cacheVariables": { "EMIL_ENABLE_COVERAGE": "On" }, "generator": "Ninja" }, { - "name": "MutationTesting", + "name": "mutation-testing", "displayName": "Configuration for Mutation Testing", - "inherits": "ContinuousIntegration", + "inherits": "host", "cacheVariables": { - "CMAKE_C_COMPILER": "clang-12", - "CMAKE_CXX_COMPILER": "clang++-12", + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", "EMIL_ENABLE_MUTATION_TESTING": "On", - "EMIL_MUTATION_TESTING_RUNNER_ARGUMENTS": "--reporters;Elements;--report-dir;${sourceDir}/reports/mull" + "EMIL_MUTATION_TESTING_RUNNER_ARGUMENTS": "--allow-surviving;--reporters;Elements;--report-dir;${sourceDir}/reports/mull" }, "generator": "Ninja" }, { - "name": "Fuzzing", + "name": "fuzzing", "displayName": "Configuration for Fuzzing", - "inherits": "ContinuousIntegration", + "inherits": "host", "cacheVariables": { "CMAKE_C_COMPILER": "clang", "CMAKE_CXX_COMPILER": "clang++", @@ -67,18 +73,7 @@ "generator": "Ninja" }, { - "name": "Host", - "displayName": "Configuration for Host Tooling", - "inherits": "defaults", - "cacheVariables": { - "CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel", - "EMIL_BUILD_TESTS": "Off", - "EMIL_BUILD_EXAMPLES": "Off" - }, - "generator": "Ninja Multi-Config" - }, - { - "name": "HostClangMsvc", + "name": "host-ClangMsvc", "displayName": "Configuration for Host Tooling using clang-cl to target Windows", "inherits": "defaults", "toolchainFile": "${sourceDir}/cmake/toolchain-clang-x86_64-pc-windows-msvc.cmake", @@ -91,8 +86,8 @@ "generator": "Ninja Multi-Config" }, { - "name": "Embedded", - "displayName": "Configuration for Embedded", + "name": "embedded", + "displayName": "Configuration for embedded", "inherits": "defaults", "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake", "cacheVariables": { @@ -102,18 +97,18 @@ "generator": "Ninja Multi-Config" }, { - "name": "Embedded-FreeRTOS", - "displayName": "Configuration for Embedded with FreeRTOS", - "inherits": "Embedded", + "name": "embedded-FreeRTOS", + "displayName": "Configuration for embedded with FreeRTOS", + "inherits": "embedded", "cacheVariables": { "EMIL_INCLUDE_FREERTOS": "On", "FREERTOS_CONFIG_FILE_DIRECTORY": "${sourceDir}/examples/threading/config" } }, { - "name": "Embedded-ThreadX", - "displayName": "Configuration for Embedded with ThreadX", - "inherits": "Embedded", + "name": "embedded-ThreadX", + "displayName": "Configuration for embedded with ThreadX", + "inherits": "embedded", "cacheVariables": { "EMIL_INCLUDE_THREADX": "On" } @@ -121,96 +116,96 @@ ], "buildPresets": [ { - "name": "ContinuousIntegration", + "name": "host-Debug", "configuration": "Debug", - "configurePreset": "ContinuousIntegration" + "configurePreset": "host" }, { - "name": "ContinuousIntegrationWithPackage", + "name": "host-Debug-WithPackage", "configuration": "Debug", - "configurePreset": "ContinuousIntegration", + "configurePreset": "host", "targets": ["all", "package"] }, { - "name": "Package", - "configuration": "MinSizeRel", - "configurePreset": "Package", - "targets": ["package"] + "name": "host-Release", + "configuration": "Release", + "configurePreset": "host" }, { - "name": "Coverage", - "configuration": "Debug", - "configurePreset": "Coverage" + "name": "host-RelWithDebInfo", + "configuration": "RelWithDebInfo", + "configurePreset": "host" }, { - "name": "MutationTesting", - "configuration": "Debug", - "configurePreset": "MutationTesting" + "name": "host-MinSizeRel", + "configuration": "MinSizeRel", + "configurePreset": "host" }, { - "name": "Fuzzing", + "name": "host-single-Debug", "configuration": "Debug", - "configurePreset": "Fuzzing" + "configurePreset": "host-single-Debug" }, { - "name": "Host-Debug", - "configuration": "Debug", - "configurePreset": "Host" + "name": "release-package", + "configuration": "MinSizeRel", + "configurePreset": "host-single-MinSizeRel", + "targets": ["package"] }, { - "name": "Host-Release", - "configuration": "Release", - "configurePreset": "Host" + "name": "coverage", + "configuration": "Debug", + "configurePreset": "coverage" }, { - "name": "Host-RelWithDebInfo", - "configuration": "RelWithDebInfo", - "configurePreset": "Host" + "name": "mutation-testing", + "configuration": "Debug", + "configurePreset": "mutation-testing" }, { - "name": "Host-MinSizeRel", - "configuration": "MinSizeRel", - "configurePreset": "Host" + "name": "fuzzing", + "configuration": "Debug", + "configurePreset": "fuzzing" }, { - "name": "HostClangMsvc-Debug", + "name": "host-ClangMsvc-Debug", "configuration": "Debug", - "configurePreset": "HostClangMsvc" + "configurePreset": "host-ClangMsvc" }, { - "name": "HostClangMsvc-RelWithDebInfo", + "name": "host-ClangMsvc-RelWithDebInfo", "configuration": "RelWithDebInfo", - "configurePreset": "HostClangMsvc" + "configurePreset": "host-ClangMsvc" }, { - "name": "Embedded-Debug", + "name": "embedded-Debug", "configuration": "Debug", - "configurePreset": "Embedded" + "configurePreset": "embedded" }, { - "name": "Embedded-Release", + "name": "embedded-Release", "configuration": "Release", - "configurePreset": "Embedded" + "configurePreset": "embedded" }, { - "name": "Embedded-RelWithDebInfo", + "name": "embedded-RelWithDebInfo", "configuration": "RelWithDebInfo", - "configurePreset": "Embedded" + "configurePreset": "embedded" }, { - "name": "Embedded-MinSizeRel", + "name": "embedded-MinSizeRel", "configuration": "MinSizeRel", - "configurePreset": "Embedded" + "configurePreset": "embedded" }, { - "name": "Embedded-FreeRTOS-RelWithDebInfo", + "name": "embedded-FreeRTOS-RelWithDebInfo", "configuration": "RelWithDebInfo", - "configurePreset": "Embedded-FreeRTOS" + "configurePreset": "embedded-FreeRTOS" }, { - "name": "Embedded-ThreadX-RelWithDebInfo", + "name": "embedded-ThreadX-RelWithDebInfo", "configuration": "RelWithDebInfo", - "configurePreset": "Embedded-ThreadX" + "configurePreset": "embedded-ThreadX" } ], "testPresets": [ @@ -226,20 +221,26 @@ } }, { - "name": "ContinuousIntegration", - "configurePreset": "ContinuousIntegration", + "name": "host", + "configurePreset": "host", + "configuration": "Debug", + "inherits": "defaults" + }, + { + "name": "host-single-Debug", + "configurePreset": "host-single-Debug", "configuration": "Debug", "inherits": "defaults" }, { - "name": "Coverage", - "configurePreset": "Coverage", + "name": "coverage", + "configurePreset": "coverage", "configuration": "Debug", "inherits": "defaults" }, { - "name": "MutationTesting", - "configurePreset": "MutationTesting", + "name": "mutation-testing", + "configurePreset": "mutation-testing", "configuration": "Debug", "inherits": "defaults", "output": { diff --git a/cmake/emil_test_helpers.cmake b/cmake/emil_test_helpers.cmake index 5be8b44f7..3336f6ee7 100644 --- a/cmake/emil_test_helpers.cmake +++ b/cmake/emil_test_helpers.cmake @@ -2,12 +2,10 @@ option(EMIL_ENABLE_COVERAGE "Enable compiler flags for code coverage measurement option(EMIL_ENABLE_MUTATION_TESTING "Enable compiler flags for mutation testing" Off) set(EMIL_MUTATION_TESTING_RUNNER_ARGUMENTS "" CACHE STRING "Additional arguments for the mutation testing runner") -function(emil_enable_testing) - include(GoogleTest) - +function(emil_fetch_googletest) FetchContent_Declare( googletest - GIT_REPOSITORY https://github.com/google/googletest.git + GIT_REPOSITORY https://github.com/google/googletest GIT_TAG release-1.12.1 ) @@ -18,6 +16,12 @@ function(emil_enable_testing) set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES FOLDER External/GoogleTest) mark_as_advanced(BUILD_GMOCK BUILD_GTEST BUILD_SHARED_LIBS gmock_build_tests gtest_build_samples test_build_tests gtest_disable_pthreads gtest_force_shared_crt gtest_hide_internal_symbols) +endfunction() + +function(emil_enable_testing) + include(GoogleTest) + + emil_fetch_googletest() if (EMIL_ENABLE_COVERAGE) add_compile_options( @@ -34,19 +38,10 @@ function(emil_enable_testing) if (EMIL_ENABLE_MUTATION_TESTING) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION) - - if(CLANG_VERSION VERSION_GREATER 15.0 OR CLANG_VERSION VERSION_EQUAL 15.0) - add_compile_options( - -g -O0 -grecord-command-line -fprofile-instr-generate -fcoverage-mapping - -fexperimental-new-pass-manager -fpass-plugin=/usr/lib/mull-ir-frontend - ) - else() - add_compile_options( - -g -O0 -grecord-command-line -fprofile-instr-generate -fcoverage-mapping - -fexperimental-new-pass-manager -fpass-plugin=/usr/lib/mull-ir-frontend-12 - ) - endif() + add_compile_options( + -g -O0 -grecord-command-line -fprofile-instr-generate -fcoverage-mapping + -fexperimental-new-pass-manager -fpass-plugin=/usr/lib/mull-ir-frontend + ) add_link_options(-fprofile-instr-generate) else() @@ -68,13 +63,7 @@ function(emil_add_test target) get_target_property(exclude ${target} EXCLUDE_FROM_ALL) if (NOT ${exclude}) if (EMIL_ENABLE_MUTATION_TESTING) - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION) - - if(CLANG_VERSION VERSION_GREATER 15.0 OR CLANG_VERSION VERSION_EQUAL 15.0) - add_test(NAME ${target} COMMAND mull-runner ${EMIL_MUTATION_TESTING_RUNNER_ARGUMENTS} $) - else() - add_test(NAME ${target} COMMAND mull-runner-12 ${EMIL_MUTATION_TESTING_RUNNER_ARGUMENTS} $) - endif() + add_test(NAME ${target} COMMAND mull-runner ${EMIL_MUTATION_TESTING_RUNNER_ARGUMENTS} $) else() add_test(NAME ${target} COMMAND ${target}) endif() diff --git a/external/crypto/mbedtls/CMakeLists.txt b/external/crypto/mbedtls/CMakeLists.txt index db0eb2144..b5514e418 100644 --- a/external/crypto/mbedtls/CMakeLists.txt +++ b/external/crypto/mbedtls/CMakeLists.txt @@ -17,6 +17,10 @@ function(add_mbedtls_target_properties) foreach(target ${ARGN}) target_compile_options(${target} PUBLIC -DMBEDTLS_CONFIG_FILE="mbedtls/mbedtls_emil_config.h" + # see https://github.com/Mbed-TLS/mbedtls/pull/6966 + # mbedtls sets the -Wdocumentation flag, which is throwing warnings + # since clang-15 + $<$:-Wno-documentation> ) target_include_directories(${target} PUBLIC diff --git a/upgrade/pack_builder/SupportedTargets.cpp b/upgrade/pack_builder/SupportedTargets.cpp index f376b6127..e4bf44d6a 100644 --- a/upgrade/pack_builder/SupportedTargets.cpp +++ b/upgrade/pack_builder/SupportedTargets.cpp @@ -14,9 +14,16 @@ namespace application return *this; } + SupportedTargetsBuilder& SupportedTargetsBuilder::Order(uint8_t order) + { + this->order.Emplace(order); + return *this; + } + SupportedTargetsBuilder& SupportedTargetsBuilder::AddCmd(const SupportedTargets::Target& target) { AddToMandatoryWhenNecessary(target); + AddInOrder(target); targets.cmd.emplace_back(target); return *this; } @@ -24,6 +31,7 @@ namespace application SupportedTargetsBuilder& SupportedTargetsBuilder::AddHex(const SupportedTargets::Target& target) { AddToMandatoryWhenNecessary(target); + AddInOrder(target); targets.hex.emplace_back(target); return *this; } @@ -31,6 +39,7 @@ namespace application SupportedTargetsBuilder& SupportedTargetsBuilder::AddElf(const SupportedTargets::Target& target, uint32_t offset) { AddToMandatoryWhenNecessary(target); + AddInOrder(target); targets.elf.emplace_back(target, offset); return *this; } @@ -38,6 +47,7 @@ namespace application SupportedTargetsBuilder& SupportedTargetsBuilder::AddBin(const SupportedTargets::Target& target, uint32_t offset) { AddToMandatoryWhenNecessary(target); + AddInOrder(target); targets.bin.emplace_back(target, offset); return *this; } @@ -45,7 +55,19 @@ namespace application void SupportedTargetsBuilder::AddToMandatoryWhenNecessary(const SupportedTargets::Target& target) { if (mandatory) + { targets.mandatory.emplace_back(target); + mandatory = false; + } + } + + void SupportedTargetsBuilder::AddInOrder(const SupportedTargets::Target& target) + { + if (order) + { + targets.order[*order].emplace_back(target); + order = infra::none; + } } SupportedTargetsBuilder SupportedTargets::Create() diff --git a/upgrade/pack_builder/SupportedTargets.hpp b/upgrade/pack_builder/SupportedTargets.hpp index 256e23b4e..acbd4cbc8 100644 --- a/upgrade/pack_builder/SupportedTargets.hpp +++ b/upgrade/pack_builder/SupportedTargets.hpp @@ -1,6 +1,8 @@ #ifndef UPGRADE_SUPPORTED_TARGETS_HPP #define UPGRADE_SUPPORTED_TARGETS_HPP +#include "infra/util/Optional.hpp" +#include #include #include #include @@ -43,6 +45,11 @@ namespace application return mandatory; } + const auto& OrderOfTargets() const + { + return order; + } + private: std::vector cmd; std::vector hex; @@ -50,6 +57,7 @@ namespace application std::vector bin; std::vector mandatory; + std::map> order; }; class SupportedTargetsBuilder @@ -62,6 +70,7 @@ namespace application SupportedTargetsBuilder& Mandatory(); SupportedTargetsBuilder& Optional(); + SupportedTargetsBuilder& Order(uint8_t order); SupportedTargetsBuilder& AddCmd(const SupportedTargets::Target& target); SupportedTargetsBuilder& AddHex(const SupportedTargets::Target& target); @@ -70,10 +79,12 @@ namespace application private: void AddToMandatoryWhenNecessary(const SupportedTargets::Target& target); + void AddInOrder(const SupportedTargets::Target& target); private: SupportedTargets targets; bool mandatory{ false }; + infra::Optional order; }; } diff --git a/upgrade/pack_builder/test/TestSupportedTargets.cpp b/upgrade/pack_builder/test/TestSupportedTargets.cpp index 659112c61..e8fabe12a 100644 --- a/upgrade/pack_builder/test/TestSupportedTargets.cpp +++ b/upgrade/pack_builder/test/TestSupportedTargets.cpp @@ -35,3 +35,40 @@ TEST(SupportedTargetsTest, should_add_mandatory_targets) EXPECT_EQ(2, targets.HexTargets().size()); EXPECT_EQ("application", targets.MandatoryTargets()[0]); } + +TEST(SupportedTargetsTest, should_add_target_to_mandatory_only_if_specified) +{ + application::SupportedTargets targets = application::SupportedTargets::Create() + .Mandatory() + .AddHex("application") + .AddHex("data"); + + EXPECT_EQ(1, targets.MandatoryTargets().size()); + EXPECT_EQ("application", targets.MandatoryTargets()[0]); +} + +TEST(SupportedTargetsTest, should_add_targets_in_order) +{ + application::SupportedTargets targets = application::SupportedTargets::Create() + .Order(2) + .AddHex("application") + .Order(1) + .AddHex("data"); + const auto& orderedTargets = targets.OrderOfTargets(); + + EXPECT_EQ(2, orderedTargets.size()); + EXPECT_EQ("data", orderedTargets.at(1).at(0)); + EXPECT_EQ("application", orderedTargets.at(2).at(0)); +} + +TEST(SupportedTargetsTest, should_add_target_to_order_only_if_specified) +{ + application::SupportedTargets targets = application::SupportedTargets::Create() + .Order(1) + .AddHex("data") + .AddHex("application"); + const auto& orderedTargets = targets.OrderOfTargets(); + + EXPECT_EQ(1, orderedTargets.size()); + EXPECT_EQ("data", orderedTargets.at(1).at(0)); +} diff --git a/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp b/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp index e6156e9a4..0abacb399 100644 --- a/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp +++ b/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.cpp @@ -20,6 +20,14 @@ namespace main_ {} }; + struct IncorrectOrderOfTargetException + : std::runtime_error + { + explicit IncorrectOrderOfTargetException(const std::string& target) + : std::runtime_error("Incorrect order of target: " + target) + {} + }; + UpgradePackBuilderFacade::UpgradePackBuilderFacade(const application::UpgradePackBuilder::HeaderInfo& headerInfo) : headerInfo(headerInfo) {} @@ -51,12 +59,44 @@ namespace main_ builder.WriteUpgradePack(outputFilename, fileSystem); } + infra::Optional UpgradePackBuilderFacade::GetOrder(const std::string& targetName, const std::map>& orderedTargets) const + { + for (const auto& targets : orderedTargets) + { + const auto targetPos = std::find(targets.second.begin(), targets.second.end(), targetName); + if (targetPos != targets.second.end()) + return infra::MakeOptional(targets.first); + } + return infra::none; + } + + bool UpgradePackBuilderFacade::IsTargetInOrder(const std::string& target, const std::map>& orderedTargets) const + { + const auto orderToAdd = GetOrder(target, orderedTargets); + + return orderToAdd == infra::none || currentOrderOfTarget <= *orderToAdd; + } + + void UpgradePackBuilderFacade::UpdateCurrentOrderOfTarget(const std::string& target, const std::map>& orderedTargets) + { + const auto orderToAdd = GetOrder(target, orderedTargets); + + if (orderToAdd != infra::none) + currentOrderOfTarget = std::max(currentOrderOfTarget, *orderToAdd); + } + std::vector> UpgradePackBuilderFacade::CreateInputs(const application::SupportedTargets& supportedTargets, const TargetAndFiles& requestedTargets, application::InputFactory& factory) { std::vector> inputs; + const auto& orderedTargets = supportedTargets.OrderOfTargets(); for (const auto& [target, file, address] : requestedTargets) + { + UpdateCurrentOrderOfTarget(target, orderedTargets); + if (!IsTargetInOrder(target, orderedTargets)) + throw IncorrectOrderOfTargetException(target); inputs.push_back(factory.CreateInput(target, file, address)); + } for (const auto& mandatoryTarget : supportedTargets.MandatoryTargets()) { diff --git a/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.hpp b/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.hpp index d808ff906..cae51436f 100644 --- a/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.hpp +++ b/upgrade/pack_builder_instantiations/UpgradePackBuilderFacade.hpp @@ -36,8 +36,14 @@ namespace main_ virtual void PostBuilder(application::UpgradePackBuilder& builder, application::ImageSigner& signer, const BuildOptions& buildOptions); private: + infra::Optional GetOrder(const std::string& targetName, const std::map>& orderedTargets) const; + bool IsTargetInOrder(const std::string& target, const std::map>& orderedTargets) const; + void UpdateCurrentOrderOfTarget(const std::string& target, const std::map>& orderedTargets); std::vector> CreateInputs(const application::SupportedTargets& supportedTargets, const TargetAndFiles& requestedTargets, application::InputFactory& factory); + private: + uint8_t currentOrderOfTarget = 0; + protected: application::UpgradePackBuilder::HeaderInfo headerInfo; };