github.com/0xKiwi/rules_go@v0.24.3/tests/legacy/examples/cgo/cc_dependency/BUILD.bazel (about) 1 load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library") 2 3 config_setting( 4 name = "darwin", 5 values = {"cpu": "darwin"}, 6 ) 7 8 cc_library( 9 name = "version", 10 srcs = ["cxx_version.cc"], 11 hdrs = ["version.h"], 12 linkopts = ["-ldl"], 13 visibility = ["//tests/legacy/examples/cgo:__pkg__"], 14 # TODO(yugui) Support darwin too and remove this workaround. 15 # See also comments in cxx_version.cc. 16 deps = select({ 17 ":darwin": [], 18 "//conditions:default": [":c_version_import"], 19 }), 20 ) 21 22 cc_library( 23 name = "c_version_orig", 24 srcs = ["c_version.c"], 25 hdrs = ["c_version.h"], 26 ) 27 28 # Goes through filegroup() to emulate prebuilt .so in srcs of cc_library. 29 filegroup( 30 name = "c_version_so", 31 srcs = [":c_version_orig"], 32 output_group = "dynamic_library", 33 ) 34 35 cc_import( 36 name = "c_version_import", 37 hdrs = ["c_version.h"], 38 shared_library = ":c_version_so", 39 tags = ["manual"], 40 )