site/src/reference/command-line.md
bear runs in four modes, selected by the subcommand or its absence:
combined (bear, no subcommand, the default), bear intercept, bear semantic, and bear parse-sh. Options given before -- belong to Bear;
everything after -- is the build command, passed through untouched.
bear intercept runs the build and only captures it, writing the
raw event stream to a file for later analysis.bear semantic reads an event stream and writes the compilation
database, without running a build.bear parse-sh writes the compilation database from shell command
text, such as a build's dry-run output or a saved build log, without
running anything.See How Bear works for the mechanism
behind capture and analysis, Configure Bear for every
key the -c/--config file accepts, and Exit status
for what Bear's own exit code means in each mode.
bear [OPTIONS] -- <BUILD_COMMAND>...
bear [OPTIONS] <COMMAND>
Bear is a tool that generates a compilation database for clang tooling.
| Command | Description |
|---|---|
intercept | intercepts command execution |
semantic | detect semantics of command executions |
parse-sh | produces the compilation database from build-system dry-run text (e.g. make -n output) |
help | Print this message or the help of the given subcommand(s) |
| Argument | Description |
|---|---|
<BUILD_COMMAND>... | Build command |
| Flag | Description | Default |
|---|---|---|
-c, --config <FILE> | Path of the config file | - |
-o, --output <FILE> | Path of the result file | compile_commands.json |
-a, --append | Append result to an existing output file | - |
-h, --help | Print help | - |
-V, --version | Print version | - |
intercepts command execution
bear intercept --output <FILE> -- <BUILD_COMMAND>...
| Argument | Description |
|---|---|
<BUILD_COMMAND>... | Build command |
| Flag | Description | Default |
|---|---|---|
-o, --output <FILE> | Path of the event file to write | - |
-h, --help | Print help | - |
detect semantics of command executions
bear semantic [OPTIONS]
| Flag | Description | Default |
|---|---|---|
-i, --input <FILE> | Path of the event file to read | - |
-o, --output <FILE> | Path of the result file | compile_commands.json |
-a, --append | Append result to an existing output file | - |
--print-compilers | Print the compilers Bear recognizes and exit | - |
-h, --help | Print help | - |
Reads the event stream that bear intercept (or a third-party producer) writes and produces the compilation database, e.g.:
bear semantic --input events.json
produces the compilation database from build-system dry-run text (e.g. make -n output)
bear parse-sh [OPTIONS]
| Flag | Description | Default |
|---|---|---|
-i, --input <FILE> | Path of the shell text to parse | - |
-o, --output <FILE> | Path of the result file | compile_commands.json |
-a, --append | Append result to an existing output file | - |
-C, --directory <DIR> | Initial working directory for the parsed commands | - |
-h, --help | Print help | - |
Parses the text a build system prints in dry-run mode and writes the compilation database, without running a build, e.g.:
make -n | bear parse-sh