GithubHelp home page GithubHelp logo

altarmobile / bear Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rizsotto/bear

0.0 2.0 0.0 1.29 MB

Build EAR

Home Page: https://travis-ci.org/rizsotto/Bear

License: GNU General Public License v3.0

C 92.97% C++ 2.54% Python 3.58% Shell 0.91%

bear's Introduction

Build EAR

Bear is a tool to generate compilation database for clang tooling.

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.

One way to get compilation database is to use cmake as build tool. Passing -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to cmake generates compile_commands.json file into the current directory.

When the project compiles with no cmake, but another build system, there is no free json file. Bear is a tool to generate such file during the build process.

The concept behind Bear is to exec the original build command and intercept the exec calls of the build tool. To achive that Bear uses the LD_PRELOAD or DYLD_INSERT_LIBRARIES mechanisms provided by the dynamic linker. So it has two components: the library and the binary. The library defines the exec methods and used in every child processes. The executable sets the environment up to child processes and writes the output file.

How to build

Bear should be quite portable on UNIX OSs, it has been tested on FreeBSD, Linux and OS X only.

Prerequisites

  1. ANSI C compiler to compile the sources.
  2. cmake to configure the build process.
  3. pkg-config to find dependencies during configure step.
  4. make to run the build. Makefiles are generated by cmake.
  5. libconfig to parse the config file. (Version shall be greater than 1.4)

Build commands

It could be the best to build it in a separate build directory.

cmake $BEAR_SOURCE_DIR
make all
make install # to install
make check   # to run tests
make package # to make packages

You can configure the build process with passing arguments to cmake.

You may need to set the PKG_CONFIG_PATH environment variable prior to running cmake in order for cmake to be able to find the libconfig library. For example:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

How to use

After installation the usage is like this:

bear -- make

The -- separate the parameters from the build command. The output file called compile_commands.json found in current directory.

For more options you can check the man page or pass --help parameter.

Known issues

Compiler wrappers like ccache and distcc could cause duplicates or missing items in the compilation database. Make sure you have been disabled before you run Bear. In case of duplicate entries, you might consider to edit the config file to filter out wrapper calls (by path, or by file name) or filter out the compiler calls (and collect the wrapper calls only).

Since the bear executable has runtime dependency (the libconfig library), you might suffer that the OS loader will not find it, if it is not installed into the search path. This case you need to extend the search path by define the related environment variables (LD_LIBRARY_PATH or DYLD_LIBRARY_PATH).

Problem reports

If you find a bug in this documentation or elsewhere in the program or would like to propose an improvement, please use the project's github issue tracker. Please describing the bug and where you found it. If you have a suggestion how to fix it, include that as well. Patches are also welcome.

bear's People

Contributors

rizsotto avatar breser avatar sebastinas avatar bbannier avatar sarcasm avatar mlq avatar smmckay avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.