Commit 053e4b08 authored by Maksym Balatsko's avatar Maksym Balatsko Committed by Yt
Browse files

hyperscan: build chimera in static build

parent 76a8ec16
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
{ lib, stdenv, fetchFromGitHub, cmake, ragel, python3
, util-linux, fetchpatch
{ lib
, stdenv
, fetchFromGitHub
, cmake
, ragel
, python3
, util-linux
, pkg-config
, boost
, pcre
, withStatic ? false # build only shared libs by default, build static+shared if true
}:

# NOTICE: pkg-config, pcap and pcre intentionally omitted from build inputs
#         pcap used only in examples, pkg-config used only to check for pcre
#         which is fixed 8.41 version requirement (nixpkgs have 8.42+, and
#         I not see any reason (for now) to backport 8.41.

stdenv.mkDerivation (finalAttrs: {
  pname = "hyperscan";
  version = "5.4.2";
@@ -24,7 +26,7 @@ stdenv.mkDerivation (finalAttrs: {

  buildInputs = [ boost ];
  nativeBuildInputs = [
    cmake ragel python3 util-linux
    cmake ragel python3 util-linux pkg-config
  ];

  cmakeFlags = [
@@ -34,6 +36,14 @@ stdenv.mkDerivation (finalAttrs: {
  ++ lib.optional (withStatic) "-DBUILD_STATIC_AND_SHARED=ON"
  ++ lib.optional (!withStatic) "-DBUILD_SHARED_LIBS=ON";

  # hyperscan CMake is completely broken for chimera builds when pcre is compiled
  # the only option to make it build - building from source
  # In case pcre is built from source, chimera build is turned on by default
  preConfigure = lib.optional withStatic ''
    mkdir -p pcre
    tar xvf ${pcre.src} --strip-components 1 -C pcre
  '';

  postPatch = ''
    sed -i '/examples/d' CMakeLists.txt
    substituteInPlace libhs.pc.in \
@@ -46,6 +56,7 @@ stdenv.mkDerivation (finalAttrs: {
    runHook preCheck

    bin/unit-hyperscan
    ${lib.optionalString withStatic ''bin/unit-chimera''}

    runHook postCheck
  '';