[![Packaging status](https://repology.org/badge/tiny-repos/bear.svg)](https://repology.org/project/bear/versions)
[![GitHub release](https://img.shields.io/github/release/rizsotto/Bear)](https://github.com/rizsotto/Bear/releases)
[![GitHub Release Date](https://img.shields.io/github/release-date/rizsotto/Bear)](https://github.com/rizsotto/Bear/releases)
[![Continuous Integration](https://github.com/rizsotto/Bear/workflows/continuous%20integration/badge.svg)](https://github.com/rizsotto/Bear/actions)
[![Contributors](https://img.shields.io/github/contributors/rizsotto/Bear)](https://github.com/rizsotto/Bear/graphs/contributors)
[![Gitter](https://img.shields.io/gitter/room/rizsotto/Bear)](https://gitter.im/rizsotto/Bear)
ʕ·ᴥ·ʔ Build EAR
===============
Bear is a tool that generates a compilation database for clang tooling.
The [JSON compilation database][JSONCDB] is used in the clang project
to provide information on how a single compilation unit is processed.
With this, it is easy to re-run the compilation with alternate programs.
One way to get a compilation database is to use `cmake` as the build
tool. Passing `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` to cmake generates
the `compile_commands.json` file into the current directory.
For non-cmake projects, Bear generates the JSON file during the build process.
[JSONCDB]: http://clang.llvm.org/docs/JSONCompilationDatabase.html
How it works
------------
The concept behind Bear is: to execute 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.
For intercepting the compiler executions, Bear uses the `LD_PRELOAD`
or `DYLD_INSERT_LIBRARIES` mechanisms provided by the dynamic linker.
When the dynamic linker is not working (because the executable is not a
dynamically linked executable or security protection disables the linker)
then Bear uses compiler wrappers to record the compiler calls. The wrapper
sends execution report and calls the real compiler. (Not only compilers,
but linkers, assemblers and other tools are also wrapped.)
The intercepted commands are filtered and only the compiler executions
goes into the compilation database. Those commands which ends up in the
final output are transformed a little bit (some compiler flags are
removed).
How to install
--------------
Bear is [packaged](https://repology.org/project/bear/versions) for many distributions. Check out your package manager.
Or [build it](INSTALL.md) from source.
How to use
----------
After installation the usage is like this:
bear -- <your-build-command>
The output file called `compile_commands.json` is saved in the current directory.
For more options you can check the man page or pass `--help` parameter. Note
that if you want to pass parameter to Bear, pass those _before_ the `--` sign,
everything after that will be the build command.
Side note: Since Bear is executing the build command, only those commands will
be recorded which were actually executed during the current build. Which means
if you have already built your project and you re-run the build command with
Bear you probably end up to have an empty output. (Practically it means you
need to run `make clean` before you run `bear make`.)
For more read the [wiki][WIKI] of the project, which talks about limitations,
known issues and platform specific usage.
Problem reports
---------------
Before you open a new problem report, please look at the [wiki][WIKI] if your
problem is a known one with documented workaround. It's also helpful to look
at older (maybe closed) [issues][ISSUES] before you open a new one.
If you decided to report a problem, try to give as much context as it would
help me to reproduce the error you see. If you just have a question about the
usage, please don't be shy, ask your question in an issue or in [chat][CHAT].
If you found a bug, but also found a fix for it, please share it with me and
open a pull request.
Please follow the [contribution guide][GUIDE] when you do these.
[ISSUES]: https://github.com/rizsotto/Bear/issues
[WIKI]: https://github.com/rizsotto/Bear/wiki
[CHAT]: https://gitter.im/rizsotto/Bear
[GUIDE]: https://github.com/rizsotto/Bear/blob/master/CONTRIBUTING.md
---
Thanks to [JetBrains](https://www.jetbrains.com/?from=Bear)
for donating product licenses to help develop Bear
没有合适的资源?快使用搜索试试~ 我知道了~
Bear:Bear是一个为clang工具生成编译数据库的工具
共257个文件
cc:68个
sh:57个
h:52个
需积分: 47 5 下载量 51 浏览量
2021-04-29
08:12:38
上传
评论 1
收藏 279KB ZIP 举报
温馨提示
ʔ·ᴥ·ʔ建立EAR Bear是一种工具,可生成用于clang工具的编译数据库。 在clang项目中使用来提供有关如何处理单个编译单元的信息。 这样,很容易用替代程序重新运行编译。 获取编译数据库的一种方法是使用cmake作为构建工具。 将-DCMAKE_EXPORT_COMPILE_COMMANDS=ON传递给cmake会将compile_commands.json文件生成到当前目录中。 对于非cmake项目,Bear在构建过程中生成JSON文件。 这个怎么运作 Bear背后的概念是:执行原始的构建命令并拦截由构建工具发出的命令执行。 从命令执行日志中,它尝试识别编译器调用并创建最终的编译数据库。 为了拦截编译器的执行,Bear使用动态链接器提供的LD_PRELOAD或DYLD_INSERT_LIBRARIES机制。 当动态链接器不起作用时(因为可执行文件不是动态链接的可执行文
资源推荐
资源详情
资源评论
收起资源包目录
Bear:Bear是一个为clang工具生成编译数据库的工具 (257个子文件)
citnames.1 5KB
intercept.1 4KB
bear.1 3KB
assert_compilation 3KB
assert_intercepted 3KB
success.c 1KB
success.c 1KB
success_to_resolve.c 1KB
success.c 983B
failure_prints_errno.c 940B
failure_prints_errno.c 932B
failure_prints_errno.c 930B
failure_prints_errno.c 893B
failure_prints_errno.c 892B
failure_prints_errno.c 859B
failure_prints_errno.c 857B
failure_prints_errno.c 855B
failure_prints_errno.c 822B
failure_prints_errno.c 820B
success.c 724B
io_calls.c 706B
same_name_without_exec_flag.c 687B
success.c 684B
success_to_resolve.c 682B
success.c 682B
success.c 680B
success.c 646B
same_name_in_path.c 637B
success.c 631B
success.c 629B
success_to_resolve.c 625B
success.c 595B
success.c 593B
success_to_resolve.c 589B
success.c 470B
no_exec.c 325B
ToolGcc.cc 19KB
FlagsTest.cc 15KB
Flags.cc 14KB
ExecutorTest.cc 13KB
ResultTest.cc 12KB
main.cc 10KB
Process.cc 10KB
Output.cc 10KB
SessionWrapper.cc 10KB
lib.cc 10KB
Application.cc 9KB
Application.cc 9KB
Configuration.cc 8KB
Executor.cc 7KB
ToolTest.cc 7KB
Application.cc 6KB
main.cc 6KB
OutputTest.cc 6KB
ToolWrapperTest.cc 5KB
ToolGccTest.cc 5KB
Resolver.cc 4KB
Parsers.cc 4KB
ToolWrapper.cc 4KB
SessionLibrary.cc 4KB
Semantic.cc 4KB
EventsDatabaseReader.cc 4KB
CommandTest.cc 4KB
Session.cc 3KB
ArrayTest.cc 3KB
SessionTest.cc 3KB
Paths.cc 3KB
Command.cc 3KB
EnvironmentTest.cc 3KB
Build.cc 3KB
RpcClients.cc 3KB
Guard.cc 3KB
Path.cc 3KB
ApplicationLogConfig.cc 3KB
EventsDatabaseWriter.cc 3KB
EventFactory.cc 2KB
SessionTest.cc 2KB
Linker.cc 2KB
PathsTest.cc 2KB
Logger.cc 2KB
Os.cc 2KB
PathTest.cc 2KB
BufferTest.cc 2KB
RpcServices.cc 2KB
Domain.cc 2KB
ToolAny.cc 2KB
ApplicationFromArgs.cc 2KB
Signal.cc 2KB
Reporter.cc 2KB
EventFactoryTest.cc 2KB
Session.cc 2KB
ToolExtendingWrapper.cc 2KB
Convert.cc 2KB
Environment.cc 2KB
EventReporter.cc 1KB
Errors.cc 1KB
Buffer.cc 1KB
std.cc 1KB
ToolClang.cc 1KB
ToolCuda.cc 1KB
共 257 条
- 1
- 2
- 3
资源评论
80seconds
- 粉丝: 44
- 资源: 4568
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功