Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .pipelines/v2/templates/stages-build-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,47 @@ 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:
- 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)
# ====================================================================
Expand Down
118 changes: 118 additions & 0 deletions .pipelines/v2/templates/steps-pack-cpp-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# 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

# 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)) {
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',
'foundry_local.lib'
)

New-SdkArchive -Rid 'win-arm64' -NativeArtifact 'cpp-native-win-arm64' -Files @(
'foundry_local.dll',
'foundry_local.pdb',
'foundry_local.lib'
)
Comment thread
Copilot marked this conversation as resolved.

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)" }