Repository: google/filament
File: build/common/get-mesa.sh (Shell)

Code before:
        sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${GITHUB_CLANG_VERSION} 100
    else
        set +e
        sudo apt-get -y build-dep mesa
        sudo apt -y remove llvm-18 llvm-18-* llvm-19 llvm-19-*
        set -e
        CURRENT_CLANG_VERSION=$(clang --version | head -n 1 | awk '{ print $4 }' | awk 'BEGIN { FS="\\." } { print $1 }')
        CLANG_VERSION=${CURRENT_CLANG_VERSION:-${LLVM_VERSION}}
        sudo apt-get -y install clang-${CLANG_VERSION} \
             libc++-${CLANG_VERSION}-dev \
             libc++abi-${CLANG_VERSION}-dev \
             llvm-${LLVM_VERSION} \
             llvm-${LLVM_VERSION}-{dev,tools,runtime}
        ! command -v clang > /dev/null 2>&1 && \
            sudo ln -s /usr/bin/clang-${CLANG_VERSION} /usr/bin/clang && \
            sudo ln -s /usr/bin/clang++-${CLANG_VERSION} /usr/bin/clang++
    fi # [[ "$GITHUB_WORKFLOW" ]]
elif [[ "$OS_NAME" == "Darwin" ]]; then
    if command -v brew > /dev/null 2>&1; then
        HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=true brew install autoconf automake libx11 libxext libxrandr \
                                                    llvm@${LLVM_VERSION} ninja meson pkg-config libxshmfence
        # For reasons unknown, this is necessary for pkg-config to find homebrew's packages
        LOCAL_PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"
    elif command -v port > /dev/null 2>&1; then
        sudo port install autoconf automake libx11 libXext libXrandr llvm-${LLVM_VERSION} \
             ninja meson pkgconfig libxshmfence
        LOCAL_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
    else
        echo "Error: need to install homebrew or macports to continue"
        exit 1
    fi
fi # [[ "$OS_NAME" == x ]]

LOCAL_LDFLAGS=${LDFLAGS}
LOCAL_CPPFLAGS=${CPPFLAGS}
LOCAL_PATH=${PATH}
LOCAL_CXX=$(which clang++)
LOCAL_CC=$(which clang)

CHECKOUT_MESA=false
if [[ -d "${MESA_DIR}" ]]; then
    cd ${MESA_DIR}
    if ! git fsck --connectivity-only > /dev/null 2>&1; then
        echo "git fsck failed for mesa; try redownloading"
        CHECKOUT_MESA=true;
    fi
    cd ..;
else
    CHECKOUT_MESA=true
fi


Review comment (suggestion):
```suggestion
        sudo port install autoconf automake xorg-libX11 xorg-libXext xorg-libXrandr llvm-${LLVM_VERSION} \
             ninja meson pkgconfig xorg-libxshmfence
```

Code after:
        sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${GITHUB_CLANG_VERSION} 100
    else
        set +e
        sudo apt-get -y build-dep mesa
        sudo apt -y remove llvm-18 llvm-18-* llvm-19 llvm-19-*
        set -e
        CURRENT_CLANG_VERSION=$(clang --version | head -n 1 | awk '{ print $4 }' | awk 'BEGIN { FS="\\." } { print $1 }')
        CLANG_VERSION=${CURRENT_CLANG_VERSION:-${LLVM_VERSION}}
        sudo apt-get -y install clang-${CLANG_VERSION} \
             libc++-${CLANG_VERSION}-dev \
             libc++abi-${CLANG_VERSION}-dev \
             llvm-${LLVM_VERSION} \
             llvm-${LLVM_VERSION}-{dev,tools,runtime}
        ! command -v clang > /dev/null 2>&1 && \
            sudo ln -s /usr/bin/clang-${CLANG_VERSION} /usr/bin/clang && \
            sudo ln -s /usr/bin/clang++-${CLANG_VERSION} /usr/bin/clang++
    fi # [[ "$GITHUB_WORKFLOW" ]]
elif [[ "$OS_NAME" == "Darwin" ]]; then
    if command -v brew > /dev/null 2>&1; then
        HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=true brew install autoconf automake libx11 libxext libxrandr \
                                                        llvm@${LLVM_VERSION} ninja meson pkg-config libxshmfence
        # For reasons unknown, this is necessary for pkg-config to find homebrew's packages
        LOCAL_PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"
    elif command -v port > /dev/null 2>&1; then
        sudo port install autoconf automake libx11 libXext libXrandr llvm-${LLVM_VERSION} \
             ninja meson pkgconfig libxshmfence
        # For reasons unknown, this is necessary for pkg-config to find macport's packages
        LOCAL_PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"
    else
        echo "Error: need to install homebrew or macports to continue"
        exit 1
    fi
fi # [[ "$OS_NAME" == x ]]

LOCAL_LDFLAGS=${LDFLAGS}
LOCAL_CPPFLAGS=${CPPFLAGS}
LOCAL_PATH=${PATH}
LOCAL_CXX=$(which clang++)
LOCAL_CC=$(which clang)

CHECKOUT_MESA=false
if [[ -d "${MESA_DIR}" ]]; then
    cd ${MESA_DIR}
    if ! git fsck --connectivity-only > /dev/null 2>&1; then
        echo "git fsck failed for mesa; try redownloading"
        CHECKOUT_MESA=true;
    fi
    cd ..;
else
    CHECKOUT_MESA=true
fi