Skip to content

[bazel] Link static and shared libraries correctly #8025

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 4 commits into
base: 2027
Choose a base branch
from

Conversation

AustinSchuh
Copy link
Contributor

This gets us to the point where most of the static and shared libraries are built correctly, and match the gradle versions. I've verified this with a script which compares artifacts. The packaging and release parts still need to be finished, but this is big enough already.

Chunks of this code are from PJ, the rest is from me. I've lost track of which pieces are from whom.

cc_shared_library does most everything we want to generate the correct graph of shared libraries. I ended up needing to create my own version of it for static libraries, since we want similar complexity when splitting things up, and the upstream cc_static_library isn't flexible enough.

version.bzl is currently manually updated, I'd like to update it automatically. Everything which needs a version sources from there. Ideally, --embed_label would populate it with a repository rule. Feels like a good follow-on commit.

This gets us to the point where most of the static and shared libraries
are built correctly, and match the gradle versions.  I've verified this
with a script which compares artifacts.  The packaging and release parts
still need to be finished, but this is big enough already.

Chunks of this code are from PJ, the rest is from me.  I've lost track
of which pieces are from whom.

cc_shared_library does most everything we want to generate the correct
graph of shared libraries.  I ended up needing to create my own version
of it for static libraries, since we want similar complexity when
splitting things up, and the upstream cc_static_library isn't flexible
enough.

version.bzl is currently manually updated, I'd like to update it
automatically.  Everything which needs a version sources from there.
Ideally, --embed_label would populate it with a repository rule.  Feels
like a good follow-on commit.

Signed-off-by: Austin Schuh <austin.linux@gmail.com>
@AustinSchuh AustinSchuh requested review from PeterJohnson and a team as code owners June 16, 2025 05:06
@github-actions github-actions bot added component: ntcore NetworkTables library component: cscore CameraServer library component: wpiutil WPI utility library component: wpilibj WPILib Java component: wpilibc WPILib C++ component: hal Hardware Abstraction Layer component: command-based WPILib Command Based Library component: wpimath Math library component: glass Glass app and backend component: datalogtool DataLog Tool component: wpinet WPI networking library component: apriltag AprilTag library component: examples component: sysid SysId app component: wpiunits Java units library component: epilogue Annotation-based logging library 2027 2027 target labels Jun 16, 2025
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
@AustinSchuh
Copy link
Contributor Author

Not surprisingly, looks like windows + osx are a bit wonky. I need to do some digging to learn why and what the correct answer is.

"@bazel_tools//src/conditions:darwin": [
user_link_flags = select({
"@platforms//os:osx": [
"-Wl,-install_name,libcscorejnicvstatic.so",
Copy link
Member

Choose a reason for hiding this comment

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

macOS libraries are .dylib, not .so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2027 2027 target component: apriltag AprilTag library component: command-based WPILib Command Based Library component: cscore CameraServer library component: datalogtool DataLog Tool component: epilogue Annotation-based logging library component: examples component: glass Glass app and backend component: hal Hardware Abstraction Layer component: ntcore NetworkTables library component: sysid SysId app component: wpilibc WPILib C++ component: wpilibj WPILib Java component: wpimath Math library component: wpinet WPI networking library component: wpiunits Java units library component: wpiutil WPI utility library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants