第 6 组:源码链接、构建和文档约束闭环完成
This commit is contained in:
@@ -5,10 +5,29 @@ cd "$(dirname "$0")"
|
||||
|
||||
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
||||
cxx=${CXX:-g++}
|
||||
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_rs274_source_link.XXXXXX")
|
||||
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_SOURCE_LINK_BUILD_DIR-build/source-link-test}
|
||||
if [[ -z "$build_dir" ]]; then
|
||||
echo "CNC_SIM_SOURCE_LINK_BUILD_DIR must not be empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$build_dir" =~ [[:space:]] ]]; then
|
||||
echo "CNC_SIM_SOURCE_LINK_BUILD_DIR must not contain whitespace: $build_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
manifest=${1:-linuxcnc-rs274-source-files.txt}
|
||||
|
||||
trap 'rm -rf "$build_dir"' EXIT
|
||||
mkdir -p "$build_dir"
|
||||
build_dir=$(cd "$build_dir" && pwd)
|
||||
if [[ "$build_dir" == "/" ]]; then
|
||||
echo "CNC_SIM_SOURCE_LINK_BUILD_DIR must not be the filesystem root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs.sh "$manifest"
|
||||
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-switchkins-remap-table.sh linuxcnc-kinematics-source-files.txt
|
||||
# The LinuxCNC source-linked dump path is not concurrency-safe under parallel execution.
|
||||
@@ -33,7 +52,6 @@ objects=()
|
||||
linuxcnc_index=0
|
||||
for source in "${linuxcnc_sources[@]}"; do
|
||||
obj="$build_dir/linuxcnc_${linuxcnc_index}.o"
|
||||
"$cxx" "${common_flags[@]}" -c "$source" -o "$obj"
|
||||
objects+=("$obj")
|
||||
linuxcnc_index=$((linuxcnc_index + 1))
|
||||
done
|
||||
@@ -44,33 +62,94 @@ project_source_list="$build_dir/linuxcnc_rs274_dump_project_sources.txt"
|
||||
mapfile -t project_sources < "$project_source_list"
|
||||
for source in "${project_sources[@]}"; do
|
||||
obj="$build_dir/project_${project_index}.o"
|
||||
"$cxx" "${common_flags[@]}" -c "$source" -o "$obj"
|
||||
objects+=("$obj")
|
||||
project_index=$((project_index + 1))
|
||||
done
|
||||
|
||||
"$cxx" -std=c++17 -I core/include -I core/src \
|
||||
core/tests/linuxcnc_gees_table_smoke.cpp \
|
||||
-o "$build_dir/linuxcnc_gees_table_smoke"
|
||||
|
||||
support_object_list="$build_dir/linuxcnc_support_objects.txt"
|
||||
LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-source-support-objects.sh > "$support_object_list"
|
||||
mapfile -t support_objects < "$support_object_list"
|
||||
|
||||
"$cxx" "${objects[@]}" "${support_objects[@]}" \
|
||||
"${link_flags[@]}" \
|
||||
-llinuxcnc-uspace-posix \
|
||||
-llinuxcncini \
|
||||
-llinuxcnchal \
|
||||
-lpyplugin \
|
||||
-ltooldata \
|
||||
-lnml \
|
||||
-lposemath \
|
||||
-lboost_python313 \
|
||||
-lpython3.13 \
|
||||
-lfmt \
|
||||
-ldl \
|
||||
-o "$build_dir/linuxcnc_rs274_source_dump"
|
||||
source_link_signature="$build_dir/source-link-build.signature"
|
||||
source_link_next_signature="$build_dir/source-link-build.signature.next"
|
||||
{
|
||||
printf 'CXX=%s\n' "$cxx"
|
||||
printf 'PWD=%s\n' "$PWD"
|
||||
printf 'LINUXCNC_ROOT=%s\n' "$(cd "$linuxcnc_root" && pwd)"
|
||||
printf 'COMMON_FLAGS='
|
||||
printf ' %s' "${common_flags[@]}"
|
||||
printf '\n'
|
||||
printf 'LINK_FLAGS='
|
||||
printf ' %s' "${link_flags[@]}"
|
||||
printf '\n'
|
||||
printf 'LINUXCNC_SOURCES:\n'
|
||||
printf '%s\n' "${linuxcnc_sources[@]}"
|
||||
printf 'PROJECT_SOURCES:\n'
|
||||
printf '%s\n' "${project_sources[@]}"
|
||||
printf 'SUPPORT_OBJECTS:\n'
|
||||
printf '%s\n' "${support_objects[@]}"
|
||||
} > "$source_link_next_signature"
|
||||
if [[ ! -f "$source_link_signature" ]] || ! cmp -s "$source_link_signature" "$source_link_next_signature"; then
|
||||
rm -f "$build_dir"/linuxcnc_*.o \
|
||||
"$build_dir"/*.d \
|
||||
"$build_dir"/project_*.o \
|
||||
"$build_dir"/linuxcnc_gees_table_smoke.o \
|
||||
"$build_dir"/linuxcnc_rs274_source_dump \
|
||||
"$build_dir"/linuxcnc_gees_table_smoke
|
||||
fi
|
||||
mv "$source_link_next_signature" "$source_link_signature"
|
||||
|
||||
source_link_makefile="$build_dir/source-link.mk"
|
||||
{
|
||||
printf 'CXX := %s\n' "$cxx"
|
||||
printf 'COMMON_FLAGS :='
|
||||
printf ' %s' "${common_flags[@]}"
|
||||
printf '\n'
|
||||
printf 'LINK_FLAGS :='
|
||||
printf ' %s' "${link_flags[@]}"
|
||||
printf '\n'
|
||||
printf 'OBJECTS :='
|
||||
printf ' %s' "${objects[@]}"
|
||||
printf '\n'
|
||||
printf 'SUPPORT_OBJECTS :='
|
||||
printf ' %s' "${support_objects[@]}"
|
||||
printf '\n\n'
|
||||
printf 'DEP_FILES :=\n'
|
||||
for object in "${objects[@]}"; do
|
||||
printf 'DEP_FILES += %s.d\n' "$object"
|
||||
done
|
||||
printf 'DEP_FILES += %s.d\n\n' "$build_dir/linuxcnc_gees_table_smoke.o"
|
||||
printf '.PHONY: all\n'
|
||||
printf 'all: %s %s\n\n' \
|
||||
"$build_dir/linuxcnc_rs274_source_dump" \
|
||||
"$build_dir/linuxcnc_gees_table_smoke"
|
||||
|
||||
linuxcnc_index=0
|
||||
for source in "${linuxcnc_sources[@]}"; do
|
||||
printf '%s: %s\n' "$build_dir/linuxcnc_${linuxcnc_index}.o" "$source"
|
||||
printf '\t@$(CXX) $(COMMON_FLAGS) -MMD -MP -MF %s.d -c %s -o %s\n\n' \
|
||||
"$build_dir/linuxcnc_${linuxcnc_index}.o" "$source" "$build_dir/linuxcnc_${linuxcnc_index}.o"
|
||||
linuxcnc_index=$((linuxcnc_index + 1))
|
||||
done
|
||||
|
||||
project_index=0
|
||||
for source in "${project_sources[@]}"; do
|
||||
printf '%s: %s\n' "$build_dir/project_${project_index}.o" "$source"
|
||||
printf '\t@$(CXX) $(COMMON_FLAGS) -MMD -MP -MF %s.d -c %s -o %s\n\n' \
|
||||
"$build_dir/project_${project_index}.o" "$source" "$build_dir/project_${project_index}.o"
|
||||
project_index=$((project_index + 1))
|
||||
done
|
||||
|
||||
printf '%s: core/tests/linuxcnc_gees_table_smoke.cpp\n' "$build_dir/linuxcnc_gees_table_smoke.o"
|
||||
printf '\t@$(CXX) -std=c++17 -I core/include -I core/src -MMD -MP -MF %s.d -c core/tests/linuxcnc_gees_table_smoke.cpp -o %s\n\n' \
|
||||
"$build_dir/linuxcnc_gees_table_smoke.o" "$build_dir/linuxcnc_gees_table_smoke.o"
|
||||
printf '%s: %s\n' "$build_dir/linuxcnc_gees_table_smoke" "$build_dir/linuxcnc_gees_table_smoke.o"
|
||||
printf '\t@$(CXX) -std=c++17 -I core/include -I core/src %s -o %s\n\n' "$build_dir/linuxcnc_gees_table_smoke.o" "$build_dir/linuxcnc_gees_table_smoke"
|
||||
printf '%s: $(OBJECTS) $(SUPPORT_OBJECTS)\n' "$build_dir/linuxcnc_rs274_source_dump"
|
||||
printf '\t@$(CXX) $(OBJECTS) $(SUPPORT_OBJECTS) $(LINK_FLAGS) -llinuxcnc-uspace-posix -llinuxcncini -llinuxcnchal -lpyplugin -ltooldata -lnml -lposemath -lboost_python313 -lpython3.13 -lfmt -ldl -o %s\n' "$build_dir/linuxcnc_rs274_source_dump"
|
||||
printf '\n-include $(DEP_FILES)\n'
|
||||
} > "$source_link_makefile"
|
||||
make --output-sync=target -j"$build_jobs" -f "$source_link_makefile"
|
||||
|
||||
var_file="$build_dir/rs274ngc-source.var"
|
||||
base_var_file="$build_dir/rs274ngc-source-base.var"
|
||||
|
||||
Reference in New Issue
Block a user