Coder Social home page Coder Social logo

Generate compile_commands.json about b2 HOT 8 CLOSED

grafikrobot avatar grafikrobot commented on July 17, 2024 1
Generate compile_commands.json

from b2.

Comments (8)

grisumbras avatar grisumbras commented on July 17, 2024 1

LGTM
Also, AFAIK, link commands aren't needed.

from b2.

vinniefalco avatar vinniefalco commented on July 17, 2024

What is this "load an existing compile_commands.json?" Why?

from b2.

grafikrobot avatar grafikrobot commented on July 17, 2024

What is this "load an existing compile_commands.json?" Why?

Because B2 can do very fine grained incremental builds. And if you want to get a full picture of the project you can't throw away the history of what you previously compiled on each b2 invocation. Especially if it's an invocation that's a no-op, which would create an empty json file.

from b2.

vinniefalco avatar vinniefalco commented on July 17, 2024

That is a nice to have feature but maybe not strictly required for an initial proof of concept.

from b2.

grisumbras avatar grisumbras commented on July 17, 2024

I think, the described approach is actually not needed. Running with different build requests, and appending commands to compile_commands.json is both unnecessary complexity and potentially problematic, when e.g. some targets are removed from the build scripts.

Rather, I think something like b2 variant=debug,release --compile-db should create a new file for all jam targets it considers for update (not necessarily updates). Maybe we also don't want it to actually try updating them, although there is already -n flag for that.

There's also a question what to do with ancillary targets e.g. created by ac module. Maybe potentially add an engile rule that marks a target as hidden?

Now, that I think of it, what if we can mark Jam targets as watched (maybe by setting a variable on them), and then their actions get recorded into some list in the form of command output sources?

from b2.

grafikrobot avatar grafikrobot commented on July 17, 2024

After my many questions in slack, adjusted plan:

  1. Add a feature to register action pre-execution hooks in the engine side. Such hooks would be given the action script string and can process the string. Possibly returning a different string to execute.
  2. Add a action pre-exec hook to watch for per-toolset compile (and link?) commands that extracts the single command line invocation (by matching a regex in the action script). Control would be by adding a target variable COMMAND_DATABASE that sets a regex that extracts the command.
  3. Change, initially, the gcc/clang toolset to set the variable for each appropriate action.
  4. Add a command line arg --command-database=json that simulates the build request (i.e. equivalent to -n -a). That collects all the registered action commands and writes out the resulting json to <build-dir>/compile_commands.json.
  5. Add a command line arg --command-database-out=<filename> to specify an override to the file name and location.

from b2.

grafikrobot avatar grafikrobot commented on July 17, 2024

Step 0? Structured data output to JSON complete: c30bce8

from b2.

grafikrobot avatar grafikrobot commented on July 17, 2024

WIP here.. https://github.com/bfgroup/b2/tree/feature/compiledb

from b2.

Related Issues (20)

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.