-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[workspace] Build libpng_internal from source (#20276)
Deprecate libpng from the host OS and remove it from setup prereqs.
- Loading branch information
1 parent
5676b11
commit 7e8245c
Showing
15 changed files
with
143 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ libmumps-seq-5.2.1 | |
libnetcdf15 | ||
libogg0 | ||
libopengl0 | ||
libpng16-16 | ||
libpython3.8 | ||
libqt5core5a | ||
libqt5gui5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ libmumps-seq-5.4 | |
libnetcdf19 | ||
libogg0 | ||
libopengl0 | ||
libpng16-16 | ||
libpython3.10 | ||
libqt5core5a | ||
libqt5gui5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
load("//tools/lint:lint.bzl", "add_lint_tests") | ||
|
||
exports_files(["png_drake_vendor.h"]) | ||
|
||
add_lint_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# -*- bazel -*- | ||
|
||
load("@drake//tools/install:install.bzl", "install") | ||
load("@drake//tools/skylark:cc.bzl", "cc_library") | ||
|
||
licenses(["notice"]) # libpng-2.0 | ||
|
||
package(default_visibility = ["//visibility:private"]) | ||
|
||
# Allow Drake's linter cross-checks to use the headers. | ||
exports_files(glob(["*.h"])) | ||
|
||
# This setting governs when we'll compile with Intel SIMD enabled. We don't use | ||
# Intel SIMD on macOS (even for Apple hardware that supports it) to reduce our | ||
# test matrix burden for the deprecated architecture. | ||
config_setting( | ||
name = "build_intel", | ||
constraint_values = [ | ||
"@platforms//cpu:x86_64", | ||
"@platforms//os:linux", | ||
], | ||
) | ||
|
||
_PUBLIC_HDRS = [ | ||
"png.h", | ||
"pngconf.h", | ||
":pnglibconf.h", | ||
] | ||
|
||
_PRIVATE_HDRS = [ | ||
"pngdebug.h", | ||
"pnginfo.h", | ||
"pngstruct.h", | ||
"pngpriv.h", | ||
] | ||
|
||
_SRCS = [ | ||
"png.c", | ||
"pngerror.c", | ||
"pngget.c", | ||
"pngmem.c", | ||
"pngpread.c", | ||
"pngread.c", | ||
"pngrio.c", | ||
"pngrtran.c", | ||
"pngrutil.c", | ||
"pngset.c", | ||
"pngtrans.c", | ||
"pngwio.c", | ||
"pngwrite.c", | ||
"pngwtran.c", | ||
"pngwutil.c", | ||
] | ||
|
||
_SRCS_INTEL = [ | ||
"intel/filter_sse2_intrinsics.c", | ||
"intel/intel_init.c", | ||
] | ||
|
||
genrule( | ||
name = "_pnglibconf.h", | ||
srcs = [ | ||
"scripts/pnglibconf.h.prebuilt", | ||
"@drake//tools/workspace/libpng_internal:png_drake_vendor.h", | ||
], | ||
outs = ["pnglibconf.h"], | ||
cmd = "cat $(SRCS) > $@", | ||
) | ||
|
||
cc_library( | ||
name = "libpng", | ||
hdrs = _PUBLIC_HDRS, | ||
srcs = _SRCS + _PRIVATE_HDRS + select({ | ||
":build_intel": _SRCS_INTEL, | ||
"//conditions:default": [], | ||
}), | ||
includes = ["."], | ||
copts = [ | ||
"-fvisibility=hidden", | ||
"-w", | ||
# Turn off <config.h> guessing. It should be implicitly off by default, | ||
# but it would be a disaster if the default somehow didn't work. | ||
"-DPNG_NO_CONFIG_H=1", | ||
# Don't allow the pngpriv.h auto-sensing of Neon to take effect. | ||
"-DPNG_ARM_NEON_OPT=0", | ||
"-DPNG_ARM_NEON_IMPLEMENTATION=0", | ||
] + select({ | ||
":build_intel": [ | ||
# Use SSE4.1 (or earlier) SIMD instructions. | ||
"-msse4.1", | ||
"-DPNG_INTEL_SSE_OPT=1", | ||
"-DPNG_INTEL_SSE_IMPLEMENTATION=3", | ||
], | ||
"//conditions:default": [ | ||
"-DPNG_INTEL_SSE_OPT=0", | ||
"-DPNG_INTEL_SSE_IMPLEMENTATION=0", | ||
], | ||
}), | ||
linkopts = ["-lm"], | ||
linkstatic = True, | ||
deps = [ | ||
"@zlib", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
install( | ||
name = "install", | ||
docs = ["LICENSE"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
/* The following are Drake's adjustments to libpng. */ | ||
|
||
/* Always use the macros, never the slow out-of-line functions. */ | ||
#undef PNG_READ_INT_FUNCTIONS_SUPPORTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("//tools/workspace:github.bzl", "github_archive") | ||
|
||
def libpng_internal_repository( | ||
name, | ||
mirrors = None): | ||
github_archive( | ||
name = name, | ||
repository = "glennrp/libpng", | ||
commit = "v1.6.40", | ||
sha256 = "62d25af25e636454b005c93cae51ddcd5383c40fa14aa3dae8f6576feb5692c2", # noqa | ||
build_file = ":package.BUILD.bazel", | ||
mirrors = mirrors, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters