local_setup.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # generated from colcon_core/shell/template/prefix.sh.em
  2. # This script extends the environment with all packages contained in this
  3. # prefix path.
  4. # since a plain shell script can't determine its own path when being sourced
  5. # either use the provided COLCON_CURRENT_PREFIX
  6. # or fall back to the build time prefix (if it exists)
  7. _colcon_prefix_sh_COLCON_CURRENT_PREFIX="/home/neousys/autoware.ai/src/install"
  8. if [ -z "$COLCON_CURRENT_PREFIX" ]; then
  9. if [ ! -d "$_colcon_prefix_sh_COLCON_CURRENT_PREFIX" ]; then
  10. echo "The build time path \"$_colcon_prefix_sh_COLCON_CURRENT_PREFIX\" doesn't exist. Either source a script for a different shell or set the environment variable \"COLCON_CURRENT_PREFIX\" explicitly." 1>&2
  11. unset _colcon_prefix_sh_COLCON_CURRENT_PREFIX
  12. return 1
  13. fi
  14. else
  15. _colcon_prefix_sh_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX"
  16. fi
  17. # function to prepend a value to a variable
  18. # which uses colons as separators
  19. # duplicates as well as trailing separators are avoided
  20. # first argument: the name of the result variable
  21. # second argument: the value to be prepended
  22. _colcon_prefix_sh_prepend_unique_value() {
  23. # arguments
  24. _listname="$1"
  25. _value="$2"
  26. # get values from variable
  27. eval _values=\"\$$_listname\"
  28. # backup the field separator
  29. _colcon_prefix_sh_prepend_unique_value_IFS="$IFS"
  30. IFS=":"
  31. # start with the new value
  32. _all_values="$_value"
  33. # iterate over existing values in the variable
  34. for _item in $_values; do
  35. # ignore empty strings
  36. if [ -z "$_item" ]; then
  37. continue
  38. fi
  39. # ignore duplicates of _value
  40. if [ "$_item" = "$_value" ]; then
  41. continue
  42. fi
  43. # keep non-duplicate values
  44. _all_values="$_all_values:$_item"
  45. done
  46. unset _item
  47. # restore the field separator
  48. IFS="$_colcon_prefix_sh_prepend_unique_value_IFS"
  49. unset _colcon_prefix_sh_prepend_unique_value_IFS
  50. # export the updated variable
  51. eval export $_listname=\"$_all_values\"
  52. unset _all_values
  53. unset _values
  54. unset _value
  55. unset _listname
  56. }
  57. # add this prefix to the COLCON_PREFIX_PATH
  58. _colcon_prefix_sh_prepend_unique_value COLCON_PREFIX_PATH "$_colcon_prefix_sh_COLCON_CURRENT_PREFIX"
  59. unset _colcon_prefix_sh_prepend_unique_value
  60. # check environment variable for custom Python executable
  61. if [ -n "$COLCON_PYTHON_EXECUTABLE" ]; then
  62. if [ ! -f "$COLCON_PYTHON_EXECUTABLE" ]; then
  63. echo "error: COLCON_PYTHON_EXECUTABLE '$COLCON_PYTHON_EXECUTABLE' doesn't exist"
  64. return 1
  65. fi
  66. _colcon_python_executable="$COLCON_PYTHON_EXECUTABLE"
  67. else
  68. # try the Python executable known at configure time
  69. _colcon_python_executable="/usr/bin/python3"
  70. # if it doesn't exist try a fall back
  71. if [ ! -f "$_colcon_python_executable" ]; then
  72. if ! /usr/bin/env python3 --version > /dev/null 2> /dev/null; then
  73. echo "error: unable to find python3 executable"
  74. return 1
  75. fi
  76. _colcon_python_executable=`/usr/bin/env python3 -c "import sys; print(sys.executable)"`
  77. fi
  78. fi
  79. # function to source another script with conditional trace output
  80. # first argument: the path of the script
  81. _colcon_prefix_sh_source_script() {
  82. if [ -f "$1" ]; then
  83. if [ -n "$COLCON_TRACE" ]; then
  84. echo ". \"$1\""
  85. fi
  86. . "$1"
  87. else
  88. echo "not found: \"$1\"" 1>&2
  89. fi
  90. }
  91. # get all commands in topological order
  92. _colcon_ordered_commands="$($_colcon_python_executable "$_colcon_prefix_sh_COLCON_CURRENT_PREFIX/_local_setup_util_sh.py" sh)"
  93. unset _colcon_python_executable
  94. if [ -n "$COLCON_TRACE" ]; then
  95. echo "Execute generated script:"
  96. echo "<<<"
  97. echo "${_colcon_ordered_commands}"
  98. echo ">>>"
  99. fi
  100. eval "${_colcon_ordered_commands}"
  101. unset _colcon_ordered_commands
  102. unset _colcon_prefix_sh_source_script
  103. unset _colcon_prefix_sh_COLCON_CURRENT_PREFIX