Skip to content

Add support for linking and archiving commands #618

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

5c4lar
Copy link

@5c4lar 5c4lar commented Feb 14, 2025

Add Support for Link and Archive Commands

Problem

Currently, Bear lacks comprehensive support for properly handling linker and archive (ar) commands in the compilation database. While previous pr #529 try to implement this functionality, there are no progress in that track for too long.

Proposed Solution

Implement dedicated handlers for both link and archive commands to enhance Bear's compilation database generation capabilities:

  1. Linker Command Support (ToolLinker):

    • Recognize common linker invocations (ld, gold, lld)
    • Parse relevant linker flags and input files
  2. Archive Command Support (ToolAr):

    • Support standard ar command operations
    • Parse archive member specifications
    • Handle common ar flags and operations

Options are added to the config, example config to generate link_commands.json and ar_commands.json:

{
    "output": {
        "format": {
            "command_as_array": true,
            "drop_output_field": false
        },
        "content": {
            "include_only_existing_source": true,
            "duplicate_filter_fields": "file_output"
        },
        "link_commands_output": "link_commands.json",
        "ar_commands_output": "ar_commands.json"
    }
} 

Future Considerations

  • Unit tests

Suggestions for improvement and organization of the code are welcome.

@rizsotto
Copy link
Owner

Hey @5c4lar , sorry for the late response. Thanks for raising the PR!

I am hesitant to merge anything on the C++ side of this project. I am heading towards the rust implementation with a better user experience. Would you be interested to contribute to that? (Probably not right now, but in the near future.)

@5c4lar
Copy link
Author

5c4lar commented Mar 1, 2025

Hey @5c4lar , sorry for the late response. Thanks for raising the PR!

I am hesitant to merge anything on the C++ side of this project. I am heading towards the rust implementation with a better user experience. Would you be interested to contribute to that? (Probably not right now, but in the near future.)

That’s totally fine for me to also work on Rust if that is preferred. I am interested in contributing to the Rust implementation in the near future! (After finishing what I'm working on right now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants