fixdep: parse Makefile more correctly to handle comments etc.
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 7 Jan 2023 09:18:16 +0000 (18:18 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sun, 22 Jan 2023 14:43:33 +0000 (23:43 +0900)
commitbc6df812a1529ab0cbac7f17ac6c4f4aff2a8bbf
treeabdec3d8fe12b46f2c0bcaa06694190a76eb6700
parent295d8398c67e314d99bb070f38883f83fe94a97a
fixdep: parse Makefile more correctly to handle comments etc.

fixdep parses dependency files (*.d) emitted by the compiler.

*.d files are Makefiles describing the dependencies of the main source
file.

fixdep understands minimal Makefile syntax. It works well enough for
GCC and Clang, but not for rustc.

This commit improves the parser a little more for better processing
comments, escape sequences, etc.

My main motivation is to drop comments. rustc may output comments
(e.g. env-dep). Currentyly, rustc build rules invoke sed to remove
comments, but it is more efficient to do it in fixdep.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
scripts/basic/fixdep.c