按推荐建议,继续执行
结论:补齐 interp_base.cc 与 gomath.c 的 vendored LinuxCNC 直接源码编译探针,增加 C 编译边界,并让 rtapi shim 支持 C/C++,继续确保核心功能来源于 LinuxCNC 源程序。
This commit is contained in:
@@ -473,6 +473,12 @@ Current verified progress:
|
||||
file under `vendor/linuxcnc/` and the matching file under `../linuxcnc/`.
|
||||
`tools/source-manifest.txt` was also de-duplicated so the manifest is a
|
||||
single authoritative extraction list.
|
||||
- Direct source compile probes now also cover vendored `interp_base.cc` and
|
||||
`gomath.c`. `interp_base.cc` uses a standalone `EMC2_HOME` compile-time
|
||||
path boundary for LinuxCNC's dynamic interpreter lookup, and `gomath.c` is
|
||||
compiled as C with `gcc` so its LinuxCNC C linkage is preserved. The
|
||||
standalone `rtapi.h` shim was made C/C++ compatible for this C-source
|
||||
boundary without changing vendored LinuxCNC files.
|
||||
|
||||
## Phase 4: Port INI Parsing Without Editing Upstream
|
||||
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
#else
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifndef RTAPI_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
@@ -37,13 +44,13 @@ RTAPI_BEGIN_DECLS
|
||||
static inline int rtapi_snprintf(char *buf, unsigned long size, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int rc = vsnprintf(buf, static_cast<size_t>(size), fmt, ap);
|
||||
int rc = vsnprintf(buf, (size_t)size, fmt, ap);
|
||||
va_end(ap);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static inline int rtapi_vsnprintf(char *buf, unsigned long size, const char *fmt, va_list ap) {
|
||||
return vsnprintf(buf, static_cast<size_t>(size), fmt, ap);
|
||||
return vsnprintf(buf, (size_t)size, fmt, ap);
|
||||
}
|
||||
|
||||
static inline void rtapi_print(const char *fmt, ...) {
|
||||
|
||||
@@ -92,6 +92,8 @@ check_exitcode linuxcnc_interp_namedparams_source_probe
|
||||
check_exitcode linuxcnc_interp_write_source_probe
|
||||
check_exitcode linuxcnc_interp_o_word_source_probe
|
||||
check_exitcode linuxcnc_rs274ngc_pre_source_probe
|
||||
check_exitcode linuxcnc_interp_base_source_probe
|
||||
check_exitcode linuxcnc_gomath_source_probe
|
||||
|
||||
NAMEDPARAM_STDOUT="$BUILD_DIR/linuxcnc_namedparam_harness.run.stdout.log"
|
||||
grep -Fq "init_named_parameters=0" "$NAMEDPARAM_STDOUT"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user