woff2: add pkgsStatic support

This commit is contained in:
Tobias Mayer 2019-12-16 13:12:48 +01:00
parent 812ccd8e4c
commit 0aeacdeaae
3 changed files with 50 additions and 5 deletions

View File

@ -0,0 +1,36 @@
diff a/cmake/FindBrotliDec.cmake b/cmake/FindBrotliDec.cmake
--- a/cmake/FindBrotliDec.cmake
+++ b/cmake/FindBrotliDec.cmake
@@ -18,10 +18,10 @@ find_path(BROTLIDEC_INCLUDE_DIRS
HINTS ${PC_BROTLIDEC_INCLUDEDIR}
)
-find_library(BROTLIDEC_LIBRARIES
- NAMES brotlidec
- HINTS ${PC_BROTLIDEC_LIBDIR}
-)
+if(NOT BUILD_SHARED_LIBS)
+ set(_S "STATIC_")
+endif()
+set(BROTLIDEC_LIBRARIES ${PC_BROTLIDEC_${_S}LIBRARIES})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BrotliDec
diff a/cmake/FindBrotliEnc.cmake b/cmake/FindBrotliEnc.cmake
--- a/cmake/FindBrotliEnc.cmake
+++ b/cmake/FindBrotliEnc.cmake
@@ -18,10 +18,10 @@ find_path(BROTLIENC_INCLUDE_DIRS
HINTS ${PC_BROTLIENC_INCLUDEDIR}
)
-find_library(BROTLIENC_LIBRARIES
- NAMES brotlienc
- HINTS ${PC_BROTLIENC_LIBDIR}
-)
+if(NOT BUILD_SHARED_LIBS)
+ set(_S "STATIC_")
+endif()
+set(BROTLIENC_LIBRARIES ${PC_BROTLIENC_${_S}LIBRARIES})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BrotliEnc

View File

@ -1,4 +1,4 @@
{ brotli, cmake, fetchFromGitHub, stdenv }: { brotli, cmake, pkgconfig, fetchFromGitHub, stdenv, static ? false }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "woff2"; pname = "woff2";
@ -13,18 +13,24 @@ stdenv.mkDerivation rec {
outputs = [ "out" "dev" "lib" ]; outputs = [ "out" "dev" "lib" ];
nativeBuildInputs = [ cmake ]; # Need to explicitly link to brotlicommon
patches = stdenv.lib.optional static ./brotli-static.patch;
nativeBuildInputs = [ cmake pkgconfig ];
cmakeFlags = [ "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}" ]
++ stdenv.lib.optional static "-DCMAKE_SKIP_RPATH:BOOL=TRUE";
propagatedBuildInputs = [ brotli ]; propagatedBuildInputs = [ brotli ];
postPatch = ''
# without this binaries only get built if shared libs are disable # without this binaries only get built if shared libs are disable
patchPhase = ''
sed 's@^if (NOT BUILD_SHARED_LIBS)$@if (TRUE)@g' -i CMakeLists.txt sed 's@^if (NOT BUILD_SHARED_LIBS)$@if (TRUE)@g' -i CMakeLists.txt
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Webfont compression reference code"; description = "Webfont compression reference code";
homepage = https://github.com/google/woff2; homepage = "https://github.com/google/woff2";
license = licenses.mit; license = licenses.mit;
maintainers = [ maintainers.hrdinka ]; maintainers = [ maintainers.hrdinka ];
platforms = platforms.unix; platforms = platforms.unix;

View File

@ -203,6 +203,9 @@ in {
# it doesnt like the --disable-shared flag # it doesnt like the --disable-shared flag
stdenv = super.stdenv; stdenv = super.stdenv;
}; };
woff2 = super.woff2.override {
static = true;
};
lz4 = super.lz4.override { lz4 = super.lz4.override {
enableShared = false; enableShared = false;
enableStatic = true; enableStatic = true;