Robert Szewczyk | 38cf731 | 2020-06-29 09:07:49 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2020 Project CHIP Authors |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 17 | _bootstrap_or_activate() { |
| 18 | if [ -n "$BASH" ]; then |
| 19 | local _BOOTSTRAP_PATH="${BASH_SOURCE[0]}" |
| 20 | else |
| 21 | local _BOOTSTRAP_PATH="$1" |
| 22 | fi |
Michael Spang | 871ce0b | 2020-06-26 11:47:03 -0400 | [diff] [blame] | 23 | |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 24 | local _BOOTSTRAP_NAME="${_BOOTSTRAP_PATH##*/}" |
| 25 | local _CHIP_ROOT="$(cd "${_BOOTSTRAP_PATH%/*}/.." && pwd)" |
Michael Spang | 871ce0b | 2020-06-26 11:47:03 -0400 | [diff] [blame] | 26 | |
Rob Mohr | 5cda0bd | 2021-04-10 01:23:15 -0700 | [diff] [blame] | 27 | local _CONFIG_FILE="scripts/environment.json" |
| 28 | |
| 29 | if [ "$_BOOTSTRAP_NAME" = "no_cipd_bootstrap.sh" ]; then |
| 30 | _CONFIG_FILE="scripts/environment_no_cipd.json" |
| 31 | _BOOTSTRAP_NAME="bootstrap.sh" |
| 32 | fi |
| 33 | |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 34 | if [ "$_BOOTSTRAP_NAME" = "bootstrap.sh" ] || |
| 35 | [ ! -f "$_CHIP_ROOT/third_party/pigweed/repo/pw_env_setup/util.sh" ]; then |
| 36 | git submodule update --init |
| 37 | fi |
Michael Spang | abccd70 | 2020-07-03 09:48:41 -0400 | [diff] [blame] | 38 | |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 39 | local _CHIP_BANNER="$( |
| 40 | cat <<EOF |
Martin Turon | fc07dcf | 2021-12-03 09:54:30 -0800 | [diff] [blame] | 41 | ░▓░ |
| 42 | ▓█▓ |
| 43 | ▓█▓ ▒█ ▒█ |
| 44 | ▒██▒▒▓██▒███▒ ░▒▓▒░ ░▒▓▒░ ░░▓█▒░ ░█ █████████████░ ░▒█▒░ ░░▒░ |
| 45 | ░▓█████▓██░ ▒█▒░░▒▓██▓▒░░▒█▒ ░█▓▒░░▒████ █▓░ █▓░ ▒█▒░░░▒█▓░ ██▒░░ |
| 46 | ▒█▒░ ░██▒ ░█░ █▓ ░█░ ░▓▒ ░▓█ █▓ █▓ ▒█░░ ░██ ▒▓ |
| 47 | ░▓██▓░ ░██▓█░ ░█ ▓█ █░ ░█░ ██ █▓ █▓ ▓██████████ ▒█ |
| 48 | ░▓███▒ ▒███▒░ ░█ ▓█ █░ ██░ ░███ █▓ █▓ ░█▒░ ▒█ |
| 49 | ░▒████████░ ░███▓▓█▓▓▒ ░█ ▒▒ █░ ░█▓██▓█░▒█ ░▓▓█░ ░▓▓█░ ▒▓▓██▓█░ ▒▓ |
| 50 | ░██▒░ ▒██▒ ▒██░ ░▒█▓ |
| 51 | ░▓░ ░▓░ |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 52 | EOF |
| 53 | )" |
Michael Spang | 871ce0b | 2020-06-26 11:47:03 -0400 | [diff] [blame] | 54 | |
szatmz | 2244db6 | 2020-12-04 14:42:01 -0500 | [diff] [blame] | 55 | PW_PROJECT_ROOT="$_CHIP_ROOT" |
| 56 | export PW_PROJECT_ROOT |
| 57 | |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 58 | PW_ROOT="$_CHIP_ROOT/third_party/pigweed/repo" |
| 59 | export PW_ROOT |
szatmz | 4b82c2b | 2020-10-16 12:32:43 -0400 | [diff] [blame] | 60 | |
Andrei Litvin | a4201ea | 2022-04-11 06:37:33 -1000 | [diff] [blame] | 61 | # Do not force use Rosetta in Pigweed because Matter is using host toolchain |
| 62 | if [ -z "$PW_BOOTSTRAP_USE_ROSETTA" ]; then |
| 63 | export PW_BOOTSTRAP_USE_ROSETTA=false |
| 64 | fi |
| 65 | |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 66 | . "$_CHIP_ROOT/third_party/pigweed/repo/pw_env_setup/util.sh" |
szatmz | 4b82c2b | 2020-10-16 12:32:43 -0400 | [diff] [blame] | 67 | |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 68 | _chip_bootstrap_banner() { |
| 69 | if [ -z "$PW_ENVSETUP_QUIET" ] && [ -z "$PW_ENVSETUP_NO_BANNER" ]; then |
| 70 | pw_bold_white "$_CHIP_BANNER\n" |
| 71 | fi |
| 72 | } |
| 73 | |
| 74 | local _PW_BANNER_FUNC="_chip_bootstrap_banner" |
| 75 | |
| 76 | export _PW_ACTUAL_ENVIRONMENT_ROOT="$(pw_get_env_root)" |
| 77 | local _SETUP_SH="$_PW_ACTUAL_ENVIRONMENT_ROOT/activate.sh" |
| 78 | |
| 79 | export PW_DOCTOR_SKIP_CIPD_CHECKS=1 |
Rob Walker | 5c21f07 | 2020-10-20 16:20:09 -0700 | [diff] [blame] | 80 | export PATH # https://bugs.chromium.org/p/pigweed/issues/detail?id=281 |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 81 | |
| 82 | if [ "$_BOOTSTRAP_NAME" = "bootstrap.sh" ] || |
| 83 | [ ! -f "$_SETUP_SH" ] || |
| 84 | [ ! -s "$_SETUP_SH" ]; then |
| 85 | pw_bootstrap --shell-file "$_SETUP_SH" \ |
| 86 | --install-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT" \ |
Michael Spang | 2c81a99 | 2021-05-31 12:04:46 -0400 | [diff] [blame] | 87 | --config-file "$_CHIP_ROOT/$_CONFIG_FILE" \ |
| 88 | --virtualenv-gn-out-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT/gn_out" |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 89 | pw_finalize bootstrap "$_SETUP_SH" |
| 90 | else |
| 91 | pw_activate |
| 92 | pw_finalize activate "$_SETUP_SH" |
| 93 | fi |
| 94 | } |
| 95 | |
| 96 | _bootstrap_or_activate "$0" |
| 97 | unset -f _bootstrap_or_activate |
| 98 | |
| 99 | pw_cleanup |
| 100 | |
| 101 | unset PW_CIPD_INSTALL_DIR |
| 102 | unset CIPD_CACHE_DIR |
| 103 | unset _PW_BANNER_FUNC |
| 104 | unset _PW_TEXT |
| 105 | unset PW_DOCTOR_SKIP_CIPD_CHECKS |
| 106 | |
Michael Spang | c7ed260 | 2020-10-20 18:21:14 -0400 | [diff] [blame] | 107 | unset -f _chip_bootstrap_banner |