Fix Windows batch script - remove PowerShell dependency

- Replace PowerShell Set-Content with native batch commands
- Use type, findstr, echo and move for file processing
- Should work on all Windows systems without PowerShell restrictions
This commit is contained in:
xlemmingx 2025-10-07 18:55:13 +02:00
parent 7a6f7c46d0
commit de28645511

View File

@ -85,25 +85,22 @@ echo Updating CMakeLists.txt...
REM Create backup REM Create backup
copy "%CMAKE_FILE%" "%CMAKE_FILE%.backup" >nul copy "%CMAKE_FILE%" "%CMAKE_FILE%.backup" >nul
REM For Windows, we'll use PowerShell for text replacement REM Simple replacement - add the two lines after the zephyr_library_sources_ifdef line
powershell -Command ^ set TEMP_FILE=%CMAKE_FILE%.tmp
"$content = Get-Content '%CMAKE_FILE%'; ^ type nul > "%TEMP_FILE%"
$newContent = @(); ^
$inSection = $false; ^ REM Use findstr to process the file line by line
foreach ($line in $content) { ^ for /f "delims=" %%i in ('type "%CMAKE_FILE%"') do (
if ($line -match 'zephyr_library_sources_ifdef\(CONFIG_HAS_SEMTECH_SX126X') { ^ echo %%i >> "%TEMP_FILE%"
$newContent += $line; ^ echo %%i | findstr /c:"zephyr_library_sources_ifdef(CONFIG_HAS_SEMTECH_SX126X" >nul
$newContent += ' ${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio.c'; ^ if not errorlevel 1 (
$newContent += ' ${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio_sx126x.c'; ^ echo ${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio.c >> "%TEMP_FILE%"
$inSection = $true; ^ echo ${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio_sx126x.c >> "%TEMP_FILE%"
} elseif ($inSection -and $line -match '^\)') { ^ )
$newContent += $line; ^ )
$inSection = $false; ^
} elseif (-not $inSection) { ^ REM Replace original file with modified version
$newContent += $line; ^ move "%TEMP_FILE%" "%CMAKE_FILE%"
} ^
}; ^
$newContent | Set-Content '%CMAKE_FILE%'"
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo [31mError: Failed to update CMakeLists.txt[0m echo [31mError: Failed to update CMakeLists.txt[0m