Skip to content

Add Argus library for ride height sensor#98

Open
dhairs wants to merge 2 commits into
mainfrom
argus-ride-height-sensor-lib
Open

Add Argus library for ride height sensor#98
dhairs wants to merge 2 commits into
mainfrom
argus-ride-height-sensor-lib

Conversation

@dhairs
Copy link
Copy Markdown
Contributor

@dhairs dhairs commented Nov 23, 2025

closes #97

The library can be used by adding:

extra_deps = [
        "@afbr_s50_lib//:afbr_s50_lib"
    ],

to a firmware_project_g4 target.

@dhairs dhairs requested a review from a team as a code owner November 23, 2025 19:59
@dhairs dhairs requested review from KaitlynWChang and zohaib642 and removed request for a team November 23, 2025 19:59
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @dhairs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the Broadcom AFBR-S50 API library into the project's build system. This integration allows other firmware projects to easily incorporate ride height sensor functionalities by declaring a simple Bazel dependency. The changes involve configuring Bazel to retrieve the external library and defining a dedicated build target for its components, streamlining its adoption across the codebase.

Highlights

  • New Library Integration: The Broadcom AFBR-S50 API library, designed for ride height sensors, has been integrated into the project.
  • Bazel Configuration: A new git_repository rule has been added to MODULE.bazel to fetch the AFBR-S50 API from its GitHub repository at a specific commit.
  • Build Target Definition: A new Bazel cc_library target named afbr_s50_lib has been created, making the library's compiled archives and header files available for use by other firmware projects.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the Broadcom AFBR-S50 library as a dependency using Bazel's git_repository rule. The overall approach is sound, but there are a few areas for improvement. My review includes feedback on making the dependency declaration more consistent with the existing Bzlmod patterns in your project for better maintainability. I've also identified a critical issue in the new cc_library definition where it incorrectly includes precompiled libraries for all architectures, which would cause linker errors. I have provided a detailed suggestion on how to fix this using select() to correctly choose the library based on the target platform. Additionally, I've made a suggestion regarding Bazel's conventional file naming to improve project structure clarity.

Comment on lines +3 to +18
cc_library(
name = "afbr_s50_lib",

srcs = glob(
["AFBR-S50/Lib/**/*.a"],
allow_empty = True
),

hdrs = glob(
["AFBR-S50/Include/**/*.h"],
allow_empty = True
),

includes = ["AFBR-S50/Include"],
visibility = ["//visibility:public"],
) No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This cc_library definition has a critical issue and a few areas for improvement:

  1. [Critical] Incorrect srcs: The glob for srcs is too broad and will match all pre-compiled static libraries for every architecture (e.g., Cortex-M0, Cortex-M4F). This will cause linker errors due to duplicate symbol definitions. You should use select() to pick the correct library based on the target architecture.

  2. Unnecessary allow_empty: The hdrs glob probably shouldn't have allow_empty = True. If the headers are missing, the library is unusable, and the build should fail.

  3. Missing newline: The file is missing a newline at the end.

Here is a suggested replacement that addresses these points:

cc_library(
    name = "afbr_s50_lib",
    hdrs = glob(["AFBR-S50/Include/**/*.h"]),
    srcs = select({
        # TODO: Verify these platform constraints match your project's configuration.
        "@toolchains_arm_gnu//constraints:cortex_m4_fpu": glob(["AFBR-S50/Lib/GCC/ARM-Cortex-M4F/*.a"]),
        "@toolchains_arm_gnu//constraints:cortex_m0": glob(["AFBR-S50/Lib/GCC/ARM-Cortex-M0/*.a"]),
        "//conditions:default": [],
    }),
    includes = ["AFBR-S50/Include"],
    visibility = ["//visibility:public"],
)

Comment thread MODULE.bazel
Comment on lines +70 to +79
# AFBR-S50 API Library
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "afbr_s50_lib",
remote = "https://github.com/Broadcom/AFBR-S50-API.git",
commit = "68b16693bedae0704b49edcfa2a79e82e5520ae3",
shallow_since = "2024-01-01",
build_file = "//drivers:afbr-s50/afbr-s50.BUILD",
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with how other external dependencies like openocd and dfu are managed, consider moving this git_repository definition into a module extension (.bzl file) and using use_extension and use_repo here. This improves maintainability by centralizing dependency logic and keeping MODULE.bazel cleaner.

Comment thread MODULE.bazel
remote = "https://github.com/Broadcom/AFBR-S50-API.git",
commit = "68b16693bedae0704b49edcfa2a79e82e5520ae3",
shallow_since = "2024-01-01",
build_file = "//drivers:afbr-s50/afbr-s50.BUILD",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The filename afbr-s50.BUILD and its location are unconventional. Standard Bazel practice is to name build files BUILD or BUILD.bazel and place them in the directory that represents the package. I'd suggest renaming drivers/afbr-s50/afbr-s50.BUILD to drivers/afbr-s50/BUILD.bazel and updating this build_file attribute to //drivers/afbr-s50:BUILD.bazel. This will make the project structure more intuitive and align with Bazel conventions.

Copy link
Copy Markdown
Contributor

@alicedimauro alicedimauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this as issue for Arav?

Copy link
Copy Markdown
Contributor

@alicedimauro alicedimauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhairs
Copy link
Copy Markdown
Contributor Author

dhairs commented Nov 26, 2025

No, preferably new members don't have to worry about build system internals. I'll be the one setting up and validating this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build documentation Improvements or additions to documentation drivers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Build support for the Ride Height Sensor

2 participants