[Python] compare in python content of compile_commands.json

Discussão em 'Python' iniciado por Stack, Abril 23, 2025.

  1. Stack

    Stack Membro Participativo

    i want to "freeze" create a snapshot of a compile_commands.json file e.g.

    [
    {
    "directory": "/home/user/development/project",
    "command": "/usr/bin/c++ ... -c ../foo/foo.cc",
    "file": "../foo/foo.cc"
    },

    ...

    {
    "directory": "/home/user/development/project",
    "command": "/usr/bin/c++ ... -c ../foo/bar.cc",
    "file": "../foo/bar.cc"
    }
    ]


    so what interest me are the flags and settings for the compiler in "command":. lets say i have:

    current compile_commands.json -> create snapshot of commands flags/settings

    new compile_commands.json -> compare against current compile_commands.json


    now the only time the script should report a change is e.g. :

    - flag has been removed
    - new flag has been added
    - content changed e.g. std=c++11 to c++14 or some include beeing modified


    in case only the positions of the same flags/settings have been changed then nothing shall trigger because the content is still the same just already known flags/settings have been positioned differently. is there a way in python to create such snapshots and then compare and detect only actual content change ?

    Continue reading...

Compartilhe esta Página