diff --git a/setup_framework.bat b/setup_framework.bat index 3e20a14..7890af5 100644 --- a/setup_framework.bat +++ b/setup_framework.bat @@ -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