74 lines
3.4 KiB
PowerShell
74 lines
3.4 KiB
PowerShell
|
|
$Template = ""
|
|
$IncDirs = [System.Collections.Hashtable]::new()
|
|
$files = Get-ChildItem -Path $PSScriptRoot/../../Library -Recurse -Include '*.h' #-Name
|
|
|
|
$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 "# 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
|
|
|
|
foreach($file in $files)
|
|
{
|
|
try
|
|
{
|
|
$IncDirs.Add($file.DirectoryName, $file.DirectoryName)
|
|
} catch {}
|
|
}
|
|
|
|
foreach($IncDir in $IncDirs.Values)
|
|
{
|
|
$Template = $PSScriptRoot
|
|
$Template = $Template -replace "\\cmake\\stm32cubemx", ''
|
|
$Template = $Template -replace "\\", '/'
|
|
|
|
$TempString = $IncDir -replace '\\', '/'
|
|
$TempString = $TempString -replace $Template, ''
|
|
$TempString = ' ${CMAKE_SOURCE_DIR}' + $TempString
|
|
Write-Output $TempString | 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 'target_include_directories(stm32cubemx INTERFACE ${DS_Include_Dirs})' | 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 'set(DS_Application_Src' | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8
|
|
|
|
|
|
$files = Get-ChildItem -Path $PSScriptRoot/../../Library -Recurse -Include '*.c' #-Name
|
|
|
|
foreach($file in $files)
|
|
{
|
|
$Template = $PSScriptRoot
|
|
$Template = $Template -replace "\\cmake\\stm32cubemx", ''
|
|
$Template = $Template -replace "\\", '/'
|
|
|
|
$TempString = $file.FullName -replace '\\', '/'
|
|
$TempString = $TempString -replace $Template, ''
|
|
$TempString = ' ${CMAKE_SOURCE_DIR}' + $TempString
|
|
Write-Output $TempString | 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 'target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${DS_Application_Src})' | 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
|
|
|
|
|