转向直接移植LinuxCNC源程序
结论:明确禁止继续扩展自写 CNC 主体语义,最小 runtime 仅保留为迁移探针;新增 interp_convert.cc 源码直连编译探针,并以最小 emcStatus 状态边界 shim 暴露 native runtime 阻塞点。检查:git diff --check 通过;wasm-port/tests/native/verify_native_probes.sh 通过,linuxcnc_interp_convert_source_probe exitcode=0。
This commit is contained in:
@@ -19,6 +19,17 @@ Build a standalone CNC simulation system that:
|
||||
- does not drive real hardware;
|
||||
- preserves LinuxCNC software behavior as closely as practical.
|
||||
|
||||
## Current Direction
|
||||
|
||||
The migration target is the LinuxCNC source program itself, adapted to run as
|
||||
the standalone WASM simulation program. The project must not evolve a
|
||||
project-authored interpreter, planner, or CNC semantics layer now that the
|
||||
porting harness is running.
|
||||
|
||||
Existing minimal runtime wrappers are migration probes only. They are allowed
|
||||
to expose, compile, and validate vendored LinuxCNC code, but they must not be
|
||||
expanded into a separate implementation of G-code behavior.
|
||||
|
||||
## Repository Boundaries
|
||||
|
||||
1. `../linuxcnc/` is upstream and must be treated as read-only input for the
|
||||
@@ -33,21 +44,24 @@ Build a standalone CNC simulation system that:
|
||||
## Engineering Rules
|
||||
|
||||
1. Reuse LinuxCNC source before reimplementing any CNC logic.
|
||||
2. Prefer wrappers, shims, and extraction scripts over invasive source edits.
|
||||
3. Preserve LinuxCNC semantics for:
|
||||
2. Do not add new project-authored CNC semantics when LinuxCNC source exists.
|
||||
Replace temporary wrapper behavior with direct calls into vendored LinuxCNC
|
||||
source, or with the narrowest shims needed to make those calls compile.
|
||||
3. Prefer wrappers, shims, and extraction scripts over invasive source edits.
|
||||
4. Preserve LinuxCNC semantics for:
|
||||
- G-code execution;
|
||||
- modal state;
|
||||
- parameter and variable behavior;
|
||||
- kinematics;
|
||||
- planner behavior;
|
||||
- machine and controller state visible to software.
|
||||
4. Replace only the native runtime edges:
|
||||
5. Replace only the native runtime edges:
|
||||
- file IO;
|
||||
- process model;
|
||||
- HAL runtime;
|
||||
- IPC;
|
||||
- GUI.
|
||||
5. Frontend code must be implemented with web technology, not migrated from
|
||||
6. Frontend code must be implemented with web technology, not migrated from
|
||||
native GUI code.
|
||||
|
||||
## Required Layout
|
||||
|
||||
@@ -38,6 +38,8 @@ Use this skill when the work involves any of the following:
|
||||
4. Native runtime dependencies are replaced at the edges, not copied whole.
|
||||
5. Machine state and controller-visible behavior are first-class compatibility
|
||||
targets, not optional nice-to-haves.
|
||||
6. Do not continue building a project-authored CNC program once the porting
|
||||
harness runs; move behavior back to vendored LinuxCNC source functions.
|
||||
|
||||
## Source Reuse Priorities
|
||||
|
||||
@@ -96,6 +98,16 @@ Preferred order of work:
|
||||
6. Build the WASM export layer second.
|
||||
7. Build the JS SDK and HTML frontend last.
|
||||
|
||||
Current migration emphasis:
|
||||
|
||||
- Treat `linuxcnc_interp_minimal_runtime.cpp` as a temporary probe surface.
|
||||
- Retire hand-written `convert_g()` behavior by linking and calling vendored
|
||||
LinuxCNC interpreter conversion code.
|
||||
- Add shims only for host/runtime edges that prevent vendored LinuxCNC source
|
||||
from compiling.
|
||||
- Do not add new G-code behavior in JavaScript or in standalone C++ wrappers
|
||||
except as a short-lived adapter around LinuxCNC code.
|
||||
|
||||
## Filesystem And Browser Guidance
|
||||
|
||||
For browser use:
|
||||
|
||||
@@ -371,7 +371,18 @@ Current verified progress:
|
||||
`interp_convert.cc::convert_straight()` and
|
||||
`rs274ngc_return.hh::NCE_CANNOT_DO_G1_WITH_ZERO_FEED_RATE`.
|
||||
- This proves the current extracted interpreter slice can parse and execute a
|
||||
simple traverse and feed move through a standalone canonical event sink.
|
||||
small fixture set through a standalone canonical event sink.
|
||||
- Important direction change: the minimal wrapper behavior is a migration
|
||||
probe, not the program body. Do not expand it into a separate CNC
|
||||
implementation. The next work must retire hand-written wrapper semantics and
|
||||
move execution through vendored LinuxCNC interpreter source such as
|
||||
`interp_convert.cc`, `interp_read.cc`, `interp_check.cc`, and
|
||||
`interp_execute.cc`.
|
||||
- `tools/build_native_probes.sh` now includes
|
||||
`linuxcnc_interp_convert_source_probe`, which directly compiles vendored
|
||||
`interp_convert.cc`. The required `emcStatus` shim is limited to the native
|
||||
status boundary used by `tag_arc()` for machine units; it is not a
|
||||
project-authored CNC behavior implementation.
|
||||
|
||||
## Phase 4: Port INI Parsing Without Editing Upstream
|
||||
|
||||
@@ -670,9 +681,11 @@ Keep these documents under `wasm-port/docs/`:
|
||||
Continue expanding the standalone interpreter core from the verified minimal
|
||||
traverse path:
|
||||
|
||||
1. replace the temporary minimal `convert_g()` implementation with thin
|
||||
wrappers around more vendored interpreter conversion code,
|
||||
2. add `_x`/`_y`/`_z` named parameter fixture coverage and align it with
|
||||
`#5420`/`#5421`/`#5422`,
|
||||
3. keep all source changes inside `wasm-port/` and leave `../linuxcnc/`
|
||||
1. replace the temporary minimal `convert_g()` implementation with calls into
|
||||
vendored LinuxCNC interpreter conversion code.
|
||||
2. identify and shim the native runtime symbols blocking direct compilation of
|
||||
`interp_convert.cc`, `interp_execute.cc`, and related interpreter files.
|
||||
3. keep fixture coverage as regression protection while deleting temporary
|
||||
hand-written semantics.
|
||||
4. keep all source changes inside `wasm-port/` and leave `../linuxcnc/`
|
||||
read-only.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "nml_intf/emc.hh"
|
||||
|
||||
static EMC_STAT standalone_emc_status;
|
||||
EMC_STAT *emcStatus = &standalone_emc_status;
|
||||
@@ -1,7 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
// Minimal shim for the standalone INI parser build.
|
||||
// Minimal shim for standalone interpreter source probes.
|
||||
enum EmcJointType : int {
|
||||
EMC_LINEAR = 1,
|
||||
EMC_ANGULAR = 2,
|
||||
};
|
||||
|
||||
class EMC_STAT {
|
||||
public:
|
||||
struct Motion {
|
||||
struct Traj {
|
||||
double linearUnits = 1.0;
|
||||
} traj;
|
||||
} motion;
|
||||
};
|
||||
|
||||
extern EMC_STAT *emcStatus;
|
||||
|
||||
@@ -35,6 +35,7 @@ check_exitcode linuxcnc_namedparam_harness
|
||||
check_exitcode linuxcnc_interp_minimal_harness
|
||||
check_exitcode linuxcnc_interp_minimal_harness.run
|
||||
check_exitcode linuxcnc_rs274_compile_probe
|
||||
check_exitcode linuxcnc_interp_convert_source_probe
|
||||
|
||||
check_fixture_output() {
|
||||
local fixture="$1"
|
||||
|
||||
@@ -31,7 +31,11 @@ rm -f \
|
||||
"$BUILD_DIR/linuxcnc_rs274_compile_probe.o" \
|
||||
"$BUILD_DIR/linuxcnc_rs274_compile_probe.exitcode" \
|
||||
"$BUILD_DIR/linuxcnc_rs274_compile_probe.stdout.log" \
|
||||
"$BUILD_DIR/linuxcnc_rs274_compile_probe.stderr.log"
|
||||
"$BUILD_DIR/linuxcnc_rs274_compile_probe.stderr.log" \
|
||||
"$BUILD_DIR/linuxcnc_interp_convert_source_probe.o" \
|
||||
"$BUILD_DIR/linuxcnc_interp_convert_source_probe.exitcode" \
|
||||
"$BUILD_DIR/linuxcnc_interp_convert_source_probe.stdout.log" \
|
||||
"$BUILD_DIR/linuxcnc_interp_convert_source_probe.stderr.log"
|
||||
|
||||
g++ -std=c++20 -O2 \
|
||||
-D_GNU_SOURCE \
|
||||
@@ -160,4 +164,26 @@ RS274_RC=$?
|
||||
set -e
|
||||
|
||||
echo "$RS274_RC" > "$BUILD_DIR/linuxcnc_rs274_compile_probe.exitcode"
|
||||
|
||||
set +e
|
||||
g++ -std=c++20 -O2 \
|
||||
-D_GNU_SOURCE \
|
||||
-DM_PI=3.14159265358979323846 \
|
||||
-DOBJECT_FWD_DWA2002724_HPP \
|
||||
-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/libnml/posemath" \
|
||||
-c "$VENDOR_DIR/src/emc/rs274ngc/interp_convert.cc" \
|
||||
-o "$BUILD_DIR/linuxcnc_interp_convert_source_probe.o" \
|
||||
>"$BUILD_DIR/linuxcnc_interp_convert_source_probe.stdout.log" \
|
||||
2>"$BUILD_DIR/linuxcnc_interp_convert_source_probe.stderr.log"
|
||||
CONVERT_SOURCE_RC=$?
|
||||
set -e
|
||||
|
||||
echo "$CONVERT_SOURCE_RC" > "$BUILD_DIR/linuxcnc_interp_convert_source_probe.exitcode"
|
||||
echo "native probes complete"
|
||||
|
||||
Reference in New Issue
Block a user