2024-01-02 11:29:13 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch
|
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
|
|
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-18 21:22:44 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "http-parser";
|
2021-07-18 21:22:44 +00:00
|
|
|
version = "2.9.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nodejs";
|
|
|
|
repo = "http-parser";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "1vda4dp75pjf5fcph73sy0ifm3xrssrmf927qd1x8g3q46z0cv6c";
|
|
|
|
};
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-Wno-error";
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
patches = [
|
2024-01-02 11:29:13 +00:00
|
|
|
./enable-static-shared.patch
|
2022-05-18 14:49:53 +00:00
|
|
|
] ++ lib.optionals stdenv.isAarch32 [
|
2022-04-15 01:41:22 +00:00
|
|
|
# https://github.com/nodejs/http-parser/pull/510
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/nodejs/http-parser/commit/4f15b7d510dc7c6361a26a7c6d2f7c3a17f8d878.patch";
|
|
|
|
sha256 = "sha256-rZZMJeow3V1fTnjadRaRa+xTq3pdhZn/eJ4xjxEDoU4=";
|
|
|
|
})
|
|
|
|
];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"DESTDIR="
|
|
|
|
"PREFIX=$(out)"
|
|
|
|
"BINEXT=${stdenv.hostPlatform.extensions.executable}"
|
|
|
|
"Platform=${lib.toLower stdenv.hostPlatform.uname.system}"
|
|
|
|
"AEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.staticLibrary}"
|
|
|
|
"ENABLE_SHARED=${if enableShared then "1" else "0"}"
|
|
|
|
"ENABLE_STATIC=${if enableStatic then "1" else "0"}"
|
|
|
|
] ++ lib.optionals enableShared [
|
|
|
|
"SOEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.sharedLibrary}"
|
|
|
|
] ++ lib.optionals enableStatic [
|
|
|
|
"AEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.staticLibrary}"
|
|
|
|
] ++ lib.optionals (enableShared && stdenv.hostPlatform.isWindows) [
|
|
|
|
"SONAME=$(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOEXT)"
|
|
|
|
"LIBNAME=$(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOREV).$(SOEXT)"
|
|
|
|
"LDFLAGS=-Wl,--out-implib=$(LIBNAME).a"
|
|
|
|
];
|
|
|
|
|
|
|
|
buildFlags = lib.optional enableShared "library"
|
|
|
|
++ lib.optional enableStatic "package";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkTarget = "test";
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
postInstall = lib.optionalString stdenv.hostPlatform.isWindows ''
|
|
|
|
install -D *.dll.a $out/lib
|
|
|
|
ln -sf libhttp_parser.${version}.dll.a $out/lib/libhttp_parser.dll.a
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "An HTTP message parser written in C";
|
|
|
|
homepage = "https://github.com/nodejs/http-parser";
|
|
|
|
maintainers = with maintainers; [ matthewbauer ];
|
|
|
|
license = licenses.mit;
|
2024-01-02 11:29:13 +00:00
|
|
|
platforms = platforms.all;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|