forked from gatsby/embedded-autobuild
53 lines
1.5 KiB
Batchfile
53 lines
1.5 KiB
Batchfile
@echo off
|
|
REM Check if exactly two arguments are provided and not empty
|
|
if "%~1"=="" (
|
|
echo Usage: setenv_xilinx.bat ^<version^>
|
|
exit /b 1
|
|
)
|
|
if not "%~2"=="" (
|
|
echo Usage: setenv_xilinx.bat ^<version^>
|
|
exit /b 1
|
|
)
|
|
|
|
REM Use regex to check if input version code is valid
|
|
set "xilinx_version=%1"
|
|
set "version_pattern=20[12][01234789][.][12]"
|
|
echo %xilinx_version% | findstr /r /c:"%version_pattern%" >nul
|
|
if %errorlevel% NEQ 0 (
|
|
echo Error: %xilinx_version% is not a valid version coede ^(e.g., 2019.1^)
|
|
exit /b 1
|
|
)
|
|
|
|
REM Convert it to a integer
|
|
for /f "tokens=1,2 delims=." %%a in ("%xilinx_version%") do (
|
|
set major=%%a
|
|
set minor=%%b
|
|
)
|
|
set /a version_number=%major%%minor%
|
|
set /a lowest_vitis_version=20192
|
|
|
|
REM Determine the correct settings.bat path based on the Xilinx version
|
|
if %version_number% lss %lowest_vitis_version% (
|
|
echo Setup enviroment for Xilinx SDK.
|
|
set settings_bat=C:\Xilinx\SDK\%xilinx_version%\settings64.bat
|
|
) else (
|
|
echo Setup enviroment for Xilinx Vitis.
|
|
set settings_bat=C:\Xilinx\Vitis\%xilinx_version%\settings64.bat
|
|
)
|
|
|
|
REM Check if the settings.bat file exists
|
|
if not exist "%settings_bat%" (
|
|
echo Error: Could not find settings file at %settings_bat%.
|
|
echo Please check your Xilinx tools installation.
|
|
exit /b 1
|
|
)
|
|
|
|
REM Call the settings.bat file to set up the environment
|
|
call "%settings_bat%"
|
|
if "%ERRORLEVEL%" neq "0" (
|
|
echo Error: Failed to source "%settings_bat%".
|
|
exit /b 1
|
|
)
|
|
|
|
exit /b 0
|