diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-09-27 17:13:45 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-09-27 23:27:06 +0200 |
commit | af2756ee01fa6b1921c6bcb581817e64c30beb48 (patch) | |
tree | 879859caaf90ed0d0413fa29378b41148baa84cc /tools/cmake-dump.awk | |
parent | 688c458095974fcd85b2f92c6b5380edfb564398 (diff) | |
download | liberty-af2756ee01fa6b1921c6bcb581817e64c30beb48.tar.gz liberty-af2756ee01fa6b1921c6bcb581817e64c30beb48.tar.xz liberty-af2756ee01fa6b1921c6bcb581817e64c30beb48.zip |
Add a rudimentary CMake script parser
Diffstat (limited to 'tools/cmake-dump.awk')
-rw-r--r-- | tools/cmake-dump.awk | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/cmake-dump.awk b/tools/cmake-dump.awk new file mode 100644 index 0000000..d0b68b9 --- /dev/null +++ b/tools/cmake-dump.awk @@ -0,0 +1,24 @@ +# cmake-dump.awk: dump parsed CMake scripts as tables +# +# Copyright (c) 2022, Přemysl Eric Janouch <p@janouch.name> +# SPDX-License-Identifier: 0BSD +# +# Parsed scripts are output in a table, with commands separated using ASCII +# Record Separators, and arguments using Unit Separators. +# +# Example usage: awk -f cmake-parser.awk -f cmake-dump.awk CMakeLists.txt \ +# | sed 'y/\x1F\x1E\t\n/\t\n /' \ +# | sed -n '/^project\t\([^\t]*\).*\tVERSION\t\([^\t]*\).*/{s//\1 \2/p;q;}' + +function sanitize(s) { + if (s ~ /[\x1E\x1F]/) + fatal("conflicting ASCII control characters found in source") + return s +} + +Command { + out = sanitize(Command) + for (i in Args) + out = out "\x1F" sanitize(Args[i]) + printf "%s\x1E", out +} |