From 0aeacdeaae6fc6f7d0d6af71ef6a5af2661e9fd5 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Mon, 16 Dec 2019 13:12:48 +0100 Subject: [PATCH] woff2: add pkgsStatic support --- .../development/web/woff2/brotli-static.patch | 36 +++++++++++++++++++ pkgs/development/web/woff2/default.nix | 16 ++++++--- pkgs/top-level/static.nix | 3 ++ 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 pkgs/development/web/woff2/brotli-static.patch diff --git a/pkgs/development/web/woff2/brotli-static.patch b/pkgs/development/web/woff2/brotli-static.patch new file mode 100644 index 000000000000..4ed6d7e741a8 --- /dev/null +++ b/pkgs/development/web/woff2/brotli-static.patch @@ -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 diff --git a/pkgs/development/web/woff2/default.nix b/pkgs/development/web/woff2/default.nix index b77184e56525..ff0484547fc2 100644 --- a/pkgs/development/web/woff2/default.nix +++ b/pkgs/development/web/woff2/default.nix @@ -1,4 +1,4 @@ -{ brotli, cmake, fetchFromGitHub, stdenv }: +{ brotli, cmake, pkgconfig, fetchFromGitHub, stdenv, static ? false }: stdenv.mkDerivation rec { pname = "woff2"; @@ -13,18 +13,24 @@ stdenv.mkDerivation rec { 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 ]; - # without this binaries only get built if shared libs are disable - patchPhase = '' + postPatch = '' + # without this binaries only get built if shared libs are disable sed 's@^if (NOT BUILD_SHARED_LIBS)$@if (TRUE)@g' -i CMakeLists.txt ''; meta = with stdenv.lib; { description = "Webfont compression reference code"; - homepage = https://github.com/google/woff2; + homepage = "https://github.com/google/woff2"; license = licenses.mit; maintainers = [ maintainers.hrdinka ]; platforms = platforms.unix; diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index 5aa5a103bde2..1d3c4af50430 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -203,6 +203,9 @@ in { # it doesn’t like the --disable-shared flag stdenv = super.stdenv; }; + woff2 = super.woff2.override { + static = true; + }; lz4 = super.lz4.override { enableShared = false; enableStatic = true;