summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Balsini <balsini@google.com>2019-08-06 04:45:32 +0100
committerAlessio Balsini <balsini@android.com>2019-08-08 23:37:00 +0100
commit303324dc363a52aaa6501d738d115390137a91ab (patch)
tree34e1060c45903444a565152d81442f29e2c30d4d
parent9f1ecd00d8913e1b355340129d2357f342f9edf3 (diff)
envsetup.sh checks, but does not set ENVSETUP_SH_INCLUDED=1
envsetup.sh has a guard that prevents the file to be sourced multiple times. This is useful if a script wants to: 1) source envsetup.sh to get the default environment; 2) change some variables 3) call another script that calls envsetup.sh again, overwriting the modifications. This is what happens with build_abi.sh which, after sourcing envsetup.sh, changes the environment variables and builds the kernel with build.sh. The ladder script sources again envsetup.sh, overwriting the canges made by build_abi.sh. This unexpected behavior is solved by envsetup.sh, which can either immediately return if ENVSETUP_SH_INCLUDED is set or set ENVSETUP_SH_INCLUDED=1 and continue the execution. This avoids envsetup.sh to be sourced multiple times, thus overriding the environment variables. This solution causes the issue of making the build script unusable if the user manually sources build.sh. This patch solves the issue by removing the ENVSETUP_SH_INCLUDED=1 operation from envsetup.sh, which is instead moved to build_abi.sh. Test: manual inspection Bug: 138854687 Change-Id: If52b0546809d77304ed8d11c9da062e13a3c7ec5 Signed-off-by: Alessio Balsini <balsini@google.com>
-rwxr-xr-xbuild_abi.sh3
-rw-r--r--envsetup.sh13
2 files changed, 11 insertions, 5 deletions
diff --git a/build_abi.sh b/build_abi.sh
index d276c50..b2f9170 100755
--- a/build_abi.sh
+++ b/build_abi.sh
@@ -29,6 +29,7 @@ set -e
set -a
source "${ROOT_DIR}/build/envsetup.sh"
+export ENVSETUP_SH_INCLUDED=1
# inject CONFIG_DEBUG_INFO=y
export POST_DEFCONFIG_CMDS="${POST_DEFCONFIG_CMDS} : && update_config_for_abi_dump"
@@ -38,6 +39,8 @@ function update_config_for_abi_dump() {
(cd ${OUT_DIR} && \
make O=${OUT_DIR} ${CC_LD_ARG} $archsubarch CROSS_COMPILE=${CROSS_COMPILE} olddefconfig)
}
+export -f check_defconfig
+export -f update_config_for_abi_dump
function version_greater_than() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
diff --git a/envsetup.sh b/envsetup.sh
index 234b44a..57d461b 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -14,13 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+
# Usage:
-# source build/envsetup.sh
-# to setup your path and cross compiler so that a kernel build command is
-# just:
-# make -j24
+# $ build/build.sh
+#
+# Usage (deprecated):
+# $ source build/envsetup.sh # to setup your path and cross compiler
+# # so that a kernel build command is just:
+# $ make -j24
-[ -n "$ENVSETUP_SH_INCLUDED" ] && return || export ENVSETUP_SH_INCLUDED=1
+[ -n "$ENVSETUP_SH_INCLUDED" ] && return
# TODO: Use a $(gettop) style method.
export ROOT_DIR=$PWD