From b36ccd2c8fbe01aa5b3fbfef366fa09ead0c360d Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Tue, 20 Oct 2020 16:20:09 -0700 Subject: [PATCH] * merge activate and bootstrap (#3311) * run activate in an external env from the Xcode connector * fix pip install nits * fix mismerge, set CHIP_ROOT unconditionally * use better names than updirs, lookinfer --- scripts/bootstrap.sh | 1 + .../Framework/chip_xcode_build_connector.sh | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index a02dd05596f5a9..42714d80f067ec 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -56,6 +56,7 @@ EOF local _SETUP_SH="$_PW_ACTUAL_ENVIRONMENT_ROOT/activate.sh" export PW_DOCTOR_SKIP_CIPD_CHECKS=1 + export PATH # https://bugs.chromium.org/p/pigweed/issues/detail?id=281 if [ "$_BOOTSTRAP_NAME" = "bootstrap.sh" ] || [ ! -f "$_SETUP_SH" ] || diff --git a/src/darwin/Framework/chip_xcode_build_connector.sh b/src/darwin/Framework/chip_xcode_build_connector.sh index d33e6382d49b88..aeb48a61062279 100755 --- a/src/darwin/Framework/chip_xcode_build_connector.sh +++ b/src/darwin/Framework/chip_xcode_build_connector.sh @@ -100,14 +100,35 @@ fi ) } +find_in_ancestors() { + declare to_find="${1}" + declare dir="${2:-$(pwd)}" + + while [[ ! -e ${dir}/${to_find} && -n ${dir} ]]; do + dir=${dir%/*} + done + + if [[ ! -e ${dir}/${to_find} ]]; then + printf 'error: find_in_ancestors: %s not found\n' "$to_find" >&2 + return 1 + fi + printf '%s\n' "$dir/$to_find" +} + ( cd "$CHIP_ROOT" # pushd and popd because we need the env vars from activate + + if ENV=$(find_in_ancestors chip_xcode_build_connector_env.sh 2>/dev/null); then + . "$ENV" + fi + [[ -n $CHIP_NO_SUBMODULES ]] || git submodule update --init if [[ -z $CHIP_NO_ACTIVATE ]]; then + # first run bootstrap in an external env to build everything + env -i PW_ENVSETUP_NO_BANNER=1 PW_ENVSETUP_QUIET=1 bash -c '. scripts/activate.sh' set +ex - echo PW_ENVSETUP_QUIET=1 . scripts/activate.sh >&2 - PW_ENVSETUP_QUIET=1 . scripts/activate.sh - (($? != 0)) && echo "Please source $CHIP_ROOT/scripts/bootstrap.sh before building" && exit 1 + # now source activate for env vars + PW_ENVSETUP_NO_BANNER=1 PW_ENVSETUP_QUIET=1 . scripts/activate.sh set -ex fi