install_members() { | |
# Read the Cargo.toml file and extract the members | |
# The awk command extracts the lines between 'members = [' and ']' | |
# The sed command removes the first and last lines (which are '[' and ']') | |
# It also removes quotes, commas, and comments, and deletes empty lines | |
members=$(awk '/members = \[/,/\]/' Cargo.toml | sed -e '1d;$d' -e 's/[",]//g' -e 's/#.*//g' -e '/^\s*$/d') | |
# Convert the members string into an array | |
members_array=(${(f)members}) | |
# Loop through each member and run the cargo install command | |
for member in $members_array; do | |
# Trim leading and trailing whitespace from each member | |
member=$(echo $member | xargs) | |
echo "Processing $member..." | |
# Change to the member's directory | |
# If the directory change fails, print an error message and exit the function | |
cd $member || { echo "Failed to enter directory $member"; return 1; } | |
# Run the cargo install command with the specified options | |
cargo install -Z build-std --target x86_64-unknown-linux-gnu --path . | |
# Return to the previous directory | |
cd .. | |
done | |
} | |