microsoft/mu_tiano_platforms
Publicmirrored fromhttps://github.com/microsoft/mu_tiano_platformsAvailable
.azurepipelines/Platform-Build-Job.yml
201lines · modecode
| 1 | ## @file |
| 2 | # Azure Pipeline build file for building platforms with GCC. |
| 3 | # |
| 4 | # Copyright (c) Microsoft Corporation. |
| 5 | # SPDX-License-Identifier: BSD-2-Clause-Patent |
| 6 | ## |
| 7 | |
| 8 | parameters: |
| 9 | - name: extra_install_step |
| 10 | displayName: Extra Install Steps |
| 11 | type: stepList |
| 12 | default: |
| 13 | - script: echo No extra steps provided |
| 14 | - name: tool_chain_tag |
| 15 | displayName: Tool Chain (e.g. VS2022) |
| 16 | type: string |
| 17 | default: '' |
| 18 | - name: vm_image |
| 19 | displayName: Virtual Machine Image (e.g. windows-latest) |
| 20 | type: string |
| 21 | default: 'windows-latest' |
| 22 | - name: pool_name |
| 23 | displayName: Pool Name |
| 24 | type: string |
| 25 | default: pool_name |
| 26 | - name: os_type |
| 27 | displayName: OS type on the self-hosted agent pools |
| 28 | type: string |
| 29 | values: |
| 30 | - Windows_NT |
| 31 | - Linux |
| 32 | default: Windows_NT |
| 33 | - name: container_image |
| 34 | displayName: Container Image |
| 35 | type: string |
| 36 | default: '' |
| 37 | - name: run_timeout |
| 38 | displayName: Run Timeout (in minutes) |
| 39 | type: number |
| 40 | default: 25 |
| 41 | - name: build_matrix |
| 42 | type: object |
| 43 | ## Build matrix to be supplied by both VS and GCC builds. The accepted parameters are listed below: |
| 44 | # BuildPackage: Packages to be built, i.e., QemuQ35Pkg |
| 45 | # BuildFile: Build script for building platform firmware, i.e., "Platforms/QemuQ35Pkg/PlatformBuild.py" |
| 46 | # BuildFlags: Additional build flags, set to empty string if none |
| 47 | # BuildTarget: Build targets to be used for platform firmware, i.e., "DEBUG" |
| 48 | # BuildExtraTag: Extra tags to be used as artifact identifier, this is especially useful when building the same packages with the tool chain and target |
| 49 | # BuildExtraStep: Extra steps the template will execute prior to Steps/BuildPlatform.yml |
| 50 | # Run: Indicate whether the QEMU runner should launch, this will be overridden to defer the run if a combination of Window and ARM host system is met |
| 51 | # RunFlags: Run flags to be used for launching QEMU, i.e., "SHUTDOWN_AFTER_RUN=TRUE QEMU_HEADLESS=TRUE EMPTY_DRIVE=TRUE BLD_*_QEMU_CORE_NUM=2 FILE_REGEX=*TestApp*.efi RUN_TESTS=TRUE" |
| 52 | # SelfHostAgent: Optional: Indicate whether this matrix entry should be run on selfhosted agents |
| 53 | # BuildArtifactsBinary: Artifacts to be published after building steps |
| 54 | # BuildArtifactsOther: Additional artifacts to be published after building steps |
| 55 | |
| 56 | jobs: |
| 57 | - ${{ each item in parameters.build_matrix }}: |
| 58 | - job: PlatformBuild_${{ item.Key }} |
| 59 | displayName: Build Platforms ${{ item.Key }} |
| 60 | condition: | |
| 61 | and(not(Canceled()), |
| 62 | or(${{ ne(item.Value.SelfHostAgent, true) }}, ne(variables['${{ parameters.pool_name }}'], ''))) |
| 63 | |
| 64 | workspace: |
| 65 | clean: all |
| 66 | |
| 67 | variables: |
| 68 | - name: Run |
| 69 | ${{ if EndsWith(item.Key, 'CODE_COVERAGE') }}: |
| 70 | value: false |
| 71 | ${{ elseif or(eq(item.Value.Run, true), eq(parameters.os_type, 'Linux')) }}: |
| 72 | value: true |
| 73 | ${{ else }}: |
| 74 | value: false |
| 75 | |
| 76 | ${{ if and(ne(parameters.container_image, ''), ne(item.Value.SelfHostAgent, true)) }}: |
| 77 | container: ${{ parameters.container_image }} |
| 78 | |
| 79 | ${{ if eq(item.Value.SelfHostAgent, true) }}: |
| 80 | pool: |
| 81 | name: $(${{ parameters.pool_name }}) |
| 82 | demands: |
| 83 | - Agent.OS -equals ${{ parameters.os_type }} |
| 84 | ${{ else }}: |
| 85 | pool: |
| 86 | vmImage: ${{ parameters.vm_image }} |
| 87 | |
| 88 | steps: |
| 89 | # Redirect Hafnium submodule URLs from git.trustedfirmware.org to GitHub mirrors |
| 90 | - script: | |
| 91 | git config --global url."https://github.com/TF-Hafnium/hafnium-prebuilts".insteadOf "https://git.trustedfirmware.org/hafnium/prebuilts" |
| 92 | git config --global url."https://github.com/TF-Hafnium/hafnium-project-reference".insteadOf "https://git.trustedfirmware.org/hafnium/project/reference" |
| 93 | git config --global url."https://github.com/TF-Hafnium/hafnium-third_party-dtc".insteadOf "https://git.trustedfirmware.org/hafnium/third_party/dtc" |
| 94 | git config --global url."https://github.com/TF-Hafnium/hafnium-third_party-googletest".insteadOf "https://git.trustedfirmware.org/hafnium/third_party/googletest" |
| 95 | displayName: Redirect Submodule URLs |
| 96 | |
| 97 | # Potential Extra steps from specific build targets |
| 98 | - ${{ item.Value.BuildExtraStep }} |
| 99 | |
| 100 | - template: Steps/BuildPlatform.yml@mu_devops |
| 101 | parameters: |
| 102 | tool_chain_tag: ${{ parameters.tool_chain_tag }} |
| 103 | build_pkg: ${{ item.Value.BuildPackage }} |
| 104 | build_target: ${{ item.Value.BuildTarget }} |
| 105 | build_file: ${{ item.Value.BuildFile }} |
| 106 | build_flags: ${{ item.Value.BuildFlags }} |
| 107 | run_flags: ${{ item.Value.RunFlags }} |
| 108 | run_timeout: ${{ parameters.run_timeout }} |
| 109 | extra_install_step: ${{ parameters.extra_install_step }} |
| 110 | install_tools: ${{ and(ne(item.Value.SelfHostAgent, true), eq(parameters.container_image, '')) }} |
| 111 | artifacts_identifier: '${{ item.Value.BuildPackage }} ${{ parameters.tool_chain_tag }} ${{ item.Value.BuildTarget }} ${{ item.Value.BuildExtraTag }}' |
| 112 | artifacts_binary: ${{ item.Value.BuildArtifactsBinary }} |
| 113 | ${{ if or(eq(item.Value.Run, true), eq(parameters.os_type, 'Linux'), EndsWith(item.Key, 'CODE_COVERAGE')) }}: |
| 114 | artifacts_other: ${{ item.Value.BuildArtifactsOther }} |
| 115 | |
| 116 | - ${{ if EndsWith(item.Key, 'CODE_COVERAGE') }}: |
| 117 | - template: Steps/UploadCodeCoverage.yml@mu_devops |
| 118 | parameters: |
| 119 | report_dir: 'Build/${{ item.Value.BuildPackage }}' |
| 120 | flag: '${{ item.Value.BuildPackage }}' |
| 121 | install_dependencies: true |
| 122 | |
| 123 | - job: RunQemuBuilds_${{ item.Key }} |
| 124 | displayName: Run Qemu Builds ${{ item.Key }} |
| 125 | dependsOn: PlatformBuild_${{ item.Key }} |
| 126 | # Need to skip run-in-place for Windows ARM systems, as we do not have sufficient support for QEMU on those systems. We can get rid of these steps once we do. |
| 127 | condition: | |
| 128 | and(not(EndsWith('${{ item.Key }}', 'CODE_COVERAGE')), |
| 129 | succeeded(), |
| 130 | and(ne(variables['tool_chain_tag'], 'GCC5'), |
| 131 | and(StartsWith('${{ item.Key }}', 'QemuQ35'), EndsWith('${{ item.Key }}', 'ARM')))) |
| 132 | |
| 133 | pool: |
| 134 | vmImage: ${{ parameters.vm_image }} |
| 135 | |
| 136 | steps: |
| 137 | - checkout: self |
| 138 | clean: true |
| 139 | fetchDepth: 1 |
| 140 | |
| 141 | - template: Steps/SetupPythonPreReqs.yml@mu_devops |
| 142 | parameters: |
| 143 | install_python: true |
| 144 | |
| 145 | # Set default |
| 146 | - script: |
| 147 | echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}" |
| 148 | |
| 149 | # Setup repo |
| 150 | - task: CmdLine@2 |
| 151 | displayName: Setup |
| 152 | inputs: |
| 153 | script: git submodule update --init --depth 1 |
| 154 | condition: and(gt(variables.pkg_count, 0), succeeded()) |
| 155 | |
| 156 | # Stuart Update |
| 157 | - task: CmdLine@2 |
| 158 | displayName: Update |
| 159 | inputs: |
| 160 | script: stuart_update -c ${{ item.Value.BuildFile }} TOOL_CHAIN_TAG=$(tool_chain_tag) -t ${{ item.Value.BuildTarget }} ${{ item.Value.BuildFlags }} |
| 161 | condition: and(gt(variables.pkg_count, 0), succeeded()) |
| 162 | |
| 163 | # Potential Extra steps |
| 164 | - ${{ parameters.extra_install_step }} |
| 165 | |
| 166 | - task: DownloadPipelineArtifact@2 |
| 167 | name: DownloadVisualStudioFds |
| 168 | displayName: Download Visual Studio FD files |
| 169 | inputs: |
| 170 | buildType: 'current' |
| 171 | artifactName: 'Binaries ${{ item.Value.BuildPackage }} $(tool_chain_tag) ${{ item.Value.BuildTarget }} ${{ item.Value.BuildExtraTag }}' |
| 172 | itemPattern: '**/*.fd' |
| 173 | targetPath: 'Build/${{ item.Value.BuildPackage }}/${{ item.Value.BuildTarget }}_$(tool_chain_tag)/FV/' |
| 174 | |
| 175 | - task: DownloadPipelineArtifact@2 |
| 176 | name: DownloadVisualStudioTests |
| 177 | displayName: Download Visual Studio Test Files |
| 178 | inputs: |
| 179 | buildType: 'current' |
| 180 | artifactName: 'Binaries ${{ item.Value.BuildPackage }} $(tool_chain_tag) ${{ item.Value.BuildTarget }} ${{ item.Value.BuildExtraTag }}' |
| 181 | itemPattern: '**/*.efi' |
| 182 | targetPath: 'Build/${{ item.Value.BuildPackage }}/${{ item.Value.BuildTarget }}_$(tool_chain_tag)/X64/' |
| 183 | |
| 184 | # Run |
| 185 | - task: CmdLine@2 |
| 186 | displayName: Run to Shell |
| 187 | inputs: |
| 188 | script: stuart_build -c ${{ item.Value.BuildFile }} TOOL_CHAIN_TAG=$(tool_chain_tag) TARGET=${{ item.Value.BuildTarget }} ${{ item.Value.BuildFlags }} ${{ item.Value.RunFlags }} --FlashOnly |
| 189 | condition: and(gt(variables.pkg_count, 0), succeeded()) |
| 190 | timeoutInMinutes: ${{ parameters.run_timeout }} |
| 191 | |
| 192 | # Copy build logs to the artifact staging directory |
| 193 | - template: Steps/CommonLogCopyAndPublish.yml@mu_devops |
| 194 | parameters: |
| 195 | artifacts_identifier: 'Binaries ${{ item.Value.BuildPackage }} $(tool_chain_tag) ${{ item.Value.BuildTarget }} ${{ item.Value.BuildExtraTag }}' |
| 196 | |
| 197 | # Copy other files to the artifact staging directory |
| 198 | - template: Steps/OtherCopyAndPublish.yml@mu_devops |
| 199 | parameters: |
| 200 | artifacts_other: ${{ item.Value.BuildArtifactsOther }} |
| 201 | artifacts_identifier: 'Binaries ${{ item.Value.BuildPackage }} $(tool_chain_tag) ${{ item.Value.BuildTarget }} ${{ item.Value.BuildExtraTag }}' |
| 202 | |