每轮只推进合理适量的上下文、禁止顺手扩功能 smoke:源码链接构建约束
This commit is contained in:
@@ -4,13 +4,12 @@ set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
||||
cxx=${CXX:-g++}
|
||||
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_rs274ngc_pre_link_blockers.XXXXXX")
|
||||
work_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_rs274ngc_pre_link_blockers.XXXXXX")
|
||||
manifest=${1:-linuxcnc-rs274-wasm-source-files.txt}
|
||||
keep_report_file=0
|
||||
|
||||
cleanup_rs274ngc_pre_blocker_temps() {
|
||||
rm -rf "$build_dir"
|
||||
rm -rf "$work_dir"
|
||||
if [[ "$keep_report_file" -eq 0 && -n "${report_file:-}" ]]; then
|
||||
rm -f "$report_file"
|
||||
fi
|
||||
@@ -22,11 +21,11 @@ if awk '/^} > "\$report_file" \|\| true$/{ found = 1 } END { exit !found }' test
|
||||
exit 1
|
||||
fi
|
||||
if ! awk '
|
||||
index($0, "LINUXCNC_ROOT=\"$linuxcnc_root\" ./check-linuxcnc-inputs.sh \"$manifest\"") { check_line = NR }
|
||||
index($0, "report_file=$(mktemp ") { report_line = NR }
|
||||
index($0, "check-linuxcnc-inputs-cached.sh --cache-dir \"$preflight_cache_dir\" \"$manifest\"") { check_line = NR }
|
||||
index($0, "cache_dir=${CNC_SIM_WASM_RS274NGC_PRE_LINK_BLOCKERS_CACHE_DIR-build/wasm-rs274ngc-pre-link-blockers}") { report_line = NR }
|
||||
END { exit !(check_line && report_line && check_line < report_line) }
|
||||
' test-linuxcnc-wasm-rs274ngc-pre-link-blockers.sh; then
|
||||
echo "rs274ngc_pre blocker scan creates its report before input validation" >&2
|
||||
echo "rs274ngc_pre blocker scan prepares its report cache before input validation" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! awk '
|
||||
@@ -38,58 +37,69 @@ if ! awk '
|
||||
echo "rs274ngc_pre blocker scan does not clean failed reports before preserving successful ones" >&2
|
||||
exit 1
|
||||
fi
|
||||
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs.sh "$manifest"
|
||||
report_file=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_rs274ngc_pre_undefined.XXXXXX.txt")
|
||||
preflight_cache_dir=${CNC_SIM_PREFLIGHT_CACHE_DIR:-build/wasm-probe-preflight-cache}
|
||||
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs-cached.sh --cache-dir "$preflight_cache_dir" "$manifest"
|
||||
cache_dir=${CNC_SIM_WASM_RS274NGC_PRE_LINK_BLOCKERS_CACHE_DIR-build/wasm-rs274ngc-pre-link-blockers}
|
||||
if [[ -z "$cache_dir" ]]; then
|
||||
echo "CNC_SIM_WASM_RS274NGC_PRE_LINK_BLOCKERS_CACHE_DIR must not be empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$cache_dir" =~ [[:space:]] ]]; then
|
||||
echo "CNC_SIM_WASM_RS274NGC_PRE_LINK_BLOCKERS_CACHE_DIR must not contain whitespace: $cache_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$cache_dir"
|
||||
cache_dir=$(cd "$cache_dir" && pwd)
|
||||
if [[ "$cache_dir" == "/" ]]; then
|
||||
echo "CNC_SIM_WASM_RS274NGC_PRE_LINK_BLOCKERS_CACHE_DIR must not be the filesystem root" >&2
|
||||
exit 1
|
||||
fi
|
||||
exec 8>"$cache_dir/rs274ngc-pre-link-blockers.lock"
|
||||
flock 8
|
||||
|
||||
common_flag_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-wasm-common-cxxflags.sh --profile core20-sections)
|
||||
mapfile -t common_flags <<<"$common_flag_output"
|
||||
object_output=$(CNC_SIM_PREFLIGHT_CACHE_DIR="$preflight_cache_dir" LINUXCNC_ROOT="$linuxcnc_root" ./build-linuxcnc-wasm-probe-objects.sh --mode rs274ngc-pre "$manifest")
|
||||
mapfile -t objects <<<"$object_output"
|
||||
manifest=$(cd "$(dirname "$manifest")" && pwd)/$(basename "$manifest")
|
||||
linuxcnc_root=$(cd "$linuxcnc_root" && pwd)
|
||||
|
||||
shim_output=$(./list-linuxcnc-wasm-safe-shims.sh)
|
||||
mapfile -t shim_sources <<<"$shim_output"
|
||||
undefined_file="$work_dir/undefined.raw"
|
||||
defined_file="$work_dir/defined.raw"
|
||||
signature="$cache_dir/rs274ngc-pre-link-blockers.signature"
|
||||
next_signature="$cache_dir/rs274ngc-pre-link-blockers.signature.next"
|
||||
report_file="$cache_dir/rs274ngc-pre-link-blockers.txt"
|
||||
next_report_file="$cache_dir/rs274ngc-pre-link-blockers.txt.next"
|
||||
{
|
||||
printf 'PWD=%s\n' "$PWD"
|
||||
printf 'LINUXCNC_ROOT=%s\n' "$linuxcnc_root"
|
||||
printf 'MANIFEST=%s\n' "$manifest"
|
||||
printf 'FILTER_RULE_VERSION=1\n'
|
||||
printf 'OBJECTS:\n'
|
||||
printf '%s\n' "${objects[@]}"
|
||||
printf 'OBJECT_STATS:\n'
|
||||
stat -c 'OBJECT=%n:%s:%y' "${objects[@]}"
|
||||
} > "$next_signature"
|
||||
if [[ -f "$signature" && -f "$report_file" ]] && cmp -s "$signature" "$next_signature"; then
|
||||
keep_report_file=1
|
||||
if [[ -s "$report_file" ]]; then
|
||||
echo "unexpected cached unresolved project symbols after rs274ngc_pre shim coverage:" >&2
|
||||
sed -n '1,120p' "$report_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "linuxcnc wasm rs274ngc_pre link blocker scan passed"
|
||||
echo "wrote $report_file"
|
||||
rm -f "$next_signature"
|
||||
exit 0
|
||||
fi
|
||||
report_file="$next_report_file"
|
||||
rm -f "$next_report_file"
|
||||
|
||||
project_source_output=$(./list-linuxcnc-wasm-safe-project-sources.sh)
|
||||
mapfile -t project_sources <<<"$project_source_output"
|
||||
|
||||
source_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-wasm-manifest-sources.sh "$manifest" core full)
|
||||
mapfile -t linuxcnc_sources <<<"$source_output"
|
||||
|
||||
shim_index=0
|
||||
for source in "${shim_sources[@]}"; do
|
||||
obj="$build_dir/shim_${shim_index}.o"
|
||||
"$cxx" "${common_flags[@]}" -c "$source" -o "$obj"
|
||||
shim_index=$((shim_index + 1))
|
||||
done
|
||||
|
||||
project_index=0
|
||||
for source in "${project_sources[@]}"; do
|
||||
obj="$build_dir/project_${project_index}.o"
|
||||
source_flags=()
|
||||
case "$source" in
|
||||
core/src/linuxcnc_corexykins_adapter.c|core/src/linuxcnc_genserfuncs_adapter.c|core/src/linuxcnc_xyzab_tdr_kins_adapter.c)
|
||||
source_flags+=(-fpermissive)
|
||||
;;
|
||||
esac
|
||||
"$cxx" "${common_flags[@]}" "${source_flags[@]}" -c "$source" -o "$obj"
|
||||
project_index=$((project_index + 1))
|
||||
done
|
||||
|
||||
linuxcnc_index=0
|
||||
for source in "${linuxcnc_sources[@]}"; do
|
||||
obj="$build_dir/linuxcnc_${linuxcnc_index}.o"
|
||||
"$cxx" "${common_flags[@]}" -c "$source" -o "$obj"
|
||||
linuxcnc_index=$((linuxcnc_index + 1))
|
||||
done
|
||||
|
||||
undefined_file="$build_dir/undefined.raw"
|
||||
defined_file="$build_dir/defined.raw"
|
||||
|
||||
nm -u "$build_dir"/*.o \
|
||||
nm -u "${objects[@]}" \
|
||||
| awk '{print $2}' \
|
||||
| sed '/^$/d' \
|
||||
| LC_ALL=C sort -u \
|
||||
> "$undefined_file"
|
||||
|
||||
nm --defined-only "$build_dir"/*.o \
|
||||
nm --defined-only "${objects[@]}" \
|
||||
| awk '{print $3}' \
|
||||
| sed '/^$/d' \
|
||||
| LC_ALL=C sort -u \
|
||||
@@ -151,6 +161,9 @@ if [[ -s "$report_file" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv "$next_signature" "$signature"
|
||||
mv "$next_report_file" "$cache_dir/rs274ngc-pre-link-blockers.txt"
|
||||
report_file="$cache_dir/rs274ngc-pre-link-blockers.txt"
|
||||
echo "linuxcnc wasm rs274ngc_pre link blocker scan passed"
|
||||
keep_report_file=1
|
||||
echo "wrote $report_file"
|
||||
|
||||
Reference in New Issue
Block a user