From fbc162818e5e02440acc10f9cf80e43312b039ef Mon Sep 17 00:00:00 2001 From: Anton Kolesnyk Date: Mon, 6 Jun 2022 10:48:25 -0700 Subject: [PATCH 1/2] ApiView command line generation script --- eng/scripts/Get-ApiViewCommandLine.ps1 | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 eng/scripts/Get-ApiViewCommandLine.ps1 diff --git a/eng/scripts/Get-ApiViewCommandLine.ps1 b/eng/scripts/Get-ApiViewCommandLine.ps1 new file mode 100644 index 0000000000..7980009454 --- /dev/null +++ b/eng/scripts/Get-ApiViewCommandLine.ps1 @@ -0,0 +1,53 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +# Usage: Get-ApiViewCommandLine.ps1 .\azure-sdk-for-cpp azure-identity +# Or: ..\Get-ApiViewCommandLine.ps1 . azure-core +# Or: Get-ApiViewCommandLine.ps1 ..\.. azure-security-attestation +# Or: c:\src\azure-sdk-for-cpp\eng\scripts\Get-ApiViewCommandLine.ps1 c:\src\azure-sdk-for-cpp azure-identity + +param($RepoPath, $LibName) + +[String]$SdkRoot = Resolve-Path ($RepoPath + "\sdk") + +[String[]]$AllIncDirs = Get-ChildItem -Directory -Filter "inc" -Recurse $SdkRoot | Select-Object -ExpandProperty FullName + +[String[]]$AllIncDirsWithoutInc = $AllIncDirs | Select-Object @{ Label="Substr"; Expression = { $_.Substring(0, $_.Length - "inc".Length) } } | Select-Object -ExpandProperty Substr + +[String[]]$AllLibIncDirs = @() +for($i = 0; $i -lt $AllIncDirsWithoutInc.Length; $i++) { + $isLibDir = $true + $libDir = $AllIncDirsWithoutInc[$i] + for($j = 0; $j -lt $AllIncDirsWithoutInc.Length; $j++) { + if ($i -eq $j) { + continue + } + + $StartsWith = $AllIncDirsWithoutInc[$j] + "*" + if ($libDir -Like $StartsWith) { + $isLibDir = $false + break + } + } + + if ($isLibDir){ + $AllLibIncDirs += $libDir + "inc" + } +} + +[String]$LibIncDir = $AllLibIncDirs | Where-Object {$_ -Match ("\\" + $LibName + "\\inc") } | Select-Object -First 1 + +[String[]]$LibHeaders = Get-ChildItem -File -Recurse $LibIncDir | Select-Object -ExpandProperty FullName + +$CmdLine = "clang++" +foreach ($header in $LibHeaders) { + $CmdLine += " " + $header +} + +$CmdLine += " -Xclang -ast-dump" + +foreach ($incDir in $AllLibIncDirs) { + $CmdLine += " -I " + $incDir +} + +$CmdLine From ba42fd33ddbd02fcd568a67c953a693e411f502c Mon Sep 17 00:00:00 2001 From: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com> Date: Mon, 6 Jun 2022 12:50:19 -0700 Subject: [PATCH 2/2] Strongly typed parameters Co-authored-by: Ben Broderick Phillips --- eng/scripts/Get-ApiViewCommandLine.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/Get-ApiViewCommandLine.ps1 b/eng/scripts/Get-ApiViewCommandLine.ps1 index 7980009454..9359416cfa 100644 --- a/eng/scripts/Get-ApiViewCommandLine.ps1 +++ b/eng/scripts/Get-ApiViewCommandLine.ps1 @@ -6,7 +6,7 @@ # Or: Get-ApiViewCommandLine.ps1 ..\.. azure-security-attestation # Or: c:\src\azure-sdk-for-cpp\eng\scripts\Get-ApiViewCommandLine.ps1 c:\src\azure-sdk-for-cpp azure-identity -param($RepoPath, $LibName) +param([String]$RepoPath, [String]$LibName) [String]$SdkRoot = Resolve-Path ($RepoPath + "\sdk")