Skip to content

[clang] Support for compilation database #1115

Open
@prabhu

Description

@prabhu

compile_commands.json has a list of files processed during the compilation. By creating components of type file (and invoking atom with -l h in cdxgen's --deep mode), we can create a decent "build" SBOM for Linux Kernel and other complex C projects.

[
  { "directory": "/home/user/llvm/build",
    "arguments": ["/usr/bin/clang++", "-Irelative", "-DSOMEDEF=With spaces, quotes and \\-es.", "-c", "-o", "file.o", "file.cc"],
    "file": "file.cc" },

  { "directory": "/home/user/llvm/build",
    "command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc",
    "file": "file2.cc" },

  ...
]

https://clang.llvm.org/docs/JSONCompilationDatabase.html
https://github.com/rizsotto/Bear

Working python example that collects all .cmd file to create a single json file
https://github.com/amezin/vscode-linux-kernel

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions