From 35aafb241951966e2a216ee27db9dd6365ccc0cc Mon Sep 17 00:00:00 2001 From: Zimin Li Date: Mon, 29 Jun 2026 10:31:42 +0000 Subject: [PATCH 1/2] build: refresh InfiniCCL root exports - append both `INFINICCL_ROOT` and `InfiniCCL_ROOT` to `~/.bashrc` when the install path is missing - update existing root exports when they point to a different checkout - clarify the post-install source reminder for path updates --- scripts/build.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 9b8eaa8..26c7cd5 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -34,23 +34,30 @@ cmake --install "$BUILD_DIR" # Handle Environment Variables (`PATH` and `LD_LIBRARY_PATH`) BIN_PATH="$INSTALL_PREFIX/bin" LIB_PATH="$INSTALL_PREFIX/lib" -INFINICCL_ROOT="$PROJECT_ROOT" # Check if `PATH` already contains the `bin` path. if [[ ":$PATH:" != *":$BIN_PATH:"* ]]; then echo "--> Adding $BIN_PATH to current session PATH..." export PATH="$BIN_PATH:$PATH" - - # Optional: Automatically update `~/.bashrc` for the user. - if ! grep -q "$BIN_PATH" "$HOME/.bashrc"; then - echo "--> Updating ~/.bashrc with InfiniCCL paths..." - echo "" >> "$HOME/.bashrc" - echo "# InfiniCCL Paths" >> "$HOME/.bashrc" - echo "export INFINICCL_ROOT=\"$INFINICCL_ROOT\"" >> "$HOME/.bashrc" - echo "export PATH=\"$BIN_PATH:\$PATH\"" >> "$HOME/.bashrc" - echo "export LD_LIBRARY_PATH=\"$LIB_PATH:\$LD_LIBRARY_PATH\"" >> "$HOME/.bashrc" - echo "Successfully updated ~/.bashrc. Please run 'source ~/.bashrc' or restart your terminal." - fi +fi + +# Automatically update `~/.bashrc` for the user. +if ! grep -q "$BIN_PATH" "$HOME/.bashrc"; then + echo "--> Updating ~/.bashrc with InfiniCCL paths..." + echo "" >> "$HOME/.bashrc" + echo "# InfiniCCL Paths" >> "$HOME/.bashrc" + echo "export INFINICCL_ROOT=\"$PROJECT_ROOT\"" >> "$HOME/.bashrc" + echo "export InfiniCCL_ROOT=\"$PROJECT_ROOT\"" >> "$HOME/.bashrc" + echo "export PATH=\"$BIN_PATH:\$PATH\"" >> "$HOME/.bashrc" + echo "export LD_LIBRARY_PATH=\"$LIB_PATH:\$LD_LIBRARY_PATH\"" >> "$HOME/.bashrc" + echo "Successfully updated ~/.bashrc. Please run 'source ~/.bashrc' or restart your terminal." +fi + +# Update `INFINICCL_ROOT` if it already exists but points to a different project. +if [[ -n "${INFINICCL_ROOT:-}" && "$INFINICCL_ROOT" != "$PROJECT_ROOT" ]]; then + echo "--> Updating INFINICCL_ROOT in ~/.bashrc..." + sed -i "s|^export INFINICCL_ROOT=.*|export INFINICCL_ROOT=\"$PROJECT_ROOT\"|" "$HOME/.bashrc" + sed -i "s|^export InfiniCCL_ROOT=.*|export InfiniCCL_ROOT=\"$PROJECT_ROOT\"|" "$HOME/.bashrc" fi echo "========================================================" @@ -59,5 +66,5 @@ echo " Binaries: $BIN_PATH" echo " Libraries: $LIB_PATH" echo " Headers: $INSTALL_PREFIX/include" echo "========================================================" -echo " NOTE: If this is your first install, run: source ~/.bashrc" +echo " NOTE: If this is your first install or there's a path update, run: source ~/.bashrc" echo " You can now run 'icclrun' from anywhere." From 5befadff8b8325b401ffa99504591d8b92603104 Mon Sep 17 00:00:00 2001 From: Zimin Li Date: Mon, 29 Jun 2026 10:57:28 +0000 Subject: [PATCH 2/2] build: make InfiniCCL root exports idempotent - add a helper to update or append `.bashrc` exports - update `INFINICCL_ROOT` and `InfiniCCL_ROOT` based on `.bashrc` contents --- scripts/build.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 26c7cd5..2a18346 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -12,6 +12,19 @@ DEFAULT_INSTALL_PATH="$HOME/.infini" INSTALL_PREFIX="${INSTALL_PREFIX:-$DEFAULT_INSTALL_PATH}" BUILD_DIR="${BUILD_DIR:-build}" +update_bashrc_export() { + local name="$1" + local value="$2" + local escaped_value + escaped_value=$(printf '%s' "$value" | sed 's/[\\&|]/\\&/g') + + if grep -q "^export ${name}=" "$HOME/.bashrc"; then + sed -i "s|^export ${name}=.*|export ${name}=\"$escaped_value\"|" "$HOME/.bashrc" + else + echo "export ${name}=\"$value\"" >> "$HOME/.bashrc" + fi +} + echo "========================================================" echo " Starting InfiniCCL Build" echo " Build Directory: $BUILD_DIR" @@ -46,19 +59,14 @@ if ! grep -q "$BIN_PATH" "$HOME/.bashrc"; then echo "--> Updating ~/.bashrc with InfiniCCL paths..." echo "" >> "$HOME/.bashrc" echo "# InfiniCCL Paths" >> "$HOME/.bashrc" - echo "export INFINICCL_ROOT=\"$PROJECT_ROOT\"" >> "$HOME/.bashrc" - echo "export InfiniCCL_ROOT=\"$PROJECT_ROOT\"" >> "$HOME/.bashrc" echo "export PATH=\"$BIN_PATH:\$PATH\"" >> "$HOME/.bashrc" echo "export LD_LIBRARY_PATH=\"$LIB_PATH:\$LD_LIBRARY_PATH\"" >> "$HOME/.bashrc" echo "Successfully updated ~/.bashrc. Please run 'source ~/.bashrc' or restart your terminal." fi -# Update `INFINICCL_ROOT` if it already exists but points to a different project. -if [[ -n "${INFINICCL_ROOT:-}" && "$INFINICCL_ROOT" != "$PROJECT_ROOT" ]]; then - echo "--> Updating INFINICCL_ROOT in ~/.bashrc..." - sed -i "s|^export INFINICCL_ROOT=.*|export INFINICCL_ROOT=\"$PROJECT_ROOT\"|" "$HOME/.bashrc" - sed -i "s|^export InfiniCCL_ROOT=.*|export InfiniCCL_ROOT=\"$PROJECT_ROOT\"|" "$HOME/.bashrc" -fi +echo "--> Updating INFINICCL_ROOT in ~/.bashrc..." +update_bashrc_export "INFINICCL_ROOT" "$PROJECT_ROOT" +update_bashrc_export "InfiniCCL_ROOT" "$PROJECT_ROOT" echo "========================================================" echo " Build and Install Finished!"