From 53e05a971d8ea30d931bc1f21fa1b030716d4e32 Mon Sep 17 00:00:00 2001 From: Petr Hodina Date: Tue, 18 Mar 2025 21:42:22 +0100 Subject: [PATCH] libnop: init at 0-unstable-2022-09-04 --- .../li/libnop/001-system-install.patch | 89 +++++++++++++++++++ .../li/libnop/002-fix-template-warning.patch | 54 +++++++++++ pkgs/by-name/li/libnop/package.nix | 47 ++++++++++ 3 files changed, 190 insertions(+) create mode 100644 pkgs/by-name/li/libnop/001-system-install.patch create mode 100644 pkgs/by-name/li/libnop/002-fix-template-warning.patch create mode 100644 pkgs/by-name/li/libnop/package.nix diff --git a/pkgs/by-name/li/libnop/001-system-install.patch b/pkgs/by-name/li/libnop/001-system-install.patch new file mode 100644 index 000000000000..c97e47e207e4 --- /dev/null +++ b/pkgs/by-name/li/libnop/001-system-install.patch @@ -0,0 +1,89 @@ +From ae29a8772f38fdb1efc24af9ec2e3f6814eb2158 Mon Sep 17 00:00:00 2001 +From: Petr Hodina +Date: Sun, 4 May 2025 09:30:55 +0200 +Subject: [PATCH] Makefile: Add install into the system + +--- + Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ + libnop.pc.in | 7 +++++++ + 2 files changed, 51 insertions(+) + create mode 100644 libnop.pc.in + +diff --git a/Makefile b/Makefile +index 84cb459..e5b8a67 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,5 +1,7 @@ + what_to_build:: all + ++VERSION ?= 0-unstable-2022-09-04 ++ + -include local.mk + + TOOLCHAIN ?= +@@ -17,6 +19,12 @@ HOST_CFLAGS := -g -O2 -Wall -Werror -Wextra -Iinclude + HOST_CXXFLAGS := -std=c++14 + HOST_LDFLAGS := + ++# Define install locations in the system ++INSTALL_PREFIX ?= /usr/local ++INCLUDE_INSTALL_DIR ?= $(INSTALL_PREFIX)/include/ ++PKGCONFIG_INSTALL_DIR ?= $(INSTALL_PREFIX)/lib/pkgconfig ++CMAKE_CONFIG_INSTALL_DIR ?= $(INSTALL_PREFIX)/lib/cmake/libnop ++ + ifeq ($(HOST_OS),Linux) + HOST_LDFLAGS := -lpthread + endif +@@ -138,3 +146,39 @@ all:: $(ALL) + # we generate .d as a side-effect of compiling. override generic rule: + %.d: + -include $(DEPS) ++ ++# Handle install into the system ++.PHONY: install install-pkgconfig install-cmake ++ ++install: install-headers install-pkgconfig install-cmake ++ ++install-headers: ++ @echo "Installing headers to $(INCLUDE_INSTALL_DIR)" ++ mkdir -p $(INCLUDE_INSTALL_DIR) ++ cp -r include/* $(INCLUDE_INSTALL_DIR) ++ ++install-pkgconfig: $(OUT)/libnop.pc ++ @echo "Installing pkg-config file to $(PKGCONFIG_INSTALL_DIR)" ++ mkdir -p $(PKGCONFIG_INSTALL_DIR) ++ cp $< $(PKGCONFIG_INSTALL_DIR) ++ ++PC_TEMPLATE := libnop.pc.in ++ ++$(OUT)/libnop.pc: $(PC_TEMPLATE) ++ mkdir -p $(dir $@) ++ sed \ ++ -e 's|@prefix@|$(INSTALL_PREFIX)|g' \ ++ -e 's|@includedir@|$(INSTALL_PREFIX)/include|g' \ ++ -e 's|@version@|$(VERSION)|g' \ ++ $< > $@ ++ ++install-cmake: $(OUT)/libnopConfig.cmake ++ @echo "Installing CMake config to $(CMAKE_CONFIG_INSTALL_DIR)" ++ mkdir -p $(CMAKE_CONFIG_INSTALL_DIR) ++ cp $< $(CMAKE_CONFIG_INSTALL_DIR) ++ ++$(OUT)/libnopConfig.cmake: ++ mkdir -p $(dir $@) ++ echo "set(LIBNOP_INCLUDE_DIR \"$(INCLUDE_INSTALL_DIR)\")" > $@ ++ echo "set(LIBNOP_FOUND TRUE)" >> $@ ++ echo "mark_as_advanced(LIBNOP_INCLUDE_DIR)" >> $@ +diff --git a/libnop.pc.in b/libnop.pc.in +new file mode 100644 +index 0000000..8c5475b +--- /dev/null ++++ b/libnop.pc.in +@@ -0,0 +1,7 @@ ++prefix=@prefix@ ++includedir=@includedir@ ++ ++Name: libnop ++Description: Header-only C++ Native Object Protocols library ++Version: @version@ ++Cflags: -I${includedir} diff --git a/pkgs/by-name/li/libnop/002-fix-template-warning.patch b/pkgs/by-name/li/libnop/002-fix-template-warning.patch new file mode 100644 index 000000000000..9c9001586d1f --- /dev/null +++ b/pkgs/by-name/li/libnop/002-fix-template-warning.patch @@ -0,0 +1,54 @@ +From 199978a0fb0dc31de43b80f7504b53958fd202ee Mon Sep 17 00:00:00 2001 +From: Petr Hodina +Date: Sun, 4 May 2025 09:58:20 +0200 +Subject: [PATCH] C++: Fix compilation issue + -Wno-missing-template-arg-list-after-template-kw + +--- + include/nop/rpc/interface.h | 2 +- + include/nop/types/variant.h | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/include/nop/rpc/interface.h b/include/nop/rpc/interface.h +index 167d203..9772d06 100644 +--- a/include/nop/rpc/interface.h ++++ b/include/nop/rpc/interface.h +@@ -245,7 +245,7 @@ struct InterfaceMethod { + template + static void Invoke(Sender* sender, Status* return_value, + Args... args) { +- sender->NOP_TEMPLATE SendMethod(InterfaceMethod::Selector, return_value, ++ sender->NOP_TEMPLATE SendMethod<>(InterfaceMethod::Selector, return_value, + std::forward_as_tuple(args...)); + } + +diff --git a/include/nop/types/variant.h b/include/nop/types/variant.h +index fdf8e03..af8c81e 100644 +--- a/include/nop/types/variant.h ++++ b/include/nop/types/variant.h +@@ -239,7 +239,7 @@ class Variant { + // resulting type. + template + void Construct(Args&&... args) { +- index_ = value_.NOP_TEMPLATE Construct(std::forward(args)...); ++ index_ = value_.NOP_TEMPLATE Construct<>(std::forward(args)...); + } + void Construct(EmptyVariant) {} + +@@ -256,14 +256,14 @@ class Variant { + // multiple element types. + template + void Assign(TypeTag, U&& value) { +- if (!value_.NOP_TEMPLATE Assign(TypeTag{}, index_, std::forward(value))) { ++ if (!value_.NOP_TEMPLATE Assign<>(TypeTag{}, index_, std::forward(value))) { + Destruct(); + Construct(TypeTag{}, std::forward(value)); + } + } + template + void Assign(T&& value) { +- if (!value_.NOP_TEMPLATE Assign(index_, std::forward(value))) { ++ if (!value_.NOP_TEMPLATE Assign<>(index_, std::forward(value))) { + Destruct(); + Construct(std::forward(value)); + } diff --git a/pkgs/by-name/li/libnop/package.nix b/pkgs/by-name/li/libnop/package.nix new file mode 100644 index 000000000000..09cba2b2404c --- /dev/null +++ b/pkgs/by-name/li/libnop/package.nix @@ -0,0 +1,47 @@ +{ + lib, + stdenv, + fetchpatch, + fetchFromGitHub, + gtest, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "libnop"; + version = "0-unstable-2022-09-04"; + + src = fetchFromGitHub { + owner = "luxonis"; + repo = "libnop"; + rev = "ab842f51dc2eb13916dc98417c2186b78320ed10"; + sha256 = "sha256-d2z/lDI9pe5TR82MxGkR9bBMNXPvzqb9Gsd5jOv6x1A="; + }; + + patches = [ + # System install + # https://github.com/luxonis/libnop/pull/6/commits/ae29a8772f38fdb1efc24af9ec2e3f6814eb2158.patch + ./001-system-install.patch + # Fix template warning + # https://github.com/luxonis/libnop/pull/6/commits/199978a0fb0dc31de43b80f7504b53958fd202ee.patch + ./002-fix-template-warning.patch + ]; + + nativeBuildInputs = [ gtest ]; + + # Add optimization flags to address _FORTIFY_SOURCE warning + NIX_CFLAGS_COMPILE = [ "-O1" ]; + + installPhase = '' + runHook preInstall + make INSTALL_PREFIX=$out install + runHook postInstall + ''; + + meta = { + description = "A fast, header-only C++ serialization library"; + homepage = "https://github.com/google/libnop"; + license = lib.licenses.asl20; + platforms = lib.platforms.all; + maintainers = with lib.maintainers; [ phodina ]; + }; +})