local_setup.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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/wub/work/1_nzzn/2_code/13_LG/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. _contained_value=""
  34. # iterate over existing values in the variable
  35. for _item in $_values; do
  36. # ignore empty strings
  37. if [ -z "$_item" ]; then
  38. continue
  39. fi
  40. # ignore duplicates of _value
  41. if [ "$_item" = "$_value" ]; then
  42. _contained_value=1
  43. continue
  44. fi
  45. # keep non-duplicate values
  46. _all_values="$_all_values:$_item"
  47. done
  48. unset _item
  49. if [ -z "$_contained_value" ]; then
  50. if [ -n "$COLCON_TRACE" ]; then
  51. if [ "$_all_values" = "$_value" ]; then
  52. echo "export $_listname=$_value"
  53. else
  54. echo "export $_listname=$_value:\$$_listname"
  55. fi
  56. fi
  57. fi
  58. unset _contained_value
  59. # restore the field separator
  60. IFS="$_colcon_prefix_sh_prepend_unique_value_IFS"
  61. unset _colcon_prefix_sh_prepend_unique_value_IFS
  62. # export the updated variable
  63. eval export $_listname=\"$_all_values\"
  64. unset _all_values
  65. unset _values
  66. unset _value
  67. unset _listname
  68. }
  69. # add this prefix to the COLCON_PREFIX_PATH
  70. _colcon_prefix_sh_prepend_unique_value COLCON_PREFIX_PATH "$_colcon_prefix_sh_COLCON_CURRENT_PREFIX"
  71. unset _colcon_prefix_sh_prepend_unique_value
  72. # check environment variable for custom Python executable
  73. if [ -n "$COLCON_PYTHON_EXECUTABLE" ]; then
  74. if [ ! -f "$COLCON_PYTHON_EXECUTABLE" ]; then
  75. echo "error: COLCON_PYTHON_EXECUTABLE '$COLCON_PYTHON_EXECUTABLE' doesn't exist"
  76. return 1
  77. fi
  78. _colcon_python_executable="$COLCON_PYTHON_EXECUTABLE"
  79. else
  80. # try the Python executable known at configure time
  81. _colcon_python_executable="/usr/bin/python3"
  82. # if it doesn't exist try a fall back
  83. if [ ! -f "$_colcon_python_executable" ]; then
  84. if ! /usr/bin/env python3 --version > /dev/null 2> /dev/null; then
  85. echo "error: unable to find python3 executable"
  86. return 1
  87. fi
  88. _colcon_python_executable=`/usr/bin/env python3 -c "import sys; print(sys.executable)"`
  89. fi
  90. fi
  91. # function to source another script with conditional trace output
  92. # first argument: the path of the script
  93. _colcon_prefix_sh_source_script() {
  94. if [ -f "$1" ]; then
  95. if [ -n "$COLCON_TRACE" ]; then
  96. echo "# . \"$1\""
  97. fi
  98. . "$1"
  99. else
  100. echo "not found: \"$1\"" 1>&2
  101. fi
  102. }
  103. # get all commands in topological order
  104. _colcon_ordered_commands="$($_colcon_python_executable "$_colcon_prefix_sh_COLCON_CURRENT_PREFIX/_local_setup_util_sh.py" sh)"
  105. unset _colcon_python_executable
  106. if [ -n "$COLCON_TRACE" ]; then
  107. echo "_colcon_prefix_sh_source_script() {
  108. if [ -f \"\$1\" ]; then
  109. if [ -n \"\$COLCON_TRACE\" ]; then
  110. echo \"# . \\\"\$1\\\"\"
  111. fi
  112. . \"\$1\"
  113. else
  114. echo \"not found: \\\"\$1\\\"\" 1>&2
  115. fi
  116. }"
  117. echo "# Execute generated script:"
  118. echo "# <<<"
  119. echo "${_colcon_ordered_commands}"
  120. echo "# >>>"
  121. echo "unset _colcon_prefix_sh_source_script"
  122. fi
  123. eval "${_colcon_ordered_commands}"
  124. unset _colcon_ordered_commands
  125. unset _colcon_prefix_sh_source_script
  126. unset _colcon_prefix_sh_COLCON_CURRENT_PREFIX