每轮只推进合理适量的上下文、禁止顺手扩功能 smoke:源码链接构建约束
This commit is contained in:
@@ -5,10 +5,35 @@ cd "$(dirname "$0")"
|
||||
|
||||
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
||||
cxx=${CXX:-g++}
|
||||
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_interp_find_link.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_WASM_INTERP_FIND_BUILD_DIR-build/wasm-interp-find-link}
|
||||
if [[ -z "$build_dir" ]]; then
|
||||
echo "CNC_SIM_WASM_INTERP_FIND_BUILD_DIR must not be empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$build_dir" =~ [[:space:]] ]]; then
|
||||
echo "CNC_SIM_WASM_INTERP_FIND_BUILD_DIR must not contain whitespace: $build_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$build_dir"
|
||||
build_dir=$(cd "$build_dir" && pwd)
|
||||
if [[ "$build_dir" == "/" ]]; then
|
||||
echo "CNC_SIM_WASM_INTERP_FIND_BUILD_DIR must not be the filesystem root" >&2
|
||||
exit 1
|
||||
fi
|
||||
exec 9>"$build_dir/interp-find.lock"
|
||||
flock 9
|
||||
|
||||
trap 'rm -rf "$build_dir"' EXIT
|
||||
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs.sh --root-only
|
||||
preflight_cache_dir=${CNC_SIM_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)
|
||||
|
||||
tooldata_mmap_backend_shim=$(./list-linuxcnc-wasm-safe-shims.sh tooldata_mmap_backend.cc)
|
||||
tooldata_runtime_stubs_shim=$(./list-linuxcnc-wasm-safe-shims.sh tooldata_runtime_stubs.cc)
|
||||
@@ -23,38 +48,71 @@ interp_find_source=${linuxcnc_sources[1]}
|
||||
common_flag_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-wasm-common-cxxflags.sh --function-sections --data-sections)
|
||||
mapfile -t common_flags <<<"$common_flag_output"
|
||||
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
-c "$tooldata_common_source" \
|
||||
-o "$build_dir/tooldata_common.o"
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
-c "$tooldata_mmap_backend_shim" \
|
||||
-o "$build_dir/tooldata_mmap_backend.o"
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
-c "$tooldata_runtime_stubs_shim" \
|
||||
-o "$build_dir/tooldata_runtime_stubs.o"
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
-c "$rtapi_compat_shim" \
|
||||
-o "$build_dir/rtapi_compat.o"
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
-c core/wasm_shims/interp_find_probe_stubs.cc \
|
||||
-o "$build_dir/interp_find_probe_stubs.o"
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
-c "$interp_find_source" \
|
||||
-o "$build_dir/interp_find.o"
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
-c core/wasm_shims/interp_find_probe_main.cc \
|
||||
-o "$build_dir/interp_find_probe_main.o"
|
||||
sources=(
|
||||
"$tooldata_common_source"
|
||||
"$tooldata_mmap_backend_shim"
|
||||
"$tooldata_runtime_stubs_shim"
|
||||
"$rtapi_compat_shim"
|
||||
core/wasm_shims/interp_find_probe_stubs.cc
|
||||
"$interp_find_source"
|
||||
core/wasm_shims/interp_find_probe_main.cc
|
||||
)
|
||||
objects=(
|
||||
"$build_dir/tooldata_common.o"
|
||||
"$build_dir/tooldata_mmap_backend.o"
|
||||
"$build_dir/tooldata_runtime_stubs.o"
|
||||
"$build_dir/rtapi_compat.o"
|
||||
"$build_dir/interp_find_probe_stubs.o"
|
||||
"$build_dir/interp_find.o"
|
||||
"$build_dir/interp_find_probe_main.o"
|
||||
)
|
||||
|
||||
"$cxx" \
|
||||
"$build_dir/tooldata_common.o" \
|
||||
"$build_dir/tooldata_mmap_backend.o" \
|
||||
"$build_dir/tooldata_runtime_stubs.o" \
|
||||
"$build_dir/rtapi_compat.o" \
|
||||
"$build_dir/interp_find_probe_stubs.o" \
|
||||
"$build_dir/interp_find.o" \
|
||||
"$build_dir/interp_find_probe_main.o" \
|
||||
-Wl,--gc-sections \
|
||||
-o "$build_dir/interp_find_probe"
|
||||
signature="$build_dir/interp-find.signature"
|
||||
next_signature="$build_dir/interp-find.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 'SOURCES:\n'
|
||||
printf '%s\n' "${sources[@]}"
|
||||
} > "$next_signature"
|
||||
if [[ ! -f "$signature" ]] || ! cmp -s "$signature" "$next_signature"; then
|
||||
rm -f "$build_dir"/*.o "$build_dir"/*.d "$build_dir/interp_find_probe"
|
||||
fi
|
||||
mv "$next_signature" "$signature"
|
||||
|
||||
makefile="$build_dir/interp-find.mk"
|
||||
{
|
||||
printf 'CXX := %s\n' "$cxx"
|
||||
printf 'COMMON_FLAGS :='
|
||||
printf ' %s' "${common_flags[@]}"
|
||||
printf '\n\n'
|
||||
printf 'OBJECTS :='
|
||||
printf ' %s' "${objects[@]}"
|
||||
printf '\n\n'
|
||||
printf 'DEP_FILES :=\n'
|
||||
for object in "${objects[@]}"; do
|
||||
printf 'DEP_FILES += %s.d\n' "$object"
|
||||
done
|
||||
printf '\n.PHONY: all\n'
|
||||
printf 'all: %s/interp_find_probe\n\n' "$build_dir"
|
||||
|
||||
object_index=0
|
||||
for source in "${sources[@]}"; do
|
||||
printf '%s: %s\n' "${objects[$object_index]}" "$source"
|
||||
printf '\t@$(CXX) $(COMMON_FLAGS) -MMD -MP -MF %s.d -c %s -o %s\n\n' "${objects[$object_index]}" "$source" "${objects[$object_index]}"
|
||||
object_index=$((object_index + 1))
|
||||
done
|
||||
|
||||
printf '%s/interp_find_probe: $(OBJECTS)\n' "$build_dir"
|
||||
printf '\t@$(CXX) $(OBJECTS) -Wl,--gc-sections -o %s/interp_find_probe\n\n' "$build_dir"
|
||||
printf '\n-include $(DEP_FILES)\n'
|
||||
} > "$makefile"
|
||||
make --output-sync=target -j"$build_jobs" -f "$makefile" >/dev/null
|
||||
|
||||
"$build_dir/interp_find_probe"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user