diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-11-16 06:12:09 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-11-16 06:18:53 -0600 |
commit | cb70868bdae30e01323afeb7cc6021a6b10003f0 (patch) | |
tree | a10ca5ca10df21f30246f61a2326275f7f58af70 /solenv | |
parent | 1d5aaeacfce983bf7a4a7c1f056fd21ac730b8e8 (diff) |
add utility script and build_env to avoid sourcing Env.Host.sh
The goal is to able to do partial build without having
to source Env.Host.sh into one's environment
There is 2 way to use this:
1/
copy the scripts lo_find_src_root and lo_proxy_start
somewhere in your PATH, and
then you can add
alias build='lo_proxy_start build'
alias deliver='lo_proxy_start deliver'
in your .bashrc
at that point you can use build and deliver anywhere in the source tree
without the need to source anything.
This allow you to switch from one source tree to another.
the proper SRC_ROOT will be determined automatically based
on the current working directory
2/
source build_env
build_env only source the bare minimum to allow build and make to work
for the associated source tree.
If you want to work in a diffrent tree, you need to resource
Diffstat (limited to 'solenv')
-rwxr-xr-x | solenv/bin/lo_find_src_root | 23 | ||||
-rwxr-xr-x | solenv/bin/lo_proxy_start | 31 |
2 files changed, 54 insertions, 0 deletions
diff --git a/solenv/bin/lo_find_src_root b/solenv/bin/lo_find_src_root new file mode 100755 index 000000000000..a91c84759822 --- /dev/null +++ b/solenv/bin/lo_find_src_root @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# (c) 2011 Norbert Thiebaud. License : GPLv3 +# +# try to locate the SRC_ROOT based on the working directory +# we search for first Repository.mk +# in the current directoyr or its parent, all teh way to / +# Ths is a heuristic. it works 'most of the times +# but it could give false positive if you try hard enough +# + +current=$(pwd) + +while [ "${current}" != "/" ] ; do + if [ -f ${current}/.src_root ] ; then + echo "${current}" + exit 0; + fi + current=$(dirname "${current}") +done + +echo "Error cannot determine SRC_ROOT" 1>&2 +exit 1; diff --git a/solenv/bin/lo_proxy_start b/solenv/bin/lo_proxy_start new file mode 100755 index 000000000000..67dcabf5c18a --- /dev/null +++ b/solenv/bin/lo_proxy_start @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +bin_dir=$(dirname $0) +action=$(basename $0) + +if [ "$action" = "lo_proxy_start" ] ; then + action=$1 + shift +fi + +if [ -z "$SRC_ROOT" ] ; then + SRC_ROOT=$($bin_dir/lo_find_src_root) || exit 1 +fi +if [ -z "$SOLARINC" ] ; then + if [ -e "$SRC_ROOT/config.mk" ] ; then + . "$SRC_ROOT/config.mk" + fi + if [ -e "$SRC_ROOT/Env.Host.sh" ] ; then + . "$SRC_ROOT/Env.Host.sh" + fi +fi + +if [ -e $SRC_ROOT/solenv/bin/$action.pl ] ; then + $SRC_ROOT/solenv/bin/$action.pl "$@" +elif [ -e $SRC_ROOT/solenv/bin/$action.sh ] ; then + $SRC_ROOT/solenv/bin/$action.sh "$@" +else + echo "$action.[pl|sh] not found" 2>&1 + exit 1 +fi + |