From e995ff4e246404913c95b69d5a7bff584ec3a2fa Mon Sep 17 00:00:00 2001 From: Mikhail Date: Thu, 29 May 2025 00:13:54 +0300 Subject: [PATCH] Release 1.0 --- UpdateCMakeList.ps1 | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/UpdateCMakeList.ps1 b/UpdateCMakeList.ps1 index e13f392..5d68bbc 100644 --- a/UpdateCMakeList.ps1 +++ b/UpdateCMakeList.ps1 @@ -3,10 +3,26 @@ $Template = "" $IncDirs = [System.Collections.Hashtable]::new() $files = Get-ChildItem -Path $PSScriptRoot/../../Library -Recurse -Include '*.h' #-Name -/cmake/stm32cubemx +$StartString = Select-String -Path $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Pattern "# Library folder" +$StopString = Select-String -Path $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Pattern "# Library folder end" + +if ($StartString.Count -eq 2 -and $StopString.Count -eq 1) +{ + # Считываем содержимое файла + $content = Get-Content $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt + + # Указываем диапазон строк для удаления + $startLine = $StartString[0].LineNumber + $endLine = $StopString[0].LineNumber + + # Удаляем строки в указанном диапазоне + $content = $content[0..($startLine-2)] + $content[($endLine)..($content.Length)] + + # Записываем обновленный файл + $content | Out-File $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Encoding UTF8 +} + -Write-Output "" | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8 -Write-Output "" | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8 Write-Output "# Library folder" | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8 Write-Output "set(DS_Include_Dirs" | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8 @@ -52,5 +68,6 @@ foreach($file in $files) Write-Output ')' | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8 Write-Output 'target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${DS_Application_Src})' | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8 -Write-Output "" | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8 +Write-Output "# Library folder end" | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8 +