#!/bin/bash # 默认构建类型 BUILD_TYPE="Release" # 解析命令行参数 if [[ "$1" == "--debug" ]]; then BUILD_TYPE="Debug" echo "Building ylib in DEBUG mode" fi # 安装软件 sudo apt update sudo apt install -y g++ sudo apt install -y cmake sudo apt install -y libssl-dev sudo apt install -y xorg libx11-dev libgl1-mesa-dev sudo apt install -y openssl sudo apt install -y libboost-dev sudo apt install -y libmysqlcppconn-dev sudo apt install -y libleveldb-dev sudo apt install -y libsoci-dev sudo apt install -y unixodbc-dev sudo apt install -y libz-dev sudo apt install -y libmimalloc-dev # 初始化变量 src_dir=$(pwd) cd .. root_dir=$(pwd) install_dir=$(pwd)/ylib_linux_build # 根据构建类型设置不同的构建目录 if [ "$BUILD_TYPE" == "Debug" ]; then install_dir="${install_dir}_debug" echo "Debug build directory: $install_dir" fi # 创建必要文件夹 if [ ! -d $install_dir ]; then mkdir -p $install_dir else # 如果目录已存在,清理它 echo "Cleaning existing build directory: $install_dir" rm -rf $install_dir/* fi ######核心###### cd $install_dir echo "Running cmake with build type: $BUILD_TYPE" cmake $src_dir -DCMAKE_BUILD_TYPE=$BUILD_TYPE make -j4 sudo make install echo "ylib $BUILD_TYPE build completed successfully!"