2022-04-09 13:45:16 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, boehmgc
|
|
|
|
, bison
|
|
|
|
, flex
|
|
|
|
, protobuf
|
|
|
|
, gmp
|
|
|
|
, boost
|
|
|
|
, python3
|
|
|
|
, doxygen
|
|
|
|
, graphviz
|
|
|
|
, libbpf
|
|
|
|
, libllvm
|
|
|
|
, enableDocumentation ? true
|
|
|
|
, enableBPF ? true
|
|
|
|
, enableDPDK ? true
|
|
|
|
, enableBMV2 ? true
|
|
|
|
, enableGraphBackend ? true
|
|
|
|
, enableP4Tests ? true
|
|
|
|
, enableGTests ? true
|
|
|
|
, enableMultithreading ? false
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
toCMakeBoolean = v: if v then "ON" else "OFF";
|
|
|
|
in
|
2023-07-29 11:02:22 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2022-04-09 13:45:16 +00:00
|
|
|
pname = "p4c";
|
2023-07-29 06:27:17 +00:00
|
|
|
version = "1.2.4.1";
|
2022-04-09 13:45:16 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "p4lang";
|
|
|
|
repo = "p4c";
|
2023-07-29 11:02:22 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
hash = "sha256-Whdryz1Gt0ymE7cj+mI95lW3Io9yBvLqcWa04gu5zEw=";
|
2022-04-09 13:45:16 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
postFetch = ''
|
|
|
|
rm -rf backends/ebpf/runtime/contrib/libbpf
|
|
|
|
rm -rf control-plane/p4runtime
|
|
|
|
'';
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DENABLE_BMV2=${toCMakeBoolean enableBMV2}"
|
|
|
|
"-DENABLE_EBPF=${toCMakeBoolean enableBPF}"
|
|
|
|
"-DENABLE_UBPF=${toCMakeBoolean enableBPF}"
|
|
|
|
"-DENABLE_DPDK=${toCMakeBoolean enableDPDK}"
|
|
|
|
"-DENABLE_P4C_GRAPHS=${toCMakeBoolean enableGraphBackend}"
|
|
|
|
"-DENABLE_P4TEST=${toCMakeBoolean enableP4Tests}"
|
|
|
|
"-DENABLE_DOCS=${toCMakeBoolean enableDocumentation}"
|
|
|
|
"-DENABLE_GC=ON"
|
|
|
|
"-DENABLE_GTESTS=${toCMakeBoolean enableGTests}"
|
2022-09-28 22:40:36 +00:00
|
|
|
"-DENABLE_PROTOBUF_STATIC=OFF" # static protobuf has been removed since 3.21.6
|
2022-04-09 13:45:16 +00:00
|
|
|
"-DENABLE_MULTITHREAD=${toCMakeBoolean enableMultithreading}"
|
|
|
|
"-DENABLE_GMP=ON"
|
|
|
|
];
|
|
|
|
|
|
|
|
checkTarget = "check";
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
bison
|
|
|
|
flex
|
|
|
|
cmake
|
|
|
|
]
|
2022-10-06 16:38:53 +00:00
|
|
|
++ lib.optionals enableDocumentation [ doxygen graphviz ]
|
|
|
|
++ lib.optionals enableBPF [ libllvm libbpf ];
|
2022-04-09 13:45:16 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
protobuf
|
|
|
|
boost
|
|
|
|
boehmgc
|
|
|
|
gmp
|
|
|
|
flex
|
2022-10-08 23:06:06 +00:00
|
|
|
python3
|
2022-04-09 13:45:16 +00:00
|
|
|
];
|
|
|
|
|
2023-07-29 11:02:22 +00:00
|
|
|
meta = {
|
2023-01-17 13:43:03 +00:00
|
|
|
changelog = "https://github.com/p4lang/p4c/releases";
|
2022-04-09 13:45:16 +00:00
|
|
|
description = "Reference compiler for the P4 programming language";
|
2023-07-29 11:02:22 +00:00
|
|
|
homepage = "https://github.com/p4lang/p4c";
|
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ raitobezarius govanify ];
|
|
|
|
platforms = lib.platforms.linux;
|
2022-04-09 13:45:16 +00:00
|
|
|
};
|
2023-07-29 11:02:22 +00:00
|
|
|
})
|