Skip to content

system_library failing on MacOS #416

@alexeagle

Description

@alexeagle

With latest bazel_dep(name = "rules_cc", version = "0.1.1") I add to MODULE.bazel:

system_library = use_repo_rule("@rules_cc//cc:system_library.bzl", "system_library")
system_library(
    name = "libmagic",
    hdrs = ["magic.h"],
    static_lib_names = ["libmagic.a"],
    shared_lib_names = ["libmagic.dylib", "libmagic.so"],
    # Look into homebrew specific /lib and /include directories.
    lib_path_hints = ["/opt/homebrew/lib"], 
    includes = ["/opt/homebrew/include"]
)

But it fails to build:

alexeagle@aspect-build bazel105 % find $(brew --prefix) -name magic.h
/opt/homebrew/include/magic.h
/opt/homebrew/Cellar/libmagic/5.46/include/magic.h
/opt/homebrew/Cellar/imagemagick/7.1.1-47/include/ImageMagick-7/MagickCore/magic.h
alexeagle@aspect-build bazel105 % find $(brew --prefix) -name libmagic.dylib
/opt/homebrew/lib/libmagic.dylib
/opt/homebrew/Cellar/libmagic/5.46/lib/libmagic.dylib
alexeagle@aspect-build bazel105 % bazel build @libmagic                     
INFO: Repository +_repo_rules+libmagic instantiated at:
  <builtin>: in <toplevel>
Repository rule system_library defined at:
  /private/var/tmp/_bazel_alexeagle/4477e74205cb05f1e66aea9fd72f89b1/external/rules_cc+/cc/system_library.bzl:325:33: in <toplevel>
ERROR: /private/var/tmp/_bazel_alexeagle/4477e74205cb05f1e66aea9fd72f89b1/external/rules_cc+/cc/system_library.bzl:154:13: An error occurred during the fetch of repository '+_repo_rules+libmagic':
   Traceback (most recent call last):
        File "/private/var/tmp/_bazel_alexeagle/4477e74205cb05f1e66aea9fd72f89b1/external/rules_cc+/cc/system_library.bzl", line 154, column 13, in _system_library_impl
                fail("Library {} could not be found".format(repo_name))
Error in fail: Library +_repo_rules+libmagic could not be found

FYI @thesayyn

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions