.\" Automatically generated by Pandoc 2.0.6 .\" .TH "BEAR" "1" "April 20, 2017" "Bear User Manuals" "" .hy .SH NAME .PP Bear \- Build EAR .SH SYNOPSIS .PP bear [\f[I]options\f[]] [\f[I]build command\f[]] .SH DESCRIPTION .PP Bear is a tool to generate compilation database for clang tooling. .PP The JSON compilation database is used in Clang project to provide information how a single compilation unit was processed. When that is available then it is easy to re\-run the compilation with different programs. .PP Bear executes the original build command and intercepts the subsequent execution calls. To achieve that Bear uses library preload mechanism provided by the dynamic linker. There is a library which defines the \f[I]exec\f[] methods and used in every child processes of the build command. The executable itself sets the environment up to child processes and writes the output file. .SH OPTIONS .TP .B \-\-version Print out Bear version number. .RS .RE .TP .B \-v, \-\-verbose Enable verbose output from Bear. A second, third and fourth flags increases verbosity. .RS .RE .TP .B \-o \f[I]file\f[], \-\-cdb \f[I]file\f[] Specify output file. (Default value provided.) The output is not continuously updated, it's done when the build command finished. .RS .RE .TP .B \-\-use\-cc \f[I]program\f[] Hint Bear to classify the given program name as C compiler. .RS .RE .TP .B \-\-use\-c++ \f[I]program\f[] Hint Bear to classify the given program name as C++ compiler. .RS .RE .TP .B \-\-use\-only Force to use only the \f[C]\-\-use\-cc\f[] and \f[C]\-\-use\-c++\f[] given compilers. .RS .RE .TP .B \-a, \-\-append Use previously generated output file and append the new entries to it. This way you can run Bear continuously during work, and it keeps the compilation database up to date. File deletion and addition are both considered. But build process change (compiler flags change) might cause duplicate entries. .RS .RE .TP .B \-l \f[I]path\f[], \-\-libear \f[I]path\f[] Specify the preloaded library location. (Default value provided.) .RS .RE .SH OUTPUT .PP The JSON compilation database definition changed over time. The current version of Bear generates entries where: .TP .B \f[C]directory\f[] has absolute path. .RS .RE .TP .B \f[C]file\f[] has relative path to the \f[C]directory\f[]. .RS .RE .TP .B \f[C]arguments\f[] used instead of \f[C]command\f[] to avoid shell escaping problems. The source file in the compiler call match to the \f[C]file\f[] attribute, therefore it is relative path to \f[C]directory\f[]. Other filesystem related references are not modified (those still can be absolute or relative depending the original command). .RS .RE .PP Some non compilation related flags are filtered out from the final output. .SH EXIT STATUS .PP Bear exit status is the exit status of the build command. Except when bear crashes, then it sets to non zero. .SH ENVIRONMENT .TP .B \f[C]INTERCEPT_BUILD_TARGET_DIR\f[] Temporary directory to collect the execution reports at one place. Directory path is derived from \f[C]TMPDIR\f[], \f[C]TEMP\f[] or \f[C]TMP\f[] environment variable. .RS .RE .TP .B \f[C]LD_PRELOAD\f[] Used by the dynamic loader on Linux, FreeBSD and other UNIX OS. Value set by Bear, overrides previous value for child processes. .RS .RE .TP .B \f[C]DYLD_INSERT_LIBRARIES\f[] Used by the dynamic loader on OS X. Value set by Bear, overrides previous value for child processes. .RS .RE .TP .B \f[C]DYLD_FORCE_FLAT_NAMESPACE\f[] Used by the dynamic loader on OS X. Value set by bear, overrides previous value for child processes. .RS .RE .SH FILES .TP .B \f[C]libear.so\f[] or \f[C]libear.dylib\f[] The preload library which implements the \f[I]exec\f[] methods. .RS .RE .SH SEE ALSO .PP ld.so(8), exec(3) .SH BUGS .PP Because Bear uses \f[C]LD_PRELOAD\f[] or \f[C]DYLD_INSERT_LIBRARIES\f[] environment variables, it does not append to it, but overrides it. So builds which are using these variables might not work. (I don't know any build tool which does that, but please let me know if you do.) .PP Security extension/modes on different operating systems might disable library preloads. This case Bear behaves normally, but the result compilation database will be empty. (Please make sure it's not the case when reporting bugs.) Notable examples for enabled security modes are: SIP on OS X Captain and SELinux on Fedora, CentOS, RHEL. .SH COPYRIGHT .PP Copyright (C) 2012\-2017 by László Nagy .SH AUTHORS László Nagy.