Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[workspace] Build libtiff_internal from source #20331

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion setup/mac/binary_distribution/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ brew 'glib'
brew 'graphviz'
brew 'ipopt'
brew 'jpeg'
brew 'libtiff'
brew 'numpy'
brew 'openblas'
brew 'pkg-config'
Expand Down
1 change: 0 additions & 1 deletion setup/ubuntu/binary_distribution/packages-focal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ libqt5widgets5
libspdlog-dev
libsqlite3-0
libtheora0
libtiff5
libx11-6
libxml2
libxt6
Expand Down
1 change: 0 additions & 1 deletion setup/ubuntu/binary_distribution/packages-jammy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ libqt5widgets5
libspdlog-dev
libsqlite3-0
libtheora0
libtiff5
libx11-6
libxml2
libxt6
Expand Down
1 change: 0 additions & 1 deletion setup/ubuntu/source_distribution/packages-focal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ libjpeg-turbo8-dev
liblapack-dev
libmumps-seq-dev
libopengl-dev
libtiff-dev
libtinyxml-dev
libtool
libx11-dev
Expand Down
1 change: 0 additions & 1 deletion setup/ubuntu/source_distribution/packages-jammy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ libjpeg-turbo8-dev
liblapack-dev
libmumps-seq-dev
libopengl-dev
libtiff-dev
libtinyxml-dev
libtool
libx11-dev
Expand Down
15 changes: 0 additions & 15 deletions tools/wheel/image/dependencies/projects.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,12 @@ set(bzip2_url "https://sourceware.org/pub/bzip2/bzip2-${bzip2_version}.tar.gz")
set(bzip2_md5 "67e051268d0c475ea773822f7500d0e5")
list(APPEND ALL_PROJECTS bzip2)

# xz
set(xz_version 5.2.5)
set(xz_url "https://drake-mirror.csail.mit.edu/other/xz/xz-${xz_version}.tar.gz")
set(xz_md5 "0d270c997aff29708c74d53f599ef717")
list(APPEND ALL_PROJECTS xz)

# libjpeg-turbo
set(libjpeg-turbo_version 2.1.4)
set(libjpeg-turbo_url "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/${libjpeg-turbo_version}.tar.gz")
set(libjpeg-turbo_md5 "357dc26a802c34387512a42697846d16")
list(APPEND ALL_PROJECTS libjpeg-turbo)

# TODO(jwnimmer-tri) When we purge `libtiff`, we can also purge `xz`, above.
# The only user of `xz` is `libtiff`.
#
# libtiff
set(libtiff_version 4.1.0)
set(libtiff_url "http://download.osgeo.org/libtiff/tiff-${libtiff_version}.tar.gz")
set(libtiff_md5 "2165e7aba557463acc0664e71a3ed424")
list(APPEND ALL_PROJECTS libtiff)

# eigen
if(APPLE)
# This version mimics homebrew.
Expand Down
23 changes: 0 additions & 23 deletions tools/wheel/image/dependencies/projects/libtiff.cmake

This file was deleted.

16 changes: 0 additions & 16 deletions tools/wheel/image/dependencies/projects/xz.cmake

This file was deleted.

1 change: 1 addition & 0 deletions tools/workspace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ _DRAKE_EXTERNAL_PACKAGE_INSTALLS = ["@%s//:install" % p for p in [
"ipopt",
"lcm",
"libpng_internal",
"libtiff_internal",
"meshcat",
"msgpack_internal",
"net_sf_jchart2d",
Expand Down
5 changes: 5 additions & 0 deletions tools/workspace/default.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ load("//tools/workspace/libpfm:repository.bzl", "libpfm_repository")
load("//tools/workspace/libpng:repository.bzl", "libpng_repository")
load("//tools/workspace/libpng_internal:repository.bzl", "libpng_internal_repository") # noqa
load("//tools/workspace/libtiff:repository.bzl", "libtiff_repository")
load("//tools/workspace/libtiff_internal:repository.bzl", "libtiff_internal_repository") # noqa
load("//tools/workspace/meshcat:repository.bzl", "meshcat_repository")
load("//tools/workspace/mosek:repository.bzl", "mosek_repository")
load("//tools/workspace/msgpack_internal:repository.bzl", "msgpack_internal_repository") # noqa
Expand Down Expand Up @@ -264,7 +265,11 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS):
if "libpng_internal" not in excludes:
libpng_internal_repository(name = "libpng_internal", mirrors = mirrors)
if "libtiff" not in excludes:
# The @libtiff external is deprecated in Drake's WORKSPACE and will be
# removed on or after 2024-02-01.
libtiff_repository(name = "libtiff")
if "libtiff_internal" not in excludes:
libtiff_internal_repository(name = "libtiff_internal", mirrors = mirrors) # noqa
if "meshcat" not in excludes:
meshcat_repository(name = "meshcat", mirrors = mirrors)
if "mosek" not in excludes:
Expand Down
1 change: 1 addition & 0 deletions tools/workspace/libtiff/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ def libtiff_repository(
licenses = licenses,
modname = modname,
pkg_config_paths = pkg_config_paths,
extra_deprecation = "The @libtiff external is deprecated in Drake's WORKSPACE and will be removed on or after 2024-02-01.", # noqa
**kwargs
)
3 changes: 3 additions & 0 deletions tools/workspace/libtiff_internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load("//tools/lint:lint.bzl", "add_lint_tests")

add_lint_tests()
162 changes: 162 additions & 0 deletions tools/workspace/libtiff_internal/package.BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# -*- bazel -*-

load("@drake//tools/install:install.bzl", "install")
load("@drake//tools/skylark:cc.bzl", "cc_library")
load(
"@drake//tools/workspace:cmake_configure_file.bzl",
"cmake_configure_files",
)

licenses(["notice"]) # libtiff

package(default_visibility = ["//visibility:private"])

_CONFIG_HDRS = [
"libtiff/tif_config.h",
"libtiff/tiffconf.h",
"libtiff/tiffvers.h",
]

cmake_configure_files(
name = "_config_hdrs",
srcs = [x + ".cmake.in" for x in _CONFIG_HDRS],
outs = _CONFIG_HDRS,
defines = [
# From configure.ac.
"LIBTIFF_VERSION=4.6.0",
"LIBTIFF_MAJOR_VERSION=4",
"LIBTIFF_MINOR_VERSION=6",
"LIBTIFF_MICRO_VERSION=0",
# From RELEASE-DATE.
"LIBTIFF_RELEASE_DATE=20230908",
# Opt-in to compression algorithms that we do want. These are the
# built-in algorithms (i.e., no external dependencies) that are
# plausible to use on Drake's depth camera images (which are the
# only place we use TIFF images).
"LOGLUV_SUPPORT=1",
"LZW_SUPPORT=1",
"PACKBITS_SUPPORT=1",
"ZIP_SUPPORT=1",
# This is a no-op in tiff 4.6.0, but in case it's ever not a no-op we
# should probably leave it enabled.
"SUBIFD_SUPPORT=1",
# Match the upstream defaults.
"DEFAULT_EXTRASAMPLE_AS_ALPHA=1",
"STRIPCHOP_DEFAULT=1",
"STRIP_SIZE_DEFAULT=8192",
# Drake doesn't use directory searching.
"TIFF_MAX_DIR_COUNT=1",
# Our standard library is just fine, thanks.
"TIFF_INT8_T=int8_t",
"TIFF_INT16_T=int16_t",
"TIFF_INT32_T=int32_t",
"TIFF_INT64_T=int64_t",
"TIFF_UINT8_T=uint8_t",
"TIFF_UINT16_T=uint16_t",
"TIFF_UINT32_T=uint32_t",
"TIFF_UINT64_T=uint64_t",
"TIFF_SSIZE_T=ptrdiff_t",
# Drake only supports 64-bit, little-endian hardware.
"HOST_BIG_ENDIAN=0",
"SIZEOF_SIZE_T=8",
# Platform stuff.
"HAVE_ASSERT_H=1",
"HAVE_FCNTL_H=1",
"HAVE_FSEEKO=1",
"HAVE_IEEEFP=1",
"HAVE_MMAP=1",
"HAVE_STRINGS_H=1",
"HAVE_SYS_TYPES_H=1",
"HAVE_UNISTD_H=1",
],
undefines = [
# Platform stuff that we don't have or don't want.
"CXX_SUPPORT",
"HAVE_IO_H",
"HAVE_SETMODE",
"USE_WIN32_FILEIO",
# Opt-out of useless compression algorithms.
"CCITT_SUPPORT",
"MDI_SUPPORT",
"NEXT_SUPPORT",
"OJPEG_SUPPORT",
"PIXARLOG_SUPPORT",
"THUNDER_SUPPORT",
# Opt-out of compression algorithms that require external libraries.
"HAVE_JBG_NEWLEN",
"JBIG_SUPPORT",
"LERC_SUPPORT",
"LIBDEFLATE_SUPPORT",
"LIBJPEG_12_PATH",
"LZMA_SUPPORT",
"WEBP_SUPPORT",
"ZSTD_SUPPORT",
# Opt-out of JPEG support. We don't want lossy compression.
"CHECK_JPEG_YCBCR_SUBSAMPLING",
"CHUNKY_STRIP_READ_SUPPORT",
"JPEG_DUAL_MODE_8_12",
"JPEG_SUPPORT",
# Match the upstream defaults.
"DEFER_STRILE_LOAD",
# Dead code (unused).
"PACKAGE_BUGREPORT",
"PACKAGE_NAME",
"PACKAGE_TARNAME",
"PACKAGE_URL",
# We don't use the getopt-based tools.
"HAVE_GETOPT",
"HAVE_DECL_OPTARG",
# Ignore stray @VAR@ in comments.
"VAR",
],
strict = True,
)

_PUBLIC_HDRS = [
"libtiff/tiff.h",
"libtiff/tiffio.h",
":libtiff/tiffvers.h",
":libtiff/tiffconf.h",
]

_PRIVATE_HDRS = [
"libtiff/t4.h",
"libtiff/tif_dir.h",
"libtiff/tif_fax3.h",
"libtiff/tif_hash_set.h",
"libtiff/tif_predict.h",
"libtiff/tiffiop.h",
"libtiff/uvcode.h",
":libtiff/tif_config.h",
]

_SRCS = glob(
[
"libtiff/tif*.c",
],
exclude = [
"**/*win32*",
],
)

cc_library(
name = "libtiff",
hdrs = _PUBLIC_HDRS,
srcs = _SRCS + _PRIVATE_HDRS,
includes = ["libtiff"],
copts = [
"-fvisibility=hidden",
"-w",
],
linkstatic = True,
deps = [
"@zlib",
],
visibility = ["//visibility:public"],
)

install(
name = "install",
docs = ["LICENSE.md"],
visibility = ["//visibility:public"],
)
19 changes: 19 additions & 0 deletions tools/workspace/libtiff_internal/repository.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("//tools/workspace:github.bzl", "github_archive")

def libtiff_internal_repository(
name,
mirrors = None):
github_archive(
name = name,
# N.B. Upstream is https://gitlab.com/libtiff/libtiff but this github
# mirror seems to be kept up to date.
repository = "libsdl-org/libtiff",
upgrade_advice = """
The package.BUILD.bazel file hard-codes the version number and release
date; be sure to update those to match the new commit.
""",
commit = "v4.6.0",
sha256 = "c760de148e0b2ceec115dd5afa660e91617aac4a94da997aa8a8fc2a58f1d378", # noqa
build_file = ":package.BUILD.bazel",
mirrors = mirrors,
)
5 changes: 1 addition & 4 deletions tools/workspace/vtk_internal/settings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,7 @@ MODULE_SETTINGS = {
"VTK_MODULE_USE_EXTERNAL_vtktiff=1",
],
"deps_extra": [
# TODO(jwnimmer-tri) VTK is the only user of this library.
# We should write our own WORKSPACE rule to build it sensibly,
# or switch to VTK's vendored version.
"@libtiff",
"@libtiff_internal//:libtiff",
],
},
"VTK::zlib": {
Expand Down