@@ -177,61 +177,26 @@ function PrepareIdfPython {
177177}
178178
179179function PrepareIdfDocumentation {
180- $DocumentationBasePath = " .\build\$InstallerType \docs"
181- $DownloadedZipName = " esp-idf-en-$OfflineBranch .zip"
182- $DownloadUrl = " https://docs.espressif.com/projects/esp-idf/en/$OfflineBranch /esp32/$DownloadedZipName "
183-
184- if (-Not (Test-Path - Path $DocumentationBasePath - PathType Container)) {
185- New-Item - ItemType Directory - Path $DocumentationBasePath
186- }
187-
188- $ZipFilePath = Join-Path - Path $DocumentationBasePath - ChildPath $DownloadedZipName
189- # Download the ZIP file if it doesn't already exist
190- if (-Not (Test-Path - Path $ZipFilePath - PathType Leaf)) {
191- " Downloading: $DownloadUrl "
192- try {
193- $Request = Invoke-WebRequest $DownloadUrl - OutFile $ZipFilePath - MaximumRedirection 0
194- [int ]$StatusCode = $Request.StatusCode
195- }
196- catch {
197- [int ]$StatusCode = $_.Exception.Response.StatusCode
198- }
199-
200-
201- if ($StatusCode -eq 302 ) {
202- FailBuild - Message " Failed to download documentation from $DownloadUrl . Status code: $StatusCode "
203- }
204- } else {
205- " Documentation ZIP file already exists: $ZipFilePath "
206- }
207-
208- $ExtractedPath = Join-Path - Path $DocumentationBasePath - ChildPath " html"
209- # Extract the ZIP file if not already extracted
210- if (-Not (Test-Path - Path $ExtractedPath - PathType Container)) {
211- " Extracting documentation to: $ExtractedPath "
212- try {
213- Expand-Archive - Path $ZipFilePath - DestinationPath $ExtractedPath
214- } catch {
215- FailBuild - Message " Failed to extract documentation ZIP file at $ZipFilePath . Error: $_ "
216- }
217- } else {
218- " Documentation already extracted to: $ExtractedPath "
219- }
220-
221- # Create a symbolic link to the HTML index
222- $HtmlIndexPath = Join-Path - Path $ExtractedPath - ChildPath " index.html"
223- if (-Not (Test-Path - Path $HtmlIndexPath - PathType Leaf)) {
224- FailBuild - Message " Documentation HTML index not found in extracted documentation path: $ExtractedPath ."
225- }
226- $SymLinkFilePath = " .\build\$InstallerType \IDFdocumentation.html"
227- if (-Not (Test-Path - Path $SymLinkFilePath - PathType Leaf)) {
228- " Creating symbolic link: $SymLinkFilePath -> $HtmlIndexPath "
229- try {
230- $AbsoluteHtmlIndexPath = Resolve-Path - Path $HtmlIndexPath - ErrorAction SilentlyContinue
231- New-Item - ItemType SymbolicLink - Path $SymLinkFilePath - Value $AbsoluteHtmlIndexPath > $null
232- } catch {
233- " ERROR: Failed to create symbolic link at $SymLinkFilePath . Error: $_ "
234- }
180+ $FullFilePath = " .\build\$InstallerType \IDFdocumentation.pdf"
181+ $DownloadUrl = " https://docs.espressif.com/projects/esp-idf/en/$OfflineBranch /esp32/esp-idf-en-$OfflineBranch -esp32.pdf"
182+
183+ if (Test-Path - Path $FullFilePath - PathType Leaf) {
184+ " $FullFilePath found."
185+ return
186+ }
187+
188+ " Downloading: $DownloadUrl "
189+ try {
190+ $Request = Invoke-WebRequest $DownloadUrl - OutFile $FullFilePath - MaximumRedirection 0
191+ [int ]$StatusCode = $Request.StatusCode
192+ }
193+ catch {
194+ [int ]$StatusCode = $_.Exception.Response.StatusCode
195+ }
196+
197+
198+ if ($StatusCode -eq 302 ) {
199+ FailBuild - Message " Failed to download documentation from $DownloadUrl . Status code: $StatusCode "
235200 }
236201}
237202
0 commit comments