-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add setup script, rename prefix script into local_setup (#5)
- Loading branch information
1 parent
ad6f16f
commit 459c801
Showing
4 changed files
with
147 additions
and
48 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
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 |
---|---|---|
@@ -1,48 +1,46 @@ | ||
# generated from colcon_bash/shell/template/package.bash.em | ||
|
||
# This script extends the environment for this package. | ||
|
||
# a bash script is able to determine its own path if necessary | ||
if [ -z "$COLCON_CURRENT_PREFIX" ]; then | ||
# the prefix is two levels up from the package specific share directory | ||
_colcon_package_bash_COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`/../.." > /dev/null && pwd)" | ||
else | ||
_colcon_package_bash_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" | ||
fi | ||
|
||
# function to source another script with conditional trace output | ||
# first argument: the name of the script file | ||
# first argument: the path of the script | ||
# additional arguments: arguments to the script | ||
colcon_package_source_bash_script() { | ||
# arguments | ||
_colcon_package_source_bash_script="$1" | ||
|
||
# source script with conditional trace output | ||
if [ -f "$_colcon_package_source_bash_script" ]; then | ||
_colcon_package_bash_source_script() { | ||
if [ -f "$1" ]; then | ||
if [ -n "$COLCON_TRACE" ]; then | ||
echo ". \"$_colcon_package_source_bash_script\"" | ||
echo ". \"$1\"" | ||
fi | ||
. $@@ | ||
else | ||
echo "not found: \"$_colcon_package_source_bash_script\"" 1>&2 | ||
echo "not found: \"$1\"" 1>&2 | ||
fi | ||
|
||
unset _colcon_package_source_bash_script | ||
} | ||
|
||
|
||
# a bash script is able to determine its own path if necessary | ||
# the prefix is two levels up from the package specific share directory | ||
if [ -z "$COLCON_CURRENT_PREFIX" ]; then | ||
COLCON_CURRENT_PREFIX=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`/../.." > /dev/null && pwd) | ||
fi | ||
@[if hooks]@ | ||
_package_COLCON_CURRENT_PREFIX=$COLCON_CURRENT_PREFIX | ||
@[end if]@ | ||
|
||
colcon_package_source_bash_script "$COLCON_CURRENT_PREFIX/share/@(pkg_name)/package.sh" | ||
# source sh script of this package | ||
_colcon_package_bash_source_script "$_colcon_package_bash_COLCON_CURRENT_PREFIX/share/@(pkg_name)/@(package_script_no_ext).sh" | ||
@[if hooks]@ | ||
|
||
COLCON_CURRENT_PREFIX=$_package_COLCON_CURRENT_PREFIX | ||
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced scripts | ||
COLCON_CURRENT_PREFIX="$_colcon_package_bash_COLCON_CURRENT_PREFIX" | ||
|
||
# source bash hooks | ||
@[ for hook in hooks]@ | ||
colcon_package_source_bash_script "$COLCON_CURRENT_PREFIX/@(hook[0])"@ | ||
_colcon_package_bash_source_script "$COLCON_CURRENT_PREFIX/@(hook[0])"@ | ||
@[ for hook_arg in hook[1]]@ | ||
@(hook_arg)@ | ||
@[ end for] | ||
@[ end for]@ | ||
|
||
unset _package_COLCON_CURRENT_PREFIX | ||
@[end if]@ | ||
unset COLCON_CURRENT_PREFIX | ||
unset colcon_package_source_bash_script | ||
@[end if]@ | ||
|
||
unset _colcon_package_bash_source_script | ||
unset _colcon_package_bash_COLCON_CURRENT_PREFIX |
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 |
---|---|---|
@@ -1,34 +1,85 @@ | ||
# generated from colcon_bash/shell/template/prefix.bash.em | ||
@[if pkg_names]@ | ||
|
||
# function to source another script with conditional trace output | ||
# first argument: the name of the script file | ||
colcon_prefix_source_bash_script() { | ||
# This script extends the environment with all packages contained in this | ||
# prefix path. | ||
|
||
# a bash script is able to determine its own path if necessary | ||
if [ -z "$COLCON_CURRENT_PREFIX" ]; then | ||
_colcon_prefix_bash_COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)" | ||
else | ||
_colcon_prefix_bash_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" | ||
fi | ||
|
||
# function to prepend a value to a variable | ||
# which uses colons as separators | ||
# duplicates as well as trailing separators are avoided | ||
# first argument: the name of the result variable | ||
# second argument: the value to be prepended | ||
_colcon_prefix_bash_prepend_unique_value() { | ||
# arguments | ||
_colcon_prefix_source_bash_script="$1" | ||
_listname="$1" | ||
_value="$2" | ||
|
||
# source script with conditional trace output | ||
if [ -f "$_colcon_prefix_source_bash_script" ]; then | ||
# get values from variable | ||
eval _values=\"\$$_listname\" | ||
# backup the field separator | ||
_colcon_prefix_bash_prepend_unique_value_IFS="$IFS" | ||
IFS=":" | ||
# start with the new value | ||
_all_values="$_value" | ||
# iterate over existing values in the variable | ||
for _item in $_values; do | ||
# ignore empty strings | ||
if [ -z "$_item" ]; then | ||
continue | ||
fi | ||
# ignore duplicates of _value | ||
if [ "$_item" = "$_value" ]; then | ||
continue | ||
fi | ||
# keep non-duplicate values | ||
_all_values="$_all_values:$_item" | ||
done | ||
unset _item | ||
# restore the field separator | ||
IFS="$_colcon_prefix_bash_prepend_unique_value_IFS" | ||
unset _colcon_prefix_bash_prepend_unique_value_IFS | ||
# export the updated variable | ||
eval export $_listname=\"$_all_values\" | ||
unset _all_values | ||
unset _values | ||
unset _value | ||
unset _listname | ||
} | ||
# add this prefix to the COLCON_PREFIX_PATH | ||
_colcon_prefix_bash_prepend_unique_value COLCON_PREFIX_PATH "$_colcon_prefix_bash_COLCON_CURRENT_PREFIX" | ||
unset _colcon_prefix_bash_prepend_unique_value | ||
@[if pkg_names]@ | ||
# function to source another script with conditional trace output | ||
# first argument: the path of the script | ||
_colcon_prefix_bash_source_script() { | ||
if [ -f "$1" ]; then | ||
if [ -n "$COLCON_TRACE" ]; then | ||
echo ". \"$_colcon_prefix_source_bash_script\"" | ||
echo ". \"$1\"" | ||
fi | ||
. "$_colcon_prefix_source_bash_script" | ||
. "$1" | ||
else | ||
echo "not found: \"$_colcon_prefix_source_bash_script\"" 1>&2 | ||
echo "not found: \"$1\"" 1>&2 | ||
fi | ||
|
||
unset _colcon_prefix_source_bash_script | ||
} | ||
|
||
# a bash script is able to determine its own path | ||
_prefix_COLCON_CURRENT_PREFIX=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd) | ||
|
||
# source packages | ||
@[ for pkg_name in pkg_names]@ | ||
COLCON_CURRENT_PREFIX=$_prefix_COLCON_CURRENT_PREFIX@('' if merge_install else ('/' + pkg_name)) | ||
colcon_prefix_source_bash_script "$COLCON_CURRENT_PREFIX/share/@(pkg_name)/package.bash" | ||
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script | ||
COLCON_CURRENT_PREFIX=$_colcon_prefix_bash_COLCON_CURRENT_PREFIX@('' if merge_install else ('/' + pkg_name)) | ||
_colcon_prefix_bash_source_script "$COLCON_CURRENT_PREFIX/share/@(pkg_name)/@(package_script_no_ext).bash" | ||
|
||
@[ end for]@ | ||
unset COLCON_CURRENT_PREFIX | ||
unset _prefix_COLCON_CURRENT_PREFIX | ||
unset colcon_prefix_source_bash_script | ||
unset _colcon_prefix_bash_source_script | ||
@[end if]@ | ||
|
||
unset _colcon_prefix_bash_COLCON_CURRENT_PREFIX |
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,35 @@ | ||
# generated from colcon_bash/shell/template/prefix_chain.bash.em | ||
|
||
# This script extends the environment with the environment of other prefix | ||
# paths which were sourced when this file was generated as well as all packages | ||
# contained in this prefix path. | ||
|
||
# function to source another script with conditional trace output | ||
# first argument: the path of the script | ||
_colcon_prefix_chain_bash_source_script() { | ||
if [ -f "$1" ]; then | ||
if [ -n "$COLCON_TRACE" ]; then | ||
echo ". \"$1\"" | ||
fi | ||
. "$1" | ||
else | ||
echo "not found: \"$1\"" 1>&2 | ||
fi | ||
} | ||
@[if colcon_prefix_path]@ | ||
|
||
# source chained prefixes | ||
@[ for prefix in reversed(colcon_prefix_path)]@ | ||
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script | ||
COLCON_CURRENT_PREFIX="@(prefix)" | ||
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/@(prefix_script_no_ext).bash" | ||
@[ end for]@ | ||
@[end if]@ | ||
|
||
# source this prefix | ||
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script | ||
COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)" | ||
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/@(prefix_script_no_ext).bash" | ||
|
||
unset COLCON_CURRENT_PREFIX | ||
unset _colcon_prefix_chain_bash_source_script |