Skip to content

Commit 53e05a9

Browse files
phodinaJohnRTitor
authored andcommitted
libnop: init at 0-unstable-2022-09-04
1 parent 53a79ee commit 53e05a9

File tree

3 files changed

+190
-0
lines changed

3 files changed

+190
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
From ae29a8772f38fdb1efc24af9ec2e3f6814eb2158 Mon Sep 17 00:00:00 2001
2+
From: Petr Hodina <[email protected]>
3+
Date: Sun, 4 May 2025 09:30:55 +0200
4+
Subject: [PATCH] Makefile: Add install into the system
5+
6+
---
7+
Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++
8+
libnop.pc.in | 7 +++++++
9+
2 files changed, 51 insertions(+)
10+
create mode 100644 libnop.pc.in
11+
12+
diff --git a/Makefile b/Makefile
13+
index 84cb459..e5b8a67 100644
14+
--- a/Makefile
15+
+++ b/Makefile
16+
@@ -1,5 +1,7 @@
17+
what_to_build:: all
18+
19+
+VERSION ?= 0-unstable-2022-09-04
20+
+
21+
-include local.mk
22+
23+
TOOLCHAIN ?=
24+
@@ -17,6 +19,12 @@ HOST_CFLAGS := -g -O2 -Wall -Werror -Wextra -Iinclude
25+
HOST_CXXFLAGS := -std=c++14
26+
HOST_LDFLAGS :=
27+
28+
+# Define install locations in the system
29+
+INSTALL_PREFIX ?= /usr/local
30+
+INCLUDE_INSTALL_DIR ?= $(INSTALL_PREFIX)/include/
31+
+PKGCONFIG_INSTALL_DIR ?= $(INSTALL_PREFIX)/lib/pkgconfig
32+
+CMAKE_CONFIG_INSTALL_DIR ?= $(INSTALL_PREFIX)/lib/cmake/libnop
33+
+
34+
ifeq ($(HOST_OS),Linux)
35+
HOST_LDFLAGS := -lpthread
36+
endif
37+
@@ -138,3 +146,39 @@ all:: $(ALL)
38+
# we generate .d as a side-effect of compiling. override generic rule:
39+
%.d:
40+
-include $(DEPS)
41+
+
42+
+# Handle install into the system
43+
+.PHONY: install install-pkgconfig install-cmake
44+
+
45+
+install: install-headers install-pkgconfig install-cmake
46+
+
47+
+install-headers:
48+
+ @echo "Installing headers to $(INCLUDE_INSTALL_DIR)"
49+
+ mkdir -p $(INCLUDE_INSTALL_DIR)
50+
+ cp -r include/* $(INCLUDE_INSTALL_DIR)
51+
+
52+
+install-pkgconfig: $(OUT)/libnop.pc
53+
+ @echo "Installing pkg-config file to $(PKGCONFIG_INSTALL_DIR)"
54+
+ mkdir -p $(PKGCONFIG_INSTALL_DIR)
55+
+ cp $< $(PKGCONFIG_INSTALL_DIR)
56+
+
57+
+PC_TEMPLATE := libnop.pc.in
58+
+
59+
+$(OUT)/libnop.pc: $(PC_TEMPLATE)
60+
+ mkdir -p $(dir $@)
61+
+ sed \
62+
+ -e 's|@prefix@|$(INSTALL_PREFIX)|g' \
63+
+ -e 's|@includedir@|$(INSTALL_PREFIX)/include|g' \
64+
+ -e 's|@version@|$(VERSION)|g' \
65+
+ $< > $@
66+
+
67+
+install-cmake: $(OUT)/libnopConfig.cmake
68+
+ @echo "Installing CMake config to $(CMAKE_CONFIG_INSTALL_DIR)"
69+
+ mkdir -p $(CMAKE_CONFIG_INSTALL_DIR)
70+
+ cp $< $(CMAKE_CONFIG_INSTALL_DIR)
71+
+
72+
+$(OUT)/libnopConfig.cmake:
73+
+ mkdir -p $(dir $@)
74+
+ echo "set(LIBNOP_INCLUDE_DIR \"$(INCLUDE_INSTALL_DIR)\")" > $@
75+
+ echo "set(LIBNOP_FOUND TRUE)" >> $@
76+
+ echo "mark_as_advanced(LIBNOP_INCLUDE_DIR)" >> $@
77+
diff --git a/libnop.pc.in b/libnop.pc.in
78+
new file mode 100644
79+
index 0000000..8c5475b
80+
--- /dev/null
81+
+++ b/libnop.pc.in
82+
@@ -0,0 +1,7 @@
83+
+prefix=@prefix@
84+
+includedir=@includedir@
85+
+
86+
+Name: libnop
87+
+Description: Header-only C++ Native Object Protocols library
88+
+Version: @version@
89+
+Cflags: -I${includedir}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From 199978a0fb0dc31de43b80f7504b53958fd202ee Mon Sep 17 00:00:00 2001
2+
From: Petr Hodina <[email protected]>
3+
Date: Sun, 4 May 2025 09:58:20 +0200
4+
Subject: [PATCH] C++: Fix compilation issue
5+
-Wno-missing-template-arg-list-after-template-kw
6+
7+
---
8+
include/nop/rpc/interface.h | 2 +-
9+
include/nop/types/variant.h | 6 +++---
10+
2 files changed, 4 insertions(+), 4 deletions(-)
11+
12+
diff --git a/include/nop/rpc/interface.h b/include/nop/rpc/interface.h
13+
index 167d203..9772d06 100644
14+
--- a/include/nop/rpc/interface.h
15+
+++ b/include/nop/rpc/interface.h
16+
@@ -245,7 +245,7 @@ struct InterfaceMethod {
17+
template <typename Sender>
18+
static void Invoke(Sender* sender, Status<Return>* return_value,
19+
Args... args) {
20+
- sender->NOP_TEMPLATE SendMethod(InterfaceMethod::Selector, return_value,
21+
+ sender->NOP_TEMPLATE SendMethod<>(InterfaceMethod::Selector, return_value,
22+
std::forward_as_tuple(args...));
23+
}
24+
25+
diff --git a/include/nop/types/variant.h b/include/nop/types/variant.h
26+
index fdf8e03..af8c81e 100644
27+
--- a/include/nop/types/variant.h
28+
+++ b/include/nop/types/variant.h
29+
@@ -239,7 +239,7 @@ class Variant {
30+
// resulting type.
31+
template <typename... Args>
32+
void Construct(Args&&... args) {
33+
- index_ = value_.NOP_TEMPLATE Construct(std::forward<Args>(args)...);
34+
+ index_ = value_.NOP_TEMPLATE Construct<>(std::forward<Args>(args)...);
35+
}
36+
void Construct(EmptyVariant) {}
37+
38+
@@ -256,14 +256,14 @@ class Variant {
39+
// multiple element types.
40+
template <typename T, typename U>
41+
void Assign(TypeTag<T>, U&& value) {
42+
- if (!value_.NOP_TEMPLATE Assign(TypeTag<T>{}, index_, std::forward<U>(value))) {
43+
+ if (!value_.NOP_TEMPLATE Assign<>(TypeTag<T>{}, index_, std::forward<U>(value))) {
44+
Destruct();
45+
Construct(TypeTag<T>{}, std::forward<U>(value));
46+
}
47+
}
48+
template <typename T>
49+
void Assign(T&& value) {
50+
- if (!value_.NOP_TEMPLATE Assign(index_, std::forward<T>(value))) {
51+
+ if (!value_.NOP_TEMPLATE Assign<>(index_, std::forward<T>(value))) {
52+
Destruct();
53+
Construct(std::forward<T>(value));
54+
}

pkgs/by-name/li/libnop/package.nix

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchpatch,
5+
fetchFromGitHub,
6+
gtest,
7+
}:
8+
9+
stdenv.mkDerivation (finalAttrs: {
10+
pname = "libnop";
11+
version = "0-unstable-2022-09-04";
12+
13+
src = fetchFromGitHub {
14+
owner = "luxonis";
15+
repo = "libnop";
16+
rev = "ab842f51dc2eb13916dc98417c2186b78320ed10";
17+
sha256 = "sha256-d2z/lDI9pe5TR82MxGkR9bBMNXPvzqb9Gsd5jOv6x1A=";
18+
};
19+
20+
patches = [
21+
# System install
22+
# https://github.com/luxonis/libnop/pull/6/commits/ae29a8772f38fdb1efc24af9ec2e3f6814eb2158.patch
23+
./001-system-install.patch
24+
# Fix template warning
25+
# https://github.com/luxonis/libnop/pull/6/commits/199978a0fb0dc31de43b80f7504b53958fd202ee.patch
26+
./002-fix-template-warning.patch
27+
];
28+
29+
nativeBuildInputs = [ gtest ];
30+
31+
# Add optimization flags to address _FORTIFY_SOURCE warning
32+
NIX_CFLAGS_COMPILE = [ "-O1" ];
33+
34+
installPhase = ''
35+
runHook preInstall
36+
make INSTALL_PREFIX=$out install
37+
runHook postInstall
38+
'';
39+
40+
meta = {
41+
description = "A fast, header-only C++ serialization library";
42+
homepage = "https://github.com/google/libnop";
43+
license = lib.licenses.asl20;
44+
platforms = lib.platforms.all;
45+
maintainers = with lib.maintainers; [ phodina ];
46+
};
47+
})

0 commit comments

Comments
 (0)