microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
.pipelines/templates/build-package-for-windows.yml
116lines · modecode
| 1 | parameters: |
| 2 | - name: DoCompliance |
| 3 | displayName: Run Compliance Tasks? |
| 4 | type: boolean |
| 5 | default: true |
| 6 | |
| 7 | - name: DoEsrp |
| 8 | displayName: Run code sign tasks? Must be true if you are doing an OnnxRuntime extensions release. |
| 9 | type: boolean |
| 10 | default: false |
| 11 | |
| 12 | - name: BuildPlatform |
| 13 | type: string |
| 14 | values: |
| 15 | - 'x86' |
| 16 | - 'x64' |
| 17 | - 'arm64' |
| 18 | |
| 19 | - name: StageNameSuffix |
| 20 | displayName: job name for nuget |
| 21 | type: string |
| 22 | default: '' |
| 23 | |
| 24 | - name: BuildPool |
| 25 | type: string |
| 26 | default: 'onnxruntime-Win-CPU-2022' |
| 27 | |
| 28 | - name: AdditionalBuildFlags |
| 29 | displayName: Additional build flags for build_lib.bat |
| 30 | type: string |
| 31 | |
| 32 | |
| 33 | jobs: |
| 34 | - job: Windows_Packaging_${{ parameters.StageNameSuffix }} |
| 35 | workspace: |
| 36 | clean: all |
| 37 | pool: ${{ parameters.BuildPool }} |
| 38 | timeoutInMinutes: 300 |
| 39 | |
| 40 | steps: |
| 41 | - checkout: self |
| 42 | clean: true |
| 43 | submodules: none |
| 44 | - task: UsePythonVersion@0 |
| 45 | # Currently we can only run tests on x64. x86 tests faile. arm64 tests can't be run as the build machine is amd64 |
| 46 | # TODO: Fix these issues so the nuget build is properly tested. |
| 47 | - ${{ if eq(parameters.BuildPlatform, 'x64') }}: |
| 48 | - task: BatchScript@1 |
| 49 | displayName: 'build onnxruntime-extensions and run tests' |
| 50 | inputs: |
| 51 | filename: '.\build_lib.bat' |
| 52 | arguments: '--${{parameters.BuildPlatform}} --build_dir $(Build.BinariesDirectory)/out --config RelWithDebInfo --cmake_generator "Visual Studio 17 2022" --enable_cxx_tests ${{parameters.AdditionalBuildFlags}} --cmake_extra_defines OCOS_ENABLE_C_API=ON' |
| 53 | modifyEnvironment: true |
| 54 | workingFolder: $(Build.SourcesDirectory) |
| 55 | - ${{ else }}: |
| 56 | - task: BatchScript@1 |
| 57 | displayName: 'build onnxruntime-extensions' |
| 58 | inputs: |
| 59 | filename: '.\build_lib.bat' |
| 60 | arguments: '--${{parameters.BuildPlatform}} --build_dir $(Build.BinariesDirectory)/out --config RelWithDebInfo --cmake_generator "Visual Studio 17 2022" ${{parameters.AdditionalBuildFlags}} --cmake_extra_defines OCOS_ENABLE_C_API=ON' |
| 61 | modifyEnvironment: true |
| 62 | workingFolder: $(Build.SourcesDirectory) |
| 63 | |
| 64 | - script: | |
| 65 | dir $(Build.BinariesDirectory)\out\RelWithDebInfo\lib\RelWithDebInfo |
| 66 | dir $(Build.BinariesDirectory)\out\RelWithDebInfo\bin\RelWithDebInfo |
| 67 | displayName: 'List built DLLs' |
| 68 | workingDirectory: $(Build.BinariesDirectory) |
| 69 | |
| 70 | - task: PowerShell@2 |
| 71 | displayName: 'Set version' |
| 72 | inputs: |
| 73 | targetType: 'inline' |
| 74 | script: | |
| 75 | $_OrtExtVersion=(cat version.txt) |
| 76 | echo "##vso[task.setvariable variable=OrtExtVersion;]$_OrtExtVersion" |
| 77 | workingDirectory: '$(Build.SourcesDirectory)' |
| 78 | |
| 79 | - task: PowerShell@2 |
| 80 | displayName: 'Copy and Create artifacts' |
| 81 | inputs: |
| 82 | targetType: 'inline' |
| 83 | script: | |
| 84 | $target_base="$(Build.BinariesDirectory)/onnxruntime-extensions-win-${{parameters.BuildPlatform}}-$(OrtExtVersion)" |
| 85 | $target_lib_path="$target_base/lib" |
| 86 | $target_include_path="$target_base/include" |
| 87 | New-Item $target_lib_path -ItemType Directory -Force |
| 88 | New-Item $target_include_path -ItemType Directory -Force |
| 89 | Copy-Item -Path "bin/RelWithDebInfo/ortextensions.*" -Destination $target_lib_path -Force |
| 90 | Copy-Item -Path "lib/RelWithDebInfo/ortextensions.*" -Destination $target_lib_path -Force |
| 91 | Copy-Item -Path "$(Build.SourcesDirectory)/include/*" -Destination $target_include_path -Recurse -Force |
| 92 | workingDirectory: '$(Build.BinariesDirectory)/out/RelWithDebInfo' |
| 93 | |
| 94 | - template: win-esrp-dll.yml |
| 95 | parameters: |
| 96 | FolderPath: '$(Build.BinariesDirectory)/onnxruntime-extensions-win-${{parameters.BuildPlatform}}-$(OrtExtVersion)' |
| 97 | DisplayName: 'Sign DLL' |
| 98 | DoEsrp: 'true' |
| 99 | |
| 100 | - task: ArchiveFiles@2 |
| 101 | inputs: |
| 102 | rootFolderOrFile: '$(Build.BinariesDirectory)/onnxruntime-extensions-win-${{parameters.BuildPlatform}}-$(OrtExtVersion)' |
| 103 | includeRootFolder: true |
| 104 | archiveType: 'tar' # Options: zip, 7z, tar, wim |
| 105 | tarCompression: 'gz' |
| 106 | archiveFile: '$(Build.ArtifactStagingDirectory)/onnxruntime-extensions-win-${{parameters.BuildPlatform}}.tgz' |
| 107 | replaceExistingArchive: true |
| 108 | |
| 109 | - task: PublishPipelineArtifact@1 |
| 110 | inputs: |
| 111 | targetPath: '$(Build.ArtifactStagingDirectory)' |
| 112 | artifactName: 'onnxruntime-extensions-win-${{parameters.BuildPlatform}}' |
| 113 | |
| 114 | - template: component-governance-component-detection-steps.yml |
| 115 | parameters : |
| 116 | condition : 'succeeded' |
| 117 | |