按推荐建议,继续执行

结论:补齐 interp_base.cc 与 gomath.c 的 vendored LinuxCNC 直接源码编译探针,增加 C 编译边界,并让 rtapi shim 支持 C/C++,继续确保核心功能来源于 LinuxCNC 源程序。
This commit is contained in:
2026-06-07 18:23:14 +08:00
parent 4158a78760
commit e7361ddbd0
4 changed files with 100 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ INCLUDE_DIR="$ROOT_DIR/runtime/core/include"
MINIMAL_GCODE_FIXTURE="$ROOT_DIR/tests/fixtures/gcode/minimal_linear.ngc"
NAMEDPARAM_INI_FIXTURE="$ROOT_DIR/tests/fixtures/ini/namedparams.ini"
CXX="${CXX:-g++}"
CC="${CC:-gcc}"
mkdir -p "$BUILD_DIR"
@@ -45,6 +46,11 @@ MINIMAL_FLAGS=(
-DLINUXCNC_STANDALONE_USE_RS274_PRE_STATE
)
INTERP_BASE_FLAGS=(
"${MINIMAL_FLAGS[@]}"
-DEMC2_HOME=\"/standalone\"
)
MINIMAL_LINK_FLAGS=(
-Wl,--gc-sections
)
@@ -54,6 +60,24 @@ TP_FLAGS=(
-fpermissive
)
C_FLAGS=(
-std=gnu11
-O2
-D_GNU_SOURCE
-DM_PI=3.14159265358979323846
-I"$WRAP_DIR"
-I"$SHIM_DIR"
-I"$INCLUDE_DIR"
-I"$VENDOR_DIR/src"
-I"$VENDOR_DIR/src/rtapi"
-I"$VENDOR_DIR/src/emc"
-I"$VENDOR_DIR/src/emc/nml_intf"
-I"$VENDOR_DIR/src/emc/motion"
-I"$VENDOR_DIR/src/emc/tp"
-I"$VENDOR_DIR/src/emc/kinematics"
-I"$VENDOR_DIR/src/libnml/posemath"
)
write_command_file() {
local file="$1"
shift
@@ -129,6 +153,32 @@ compile_object() {
return 1
}
compile_c_object() {
local target="$1"
local source="$2"
local obj="$3"
shift 3
local stdout_log="$BUILD_DIR/$target.stdout.log"
local stderr_log="$BUILD_DIR/$target.stderr.log"
local depfile="$obj.d"
local cmdfile="$obj.cmd"
local cmd=("$CC" "$@" -MMD -MP -MF "$depfile" -c "$source" -o "$obj")
mkdir -p "$(dirname "$obj")"
if ! object_needs_rebuild "$obj" "$depfile" "$cmdfile" "${cmd[@]}"; then
printf 'up to date: %s\n' "$source" >> "$stdout_log"
return 0
fi
printf 'compile-c: %s\n' "$source" >> "$stdout_log"
if "${cmd[@]}" >> "$stdout_log" 2>> "$stderr_log"; then
write_command_file "$cmdfile" "${cmd[@]}"
return 0
fi
return 1
}
link_needs_rebuild() {
local output="$1"
local cmdfile="$2"
@@ -247,6 +297,27 @@ build_object_target() {
return "$status"
}
build_c_object_target() {
local target="$1"
local output="$2"
local source="$3"
local flags_name="$4"
local stdout_log="$BUILD_DIR/$target.stdout.log"
local stderr_log="$BUILD_DIR/$target.stderr.log"
: > "$stdout_log"
: > "$stderr_log"
local -n flags="$flags_name"
local status=0
if ! compile_c_object "$target" "$source" "$output" "${flags[@]}"; then
status=1
fi
echo "$status" > "$BUILD_DIR/$target.exitcode"
return "$status"
}
NO_LINK_FLAGS=()
INI_PROBE_SOURCES=(
@@ -629,4 +700,16 @@ build_object_target \
"$VENDOR_DIR/src/emc/rs274ngc/rs274ngc_pre.cc" \
MINIMAL_FLAGS
build_object_target \
linuxcnc_interp_base_source_probe \
"$BUILD_DIR/linuxcnc_interp_base_source_probe.o" \
"$VENDOR_DIR/src/emc/rs274ngc/interp_base.cc" \
INTERP_BASE_FLAGS
build_c_object_target \
linuxcnc_gomath_source_probe \
"$BUILD_DIR/linuxcnc_gomath_source_probe.o" \
"$VENDOR_DIR/src/libnml/posemath/gomath.c" \
C_FLAGS
echo "native probes complete"