Advertisement
Guest User

Untitled

a guest
Oct 20th, 2022
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. # generated from ament_package/template/prefix_level/setup.sh.in
  2.  
  3. # since this file is sourced use either the provided AMENT_CURRENT_PREFIX
  4. # or fall back to the destination set at configure time
  5. : ${AMENT_CURRENT_PREFIX:=/opt/ros/rolling}
  6.  
  7. # set type of shell if not already set
  8. : ${AMENT_SHELL:=sh}
  9.  
  10. # function to append non-duplicate values to environment variables
  11. # using colons as separators and avoiding leading separators
  12. ament_append_unique_value() {
  13. # arguments
  14. _listname=$1
  15. _value=$2
  16. #echo "listname $_listname"
  17. #eval echo "list value \$$_listname"
  18. #echo "value $_value"
  19.  
  20. # check if the list contains the value
  21. eval _values=\$$_listname
  22. _duplicate=
  23. _ament_append_unique_value_IFS=$IFS
  24. IFS=":"
  25. if [ "$AMENT_SHELL" = "zsh" ]; then
  26. ament_zsh_to_array _values
  27. fi
  28. for _item in $_values; do
  29. # ignore empty strings
  30. if [ -z "$_item" ]; then
  31. continue
  32. fi
  33. if [ $_item = $_value ]; then
  34. _duplicate=1
  35. fi
  36. done
  37. unset _item
  38.  
  39. # append only non-duplicates
  40. if [ -z "$_duplicate" ]; then
  41. # avoid leading separator
  42. if [ -z "$_values" ]; then
  43. eval $_listname=\"$_value\"
  44. #eval echo "set list \$$_listname"
  45. else
  46. # field separator must not be a colon
  47. unset IFS
  48. eval $_listname=\"\$$_listname:$_value\"
  49. #eval echo "append list \$$_listname"
  50. fi
  51. fi
  52. IFS=$_ament_append_unique_value_IFS
  53. unset _ament_append_unique_value_IFS
  54. unset _duplicate
  55. unset _values
  56.  
  57. unset _value
  58. unset _listname
  59. }
  60.  
  61. # iterate over all parent_prefix_path files
  62. _prefix_setup_IFS=$IFS
  63. IFS="
  64. "
  65. # this variable contains the concatenated prefix paths in reverse order
  66. _UNIQUE_PREFIX_PATH=""
  67.  
  68. # this check is used to skip parent prefix path in the Debian package
  69. if [ -z "SKIP_PARENT_PREFIX_PATH" ]; then
  70. # find parent prefix path files for all packages under the current prefix
  71. _RESOURCES="$(\find "$AMENT_CURRENT_PREFIX/share/ament_index/resource_index/parent_prefix_path" -mindepth 1 -maxdepth 1 2> /dev/null | \sort)"
  72.  
  73. if [ "$AMENT_SHELL" = "zsh" ]; then
  74. ament_zsh_to_array _RESOURCES
  75. fi
  76. for _resource in $_RESOURCES; do
  77. # read the content of the parent_prefix_path file
  78. _PARENT_PREFIX_PATH="$(\cat "$_resource")"
  79. # reverse the list
  80. _REVERSED_PARENT_PREFIX_PATH=""
  81. IFS=":"
  82. if [ "$AMENT_SHELL" = "zsh" ]; then
  83. ament_zsh_to_array _PARENT_PREFIX_PATH
  84. fi
  85. for _path in $_PARENT_PREFIX_PATH; do
  86. # replace placeholder of current prefix
  87. if [ "$_path" = "{prefix}" ]; then
  88. _path="$AMENT_CURRENT_PREFIX"
  89. fi
  90. # avoid leading separator
  91. if [ -z "$_REVERSED_PARENT_PREFIX_PATH" ]; then
  92. _REVERSED_PARENT_PREFIX_PATH=$_path
  93. else
  94. _REVERSED_PARENT_PREFIX_PATH=$_path:$_REVERSED_PARENT_PREFIX_PATH
  95. fi
  96. done
  97. unset _PARENT_PREFIX_PATH
  98. # collect all unique parent prefix path
  99. if [ "$AMENT_SHELL" = "zsh" ]; then
  100. ament_zsh_to_array _REVERSED_PARENT_PREFIX_PATH
  101. fi
  102. for _path in $_REVERSED_PARENT_PREFIX_PATH; do
  103. ament_append_unique_value _UNIQUE_PREFIX_PATH "$_path"
  104. done
  105. unset _REVERSED_PARENT_PREFIX_PATH
  106. done
  107. unset _resource
  108. unset _RESOURCES
  109. fi
  110.  
  111. # append this directory to the prefix path
  112. ament_append_unique_value _UNIQUE_PREFIX_PATH "$AMENT_CURRENT_PREFIX"
  113. unset AMENT_CURRENT_PREFIX
  114.  
  115. # store AMENT_SHELL to restore it after each prefix
  116. _prefix_setup_AMENT_SHELL=$AMENT_SHELL
  117. # source local_setup.EXT or local_setup.sh file for each prefix path
  118. IFS=":"
  119. if [ "$AMENT_SHELL" = "zsh" ]; then
  120. ament_zsh_to_array _UNIQUE_PREFIX_PATH
  121. fi
  122. for _path in $_UNIQUE_PREFIX_PATH; do
  123. # trace output
  124. if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then
  125. echo "# . \"$_path/local_setup.$AMENT_SHELL\""
  126. fi
  127. if [ -f "$_path/local_setup.$AMENT_SHELL" ]; then
  128. if [ "$AMENT_SHELL" = "sh" ]; then
  129. # provide AMENT_CURRENT_PREFIX to .sh files
  130. AMENT_CURRENT_PREFIX=$_path
  131. fi
  132. # restore IFS before sourcing other files
  133. IFS=$_prefix_setup_IFS
  134. . "$_path/local_setup.$AMENT_SHELL"
  135. # restore AMENT_SHELL after each prefix-level local_setup file
  136. AMENT_SHELL=$_prefix_setup_AMENT_SHELL
  137. fi
  138. done
  139. unset _path
  140. IFS=$_prefix_setup_IFS
  141. unset _prefix_setup_IFS
  142. unset _prefix_setup_AMENT_SHELL
  143. unset _UNIQUE_PREFIX_PATH
  144. unset AMENT_SHELL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement