已合并
调整nn仓第三方依赖 #7845
yang-di52创建于 7月23日
调整nn仓第三方依赖 #7845
已合并
yang-di52创建于 7月23日
2 个文件变更+105-8
@@ -464,16 +464,16 @@ check_dependencies_silent() {
464 curr_ver=$(python3 --version 2>&1 | awk '{print $2}')464 curr_ver=$(python3 --version 2>&1 | awk '{print $2}')
465 ;;465 ;;
466 gcc|g++)466 gcc|g++)
467- curr_ver=$(gcc --version | awk '/^gcc/ {print $NF}') 467+ curr_ver=$(gcc --version | awk '/^gcc/ {print $NF}')
468 ;;468 ;;
469 cmake)469 cmake)
470- curr_ver=$(cmake --version | awk '/^cmake/ {print $3}') 470+ curr_ver=$(cmake --version | awk '/^cmake/ {print $3}')
471 ;;471 ;;
472 pigz)472 pigz)
473- curr_ver=$(pigz --version 2>&1 | awk '{print $2}') 473+ curr_ver=$(pigz --version 2>&1 | awk '{print $2}')
474 ;;474 ;;
475 esac475 esac
476- 476+ 
477 if [[ -z "$curr_ver" ]] || ! version_ge "$curr_ver" "$req_ver"; then477 if [[ -z "$curr_ver" ]] || ! version_ge "$curr_ver" "$req_ver"; then
478 missing_deps+=("$name")478 missing_deps+=("$name")
479 fi479 fi
@@ -510,6 +510,103 @@ check_dependencies_silent() {
510 fi510 fi
511}511}
512 512 
513+install_pkg_config() {
514+ echo -e "\n==== Checking pkg-config ===="
515+ 
516+ if command -v pkg-config &> /dev/null; then
517+ echo "pkg-config has been installed"
518+ return
519+ fi
520+ 
521+ echo "pkg-config is not installed, installing..."
522+ case "$OS" in
523+ debian)
524+ run_command sudo $PKG_MANAGER update
525+ run_command sudo $PKG_MANAGER install -y pkg-config
526+ ;;
527+ rhel)
528+ run_command sudo $PKG_MANAGER install -y pkgconfig
529+ ;;
530+ macos)
531+ echo "pkg-config should be available via Xcode command line tools or brew"
532+ run_command brew install pkg-config
533+ ;;
534+ esac
535+ 
536+ if command -v pkg-config &> /dev/null; then
537+ echo "pkg-config installed successfully"
538+ else
539+ echo "pkg-config installation failed, cannot verify googletest. Please install pkg-config manually."
540+ exit 1
541+ fi
542+}
543+ 
544+install_googletest() {
545+ # Recommended googletest version: release-1.11.0
546+ echo -e "\n==== Checking googletest ===="
547+ local req_ver="1.11.0"
548+ local curr_ver=""
549+ local gtest_src_dir="/usr/src/gtest"
550+ 
551+ if pkg-config --exists gtest 2>/dev/null; then
552+ curr_ver=$(pkg-config --modversion gtest)
553+ echo "Current googletest version: $curr_ver"
554+ if version_ge "$curr_ver" "$req_ver"; then
555+ echo "googletest meets requirements"
556+ return
557+ fi
558+ fi
559+ read -p "Install googletest? [Y/n] " -n 1 -r
560+ echo
561+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
562+ echo "Skipping googletest installation"
563+ return
564+ fi
565+ 
566+ echo "Installing googletest..."
567+ case "$OS" in
568+ debian)
569+ # Install libgtest-dev
570+ run_command sudo $PKG_MANAGER install -y libgtest-dev
571+ # Check if gtest source directory exists
572+ if [ ! -d "$gtest_src_dir" ]; then
573+ echo "googletest source directory not found: $gtest_src_dir"
574+ echo "Attempting to reinstall libgtest-dev..."
575+ run_command sudo $PKG_MANAGER purge -y libgtest-dev
576+ run_command sudo $PKG_MANAGER install -y libgtest-dev
577+ # Check directory again
578+ if [ ! -d "$gtest_src_dir" ]; then
579+ echo "Still cannot find $gtest_src_dir, please install manually:"
580+ echo "1. Download source: wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz"
581+ echo "2. Extract and compile: tar -zxf release-1.11.0.tar.gz && cd googletest-release-1.11.0 && cmake . && make && sudo make install"
582+ exit 1
583+ fi
584+ fi
585+ # Force cmake execution in gtest source directory (even if cd fails)
586+ echo "Entering $gtest_src_dir to compile..."
587+ run_command sudo cmake -S "$gtest_src_dir" -B "$gtest_src_dir/build"
588+ run_command sudo make -C "$gtest_src_dir/build"
589+ run_command sudo cp "$gtest_src_dir/build/lib/"*.a /usr/lib
590+ ;;
591+ rhel)
592+ run_command sudo $PKG_MANAGER install -y gtest gtest-devel
593+ ;;
594+ macos)
595+ run_command brew install googletest
596+ echo 'export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"' >> ~/.zshrc
597+ ;;
598+ esac
599+ 
600+ if pkg-config --exists gtest 2>/dev/null; then
601+ curr_ver=$(pkg-config --modversion gtest)
602+ echo "googletest installed successfully ($curr_ver)"
603+ else
604+ echo "Warning: Unable to verify googletest installation via pkg-config."
605+ echo "Please verify googletest is correctly installed manually."
606+ exit 1
607+ fi
608+}
atomgit-bot
atomgit-botatomgit-bot7月23日

🔴 Critical

该 diff 删除了 check_dependencies_silent 函数(原位于第425–509行),但 build.sh 第33行通过 source "./install_deps.sh" 引入该脚本,并在第36行调用 check_dependencies_silent "$@"。函数被移除后,build.sh 在执行时会报 "check_dependencies_silent: command not found" 并退出,彻底阻断构建流程。

变更链:diff 删除 check_dependencies_silent 函数定义 → build.sh source 后不再有该函数 → 调用时命令未找到 → 构建失败。

建议:要么在 install_deps.sh 中保留 check_dependencies_silent 函数(可简化但必须保留函数名和基本逻辑),要么同步修改 build.sh 第36行,改用新的依赖检查方式(如调用 install_pkg_configinstall_googletest 或直接调用各 install 函数)。两个文件必须同步变更。

likedislike
不准确?
609+ 
513main() {610main() {
514 echo "===================================================="611 echo "===================================================="
515 echo "Starting project dependency installation"612 echo "Starting project dependency installation"
@@ -522,6 +619,8 @@ main() {
522 install_pigz619 install_pigz
523 install_dos2unix620 install_dos2unix
524 install_patch621 install_patch
622+ install_pkg_config
623+ install_googletest
525 624 
526 echo -e "===================================================="625 echo -e "===================================================="
527 echo "All dependencies installed successfully!"626 echo "All dependencies installed successfully!"
@@ -530,4 +629,4 @@ main() {
530 629 
531if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then630if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
532 main "$@"631 main "$@"
533-fi632+fi
@@ -1,6 +1,4 @@
1pyyaml1pyyaml
2-absl-py>=2.0.0
3-jinja2>=3.1.0
4numpy<2.02numpy<2.0
5decorator3decorator
6sympy4sympy
@@ -9,4 +7,4 @@ attrs
9psutil7psutil
10protobuf8protobuf
11setuptools>=59.0.09setuptools>=59.0.0
12-wheel10+wheel