第6组:启用ccache加速重复编译并保持闭环

This commit is contained in:
cnc
2026-06-01 06:42:35 +08:00
parent 4c55ab3435
commit 6f9431a389
7 changed files with 35 additions and 1 deletions

View File

@@ -10,6 +10,13 @@ if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then
echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2 echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2
exit 1 exit 1
fi fi
cmake_compiler_launcher_args=()
if [[ -z ${CXX:-} ]] && command -v ccache >/dev/null 2>&1; then
cmake_compiler_launcher_args+=(
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
)
fi
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs.sh "$manifest" LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs.sh "$manifest"
manifest=$(cd "$(dirname "$manifest")" && pwd)/$(basename "$manifest") manifest=$(cd "$(dirname "$manifest")" && pwd)/$(basename "$manifest")
@@ -117,7 +124,8 @@ emcmake cmake -S core -B build/wasm \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCNC_SIM_LINUXCNC_ROOT="$linuxcnc_root" \ -DCNC_SIM_LINUXCNC_ROOT="$linuxcnc_root" \
-DCNC_SIM_LINUXCNC_WASM_SOURCE_MANIFEST="$manifest" \ -DCNC_SIM_LINUXCNC_WASM_SOURCE_MANIFEST="$manifest" \
-DCNC_SIM_ENABLE_LINUXCNC_WASM_SAFE_PROBE=ON -DCNC_SIM_ENABLE_LINUXCNC_WASM_SAFE_PROBE=ON \
"${cmake_compiler_launcher_args[@]}"
cmake --build build/wasm --target cnc_sim_wasm_runtime_probe --parallel "$build_jobs" cmake --build build/wasm --target cnc_sim_wasm_runtime_probe --parallel "$build_jobs"
cmake --build build/wasm --target cnc_sim_wasm --parallel "$build_jobs" cmake --build build/wasm --target cnc_sim_wasm --parallel "$build_jobs"
mkdir -p web/public mkdir -p web/public

View File

@@ -57,6 +57,9 @@ Efficiency rules:
- Default native, source-link, build-wasm, and wasm-safe CMake probe - Default native, source-link, build-wasm, and wasm-safe CMake probe
parallelism to `CNC_SIM_BUILD_JOBS:-8`; raise it only by explicit parallelism to `CNC_SIM_BUILD_JOBS:-8`; raise it only by explicit
positive-integer environment override. positive-integer environment override.
- When `ccache` is available and `CXX` is unset, native and wasm build paths
should enable compiler caching automatically rather than requiring a manual
wrapper.
- Persistent native, source-link, and wasm-safe CMake probe build directories - Persistent native, source-link, and wasm-safe CMake probe build directories
may be overridden for local workflows, but must not point at the filesystem may be overridden for local workflows, but must not point at the filesystem
root. root.

View File

@@ -192,10 +192,19 @@ grep -F 'printf '\''\t@$(CXX) $(COMMON_FLAGS) -MMD -MP -MF %s/source_%s.d %s\n'\
grep -F 'make --output-sync=target -j"$build_jobs" -f "$source_syntax_makefile"' test-linuxcnc-source-syntax.sh >/dev/null grep -F 'make --output-sync=target -j"$build_jobs" -f "$source_syntax_makefile"' test-linuxcnc-source-syntax.sh >/dev/null
grep -F 'build_jobs=${CNC_SIM_BUILD_JOBS:-8}' build-wasm.sh >/dev/null grep -F 'build_jobs=${CNC_SIM_BUILD_JOBS:-8}' build-wasm.sh >/dev/null
grep -F 'CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs' build-wasm.sh >/dev/null grep -F 'CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs' build-wasm.sh >/dev/null
grep -F 'command -v ccache >/dev/null 2>&1' build-wasm.sh >/dev/null
grep -F 'CMAKE_C_COMPILER_LAUNCHER=ccache' build-wasm.sh >/dev/null
grep -F 'CMAKE_CXX_COMPILER_LAUNCHER=ccache' build-wasm.sh >/dev/null
grep -F 'cmake --build build/wasm --target cnc_sim_wasm_runtime_probe --parallel "$build_jobs"' build-wasm.sh >/dev/null grep -F 'cmake --build build/wasm --target cnc_sim_wasm_runtime_probe --parallel "$build_jobs"' build-wasm.sh >/dev/null
grep -F 'cmake --build build/wasm --target cnc_sim_wasm --parallel "$build_jobs"' build-wasm.sh >/dev/null grep -F 'cmake --build build/wasm --target cnc_sim_wasm --parallel "$build_jobs"' build-wasm.sh >/dev/null
grep -F 'command -v ccache >/dev/null 2>&1' test-native.sh >/dev/null
grep -F 'command -v ccache >/dev/null 2>&1' test-linuxcnc-source-link.sh >/dev/null
grep -F 'command -v ccache >/dev/null 2>&1' test-linuxcnc-source-syntax.sh >/dev/null
grep -F 'build_jobs=${CNC_SIM_BUILD_JOBS:-8}' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null grep -F 'build_jobs=${CNC_SIM_BUILD_JOBS:-8}' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null
grep -F 'CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null grep -F 'CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null
grep -F 'cmake_compiler_launcher_mode=none' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null
grep -F 'cmake_compiler_launcher_mode=ccache' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null
grep -F 'COMPILER_LAUNCHER=%s\n' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null
grep -F 'build_dir=${CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR-build/wasm-cmake-safe-probe}' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null grep -F 'build_dir=${CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR-build/wasm-cmake-safe-probe}' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null
grep -F 'CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR must not be empty' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null grep -F 'CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR must not be empty' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null
grep -F 'CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR must not contain whitespace: $build_dir' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null grep -F 'CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR must not contain whitespace: $build_dir' test-linuxcnc-wasm-cmake-safe-probe.sh >/dev/null

View File

@@ -5,6 +5,9 @@ cd "$(dirname "$0")"
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc} linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
cxx=${CXX:-g++} cxx=${CXX:-g++}
if [[ -z ${CXX:-} ]] && command -v ccache >/dev/null 2>&1; then
cxx="ccache $cxx"
fi
build_jobs=${CNC_SIM_BUILD_JOBS:-8} build_jobs=${CNC_SIM_BUILD_JOBS:-8}
if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then
echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2 echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2

View File

@@ -5,6 +5,9 @@ cd "$(dirname "$0")"
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc} linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
cxx=${CXX:-g++} cxx=${CXX:-g++}
if [[ -z ${CXX:-} ]] && command -v ccache >/dev/null 2>&1; then
cxx="ccache $cxx"
fi
build_jobs=${CNC_SIM_BUILD_JOBS:-8} build_jobs=${CNC_SIM_BUILD_JOBS:-8}
if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then
echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2 echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2

View File

@@ -9,6 +9,10 @@ if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then
echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2 echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2
exit 1 exit 1
fi fi
cmake_compiler_launcher_mode=none
if [[ -z ${CXX:-} ]] && command -v ccache >/dev/null 2>&1; then
cmake_compiler_launcher_mode=ccache
fi
build_dir=${CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR-build/wasm-cmake-safe-probe} build_dir=${CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR-build/wasm-cmake-safe-probe}
if [[ -z "$build_dir" ]]; then if [[ -z "$build_dir" ]]; then
echo "CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR must not be empty" >&2 echo "CNC_SIM_WASM_CMAKE_SAFE_PROBE_BUILD_DIR must not be empty" >&2
@@ -99,6 +103,7 @@ build_next_signature=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_wasm_cmake_safe_probe.sig
printf 'LINUXCNC_ROOT=%s\n' "$linuxcnc_root" printf 'LINUXCNC_ROOT=%s\n' "$linuxcnc_root"
printf 'MANIFEST=%s\n' "$manifest" printf 'MANIFEST=%s\n' "$manifest"
printf 'BUILD_JOBS=%s\n' "$build_jobs" printf 'BUILD_JOBS=%s\n' "$build_jobs"
printf 'COMPILER_LAUNCHER=%s\n' "$cmake_compiler_launcher_mode"
} > "$build_next_signature" } > "$build_next_signature"
if [[ ! -f "$build_signature" ]] || ! cmp -s "$build_signature" "$build_next_signature"; then if [[ ! -f "$build_signature" ]] || ! cmp -s "$build_signature" "$build_next_signature"; then
rm -rf "$build_dir" rm -rf "$build_dir"

View File

@@ -4,6 +4,9 @@ set -euo pipefail
cd "$(dirname "$0")" cd "$(dirname "$0")"
cxx=${CXX:-g++} cxx=${CXX:-g++}
if [[ -z ${CXX:-} ]] && command -v ccache >/dev/null 2>&1; then
cxx="ccache $cxx"
fi
build_jobs=${CNC_SIM_BUILD_JOBS:-8} build_jobs=${CNC_SIM_BUILD_JOBS:-8}
if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then
echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2 echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2