Skip to content

Commit

Permalink
Remove remaining config_settings, now that they're unnecessary and us…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
cpsauer authored Aug 27, 2022
1 parent c3fae06 commit ea2991b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 66 deletions.
20 changes: 18 additions & 2 deletions BUILD.bzip2
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Description:
# bzip2 is a high-quality data compressor.

load("@bazel_skylib//lib:selects.bzl", "selects")

licenses(["notice"]) # BSD derivative

cc_library(
alias(
name = "bz2lib",
visibility = ["//visibility:public"],
actual = selects.with_or({
("@platforms//os:osx", "@platforms//os:ios", "@platforms//os:watchos", "@platforms//os:tvos"): ":bz2lib_system",
"//conditions:default": ":bz2lib_source",
})
)

cc_library(
name = "bz2lib_source",
srcs = [
"blocksort.c",
"bzlib.c",
Expand All @@ -19,5 +30,10 @@ cc_library(
"bzlib.h",
],
includes = ["."],
visibility = ["//visibility:public"],
)

# For OSs that bundle bz2lib
cc_library(
name = "bz2lib_system",
linkopts = ["-lbz2"],
)
34 changes: 5 additions & 29 deletions BUILD.lzma
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,14 @@ copy_file(
alias(
name = "apple_config",
actual = select({
":aarch64": "config.lzma-ios-arm64.h",
":arm": "config.lzma-ios-armv7.h",
":x86_64": "config.lzma-osx-x86_64.h", # Configuration same as macOS
":x86_32": "config.lzma-ios-i386.h",
"@platforms//cpu:aarch64": "config.lzma-ios-arm64.h",
"@platforms//cpu:arm": "config.lzma-ios-armv7.h",
"@platforms//cpu:x86_64": "config.lzma-osx-x86_64.h", # Configuration same as macOS
"@platforms//cpu:x86_32": "config.lzma-ios-i386.h",
}),
)

# Longer term TODO: Blocked until at least after Bazel 5.1 has been released.
# config_setting()s wrappers for constraint_values are necessary for alias rules in Bazel because of a bug in 5.0
# Needs release of fix to https://github.com/bazelbuild/bazel/issues/13047, which will likely happen in 5.1
# At that time, remove these config settings below and update their use in the alias above to the raw @platforms//os constraint_value()s
# Note: There are other instances of this message to update or resolve in sync.

config_setting(
name = "aarch64",
constraint_values = ["@platforms//cpu:aarch64"],
)

config_setting(
name = "arm",
constraint_values = ["@platforms//cpu:arm"],
)

config_setting(
name = "x86_64",
constraint_values = ["@platforms//cpu:x86_64"],
)

config_setting(
name = "x86_32",
constraint_values = ["@platforms//cpu:x86_32"],
)
# 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.

cc_library(
name = "lzma",
Expand Down
36 changes: 1 addition & 35 deletions BUILD.zlib
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,11 @@ alias(
name = "zlib",
visibility = ["//visibility:public"],
actual = selects.with_or({
(":android", ":ios", ":watchos", ":tvos"): ":zlib_system",
("@platforms//os:android", "@platforms//os:osx", "@platforms//os:ios", "@platforms//os:watchos", "@platforms//os:tvos"): ":zlib_system",
"//conditions:default": ":zlib_source",
})
)

# Longer term TODO: Blocked until at least after Bazel 5.1 has been released.
# config_setting()s wrappers for constraint_values are necessary for alias rules in Bazel because of a bug in 5.0
# Needs release of fix to https://github.com/bazelbuild/bazel/issues/13047, which will likely happen in 5.1
# At that time, remove these config settings below and update their use in the alias above to the raw @platforms//os constraint_value()s
# Note: There are other instances of this message to update or resolve in sync.

config_setting(
name = "android",
constraint_values = [
"@platforms//os:android",
],
)

config_setting(
name = "ios",
constraint_values = [
"@platforms//os:ios",
],
)

config_setting(
name = "watchos",
constraint_values = [
"@platforms//os:watchos",
],
)

config_setting(
name = "tvos",
constraint_values = [
"@platforms//os:tvos",
],
)

cc_library(
name = "zlib_source",
srcs = [
Expand Down

0 comments on commit ea2991b

Please sign in to comment.