awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.39k stars 597 forks source link

compile_commands.json: files referenced via build dir #2238

Open blueyed opened 6 years ago

blueyed commented 6 years ago

I've tried using cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. to build compile_commands.json, which can be used by clang-tidy etc.

But unfortunately the files are referenced in the build dir, apparently since configure_file "moves" them there. Therefore it's not really useful as-is when editing the actual source file.

Example entry for awesome.c:

[
{
  "directory": "…/src/awesome/build",
  "command": "/usr/local/bin/cc  -I…/src/awesome/build -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libpng16 -I/usr/include/startup-notification-1.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include    -O1 -std=gnu99 -ggdb3 -fno-strict-aliasing -Wall -Wextra -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wno-unused-parameter -Wuninitialized -Winit-self -Wpointer-arith -Wformat-nonliteral -Wno-format-zero-length -Wmissing-format-attribute -Wmissing-prototypes -Wstrict-prototypes -o CMakeFiles/awesome.dir/awesome.c.o   -c …/src/awesome/build/awesome.c",
  "file": "…/src/awesome/build/awesome.c"
},

Also using the command by itself does not work, apparently since build/common/atoms-extern.h might not be generated.

I've only briefly looked into this, but wanted to leave it here for discussion / further investigation.

psychon commented 6 years ago

I've only briefly looked into this, but wanted to leave it here for discussion / further investigation.

That's the "doc fun" that we have. @FOO@-tokens in the C source need to be expanded during build so that the expanded values can be picked up by ldoc. I find two such places via grep currently:

mousegrabber.c: *@DOC_cursor_c_COMMON@
root.c: *@DOC_cursor_c_COMMON@