60 lines
1.8 KiB
Batchfile
60 lines
1.8 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 code ^(e.g., 2019.1^)
|
|
exit /b 1
|
|
)
|
|
|
|
REM Prompt user for Xilinx installation path, default to C:\Xilinx if not provided
|
|
set "default_path=C:\Xilinx"
|
|
set /p "xilinx_path=Enter Xilinx installation path (press Enter for default: %default_path%): "
|
|
if "%xilinx_path%"=="" (
|
|
set "xilinx_path=%default_path%"
|
|
)
|
|
|
|
REM Convert version to 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 and user path
|
|
if %version_number% lss %lowest_vitis_version% (
|
|
echo Setting up environment for Xilinx SDK.
|
|
set settings_bat=%xilinx_path%\SDK\%xilinx_version%\settings64.bat
|
|
) else (
|
|
echo Setting up environment for Xilinx Vitis.
|
|
set settings_bat=%xilinx_path%\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
|