每轮只推进合理适量的上下文、禁止顺手扩功能 smoke:源码链接构建约束
This commit is contained in:
@@ -5,10 +5,33 @@ cd "$(dirname "$0")"
|
||||
|
||||
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
||||
cxx=${CXX:-g++}
|
||||
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_native.XXXXXX")
|
||||
if [[ -z ${CXX:-} ]] && command -v ccache >/dev/null 2>&1; then
|
||||
cxx="ccache $cxx"
|
||||
fi
|
||||
build_jobs=${CNC_SIM_BUILD_JOBS:-8}
|
||||
if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then
|
||||
echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2
|
||||
exit 1
|
||||
fi
|
||||
build_dir=${CNC_SIM_RS274_NATIVE_BUILD_DIR-build/rs274-native-test}
|
||||
if [[ -z "$build_dir" ]]; then
|
||||
echo "CNC_SIM_RS274_NATIVE_BUILD_DIR must not be empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$build_dir" =~ [[:space:]] ]]; then
|
||||
echo "CNC_SIM_RS274_NATIVE_BUILD_DIR must not contain whitespace: $build_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap 'rm -rf "$build_dir"' EXIT
|
||||
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs.sh --root-only
|
||||
mkdir -p "$build_dir"
|
||||
build_dir=$(cd "$build_dir" && pwd)
|
||||
if [[ "$build_dir" == "/" ]]; then
|
||||
echo "CNC_SIM_RS274_NATIVE_BUILD_DIR must not be the filesystem root" >&2
|
||||
exit 1
|
||||
fi
|
||||
preflight_cache_dir="$build_dir/preflight-cache"
|
||||
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs-cached.sh --cache-dir "$preflight_cache_dir" --root-only
|
||||
linuxcnc_root=$(cd "$linuxcnc_root" && pwd)
|
||||
# The LinuxCNC rs274 backend path can bus-error when two dumps run concurrently.
|
||||
exec 9>"${TMPDIR:-/tmp}/cnc_sim_linuxcnc_rs274_native.lock"
|
||||
flock 9
|
||||
@@ -36,13 +59,68 @@ mapfile -t common_flags <<<"$common_flag_output"
|
||||
link_flag_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-native-linkflags.sh)
|
||||
mapfile -t link_flags <<<"$link_flag_output"
|
||||
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
"${project_sources[@]}" \
|
||||
"${link_flags[@]}" \
|
||||
-lrs274 \
|
||||
-ltooldata \
|
||||
-lpython3.13 \
|
||||
-o "$build_dir/linuxcnc_rs274_dump"
|
||||
project_objects=()
|
||||
project_index=0
|
||||
for source in "${project_sources[@]}"; do
|
||||
project_objects+=("$build_dir/project_${project_index}.o")
|
||||
project_index=$((project_index + 1))
|
||||
done
|
||||
|
||||
rs274_native_signature="$build_dir/rs274-native.signature"
|
||||
rs274_native_next_signature="$build_dir/rs274-native.signature.next"
|
||||
{
|
||||
printf 'CXX=%s\n' "$cxx"
|
||||
printf 'PWD=%s\n' "$PWD"
|
||||
printf 'LINUXCNC_ROOT=%s\n' "$linuxcnc_root"
|
||||
printf 'BUILD_RULE_VERSION=1\n'
|
||||
printf 'COMMON_FLAGS='
|
||||
printf ' %s' "${common_flags[@]}"
|
||||
printf '\n'
|
||||
printf 'LINK_FLAGS='
|
||||
printf ' %s' "${link_flags[@]}"
|
||||
printf '\n'
|
||||
printf 'PROJECT_SOURCES:\n'
|
||||
printf '%s\n' "${project_sources[@]}"
|
||||
} > "$rs274_native_next_signature"
|
||||
if [[ ! -f "$rs274_native_signature" ]] || ! cmp -s "$rs274_native_signature" "$rs274_native_next_signature"; then
|
||||
rm -f "$build_dir"/project_*.o \
|
||||
"$build_dir"/project_*.o.d \
|
||||
"$build_dir/linuxcnc_rs274_dump"
|
||||
fi
|
||||
mv "$rs274_native_next_signature" "$rs274_native_signature"
|
||||
|
||||
rs274_native_makefile="$build_dir/rs274-native.mk"
|
||||
{
|
||||
printf 'CXX := %s\n' "$cxx"
|
||||
printf 'COMMON_FLAGS :='
|
||||
printf ' %s' "${common_flags[@]}"
|
||||
printf '\n'
|
||||
printf 'LINK_FLAGS :='
|
||||
printf ' %s' "${link_flags[@]}"
|
||||
printf '\n\n'
|
||||
printf 'PROJECT_OBJECTS :='
|
||||
printf ' %s' "${project_objects[@]}"
|
||||
printf '\n\n'
|
||||
printf 'DEP_FILES :=\n'
|
||||
for object in "${project_objects[@]}"; do
|
||||
printf 'DEP_FILES += %s.d\n' "$object"
|
||||
done
|
||||
printf '\n.PHONY: all\n'
|
||||
printf 'all: %s\n\n' "$build_dir/linuxcnc_rs274_dump"
|
||||
|
||||
project_index=0
|
||||
for source in "${project_sources[@]}"; do
|
||||
printf '%s: %s\n' "${project_objects[$project_index]}" "$source"
|
||||
printf '\t@$(CXX) $(COMMON_FLAGS) -MMD -MP -MF %s.d -c %s -o %s\n\n' \
|
||||
"${project_objects[$project_index]}" "$source" "${project_objects[$project_index]}"
|
||||
project_index=$((project_index + 1))
|
||||
done
|
||||
|
||||
printf '%s: $(PROJECT_OBJECTS)\n' "$build_dir/linuxcnc_rs274_dump"
|
||||
printf '\t@$(CXX) $(PROJECT_OBJECTS) $(LINK_FLAGS) -lrs274 -ltooldata -lpython3.13 -o %s\n' "$build_dir/linuxcnc_rs274_dump"
|
||||
printf '\n-include $(DEP_FILES)\n'
|
||||
} > "$rs274_native_makefile"
|
||||
make --output-sync=target -j"$build_jobs" -f "$rs274_native_makefile"
|
||||
|
||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_basic_motion.ngc >"$output_dir/cnc_sim_linuxcnc_basic_motion.json"
|
||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/basic_mill.ngc >"$output_dir/cnc_sim_linuxcnc_basic_mill.json"
|
||||
|
||||
Reference in New Issue
Block a user