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