-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·42 lines (31 loc) · 932 Bytes
/
Copy pathbuild.sh
File metadata and controls
executable file
·42 lines (31 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -euo pipefail
# Release build script
BUILD_DIR="build"
JOBS="${1:-$(nproc)}"
echo "[build.sh] Configuring Release build in ${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
cmake -S . -B "${BUILD_DIR}" -DCMAKE_BUILD_TYPE=Release
echo "[build.sh] Building (jobs=${JOBS})"
cmake --build "${BUILD_DIR}" --parallel "${JOBS}"
echo "[build.sh] Done. Executable (if any) is in ${BUILD_DIR}"
#!/bin/bash
# 清理旧的构建文件(如果存在)
if [ -d "build" ]; then
echo "清理旧的构建文件..."
rm -rf build
fi
# 创建构建目录
mkdir -p build
cd build
# 运行 CMake 配置
cmake ..
# 编译项目
make -j$(nproc)
# 创建 compile_commands.json 的符号链接到根目录(用于IDE)
if [ -f "compile_commands.json" ]; then
cd ..
ln -sf build/compile_commands.json compile_commands.json 2>/dev/null || true
cd build
fi
echo "构建完成!可执行文件位于: build/demo"