From f6a46126c3d3cee4a7ad303737ab1a12dae1c8b8 Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Mon, 29 Jun 2026 10:51:36 -0700 Subject: [PATCH 1/3] create artifacts --- .../v2/templates/stages-build-native.yml | 42 +++++++ .../v2/templates/steps-pack-cpp-sdk.yml | 104 ++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 .pipelines/v2/templates/steps-pack-cpp-sdk.yml diff --git a/.pipelines/v2/templates/stages-build-native.yml b/.pipelines/v2/templates/stages-build-native.yml index 09a75c33..e7a49cd0 100644 --- a/.pipelines/v2/templates/stages-build-native.yml +++ b/.pipelines/v2/templates/stages-build-native.yml @@ -219,6 +219,48 @@ stages: runTests: false stageHeaders: false + # ==================================================================== + # Pack — C++ SDK tgz bundles (base platforms) + # ==================================================================== + - stage: cpp_pack_sdk_v2 + displayName: 'C++ Native: Pack SDK tgz (base)' + dependsOn: + - compute_version + - cpp_build_win_x64 + - cpp_build_win_arm64 + - cpp_build_linux_x64 + - cpp_build_osx_arm64 + jobs: + - job: pack + pool: + name: onnxruntime-Win-CPU-2022 + os: windows + templateContext: + inputs: + - input: pipelineArtifact + artifactName: 'cpp-native-include' + targetPath: '$(Pipeline.Workspace)/cpp-native-include' + - input: pipelineArtifact + artifactName: 'cpp-native-win-x64' + targetPath: '$(Pipeline.Workspace)/cpp-native-win-x64' + - input: pipelineArtifact + artifactName: 'cpp-native-win-arm64' + targetPath: '$(Pipeline.Workspace)/cpp-native-win-arm64' + - input: pipelineArtifact + artifactName: 'cpp-native-linux-x64' + targetPath: '$(Pipeline.Workspace)/cpp-native-linux-x64' + - input: pipelineArtifact + artifactName: 'cpp-native-osx-arm64' + targetPath: '$(Pipeline.Workspace)/cpp-native-osx-arm64' + outputs: + - output: pipelineArtifact + artifactName: 'cpp-sdk-v2' + targetPath: '$(Build.ArtifactStagingDirectory)/cpp-sdk-v2' + steps: + - template: steps-pack-cpp-sdk.yml + parameters: + outputDir: '$(Build.ArtifactStagingDirectory)/cpp-sdk-v2' + # ==================================================================== # Pack — base NuGet package (all 4 platforms) # ==================================================================== diff --git a/.pipelines/v2/templates/steps-pack-cpp-sdk.yml b/.pipelines/v2/templates/steps-pack-cpp-sdk.yml new file mode 100644 index 00000000..550d3158 --- /dev/null +++ b/.pipelines/v2/templates/steps-pack-cpp-sdk.yml @@ -0,0 +1,104 @@ +# Package per-platform C++ SDK bundles as .tgz files. +# +# Each bundle has this layout: +# include/ -> public headers (from cpp-native-include artifact) +# lib/ -> platform native binaries +# +# Output: +# $(Build.ArtifactStagingDirectory)/cpp-sdk-v2/*.tgz + +parameters: +- name: outputDir + type: string + default: '$(Build.ArtifactStagingDirectory)/cpp-sdk-v2' + displayName: 'Directory where per-platform .tgz bundles are staged' + +steps: + +- task: PowerShell@2 + displayName: 'Create C++ SDK platform bundles (.tgz)' + inputs: + targetType: inline + pwsh: true + script: | + $ErrorActionPreference = 'Stop' + + $workspace = "$(Pipeline.Workspace)" + $outDir = "${{ parameters.outputDir }}" + $workRoot = Join-Path "$(Build.BinariesDirectory)" "cpp-sdk-v2-staging" + + if (Test-Path $outDir) { Remove-Item -Recurse -Force $outDir } + if (Test-Path $workRoot) { Remove-Item -Recurse -Force $workRoot } + New-Item -ItemType Directory -Force -Path $outDir | Out-Null + New-Item -ItemType Directory -Force -Path $workRoot | Out-Null + + $includeSrc = Join-Path $workspace 'cpp-native-include' + if (-not (Test-Path $includeSrc)) { + throw "cpp-native-include artifact not found at $includeSrc" + } + + function New-SdkArchive { + param( + [string]$Rid, + [string]$NativeArtifact, + [string[]]$Files + ) + + $nativeSrc = Join-Path $workspace $NativeArtifact + if (-not (Test-Path $nativeSrc)) { + throw "Native artifact '$NativeArtifact' not found at $nativeSrc" + } + + $root = Join-Path $workRoot $Rid + $includeDst = Join-Path $root 'include' + $libDst = Join-Path $root 'lib' + New-Item -ItemType Directory -Force -Path $includeDst | Out-Null + New-Item -ItemType Directory -Force -Path $libDst | Out-Null + + Copy-Item -Path (Join-Path $includeSrc '*') -Destination $includeDst -Recurse -Force + + foreach ($f in $Files) { + $src = Join-Path $nativeSrc $f + if (-not (Test-Path $src)) { + throw "Required native file not found: $src" + } + $dst = Join-Path $libDst (Split-Path -Leaf $src) + Copy-Item -Path $src -Destination $dst -Force + } + + $archive = Join-Path $outDir ("cpp-sdk-v2-{0}.tgz" -f $Rid) + if (Test-Path $archive) { Remove-Item -Force $archive } + + Push-Location $root + try { + tar -czf $archive include lib + if ($LASTEXITCODE -ne 0) { + throw "tar failed for RID '$Rid'" + } + } finally { + Pop-Location + } + + Write-Host "Created $archive" + } + + New-SdkArchive -Rid 'win-x64' -NativeArtifact 'cpp-native-win-x64' -Files @( + 'foundry_local.dll', + 'foundry_local.pdb' + ) + + New-SdkArchive -Rid 'win-arm64' -NativeArtifact 'cpp-native-win-arm64' -Files @( + 'foundry_local.dll', + 'foundry_local.pdb' + ) + + New-SdkArchive -Rid 'linux-x64' -NativeArtifact 'cpp-native-linux-x64' -Files @( + 'libfoundry_local.so' + ) + + New-SdkArchive -Rid 'osx-arm64' -NativeArtifact 'cpp-native-osx-arm64' -Files @( + 'libfoundry_local.dylib' + ) + + Write-Host "Staged archives:" + Get-ChildItem $outDir -Filter '*.tgz' | ForEach-Object { Write-Host " $($_.Name)" } From 14f54c0ee069e0600ea8ccac7c5d2d5fde055e7f Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Mon, 29 Jun 2026 10:59:09 -0700 Subject: [PATCH 2/3] copilot --- .pipelines/v2/templates/stages-build-native.yml | 1 - .pipelines/v2/templates/steps-pack-cpp-sdk.yml | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pipelines/v2/templates/stages-build-native.yml b/.pipelines/v2/templates/stages-build-native.yml index e7a49cd0..110e9690 100644 --- a/.pipelines/v2/templates/stages-build-native.yml +++ b/.pipelines/v2/templates/stages-build-native.yml @@ -225,7 +225,6 @@ stages: - stage: cpp_pack_sdk_v2 displayName: 'C++ Native: Pack SDK tgz (base)' dependsOn: - - compute_version - cpp_build_win_x64 - cpp_build_win_arm64 - cpp_build_linux_x64 diff --git a/.pipelines/v2/templates/steps-pack-cpp-sdk.yml b/.pipelines/v2/templates/steps-pack-cpp-sdk.yml index 550d3158..fc116141 100644 --- a/.pipelines/v2/templates/steps-pack-cpp-sdk.yml +++ b/.pipelines/v2/templates/steps-pack-cpp-sdk.yml @@ -84,12 +84,14 @@ steps: New-SdkArchive -Rid 'win-x64' -NativeArtifact 'cpp-native-win-x64' -Files @( 'foundry_local.dll', - 'foundry_local.pdb' + 'foundry_local.pdb', + 'foundry_local.lib' ) New-SdkArchive -Rid 'win-arm64' -NativeArtifact 'cpp-native-win-arm64' -Files @( 'foundry_local.dll', - 'foundry_local.pdb' + 'foundry_local.pdb', + 'foundry_local.lib' ) New-SdkArchive -Rid 'linux-x64' -NativeArtifact 'cpp-native-linux-x64' -Files @( From 7f165a3f5f5b1bab2ab86bf79082cc2e86b3bebc Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Mon, 29 Jun 2026 13:40:17 -0700 Subject: [PATCH 3/3] prune --- .pipelines/v2/templates/steps-pack-cpp-sdk.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.pipelines/v2/templates/steps-pack-cpp-sdk.yml b/.pipelines/v2/templates/steps-pack-cpp-sdk.yml index fc116141..bd4c2e25 100644 --- a/.pipelines/v2/templates/steps-pack-cpp-sdk.yml +++ b/.pipelines/v2/templates/steps-pack-cpp-sdk.yml @@ -57,6 +57,18 @@ steps: Copy-Item -Path (Join-Path $includeSrc '*') -Destination $includeDst -Recurse -Force + # The SDK tgz should include only public wrapper headers. + $pathsToPrune = @( + (Join-Path $includeDst 'gsl'), + (Join-Path $includeDst 'manifest'), + (Join-Path $includeDst 'manifest.json') + ) + foreach ($pathToPrune in $pathsToPrune) { + if (Test-Path $pathToPrune) { + Remove-Item -Path $pathToPrune -Recurse -Force + } + } + foreach ($f in $Files) { $src = Join-Path $nativeSrc $f if (-not (Test-Path $src)) {