Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For issue #528: Add linking database #529

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions source/bear/man/bear.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# NAME

Bear - a tool to generate compilation database for Clang tooling.
Bear - a tool to generate compilation and linking databases for Clang tooling.

# SYNOPSIS

Expand All @@ -21,7 +21,7 @@ compilation with different programs.
Bear executes the original build command and intercept the command
executions issued by the build tool. From the log of command executions
it tries to identify the compiler calls and creates the final
compilation database.
compilation and linking databases.

# OPTIONS

Expand All @@ -44,6 +44,8 @@ compilation database.
compilation database up to date. File deletion and addition are both
considered. But build process change (compiler flags change) might
cause duplicate entries.
When creating a database using linking, both database files are required.
Otherwise, overwrites existing data.

\--config *file*
: Specify a configuration file. The configuration file captures how
Expand Down Expand Up @@ -75,14 +77,16 @@ version of Bear generates entries where:
`file`
: has absolute path.

`files`
: has absolute paths.

`output`
: has absolute path.

`arguments`
: used instead of `command` to avoid shell escaping problems. (Configuration
can force to emit the `command` field.) The compiler as the first argument
has absolute path. Some non compilation related flags are filtered out from
the final output.
has absolute path. Saves all flags.

# CONFIG FILE

Expand Down
2 changes: 1 addition & 1 deletion source/bear/source/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ namespace bear {
.map<fs::path>([](const auto &output) {
return fs::path(output).replace_extension(".events.json");
})
.unwrap_or(fs::path(cmd::citnames::DEFAULT_OUTPUT));
.unwrap_or(fs::path(cmd::intercept::DEFAULT_OUTPUT));

auto environment = sys::env::from(const_cast<const char **>(envp));
auto intercept = prepare_intercept(args, environment, commands);
Expand Down
5 changes: 4 additions & 1 deletion source/citnames/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ target_sources(citnames_a
source/semantic/ToolGcc.cc
source/semantic/ToolWrapper.cc
source/semantic/ToolExtendingWrapper.cc
source/semantic/ToolAr.cc
INTERFACE
$<TARGET_OBJECTS:citnames_a>
)
Expand Down Expand Up @@ -65,8 +66,10 @@ if (ENABLE_UNIT_TESTS)
test/OutputTest.cc
test/ParserTest.cc
test/ToolClangTest.cc
test/ToolGccTest.cc
test/ToolGccCompileTest.cc
test/ToolGccLinkTest.cc
test/ToolWrapperTest.cc
test/ToolArTest.cc
)

target_link_libraries(citnames_unit_test citnames_a)
Expand Down
21 changes: 17 additions & 4 deletions source/citnames/man/bear-citnames.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ execution is just a thing to achieve your goal. This program takes
the command which was executed, and try to find out what the intent
was to run that command. It deduces the semantic of the command.

This is useful to generate a compilation database. Citnames get a
list of commands, and it creates a JSON compilation database. (This
This is useful to generate a compilation and linking databases. Citnames get a
list of commands, and it creates a JSON compilation and linking databases. (This
is currently the only output of the tool.)

# OPTIONS
Expand Down Expand Up @@ -49,6 +49,8 @@ is currently the only output of the tool.)
compilation database up to date. File deletion and addition are both
considered. But build process change (compiler flags change) might
cause duplicate entries.
When creating a database using linking, both database files are required.
Otherwise, overwrites existing data.

\--run-checks
: Allow the program to verify file location checks on the current machine
Expand Down Expand Up @@ -86,8 +88,9 @@ Read more about the syntax of that in the `bear(1)` man page.

# CONFIG FILE

The config file influences the command recognition (by the section "compilation")
and the output format (by the section "output").
The config file influences the command recognition (by the section "compilation"),
the output format (by the section "output") and the setting for creating a linking database
(by the section "linking").

The config file is optional. The program will use default values, which can be
dumped with the `--verbose` flags.
Expand Down Expand Up @@ -118,6 +121,9 @@ the command line argument overrides the config file values.
"command_as_array": true,
"drop_output_field": false
}
},
"linking": {
"filename": "link.json"
}
}
```
Expand Down Expand Up @@ -145,12 +151,19 @@ the command line argument overrides the config file values.
The `--run-checks` flag overrides this config value. The `duplicate_filter_fields`
select the method how duplicate entries are detected in the output. The possible
values for this field are: `all`, `file` and `file_output`.
`without_duplicate_filter` is intended to disable the filtering of duplicate entries when generating a database.
`without_existence_check` is intended to disable existence check for sources/object files when generating a database.
In this version `without_duplicate_filter=true` and `without_existence_check=true`, only when used ``.

`output.format`
: The `command_as_array` controls which command field is emitted in the output.
True produces `arguments`, false produces `command` field. The `drop_output_field`
will disable the `output` field from the output.

`linking`
: Specifies the creation of a linking database. Can contain optional field `filename`,
which contains the name of the file that will be used to create the database.

# SEE ALSO

`bear(1)`, `bear-intercept(1)`
Expand Down