emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Flymake rewrite in emacs-26


From: guillaume papin
Subject: Re: New Flymake rewrite in emacs-26
Date: Wed, 11 Oct 2017 18:39:31 +0000

Regarding the way for a project to export it compile options,
there is somewhat popular, if not standard, method.
Generate a compilation database[1].

A compilation database is a JSON file, named compile_commands.json,
with looks like this for emacs:

    [
        {
            "arguments": [
                "cc",
                "-c",
                "-Demacs",
                "-I.",
                "-I../../emacs/src",
                "-I../lib",
                "-I../../emacs/lib",
                "-pthread",
                "-isystem",
                "/usr/include/gtk-3.0",
                <snip...>
                "-isystem",
                "/usr/include/libpng16",
                "-fopenmp",
                "-DMAGICKCORE_HDRI_ENABLE=1",
                "-DMAGICKCORE_QUANTUM_DEPTH=16",
                "-fopenmp",
                "-DMAGICKCORE_HDRI_ENABLE=1",
                "-DMAGICKCORE_QUANTUM_DEPTH=16",
                <snip...>
                "-Wno-unused-parameter",
                "-Wno-format-nonliteral",
                "-g3",
                "-O2",
                "../../emacs/src/intervals.c"
            ],
            "directory": "/home/papin_g/dev/src/emacs/emacs-25.1-build/src",
            "file": "../../emacs/src/intervals.c"
        },
        <snip...>
    ]

I could generate this with a tool called intercept-build[2],
by doing a clean build of emacs:

    $ intercept-build make
    ...
      CC       dbusbind.o
      CC       emacs.o
      CC       keyboard.o
    ...
    $ cat compile_commands.json
        [
            {
                "arguments": [
                    "cc",
                    "-c",
    ...

The compile options have the `-M' filtered out by the tool.

I think there is something in CEDET that knows how to load this information for 
emacs,
see ede-compdb[2], but this is also quite straightforward to do with the `json' 
libray.

What the Emacs makefile could do, is generate the JSON file with a command like 
`make compdb'.
I have done this in the past for project using GNU Make, it wasn't too 
difficult to implement.

This is also what the cmake-ide tool mentionned just before seems to be using.

[1] https://clang.llvm.org/docs/JSONCompilationDatabase.html
    Sorry for the link to Clang, it's not really Clang-specific.
[2] https://github.com/rizsotto/scan-build
    Once again, related to Clang, sorry about that.
    Bear is basically the same thing, and maybe easier to install from source:
    https://github.com/rizsotto/Bear
[3] https://github.com/randomphrase/ede-compdb
    This is a Github link, but it says that this has been integrated into CEDET.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]