Skip to content

Commit ea2991b

Browse files
authored
Remove remaining config_settings, now that they're unnecessary and use macOS system libs (#260)
* Remove Bazel workaround, crushing longer term TODO Fix to bazelbuild/bazel#13047 landed in 5.1 * Use system zlib on macOS Part of the macOS API as with all on all other Apple platforms * Parallel to zlib, use system bz2 on Apple platforms. Note that unlike libz, bz2 is not bundled with Android * Add note about lzma being private API on Apple platforms
1 parent c3fae06 commit ea2991b

File tree

3 files changed

+24
-66
lines changed

3 files changed

+24
-66
lines changed

BUILD.bzip2

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
# Description:
22
# bzip2 is a high-quality data compressor.
33

4+
load("@bazel_skylib//lib:selects.bzl", "selects")
5+
46
licenses(["notice"]) # BSD derivative
57

6-
cc_library(
8+
alias(
79
name = "bz2lib",
10+
visibility = ["//visibility:public"],
11+
actual = selects.with_or({
12+
("@platforms//os:osx", "@platforms//os:ios", "@platforms//os:watchos", "@platforms//os:tvos"): ":bz2lib_system",
13+
"//conditions:default": ":bz2lib_source",
14+
})
15+
)
16+
17+
cc_library(
18+
name = "bz2lib_source",
819
srcs = [
920
"blocksort.c",
1021
"bzlib.c",
@@ -19,5 +30,10 @@ cc_library(
1930
"bzlib.h",
2031
],
2132
includes = ["."],
22-
visibility = ["//visibility:public"],
33+
)
34+
35+
# For OSs that bundle bz2lib
36+
cc_library(
37+
name = "bz2lib_system",
38+
linkopts = ["-lbz2"],
2339
)

BUILD.lzma

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,38 +40,14 @@ copy_file(
4040
alias(
4141
name = "apple_config",
4242
actual = select({
43-
":aarch64": "config.lzma-ios-arm64.h",
44-
":arm": "config.lzma-ios-armv7.h",
45-
":x86_64": "config.lzma-osx-x86_64.h", # Configuration same as macOS
46-
":x86_32": "config.lzma-ios-i386.h",
43+
"@platforms//cpu:aarch64": "config.lzma-ios-arm64.h",
44+
"@platforms//cpu:arm": "config.lzma-ios-armv7.h",
45+
"@platforms//cpu:x86_64": "config.lzma-osx-x86_64.h", # Configuration same as macOS
46+
"@platforms//cpu:x86_32": "config.lzma-ios-i386.h",
4747
}),
4848
)
4949

50-
# Longer term TODO: Blocked until at least after Bazel 5.1 has been released.
51-
# config_setting()s wrappers for constraint_values are necessary for alias rules in Bazel because of a bug in 5.0
52-
# Needs release of fix to https://github.com/bazelbuild/bazel/issues/13047, which will likely happen in 5.1
53-
# At that time, remove these config settings below and update their use in the alias above to the raw @platforms//os constraint_value()s
54-
# Note: There are other instances of this message to update or resolve in sync.
55-
56-
config_setting(
57-
name = "aarch64",
58-
constraint_values = ["@platforms//cpu:aarch64"],
59-
)
60-
61-
config_setting(
62-
name = "arm",
63-
constraint_values = ["@platforms//cpu:arm"],
64-
)
65-
66-
config_setting(
67-
name = "x86_64",
68-
constraint_values = ["@platforms//cpu:x86_64"],
69-
)
70-
71-
config_setting(
72-
name = "x86_32",
73-
constraint_values = ["@platforms//cpu:x86_32"],
74-
)
50+
# Note: lzma is bundled with Apple platforms, but sadly, not considered public API because its header is not exposed. lzma is not bundled on Android.
7551

7652
cc_library(
7753
name = "lzma",

BUILD.zlib

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,11 @@ alias(
66
name = "zlib",
77
visibility = ["//visibility:public"],
88
actual = selects.with_or({
9-
(":android", ":ios", ":watchos", ":tvos"): ":zlib_system",
9+
("@platforms//os:android", "@platforms//os:osx", "@platforms//os:ios", "@platforms//os:watchos", "@platforms//os:tvos"): ":zlib_system",
1010
"//conditions:default": ":zlib_source",
1111
})
1212
)
1313

14-
# Longer term TODO: Blocked until at least after Bazel 5.1 has been released.
15-
# config_setting()s wrappers for constraint_values are necessary for alias rules in Bazel because of a bug in 5.0
16-
# Needs release of fix to https://github.com/bazelbuild/bazel/issues/13047, which will likely happen in 5.1
17-
# At that time, remove these config settings below and update their use in the alias above to the raw @platforms//os constraint_value()s
18-
# Note: There are other instances of this message to update or resolve in sync.
19-
20-
config_setting(
21-
name = "android",
22-
constraint_values = [
23-
"@platforms//os:android",
24-
],
25-
)
26-
27-
config_setting(
28-
name = "ios",
29-
constraint_values = [
30-
"@platforms//os:ios",
31-
],
32-
)
33-
34-
config_setting(
35-
name = "watchos",
36-
constraint_values = [
37-
"@platforms//os:watchos",
38-
],
39-
)
40-
41-
config_setting(
42-
name = "tvos",
43-
constraint_values = [
44-
"@platforms//os:tvos",
45-
],
46-
)
47-
4814
cc_library(
4915
name = "zlib_source",
5016
srcs = [

0 commit comments

Comments
 (0)