rasc_launcher.bat 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. @echo off
  2. REM RASC launcher 2024-08-05
  3. setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
  4. REM First parameter is (possibly non-existent) file containing RASC version to invoke
  5. set "RascVersionFile=%~1"
  6. REM RASC version handler script is located in the same directory as this launcher script
  7. set "RascVersionHandler=%~dp0rasc_version.bat"
  8. REM Shift to leave remaining parameters as input parameters to RASC
  9. shift
  10. REM Define input and output files
  11. set "InputFile=%~dp0configuration.xml"
  12. set "OutputFile=%~dp0output.rasc"
  13. REM Check if --gensmartbundle is passed, 9th param is .axf file
  14. if "%~3"=="--gensmartbundle" (
  15. set "InputFile=%~9"
  16. set "OutputFile=%~dpn9.sbd"
  17. )
  18. REM Check if input file exists
  19. if not exist "%InputFile%" (
  20. echo [ERROR] Input file "%InputFile%" does not exist. Exiting.
  21. exit /b 1
  22. )
  23. REM Check if output file exists
  24. if not exist "%OutputFile%" (
  25. echo [INFO] Output file "%OutputFile%" does not exist. Proceeding with RASC invocation...
  26. goto :InvokeRasc
  27. )
  28. REM Compare timestamps of input and output files
  29. xcopy /L /D /Y "%InputFile%" "%OutputFile%" | findstr /B /C:"1 " > nul
  30. if not errorlevel 1 (
  31. echo [INFO] Input file "%InputFile%" is newer than output file "%OutputFile%". Proceeding with RASC invocation...
  32. goto :InvokeRasc
  33. ) else (
  34. echo [INFO] Input file "%InputFile%" is older than output file "%OutputFile%". Skipping RASC invocation.
  35. exit /b 0
  36. )
  37. :InvokeRasc
  38. REM Invoke rasc_version.bat to check rasc_version.txt and update it if required
  39. REM If user selection of RASC version is required then the first non-interactive call will exit with error status
  40. REM In that case we re-invoke in a new command shell to allow user interaction
  41. call "%RascVersionHandler%" "%RascVersionFile%" NonInteractive || start /wait "Renesas" cmd /c ""%RascVersionHandler%" "%RascVersionFile%""
  42. if errorlevel 1 exit /b 1
  43. REM Extract specific RASC version from file
  44. REM echo "%RascVersionFile%"
  45. if exist "%RascVersionFile%" (
  46. REM echo DEBUG: Have version file: "%RascVersionFile%"
  47. set /a idx=0
  48. for /f "usebackq tokens=*" %%a in ("%RascVersionFile%") do (
  49. if !idx! EQU 2 (
  50. set "RascExe=%%a"
  51. )
  52. set /a idx+=1
  53. )
  54. )
  55. REM Synchronous behaviour for build pre/post steps
  56. set "WaitRasc="
  57. IF "%~3"=="--generate" SET CLI=true
  58. IF "%~3"=="--gensmartbundle" SET CLI=true
  59. IF "%CLI%"=="true" (
  60. SET "WaitRasc=/b /wait"
  61. SET RascExe=%RascExe:rasc.exe=rascc.exe%
  62. )
  63. set Parameters=
  64. for %%a in (%*) do (
  65. if defined FirstParamSkipped set Parameters=!Parameters! %%a
  66. set FirstParamSkipped=true
  67. )
  68. REM echo DEBUG: Launching "%RascExe%" %Parameters%
  69. start "" %WaitRasc% "%RascExe%" %Parameters%
  70. if not errorlevel 1 goto :EOF
  71. exit /b 1