compdb

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package compdb generates LLVM compilation database for Bazel targets.

Index

Constants

This section is empty.

Variables

View Source
var ErrSource = errors.New("failed to get source")

ErrSource is error to extraction the translation unit source.

Functions

func GetSource

func GetSource(a *bazel.Action) (string, error)

GetSource extracts the main translation unit source file from the action. It expects the source to be present in the bazel.Action.Arguments list, right after the compile flag "-c", e.g. "foo.c" source in:

bazel.Action{Arguments: [1, 2, 3, "-c", "foo.c", 4, 5]}

func Print

func Print(w io.Writer, cc []*Command) error

Print dumps commands in JSON format.

Types

type Command

type Command struct {
	File      string   `json:"file"`      // the main translation unit source
	Directory string   `json:"directory"` // the compilation working directory
	Arguments []string `json:"arguments"` // the compile command
}

Command defines the translation unit: the main source, where to build, and the command to compile.

Ref: https://clang.llvm.org/docs/JSONCompilationDatabase.html

func GenCommands

func GenCommands(targets []string) ([]*Command, error)

GenCommands generates compile commands for a list of targets.

func MakeCommands

func MakeCommands(aset *bazel.ActionSet) ([]*Command, error)

MakeCommands generates a list of compile commands from a set of Bazel actions. It returns an error if the actions do not include source file that is set by a pair of arguments ("-c", "file") or can't extract current working directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL