Publish obj files for PR #127295 modified source files [Just for testing no merge]#128236
Publish obj files for PR #127295 modified source files [Just for testing no merge]#128236moyo1997 wants to merge 2 commits into
Conversation
…ine artifacts Add a post-build step to global-build-job.yml that collects compiled object files (.obj/.o) for the 102 source files modified in PR dotnet#127295 (Remove Unused Includes) and publishes them as pipeline artifacts. - New script: eng/pipelines/collect-obj-files.ps1 Searches artifacts/obj/ for object files matching the 102 source basenames and copies them to a staging directory. - Modified: eng/pipelines/common/global-build-job.yml Added pwsh step + PublishBuildArtifacts task after the build step. Runs on every build leg, publishes per-leg artifacts named ObjFiles_<os>_<arch>_<config>. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@moyo1997 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ), 1. Definitions. “Code” means the computer software code, whether in human-readable or machine-executable form, “Project” means any of the projects owned or managed by .NET Foundation and offered under a license “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any “Submission” means the Code and any other copyrightable material Submitted by You, including any 2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any 3. Originality of Work. You represent that each of Your Submissions is entirely Your 4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else 5. Licenses. a. Copyright License. You grant .NET Foundation, and those who receive the Submission directly b. Patent License. You grant .NET Foundation, and those who receive the Submission directly or c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement. 6. Representations and Warranties. You represent that You are legally entitled to grant the above 7. Notice to .NET Foundation. You agree to notify .NET Foundation in writing of any facts or 8. Information about Submissions. You agree that contributions to Projects and information about 9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and 10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and .NET Foundation dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1. |
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a CI step to collect compiled object files (.obj/.o) for 102 specific source files modified in PR #127295 ("Remove Unused Includes") and publishes them as build artifacts for size-comparison analysis.
Changes:
- New PowerShell script
collect-obj-files.ps1that searchesartifacts/objfor object files matching a hardcoded list of 102 source basenames and copies matches to a staging directory. - Updates
global-build-job.ymlto invoke the script and publish the resulting object files viaPublishBuildArtifacts@1, scoped per OS/arch/config.
Show a summary per file
| File | Description |
|---|---|
| eng/pipelines/collect-obj-files.ps1 | New script enumerating 102 source basenames, recursively scanning obj dir, stripping .cpp/.c + .obj/.o suffixes, and copying matches preserving relative path. |
| eng/pipelines/common/global-build-job.yml | Adds two pipeline steps: invoke the collection script, then publish the staged object files as a per-leg build artifact. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 9
| $sourceBasenames = @( | ||
| "assembly" | ||
| "dacfn" |
| # Deduplicate basenames (some appear more than once across different source dirs) | ||
| $uniqueBasenames = $sourceBasenames | Sort-Object -Unique |
| # Search for .obj and .o files recursively | ||
| $extensions = @('*.obj', '*.o') | ||
| foreach ($ext in $extensions) { | ||
| $files = Get-ChildItem -Path $ArtifactsObjDir -Filter $ext -Recurse -File -ErrorAction SilentlyContinue | ||
| foreach ($file in $files) { | ||
| # Extract the source basename: e.g., "assembly.cpp.obj" -> "assembly" | ||
| # CMake names obj files as <sourcename>.cpp.obj (or .c.obj) on Windows, | ||
| # and <sourcename>.cpp.o (or .c.o) on Linux/macOS. | ||
| $objName = $file.Name | ||
| # Remove the object extension first | ||
| $withoutObjExt = $objName | ||
| if ($objName.EndsWith('.obj')) { | ||
| $withoutObjExt = $objName.Substring(0, $objName.Length - 4) | ||
| } | ||
| elseif ($objName.EndsWith('.o')) { | ||
| $withoutObjExt = $objName.Substring(0, $objName.Length - 2) | ||
| } | ||
|
|
||
| # Remove the source extension (.cpp, .c) | ||
| $baseName = $withoutObjExt | ||
| if ($withoutObjExt.EndsWith('.cpp')) { | ||
| $baseName = $withoutObjExt.Substring(0, $withoutObjExt.Length - 4) | ||
| } | ||
| elseif ($withoutObjExt.EndsWith('.c')) { | ||
| $baseName = $withoutObjExt.Substring(0, $withoutObjExt.Length - 2) | ||
| } | ||
|
|
||
| if ($basenameSet.Contains($baseName)) { | ||
| # Preserve relative path from artifacts/obj | ||
| $relativePath = $file.FullName.Substring($ArtifactsObjDir.TrimEnd([IO.Path]::DirectorySeparatorChar, '/').Length + 1) | ||
| $destPath = Join-Path $OutputDir $relativePath | ||
| $destDir = Split-Path $destPath -Parent | ||
| if (-not (Test-Path $destDir)) { | ||
| New-Item -ItemType Directory -Path $destDir -Force | Out-Null | ||
| } | ||
| Copy-Item -Path $file.FullName -Destination $destPath -Force | ||
| Write-Host "Copied: $relativePath ($($file.Length) bytes)" | ||
| $totalCopied++ | ||
| } |
| # CMake names obj files as <sourcename>.cpp.obj (or .c.obj) on Windows, | ||
| # and <sourcename>.cpp.o (or .c.o) on Linux/macOS. | ||
| $objName = $file.Name | ||
| # Remove the object extension first | ||
| $withoutObjExt = $objName | ||
| if ($objName.EndsWith('.obj')) { | ||
| $withoutObjExt = $objName.Substring(0, $objName.Length - 4) | ||
| } | ||
| elseif ($objName.EndsWith('.o')) { | ||
| $withoutObjExt = $objName.Substring(0, $objName.Length - 2) | ||
| } | ||
|
|
||
| # Remove the source extension (.cpp, .c) | ||
| $baseName = $withoutObjExt | ||
| if ($withoutObjExt.EndsWith('.cpp')) { | ||
| $baseName = $withoutObjExt.Substring(0, $withoutObjExt.Length - 4) | ||
| } | ||
| elseif ($withoutObjExt.EndsWith('.c')) { | ||
| $baseName = $withoutObjExt.Substring(0, $withoutObjExt.Length - 2) | ||
| } |
|
|
||
| if ($basenameSet.Contains($baseName)) { | ||
| # Preserve relative path from artifacts/obj | ||
| $relativePath = $file.FullName.Substring($ArtifactsObjDir.TrimEnd([IO.Path]::DirectorySeparatorChar, '/').Length + 1) |
| # Collect and publish .obj/.o files for the 102 source files from PR #127295 | ||
| - pwsh: | | ||
| $(Build.SourcesDirectory)/eng/pipelines/collect-obj-files.ps1 ` | ||
| -ArtifactsObjDir "$(Build.SourcesDirectory)/artifacts/obj" ` | ||
| -OutputDir "$(Build.StagingDirectory)/obj-artifacts" | ||
| displayName: Collect object files for PR #127295 |
| - task: PublishBuildArtifacts@1 | ||
| displayName: Publish object files | ||
| inputs: | ||
| PathtoPublish: '$(Build.StagingDirectory)/obj-artifacts' | ||
| ArtifactName: 'ObjFiles_${{ parameters.osGroup }}${{ parameters.osSubgroup }}_${{ parameters.archType }}_${{ parameters.buildConfig }}' |
| displayName: Collect object files for PR #127295 | ||
| continueOnError: true | ||
| condition: succeededOrFailed() |
| # Search for .obj and .o files recursively | ||
| $extensions = @('*.obj', '*.o') | ||
| foreach ($ext in $extensions) { | ||
| $files = Get-ChildItem -Path $ArtifactsObjDir -Filter $ext -Recurse -File -ErrorAction SilentlyContinue | ||
| foreach ($file in $files) { | ||
| # Extract the source basename: e.g., "assembly.cpp.obj" -> "assembly" | ||
| # CMake names obj files as <sourcename>.cpp.obj (or .c.obj) on Windows, | ||
| # and <sourcename>.cpp.o (or .c.o) on Linux/macOS. | ||
| $objName = $file.Name | ||
| # Remove the object extension first | ||
| $withoutObjExt = $objName | ||
| if ($objName.EndsWith('.obj')) { | ||
| $withoutObjExt = $objName.Substring(0, $objName.Length - 4) | ||
| } | ||
| elseif ($objName.EndsWith('.o')) { | ||
| $withoutObjExt = $objName.Substring(0, $objName.Length - 2) | ||
| } | ||
|
|
||
| # Remove the source extension (.cpp, .c) | ||
| $baseName = $withoutObjExt | ||
| if ($withoutObjExt.EndsWith('.cpp')) { | ||
| $baseName = $withoutObjExt.Substring(0, $withoutObjExt.Length - 4) | ||
| } | ||
| elseif ($withoutObjExt.EndsWith('.c')) { | ||
| $baseName = $withoutObjExt.Substring(0, $withoutObjExt.Length - 2) | ||
| } | ||
|
|
||
| if ($basenameSet.Contains($baseName)) { | ||
| # Preserve relative path from artifacts/obj | ||
| $relativePath = $file.FullName.Substring($ArtifactsObjDir.TrimEnd([IO.Path]::DirectorySeparatorChar, '/').Length + 1) | ||
| $destPath = Join-Path $OutputDir $relativePath | ||
| $destDir = Split-Path $destPath -Parent | ||
| if (-not (Test-Path $destDir)) { | ||
| New-Item -ItemType Directory -Path $destDir -Force | Out-Null | ||
| } | ||
| Copy-Item -Path $file.FullName -Destination $destPath -Force | ||
| Write-Host "Copied: $relativePath ($($file.Length) bytes)" | ||
| $totalCopied++ | ||
| } |
|
Please open a discussion at https://github.com/dotnet/runtime/discussions to explain the objectives behind these PRs first. We need to understand the rationale for these changes. As it stands, I don't think we want to publish intermediate objects even for experiments. |
…tifacts
Add a post-build step to global-build-job.yml that collects compiled object files (.obj/.o) for the 102 source files modified in PR #127295 (Remove Unused Includes) and publishes them as pipeline artifacts.