62 lines
1.6 KiB
Bash
Executable File
62 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
# LinuxCNC source basis: combined CMake source-set listers expose project
|
|
# bridge/shim/adapter sources declared in core/CMakeLists.txt so LinuxCNC
|
|
# source-linked probes can verify their thin wrapper objects without inventing
|
|
# G-code, canon, or kinematics behavior.
|
|
if [[ "$#" -lt 2 || "$#" -gt 3 ]]; then
|
|
echo "usage: $0 <set-name> <append-name> [relative-prefix]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
set_name=$1
|
|
append_name=$2
|
|
relative_prefix=${3:-}
|
|
|
|
awk -v set_name="$set_name" -v append_name="$append_name" -v relative_prefix="$relative_prefix" '
|
|
$0 ~ "^[[:space:]]*set\\(" set_name "([[:space:]]|$)" {
|
|
found_set = 1
|
|
in_set = 1
|
|
next
|
|
}
|
|
in_set && /^[[:space:]]*\)/ {
|
|
in_set = 0
|
|
next
|
|
}
|
|
$0 ~ "^[[:space:]]*list\\(APPEND " append_name "([[:space:]]|$)" {
|
|
found_append = 1
|
|
in_append = 1
|
|
next
|
|
}
|
|
in_append && /^[[:space:]]*\)/ {
|
|
in_append = 0
|
|
next
|
|
}
|
|
in_set || in_append {
|
|
line = $0
|
|
sub(/^[[:space:]]*/, "", line)
|
|
sub(/[[:space:]]*$/, "", line)
|
|
if (line == "") {
|
|
next
|
|
}
|
|
sub(/^\$\{CMAKE_CURRENT_SOURCE_DIR\}\//, "core/", line)
|
|
if (line !~ /^core\// && relative_prefix != "") {
|
|
line = relative_prefix line
|
|
}
|
|
print line
|
|
}
|
|
END {
|
|
if (!found_set) {
|
|
print "missing CMake source set: " set_name > "/dev/stderr"
|
|
exit 1
|
|
}
|
|
if (!found_append) {
|
|
print "missing CMake append source set: " append_name > "/dev/stderr"
|
|
exit 1
|
|
}
|
|
}
|
|
' core/CMakeLists.txt
|