A wrapper for clangd would make it easier to launch the clangd necessary for processing WebKit source code. The main issue is that the build relies on a sandboxed build directory and headers from the Flatpak SDK.
Created attachment 451101 [details] Patch
The way to use this script is to set your IDE's clang binary path to <WebKitSourceDirectory>/Tools/flatpak/webkit-flatpak and then pass the --enable-config and --<platform> arguments. For instance, I have this working by installing coc and coc-clangd for vim and then the contents of my local coc configuration (":CocLocalConfig") are: { "clangd.arguments": [ "--enable-config", "--gtk" ], "clangd.path": "/home/martin/WebKit/Tools/flatpak/webkit-clangd" } The first indexing for this takes a while, but eventually you should have real-time compilation errors and completion.
Comment on attachment 451101 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=451101&action=review > Tools/ChangeLog:32 > +2022-02-07 Martin Robinson <mrobinson@webkit.org> > + > + [Flatpak SDK] Add a wrapper for clangd > + https://bugs.webkit.org/show_bug.cgi?id=236240 > + > + Reviewed by NOBODY (OOPS!). > + > + * flatpak/webkit-clangd: Added. Double changelog! > Tools/flatpak/flatpakutils.py:37 > +import toml EWS chokes on this :( > Tools/flatpak/webkit-clangd:20 > +import flatpakutils What will call this script? Will it have the Tools/flatpak directory listed in PYTHONPATH?
Created attachment 451238 [details] Patch
(In reply to Philippe Normand from comment #3) > Comment on attachment 451101 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=451101&action=review > > > Tools/ChangeLog:32 > > +2022-02-07 Martin Robinson <mrobinson@webkit.org> > > + > > + [Flatpak SDK] Add a wrapper for clangd > > + https://bugs.webkit.org/show_bug.cgi?id=236240 > > + > > + Reviewed by NOBODY (OOPS!). > > + > > + * flatpak/webkit-clangd: Added. > > Double changelog! Whoops. Fixed. > > > Tools/flatpak/flatpakutils.py:37 > > +import toml > > EWS chokes on this :( Ah, odd. I've fixed this. It's because these imports are from the webkitpy directory. > > Tools/flatpak/webkit-clangd:20 > > +import flatpakutils > > What will call this script? Will it have the Tools/flatpak directory listed > in PYTHONPATH? The way this generally works is that you set up your editor or IDE to start clangd. Both Visual Studio Code and Vim (via coc-clangd) have settings for this. The connection to clangd runs in the background via your editor and it provides real-time information like completions and compilation errors.
Committed r289470 (247013@main): <https://commits.webkit.org/247013@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 451238 [details].
<rdar://problem/88689997>
Comment on attachment 451238 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=451238&action=review > Tools/flatpak/flatpakutils.py:595 > - os.environ["FLATPAK_USER_DIR"] = FLATPAK_USER_DIR_PATH + ".Local" > + os.environ["FLATPAK_USER_DIR"] = os.path.join(FLATPAK_USER_DIR_PATH, ".Local") This is not correct actually, an invalid path is computed: >>> os.path.join("/foo/bar", ".bas") '/foo/bar/.bas' I'll submit a follow-up patch.