Skip to content

Commit 8c02e49

Browse files
committed
make cc_shared_library optional in tests
Only use on Bazel >= 7
1 parent 509bfbd commit 8c02e49

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

Diff for: rules_haskell_tests/tests/repl-targets/hs_lib_repl_test/BUILD.bazel

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ load(
44
"haskell_library",
55
"haskell_toolchain_library",
66
)
7+
load(":maybe_cc_shared_library.bzl", "maybe_cc_shared_library")
78

89
[
910
haskell_toolchain_library(name = name)
@@ -42,12 +43,7 @@ cc_library(
4243
visibility = ["//visibility:public"],
4344
)
4445

45-
cc_shared_library(
46-
name = "ourclibrary_shared",
47-
deps = [
48-
":ourclibrary",
49-
],
50-
)
46+
library_name = maybe_cc_shared_library(name = "ourclibrary")
5147

5248
config_setting(
5349
name = "nix",
@@ -79,7 +75,7 @@ haskell_library(
7975
deps = [
8076
":array",
8177
":base",
82-
":ourclibrary_shared",
8378
":zlib",
79+
library_name,
8480
],
8581
)

Diff for: rules_haskell_tests/tests/repl-targets/hs_lib_repl_test/WORKSPACE

+11
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,14 @@ stack_snapshot(
140140
register_toolchains(
141141
":c2hs-toolchain",
142142
)
143+
144+
http_archive(
145+
name = "bazel_features",
146+
sha256 = "ba1282c1aa1d1fffdcf994ab32131d7c7551a9bc960fbf05f42d55a1b930cbfb",
147+
strip_prefix = "bazel_features-1.15.0",
148+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.15.0/bazel_features-v1.15.0.tar.gz",
149+
)
150+
151+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
152+
153+
bazel_features_deps()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
load("@bazel_features//:features.bzl", "bazel_features")
2+
3+
def maybe_cc_shared_library(name, **kwargs):
4+
if _has_cc_shared_library():
5+
shared_name = "%s_shared" % name
6+
native.cc_shared_library(
7+
name = shared_name,
8+
deps = [name],
9+
**kwargs,
10+
)
11+
return shared_name
12+
return name
13+
14+
15+
16+
def _has_cc_shared_library():
17+
return bazel_features.globals.CcSharedLibraryInfo != None

0 commit comments

Comments
 (0)