-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pw_env_setup: Bootstrap fish-shell support
Change-Id: I6d9838b0010ee34c8e50571439f71ecba00cfc3b Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/56840 Reviewed-by: Chad Norvell <[email protected]> Reviewed-by: Rob Mohr <[email protected]> Lint: Lint 🤖 <[email protected]> Commit-Queue: Anthony DiGirolamo <[email protected]>
- Loading branch information
1 parent
d910032
commit d988f70
Showing
10 changed files
with
673 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bootstrap.fish |
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,90 @@ | ||
# Copyright 2024 The Pigweed Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
# This script must be tested on fish 3.6.0 | ||
|
||
# Get the absolute path of the bootstrap script. | ||
set _PW_BOOTSTRAP_PATH (path resolve (status current-filename)) | ||
|
||
# Check if this file is being executed or sourced. | ||
set _pw_sourced 0 | ||
if string match --quiet '*from sourcing file*' (status) | ||
set _pw_sourced 1 | ||
end | ||
|
||
# Downstream projects need to set something other than PW_ROOT here, like | ||
# YOUR_PROJECT_ROOT. Please also set PW_PROJECT_ROOT and PW_ROOT before | ||
# invoking pw_bootstrap or pw_activate. | ||
######### BEGIN PROJECT-SPECIFIC CODE ######### | ||
set --export PW_ROOT (path resolve (dirname $_PW_BOOTSTRAP_PATH)) | ||
|
||
# Please also set PW_PROJECT_ROOT to YOUR_PROJECT_ROOT. | ||
set --export PW_PROJECT_ROOT $PW_ROOT | ||
|
||
# Downstream projects may wish to set PW_BANNER_FUNC to a function that prints | ||
# an ASCII art banner here. For example: | ||
# | ||
# set --export PW_BANNER_FUNC banner_function_name | ||
# | ||
########## END PROJECT-SPECIFIC CODE ########## | ||
|
||
source $PW_ROOT/pw_env_setup/util.fish | ||
|
||
# Check environment properties | ||
pw_deactivate | ||
pw_eval_sourced $_pw_sourced $_PW_BOOTSTRAP_PATH | ||
if not pw_check_root $PW_ROOT | ||
return | ||
end | ||
|
||
set --export _PW_ACTUAL_ENVIRONMENT_ROOT (pw_get_env_root) | ||
|
||
set SETUP_SH "$_PW_ACTUAL_ENVIRONMENT_ROOT/activate.fish" | ||
|
||
# Run full bootstrap when invoked as bootstrap, or env file is missing/empty. | ||
if test (status basename) = "bootstrap.fish" | ||
or not test -e $SETUP_SH | ||
or not test -s $SETUP_SH | ||
######### BEGIN PROJECT-SPECIFIC CODE ######### | ||
pw_bootstrap --shell-file "$SETUP_SH" --install-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT" | ||
########## END PROJECT-SPECIFIC CODE ########## | ||
set finalize_mode bootstrap | ||
else | ||
pw_activate_message | ||
set finalize_mode activate | ||
end | ||
# NOTE: Sourced scripts in fish cannot be sourced within a fuction if | ||
# variables should be exported to the calling shell. So activate.fish | ||
# must be sourced here instead of within pw_finalize or another | ||
# function. | ||
pw_finalize_pre_check $finalize_mode "$SETUP_SH" | ||
source $SETUP_SH | ||
pw_finalize_post_check $finalize_mode "$SETUP_SH" | ||
|
||
if set --query _PW_ENV_SETUP_STATUS; and test "$_PW_ENV_SETUP_STATUS" -eq 0 | ||
# This is where any additional checks about the environment should go. | ||
######### BEGIN PROJECT-SPECIFIC CODE ######### | ||
echo -n | ||
########## END PROJECT-SPECIFIC CODE ########## | ||
end | ||
|
||
set -e _pw_sourced | ||
set -e _PW_BOOTSTRAP_PATH | ||
set -e SETUP_SH | ||
|
||
# TODO(tonymd): Source fish pw_cli shell completion. | ||
|
||
pw_cleanup | ||
|
||
git -C "$PW_ROOT" config blame.ignoreRevsFile .git-blame-ignore-revs |
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
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
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
Oops, something went wrong.