Skip to content

Commit 3319873

Browse files
committed
Use .rust.json files
1 parent 39fb6c7 commit 3319873

File tree

3 files changed

+10
-39
lines changed

3 files changed

+10
-39
lines changed

eng/scripts/Language-Settings.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function Get-rust-PackageInfoFromPackageFile([IO.FileInfo]$pkg, [string]$working
169169
}
170170

171171
function Find-rust-Artifacts-For-Apireview([string]$ArtifactPath, [string]$packageName) {
172-
[array]$files = Get-ChildItem -Path $ArtifactPath -Recurse -Filter "$packageName`_rust.json"
172+
[array]$files = Get-ChildItem -Path $ArtifactPath -Recurse -Filter "$packageName.rust.json"
173173

174174
if (!$files) {
175175
Write-Host "$($packageName) does not have api review json"

eng/scripts/Pack-Crates.ps1

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -146,34 +146,14 @@ function Add-CrateToLocalRegistry($LocalRegistryPath, $Package) {
146146
'{"files":{}}' | Out-File -FilePath "$LocalRegistryPath/$packageName-$packageVersion/.cargo-checksum.json" -Encoding utf8
147147
}
148148

149-
# For all dependencies with paths, but no versions, add the version from the path
150-
function Add-PathVersions($packages) {
151-
# Install PSToml if it's not already installed
152-
if (-not (PowerShellGet\Get-InstalledModule -Name PSToml -ErrorAction SilentlyContinue)) {
153-
PowerShellGet\Install-Module -Name PSToml -Scope CurrentUser -Force
154-
}
149+
function Create-ApiViewFile($package) {
150+
$packageName = $package.name
151+
$command = "cargo run --manifest-path $RepoRoot/eng/tools/generate_api_report/Cargo.toml -- --package $packageName"
152+
Invoke-LoggedCommand $command -GroupOutput | Out-Host
155153

156-
foreach ($package in $packages) {
157-
$dirty = $false
158-
$toml = Get-Content -Path $Package.manifest_path -Raw | ConvertFrom-Toml
159-
160-
foreach ($name in $toml.dependencies.Keys) {
161-
# we want to look at the dependency as it was resolved by `cargo metadata`
162-
# this will resolve workspace depdencies, but retain their path/no-version state
163-
$dependency = $package.dependencies | Where-Object -Property name -EQ -Value $name | Select-Object -First 1
164-
# If the dependency is a path dependency, set the version to the version of the package in the workspace
165-
if ($dependency.path -and !$dependency.version) {
166-
$tomlDependency = $toml.dependencies.$name
167-
$dependencyVersion = $packages | Where-Object -Property name -EQ -Value $name | Select-Object -ExpandProperty version -First 1
168-
169-
$tomlDependency.version = $dependencyVersion
170-
$dirty = $true
171-
}
172-
}
173-
if ($dirty) {
174-
$toml | ConvertTo-Toml -Depth 10 | Set-Content -Path $Package.manifest_path -Encoding utf8
175-
}
176-
}
154+
$packagePath = Split-Path -Path $package.manifest_path -Parent
155+
156+
"$packagePath/review/$packageName.rust.json"
177157
}
178158

179159
Push-Location $RepoRoot
@@ -189,15 +169,6 @@ try {
189169
Write-Host " $packageName ($type)"
190170
}
191171

192-
function Create-ApiViewFile($package) {
193-
$command = "cargo run --manifest-path $RepoRoot/eng/tools/generate_api_report/Cargo.toml -- --package $($package.name)"
194-
Invoke-LoggedCommand $command -GroupOutput | Out-Host
195-
196-
$packagePath = Split-Path -Path $package.manifest_path -Parent
197-
198-
"$packagePath/review/$($package.name)_rust.json"
199-
}
200-
201172
foreach ($package in $packages) {
202173
Write-Host ""
203174

@@ -222,7 +193,7 @@ try {
222193
$sourcePath = "$RepoRoot/target/package/$packageName-$packageVersion"
223194
$targetPath = "$OutputPath/$packageName"
224195
$targetContentsPath = "$targetPath/contents"
225-
$targetApiReviewFile = "$targetPath/$packageName`_rust.json"
196+
$targetApiReviewFile = "$targetPath/$packageName.rust.json"
226197

227198
if (Test-Path -Path $targetContentsPath) {
228199
Remove-Item -Path $targetContentsPath -Recurse -Force

eng/tools/generate_api_report/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn main() -> Result<(), Box<dyn Error>> {
121121
}
122122

123123
// Create the package_name.rust.json in the review/ folder
124-
let output_path_str = review_folder_path.join(format!("{}_rust.json", package_name));
124+
let output_path_str = review_folder_path.join(format!("{}.rust.json", package_name));
125125
let output_path = Path::new(&output_path_str);
126126
let mut output_file = File::create(output_path)?;
127127
serde_json::to_writer(&mut output_file, &root)?;

0 commit comments

Comments
 (0)