bazel-contrib / rules_foreign_cc

Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja, Meson)
https://bazel-contrib.github.io/rules_foreign_cc
Apache License 2.0
679 stars 249 forks source link

add support for cc_shared_library deps #1243

Closed matt-sm closed 3 months ago

matt-sm commented 4 months ago

This MR adds a new dynamic_deps attr that allows the libs created by cc_shared_library targets to be added as deps.

Closes https://github.com/bazelbuild/rules_foreign_cc/issues/1242

jsharpe commented 4 months ago

This looks great! Would you be able to also add an example, say using libz.so to the examples folder so that this is tested in CI?

xiedeacc commented 3 months ago

this commit is helpful, can guys fix check failed, then merge it into master?

matt-sm commented 3 months ago

There is still an issue I am trying to fix with the output CcInfo.

This can't be merged yet.

matt-sm commented 3 months ago

I fixed the output issue and added an example.

I did however notice 'CcSharedLibraryInfo' is not defined in the minimum version required test?

matt-sm commented 3 months ago

I assume this is a blocker for adding cc_shared_library support

jsharpe commented 3 months ago

I assume this is a blocker for adding cc_shared_library support

Sigh, yes; as this even requires enforcing an experimental flag in bazel 6 as even if we went via rules_cc I think the act of referencing a cc_shared_library Provider will trigger the flag needing to be set in bazel 6?

matt-sm commented 3 months ago

I have managed to work around this via bazel_features.

I added CcSharedLibraryInfo to globals: https://github.com/bazel-contrib/bazel_features/commit/4f01bd69aaae7e90ba74118fb2a5beab2f1cfc2d

Which we can now reference and prevent earlier bazel versions from failing when compiling .bzl.

The part I don't get is how to add the bazel_features dep to stardoc. See https://buildkite.com/bazel/rules-foreign-cc/builds/5889#019143a7-0041-4a33-b20a-d01ec4779041

jsharpe commented 3 months ago

I have managed to work around this via bazel_features.

I added CcSharedLibraryInfo to globals: bazel-contrib/bazel_features@4f01bd6

Which we can now reference and prevent earlier bazel versions from failing when compiling .bzl.

The part I don't get is how to add the bazel_features dep to stardoc. See buildkite.com/bazel/rules-foreign-cc/builds/5889#019143a7-0041-4a33-b20a-d01ec4779041

I think you need to add bazel_features to the docs WORKSPACE file?

matt-sm commented 3 months ago

add bazel_features to the docs WORKSPACE file

Yes I tried this but it's still failing...

jsharpe commented 3 months ago

add bazel_features to the docs WORKSPACE file

Yes I tried this but it's still failing...

Hmm, I'm not sure then - understanding the docs generation is on my TODO list as its failing to run on main.. @UebelAndre can you remember how the docs gen works as you put it together originally IIRC?

matt-sm commented 3 months ago

Fixed - it was an error in the bzl_library deps

I wasn't using the bzl_library target @bazel_features//:features