folly: fix split outputs

Downstream derivations were picking up references to the `dev` output
through indirect `__FILE__` usage in the headers. I borrowed and
modified this trick from the Boost package, where I believe vcunat
originated it. It’s not very pretty and it should be in a hook or
something, but it works at a pinch.
This commit is contained in:
Emily 2024-11-13 12:23:30 +00:00
parent 2fc882c70c
commit fbdced9bb3

View File

@ -7,6 +7,7 @@
cmake,
ninja,
pkg-config,
removeReferencesTo,
boost,
double-conversion,
@ -54,6 +55,7 @@ stdenv.mkDerivation (finalAttrs: {
cmake
ninja
pkg-config
removeReferencesTo
];
# See CMake/folly-deps.cmake in the Folly source tree.
@ -113,6 +115,18 @@ stdenv.mkDerivation (finalAttrs: {
'@CMAKE_INSTALL_FULL_INCLUDEDIR@'
'';
postFixup = ''
# Sanitize header paths to avoid runtime dependencies leaking in
# through `__FILE__`.
(
shopt -s globstar
for header in "$dev/include"/**/*.h; do
sed -i "1i#line 1 \"$header\"" "$header"
remove-references-to -t "$dev" "$header"
done
)
'';
passthru = {
# folly-config.cmake, will `find_package` these, thus there should be
# a way to ensure abi compatibility.