# # Copyright 2022 Ettus Research, a National Instruments Brand # # SPDX-License-Identifier: LGPL-3.0-or-later # # Description: # # This template should be used for IP builds within the uhddev repository. # This job uses Azure's caching mechanism to speed up the build. A # successful job publishes the corresponding build-ip/ directory as a # pipeline artifact. # # See description for the parameters below. # parameters: ### Required parameters # PATH to device's top directory (where Makefile is located) - name: directory type: string # Name of the IP Make target (e.g. X410_IP for X410's IP) - name: ip_target type: string ### Optional parameters # Option to ignore cached artifacts (when available) and perform # a clean IP build. - name: clean_build type: boolean default: false # Number of parallel jobs to use for IP build - name: num_jobs type: number default: 5 - name: additional_setup_steps type: stepList default: [] jobs: - job: ${{ parameters.ip_target }} displayName: 'Build ${{ parameters.ip_target }}' pool: name: Drivers-NIBuildFarm-RFMIBUILD demands: - Agent.OS -equals Linux - HIGH_CPU_PER_THREAD timeoutInMinutes: 240 variables: - group: sdr-pipeline-vars condition: and(succeeded(), eq(variables.BuildRequired, true)) steps: - ${{ parameters.additional_setup_steps }} - template: setup_steps.yml # Pipeline caching is leveraged in this job to minimize the time it takes # to build all the IP. # At a high level, the pipeline checks for the newest available cache # artifact for this IP target in its visible scopes and downloads it. # The per-run key forces a miss so restoreKeys selects the newest cache; # successful writable runs then save a new cache entry. # Further details on "Pipeline caching" available online: # https://docs.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops # We always allow the Cache task to run, even in clean builds. This way # when in a cache miss, the IP build from that run will be saved as an # artifact for subsequent CI and PR runs to fetch. - task: Cache@2 inputs: key: | "uhddev-fpga" | "${{ parameters.ip_target }}" | "$(Build.BuildId)" restoreKeys: | "uhddev-fpga" | "${{ parameters.ip_target }}" path: ${{ parameters.directory }}/build-ip cacheHitVar: CACHE_RESTORED displayName: Cache IP - bash: | BUILD_IP_CACHE_HASH=`cat build-ip/.ci/build-hash` echo "BUILD_IP_CACHE_HASH=$BUILD_IP_CACHE_HASH" git fetch origin $BUILD_IP_CACHE_HASH bash $(Build.SourcesDirectory)/uhddev/.ci/fpga/scripts/refresh_ip.sh \ `realpath build-ip/` $BUILD_IP_CACHE_HASH workingDirectory: ${{ parameters.directory }} # Refresh IP when caching is allowed and an exact or fallback cache was fetched. condition: and(eq('${{ parameters.clean_build }}', 'false'), or(eq(variables.CACHE_RESTORED, 'true'), eq(variables.CACHE_RESTORED, 'inexact'))) displayName: "Refresh IP" - bash: | echo "Clean IP build requested, removing existing build-ip" rm -rf build-ip workingDirectory: ${{ parameters.directory }} # Remove build-ip directory whenever a clean IP build is requested. condition: eq('${{ parameters.clean_build }}', 'true') displayName: "Prune IP" - bash: | source $(Build.SourcesDirectory)/uhddev/.ci/fpga/scripts/run_setup.sh ./ make -j ${{ parameters.num_jobs }} ${{ parameters.ip_target }} mkdir -p build-ip/.ci/ git rev-parse --verify HEAD 2>/dev/null 1>build-ip/.ci/build-hash workingDirectory: ${{ parameters.directory }} displayName: "Build IP" - publish: ${{ parameters.directory }}/build-ip artifact: '${{ parameters.ip_target }} (Attempt $(System.JobAttempt))' condition: failed() - publish: ${{ parameters.directory }}/build-ip artifact: ${{ parameters.ip_target }} condition: succeeded() - template: check_clean_repo_steps.yml parameters: directory: ${{ parameters.directory }}