Compare commits
6
Commits
Dev
..
ai-context
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ec5860d2e | ||
|
|
7447ece442 | ||
|
|
d87198c0c3 | ||
|
|
c9daac6109 | ||
|
|
b06e03e1ef | ||
|
|
cfd0904496 |
@@ -0,0 +1 @@
|
||||
cfd09044962dc4abdeae37d7a235f308ac55012d
|
||||
@@ -0,0 +1,18 @@
|
||||
# 🤖 Технический контекст проекта (Сгенерировано ИИ)
|
||||
|
||||
# 🤖 README для репозитория
|
||||
|
||||
**1. Краткое назначение проекта.**
|
||||
Проект предназначен для автоматизации обновления файлов CMakeLists в проектах на языке C/C++ с использованием PowerShell. Цель проекта — упростить процесс модификации и управления файлами сборки CMake для разработчиков.
|
||||
|
||||
**2. Тип стека.**
|
||||
Скрипты автоматизации сборки (CMake) и скрипты PowerShell.
|
||||
|
||||
**3. Архитектурный разбор:**
|
||||
- Файл UpdateCMakeList.ps1 — содержит скрипт на языке PowerShell, предназначенный для обновления файлов CMakeLists в соответствии с заданными правилами и шаблонами.
|
||||
|
||||
Для более детального понимания структуры проекта рекомендуется ознакомиться с комментариями в коде.
|
||||
|
||||
<!-- USER_CUSTOM_CONTEXT_START -->
|
||||
# ✍️ Заметки разработчика
|
||||
*Допишите сюда свои требования, и ИИ учтет их при следующем запуске*
|
||||
+21
-23
@@ -1,19 +1,15 @@
|
||||
|
||||
$FileToWrite = Get-ChildItem -Path $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt
|
||||
$Temp = $FileToWrite.FullName.Split('\')
|
||||
$MainProjectDir = $Temp[0..($Temp.Count-4)] -join '\'
|
||||
|
||||
$Template = ""
|
||||
$IncDirs = [System.Collections.Hashtable]::new()
|
||||
$files = Get-ChildItem -Path $MainProjectDir/Library -Recurse -Include '*.h' #-Name
|
||||
$files = Get-ChildItem -Path $PSScriptRoot/../../Library -Recurse -Include '*.h' #-Name
|
||||
|
||||
$StartString = Select-String -Path $FileToWrite -Pattern "# Library folder"
|
||||
$StopString = Select-String -Path $FileToWrite -Pattern "# Library folder end"
|
||||
$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 $FileToWrite
|
||||
$content = Get-Content $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt
|
||||
|
||||
# Указываем диапазон строк для удаления
|
||||
$startLine = $StartString[0].LineNumber
|
||||
@@ -23,12 +19,12 @@ if ($StartString.Count -eq 2 -and $StopString.Count -eq 1)
|
||||
$content = $content[0..($startLine-2)] + $content[($endLine)..($content.Length)]
|
||||
|
||||
# Записываем обновленный файл
|
||||
$content | Out-File $FileToWrite -Encoding UTF8
|
||||
$content | Out-File $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Encoding UTF8
|
||||
}
|
||||
|
||||
|
||||
Write-Output "# Library folder" | Out-File -FilePath $FileToWrite -Append -Encoding utf8
|
||||
Write-Output "set(DS_Include_Dirs" | Out-File -FilePath $FileToWrite -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
|
||||
|
||||
foreach($file in $files)
|
||||
{
|
||||
@@ -40,36 +36,38 @@ foreach($file in $files)
|
||||
|
||||
foreach($IncDir in $IncDirs.Values)
|
||||
{
|
||||
$Template = $MainProjectDir
|
||||
$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 $FileToWrite -Append -Encoding utf8
|
||||
Write-Output $TempString | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8
|
||||
}
|
||||
|
||||
Write-Output ')' | Out-File -FilePath $FileToWrite -Append -Encoding utf8
|
||||
Write-Output 'target_include_directories(stm32cubemx INTERFACE ${DS_Include_Dirs})' | Out-File $FileToWrite -Append -Encoding utf8
|
||||
Write-Output '' | Out-File -FilePath $FileToWrite -Append -Encoding utf8
|
||||
Write-Output 'set(DS_Application_Src' | Out-File -FilePath $FileToWrite -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 $MainProjectDir/Library -Recurse -Include '*.c'
|
||||
$files = Get-ChildItem -Path $PSScriptRoot/../../Library -Recurse -Include '*.c' #-Name
|
||||
|
||||
foreach($file in $files)
|
||||
{
|
||||
$Template = $MainProjectDir
|
||||
$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 $FileToWrite -Append -Encoding utf8
|
||||
Write-Output $TempString | Out-File -FilePath $PSScriptRoot/../../cmake/stm32cubemx/CMakeLists.txt -Append -Encoding utf8
|
||||
}
|
||||
|
||||
Write-Output ')' | Out-File -FilePath $FileToWrite -Append -Encoding utf8
|
||||
Write-Output 'target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${DS_Application_Src})' | Out-File -FilePath $FileToWrite -Append -Encoding utf8
|
||||
Write-Output "# Library folder end" | Out-File -FilePath $FileToWrite -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user