-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from ament/windows
Windows Support
- Loading branch information
Showing
6 changed files
with
461 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
:: generated from ament_package/template/environment_hook/pythonpath.bat.in | ||
if defined AMENT_TRACE_SETUP_FILES echo Inside %~0 | ||
|
||
call:ament_prepend_unique_value PYTHONPATH "%AMENT_CURRENT_PREFIX%\@PYTHON_INSTALL_DIR@" | ||
|
||
if defined AMENT_TRACE_SETUP_FILES set PYTHONPATH | ||
if defined AMENT_TRACE_SETUP_FILES echo Leaving %~0 | ||
goto:eof | ||
|
||
:: function to prepend non-duplicate values to environment variables | ||
:: using colons as separators and avoiding trailing separators | ||
: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 %%a in ("%_list:;=";"%") do ( | ||
if "%%~a" == "%_value%" set "_is_duplicate=1" | ||
) | ||
) | ||
:: if it is not a duplicate prepend it | ||
if "%_is_duplicate%" == "" ( | ||
:: produces a trailing semicolon when the list empty, but that's ok | ||
set "_list=%_value%;%_list%" | ||
) | ||
(endlocal | ||
set "%~1=%_list%" | ||
) | ||
goto:eof |
53 changes: 53 additions & 0 deletions
53
ament_package/template/isolated_prefix_level/local_setup.bat.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
:: generated from ament_package/template/isolated_prefix_level/local_setup.sh.in | ||
if defined AMENT_TRACE_SETUP_FILES echo Inside "%~p0" | ||
|
||
:: since this file is sourced use either the provided AMENT_CURRENT_PREFIX | ||
:: or fall back to the destination set at configure time | ||
if not defined AMENT_CURRENT_PREFIX ( | ||
set "AMENT_CURRENT_PREFIX=@CMAKE_INSTALL_PREFIX@" | ||
) | ||
|
||
:: set type of shell if not already set | ||
if not defined AMENT_SHELL ( | ||
set "AMENT_SHELL=bat" | ||
) | ||
|
||
:: get all packages in topological order | ||
set "_ORDERED_PACKAGES=" | ||
:ament_get_ordered_packages _ORDERED_PACKAGES "%AMENT_CURRENT_PREFIX%" | ||
|
||
:: source prefix-level local_setup.EXT or local_setup.sh file for each package | ||
:: store AMENT_CURRENT_PREFIX to restore it before each package | ||
set "_isolated_prefix_local_setup_AMENT_CURRENT_PREFIX=%AMENT_CURRENT_PREFIX%" | ||
for %%a in ("%_ORDERED_PACKAGES:;=";"%") do ( | ||
:: restore AMENT_CURRENT_PREFIX for each prefix-level local_setup file | ||
set "AMENT_CURRENT_PREFIX=%_isolated_prefix_local_setup_AMENT_CURRENT_PREFIX%\%%a" | ||
:: bypass prefix-level local_setup file for performance reasons | ||
set "_path=%AMENT_CURRENT_PREFIX%/share/%_package%/local_setup.bat" | ||
:: trace output | ||
if "%AMENT_TRACE_SETUP_FILES%" NEQ "" echo (call "%_path%") | ||
if exist "%_path%" call "%_path%" | ||
set "_path=" | ||
) | ||
set "_ORDERED_PACKAGES=" | ||
set "_isolated_prefix_local_setup_AMENT_CURRENT_PREFIX=" | ||
set "AMENT_CURRENT_PREFIX=" | ||
|
||
:: run any command and arugments passed | ||
%* | ||
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% | ||
|
||
:: prevent double evaluation of function below | ||
if defined AMENT_TRACE_SETUP_FILES echo Leaving %~0 | ||
goto:eof | ||
|
||
:: function to get the packages in this space in topological order | ||
:: packages are seperated by a semicolon delimiter. | ||
:ament_get_ordered_packages | ||
setlocal enabledelayedexpansion | ||
set "ordered_packages=" | ||
for /f %%a in ('"@PYTHON_EXECUTABLE@" "%AMENT_CURRENT_PREFIX%\_order_isolated_packages.py" "%AMENT_CURRENT_PREFIX%"') do ( | ||
if "%ordered_packages%" NEQ "" set "ordered_packages=%ordered_packages%;" | ||
set "ordered_packages=%ordered_packages%%%a" | ||
) | ||
goto:eof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
:: generated from ament_package/template/package_level/local_setup.bat.in | ||
if defined AMENT_TRACE_SETUP_FILES echo Inside %~0 | ||
|
||
:: since this file is called use either the provided AMENT_CURRENT_PREFIX | ||
:: or fall back to the destination set at configure time | ||
if not defined AMENT_CURRENT_PREFIX ( | ||
set "AMENT_CURRENT_PREFIX=@CMAKE_INSTALL_PREFIX@" | ||
call:convert_forwardslash_to_backslash AMENT_CURRENT_PREFIX | ||
) | ||
|
||
:: unset AMENT_ENVIRONMENT_HOOKS | ||
:: if not appending to them for return | ||
if not defined AMENT_RETURN_ENVIRONMENT_HOOKS ( | ||
set "AMENT_ENVIRONMENT_HOOKS[@PROJECT_NAME@]=" | ||
) | ||
|
||
:: this is a list all environment hooks of this package | ||
@ENVIRONMENT_HOOKS@ | ||
|
||
:: source all shell-specific environment hooks of this package | ||
:: if not returning them | ||
if not defined AMENT_RETURN_ENVIRONMENT_HOOKS ( | ||
for %%a in ("%AMENT_ENVIRONMENT_HOOKS[@PROJECT_NAME@]:;=";"%") do ( | ||
if exist "%%a" call "%%a" | ||
) | ||
) | ||
|
||
:: reset AMENT_CURRENT_PREFIX after each package | ||
:: allowing to source multiple package-level setup files | ||
set "AMENT_CURRENT_PREFIX=" | ||
|
||
:: run any command and arugments passed | ||
%* | ||
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% | ||
|
||
:: prevent second eval of functions below | ||
if defined AMENT_TRACE_SETUP_FILES echo Leaving %~0 | ||
goto:eof | ||
|
||
:: converts any forwardslashes / to backslashes \ in the given variable | ||
:convert_forwardslash_to_backslash | ||
setlocal enabledelayedexpansion | ||
set "ret=%~1" | ||
set "ret=!%ret%!" | ||
set "ret=%ret:/=\%" | ||
(endlocal | ||
set "%~1=%ret%" | ||
) | ||
goto:eof | ||
|
||
:: function to append values to environment variables | ||
:: using semi-colons as separators and avoiding trailing separators | ||
:ament_append_value | ||
setlocal enabledelayedexpansion | ||
:: arguments (%~1 and %~2 are the first and second arguments) | ||
set "_listname=%~1" | ||
set "_value=%~2" | ||
:: expand the first argument | ||
set "_list=!%_listname%!" | ||
:: if not empty, append a semi-colon | ||
if "%_list%" NEQ "" set "_list=%_list%;" | ||
:: concatenate new value | ||
set "_list=%_list%%_value%" | ||
:: return by reference (%~1 is the first argument) | ||
(endlocal | ||
set "%~1=%_list%" | ||
) | ||
goto:eof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
:: generated from ament_package/template/prefix_level/local_setup.bat.in | ||
@echo off | ||
if defined AMENT_TRACE_SETUP_FILES echo Inside "%~0" | ||
|
||
:: since this file is sourced use either the provided AMENT_CURRENT_PREFIX | ||
:: or fall back to the destination set at configure time | ||
set "AMENT_CURRENT_PREFIX=" | ||
if not defined AMENT_CURRENT_PREFIX ( | ||
set "AMENT_CURRENT_PREFIX=@CMAKE_INSTALL_PREFIX@" | ||
call:convert_forwardslash_to_backslash AMENT_CURRENT_PREFIX | ||
) | ||
|
||
:: set type of shell if not already set | ||
if not defined AMENT_SHELL ( | ||
set "AMENT_SHELL=bat" | ||
) | ||
|
||
:: find all packages under the current prefix based on the resource index | ||
set "_PACKAGES=" | ||
set "AMENT_CUR_ENV_HOOKS=" | ||
call:list_files _PACKAGES "%AMENT_CURRENT_PREFIX%\share\ament_index\resource_index\packages" | ||
|
||
:: source local_setup.bat files for each package to collect environment hooks | ||
call:call_local_setups _PACKAGES | ||
|
||
:: no call the environment hooks in order | ||
call:call_ament_environment_hooks | ||
call:clear_ament_environment_hook_vars | ||
set "AMENT_CUR_ENV_HOOKS=" | ||
set "_PACKAGES=" | ||
|
||
:: run any command and arugments passed | ||
%* | ||
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% | ||
|
||
:: prevent double evaluation of functions below | ||
if defined AMENT_TRACE_SETUP_FILES echo Leaving %~0 | ||
goto:eof | ||
|
||
:foo | ||
echo %~1 | ||
goto:eof | ||
|
||
:: clears all the AMENT_ENVIRONMENT_HOOKS varaibles | ||
:clear_ament_environment_hook_vars | ||
for /f "tokens=1 delims==" %%f in ('set AMENT_ENVIRONMENT_HOOKS[') do ( | ||
endlocal | ||
set "%%f=" | ||
) | ||
goto:eof | ||
|
||
:: iterates through the environment hooks and sources them | ||
:call_ament_environment_hooks | ||
setlocal enabledelayedexpansion | ||
:: store AMENT_CURRENT_PREFIX to restore it before each package | ||
set "_prefix_local_setup_AMENT_CURRENT_PREFIX=%AMENT_CURRENT_PREFIX%" | ||
:: source each environment hook | ||
:: TODO(wjwwood): do a stable sort by filename, not dirname | ||
for /f "tokens=2 delims==" %%f in ('set AMENT_ENVIRONMENT_HOOKS[') do ( | ||
endlocal | ||
set "AMENT_CUR_ENV_HOOKS=%%f" | ||
call:call_hook | ||
) | ||
goto:eof | ||
|
||
:call_hook | ||
setlocal enabledelayedexpansion | ||
for %%f in ("%AMENT_CUR_ENV_HOOKS:;=";"%") do ( | ||
endlocal | ||
if exist %%f ( | ||
call %%f | ||
) | ||
) | ||
goto:eof | ||
|
||
:: iterates through a list of packages and sources the local_setup of each | ||
:: inorder to get a list of the AMENT_ENVIRONMENT_HOOKS | ||
:call_local_setups | ||
setlocal enabledelayedexpansion | ||
set "_package_list_name=%~1" | ||
set "_PACKAGES=!%_package_list_name%!" | ||
:: store AMENT_CURRENT_PREFIX to restore it before each package | ||
set "_prefix_local_setup_AMENT_CURRENT_PREFIX=%AMENT_CURRENT_PREFIX%" | ||
:: set the flag for sourced package-level local_setup files to | ||
:: skip sourcing the environment hooks and append their environment hooks | ||
set "AMENT_RETURN_ENVIRONMENT_HOOKS=1" | ||
:: clear any hooks currently set | ||
set "AMENT_ENVIRONMENT_HOOKS=" | ||
:: for each package, source the local_setup file if it exists | ||
:: it should only append to the AMENT_ENVIRONMENT_HOOKS since the | ||
:: AMENT_RETURN_ENVIRONMENT_HOOKS flag is set. | ||
if "%_PACKAGES%" NEQ "" ( | ||
for %%a in ("%_PACKAGES:;=";"%") do ( | ||
if defined AMENT_TRACE_SETUP_FILES ( | ||
echo Getting env hooks for package "%%~a" | ||
) | ||
:: restore AMENT_CURRENT_PREFIX for each package-level local_setup file | ||
set "AMENT_CURRENT_PREFIX=%_prefix_local_setup_AMENT_CURRENT_PREFIX%" | ||
set "_path=%AMENT_CURRENT_PREFIX%\share\%%~a\local_setup.%AMENT_SHELL%" | ||
:: trace output | ||
if defined AMENT_TRACE_SETUP_FILES echo . "!_path!" | ||
:: call if it exists | ||
if exist "!_path!" call "!_path!" | ||
) | ||
) | ||
:: export all of the new variables | ||
for /f "tokens=1,2 delims==" %%f in ('set AMENT_ENVIRONMENT_HOOKS[') do ( | ||
endlocal | ||
set "%%f=%%g" | ||
) | ||
goto:eof | ||
|
||
:: converts any forwardslashes / to backslashes \ in the given variable | ||
:convert_forwardslash_to_backslash | ||
setlocal enabledelayedexpansion | ||
set "ret=%~1" | ||
set "ret=!%ret%!" | ||
set "ret=%ret:/=\%" | ||
(endlocal | ||
set "%~1=%ret%" | ||
) | ||
goto:eof | ||
|
||
:: function to list the files in a directory in alphabetical order | ||
:: use list_files_sorted if you need numerical ordering | ||
:list_files | ||
setlocal enabledelayedexpansion | ||
:: create an array with filenames in right order | ||
set "_files=" | ||
for /f %%f in ('dir /b "%~2"') do ( | ||
if "!_files!" NEQ "" (set "_files=!_files!;") | ||
set "_files=!_files!%%~f" | ||
) | ||
:: return result by reference | ||
(endlocal | ||
set "%~1=%_files%") | ||
goto:eof | ||
|
||
:: function to list the files in a directory in numerical order | ||
:: http://stackoverflow.com/a/18749126 | ||
:list_files_sorted | ||
setlocal enabledelayedexpansion | ||
:: create an array with filenames in right order | ||
for /f %%f in ('dir /b "%~2"') do ( | ||
for /F "delims=-" %%n in ("%%f") do ( | ||
set "number=00000%%n" | ||
set "file[!number:~-6!]=%%f" | ||
) | ||
) | ||
:: process the filenames in right order | ||
set "_files=" | ||
for /F "tokens=2 delims==" %%f in ('set file[') do ( | ||
if "%_files%" NEQ "" set "_files=%_files%;" | ||
set "_files=%_files%%f%" | ||
) | ||
:: return result by reference | ||
(endlocal | ||
set "%~1=%_files%") | ||
goto:eof |
Oops, something went wrong.