-
Notifications
You must be signed in to change notification settings - Fork 118
/
ament_prefix_path.bat
39 lines (35 loc) · 1.03 KB
/
ament_prefix_path.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
:: copied from
:: ament_cmake_core/cmake/environment_hooks/environment/ament_prefix_path.bat
@echo off
call:ament_prepend_unique_value AMENT_PREFIX_PATH "%AMENT_CURRENT_PREFIX%"
goto:eof
:: Prepend non-duplicate values to environment variables
:: using semicolons as separators and avoiding trailing separators.
:: first argument: the name of the result variable
:: second argument: the value
:ament_prepend_unique_value
setlocal enabledelayedexpansion
:: arguments
set "listname=%~1"
set "value=%~2"
:: expand the list variable
set "list=!%listname%!"
:: check if the list contains the value
set "is_duplicate="
if "%list%" NEQ "" (
for %%v in ("%list:;=";"%") do (
if "%%~v" == "%value%" set "is_duplicate=1"
)
)
:: if it is not a duplicate prepend it
if "%is_duplicate%" == "" (
:: if not empty, prepend a semi-colon
if "!list!" NEQ "" set "list=;!list!"
:: prepend the value
set "list=%value%!list!"
)
endlocal & (
:: set result variable in parent scope
set "%~1=%list%"
)
goto:eof