Skip to content

Commit 1cc3aa4

Browse files
committed
Merge bitcoin/bitcoin#29707: depends: build miniupnpc with CMake
5195baa depends: fix miniupnpc snprintf usage on Windows (fanquake) 3c2d440 depends: switch miniupnpc to CMake (Cory Fields) f5618c7 depends: add upstream CMake patch to miniupnpc (fanquake) 6866b57 depends: miniupnpc 2.2.7 (fanquake) Pull request description: This picks up one of the changes from #29232, which is a switch to building miniupnpc with CMake. It includes an update to the most recent version of miniupnpc (2.2.7), which means we can drop one patch from that commit, and includes a new patch for a change I've upstreamed miniupnp/miniupnp#721, as well as some suggestions from the previous PR. ACKs for top commit: theuni: ACK 5195baa. TheCharlatan: utACK 5195baa Tree-SHA512: 5b27e132cd5eed285e9be34c8b96893417d92a1ae55c99345c9a89e1c1c5e40e4bc840bc061b879758b2b11fcb520cd98c3da985c1e153f2e5380cf63efe2d69
2 parents d73245a + 5195baa commit 1cc3aa4

File tree

7 files changed

+76
-66
lines changed

7 files changed

+76
-66
lines changed

depends/packages/miniupnpc.mk

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
package=miniupnpc
2-
$(package)_version=2.2.2
2+
$(package)_version=2.2.7
33
$(package)_download_path=https://miniupnp.tuxfamily.org/files/
44
$(package)_file_name=$(package)-$($(package)_version).tar.gz
5-
$(package)_sha256_hash=888fb0976ba61518276fe1eda988589c700a3f2a69d71089260d75562afd3687
6-
$(package)_patches=dont_leak_info.patch respect_mingw_cflags.patch no_libtool.patch
5+
$(package)_sha256_hash=b0c3a27056840fd0ec9328a5a9bac3dc5e0ec6d2e8733349cf577b0aa1e70ac1
6+
$(package)_patches=dont_leak_info.patch cmake_get_src_addr.patch fix_windows_snprintf.patch
7+
$(package)_build_subdir=build
78

8-
# Next time this package is updated, ensure that _WIN32_WINNT is still properly set.
9-
# See discussion in https://github.com/bitcoin/bitcoin/pull/25964.
109
define $(package)_set_vars
11-
$(package)_build_opts=CC="$($(package)_cc)"
12-
$(package)_build_opts_mingw32=-f Makefile.mingw CFLAGS="$($(package)_cflags) -D_WIN32_WINNT=0x0601"
13-
$(package)_build_env+=CFLAGS="$($(package)_cflags) $($(package)_cppflags)" AR="$($(package)_ar)"
10+
$(package)_config_opts = -DUPNPC_BUILD_SAMPLE=OFF -DUPNPC_BUILD_SHARED=OFF
11+
$(package)_config_opts += -DUPNPC_BUILD_STATIC=ON -DUPNPC_BUILD_TESTS=OFF
12+
$(package)_config_opts_mingw32 += -DMINIUPNPC_TARGET_WINDOWS_VERSION=0x0601
1413
endef
1514

1615
define $(package)_preprocess_cmds
1716
patch -p1 < $($(package)_patch_dir)/dont_leak_info.patch && \
18-
patch -p1 < $($(package)_patch_dir)/respect_mingw_cflags.patch && \
19-
patch -p1 < $($(package)_patch_dir)/no_libtool.patch
17+
patch -p1 < $($(package)_patch_dir)/cmake_get_src_addr.patch && \
18+
patch -p1 < $($(package)_patch_dir)/fix_windows_snprintf.patch
19+
endef
20+
21+
define $(package)_config_cmds
22+
$($(package)_cmake) -S .. -B .
2023
endef
2124

2225
define $(package)_build_cmds
23-
$(MAKE) libminiupnpc.a $($(package)_build_opts)
26+
$(MAKE)
2427
endef
2528

2629
define $(package)_stage_cmds
27-
mkdir -p $($(package)_staging_prefix_dir)/include/miniupnpc $($(package)_staging_prefix_dir)/lib &&\
28-
install *.h $($(package)_staging_prefix_dir)/include/miniupnpc &&\
29-
install libminiupnpc.a $($(package)_staging_prefix_dir)/lib
30+
cmake --install . --prefix $($(package)_staging_prefix_dir)
3031
endef
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
commit cb2026239c2a3aff393952ccb0ee1c448189402d
2+
Author: fanquake <fanquake@gmail.com>
3+
Date: Fri Mar 22 14:03:54 2024 +0000
4+
5+
build: add MINIUPNPC_GET_SRC_ADDR to CMake build
6+
7+
This mirrors the autotools build.
8+
9+
See https://github.com/miniupnp/miniupnp/pull/721.
10+
11+
diff --git a/CMakeLists.txt b/CMakeLists.txt
12+
index 1aa95a8..0cacf3e 100644
13+
--- a/CMakeLists.txt
14+
+++ b/CMakeLists.txt
15+
@@ -31,6 +31,7 @@ endif ()
16+
if (NOT WIN32)
17+
target_compile_definitions(miniupnpc-private INTERFACE
18+
MINIUPNPC_SET_SOCKET_TIMEOUT
19+
+ MINIUPNPC_GET_SRC_ADDR
20+
_BSD_SOURCE _DEFAULT_SOURCE)
21+
if (NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES ".*BSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
22+
# add_definitions (-D_POSIX_C_SOURCE=200112L)

depends/patches/miniupnpc/dont_leak_info.patch

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
commit 8815452257437ba36607d0e2381c01142d1c7bb0
1+
commit 51f6dd991c29af66fb4f64c6feb2787cce23a1a7
22
Author: fanquake <fanquake@gmail.com>
3-
Date: Thu Nov 19 10:51:19 2020 +0800
3+
Date: Mon Jan 8 11:21:40 2024 +0000
44

55
Don't leak OS and miniupnpc version info in User-Agent
66

7-
diff --git a//minisoap.c b/minisoap.c
8-
index 7860667..775580b 100644
9-
--- a/minisoap.c
10-
+++ b/minisoap.c
7+
diff --git a/src/minisoap.c b/src/minisoap.c
8+
index 903ac5f..046e0ea 100644
9+
--- a/src/minisoap.c
10+
+++ b/src/minisoap.c
1111
@@ -90,7 +90,7 @@ int soapPostSubmit(SOCKET fd,
1212
headerssize = snprintf(headerbuf, sizeof(headerbuf),
1313
"POST %s HTTP/%s\r\n"
1414
"Host: %s%s\r\n"
15-
- "User-Agent: " OS_STRING ", " UPNP_VERSION_STRING ", MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
15+
- "User-Agent: " OS_STRING " " UPNP_VERSION_STRING " MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
1616
+ "User-Agent: " UPNP_VERSION_STRING "\r\n"
1717
"Content-Length: %d\r\n"
18+
#if (UPNP_VERSION_MAJOR == 1) && (UPNP_VERSION_MINOR == 0)
1819
"Content-Type: text/xml\r\n"
19-
"SOAPAction: \"%s\"\r\n"
20-
diff --git a/miniwget.c b/miniwget.c
21-
index d5b7970..05aeb9c 100644
22-
--- a/miniwget.c
23-
+++ b/miniwget.c
20+
diff --git a/src/miniwget.c b/src/miniwget.c
21+
index e76a5e5..0cc36fe 100644
22+
--- a/src/miniwget.c
23+
+++ b/src/miniwget.c
2424
@@ -444,7 +444,7 @@ miniwget3(const char * host,
2525
"GET %s HTTP/%s\r\n"
2626
"Host: %s:%d\r\n"
2727
"Connection: Close\r\n"
28-
- "User-Agent: " OS_STRING ", " UPNP_VERSION_STRING ", MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
28+
- "User-Agent: " OS_STRING " " UPNP_VERSION_STRING " MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
2929
+ "User-Agent: " UPNP_VERSION_STRING "\r\n"
3030

3131
"\r\n",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
commit a1e9de80ab99b4c956a6a4e21d3e0de6f7a1014d
2+
Author: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
3+
Date: Sat Apr 20 15:14:47 2024 +0100
4+
5+
Fix macro expression that guards `snprintf` for Windows
6+
7+
Otherwise, the `snprintf` is still wrongly emulated for the following
8+
cases:
9+
- mingw-w64 6.0.0 or new with ucrt
10+
- mingw-w64 8.0.0 or new with iso c ext
11+
12+
--- a/src/win32_snprintf.h
13+
+++ b/src/win32_snprintf.h
14+
@@ -23,9 +23,9 @@
15+
(defined(_MSC_VER) && _MSC_VER < 1900) /* Visual Studio older than 2015 */ || \
16+
(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) && defined(__NO_ISOCEXT)) /* mingw32 without iso c ext */ || \
17+
(defined(__MINGW64_VERSION_MAJOR) && /* mingw-w64 not ... */ !( \
18+
- (defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0)) /* ... with ansi stdio */ || \
19+
+ (defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0) /* ... with ansi stdio */ || \
20+
(__MINGW64_VERSION_MAJOR >= 6 && defined(_UCRT)) /* ... at least 6.0.0 with ucrt */ || \
21+
- (__MINGW64_VERSION_MAJOR >= 8 && !defined(__NO_ISOCEXT)) /* ... at least 8.0.0 with iso c ext */ || \
22+
+ (__MINGW64_VERSION_MAJOR >= 8 && !defined(__NO_ISOCEXT))) /* ... at least 8.0.0 with iso c ext */ || \
23+
0) || \
24+
0)
25+

depends/patches/miniupnpc/no_libtool.patch

Lines changed: 0 additions & 15 deletions
This file was deleted.

depends/patches/miniupnpc/respect_mingw_cflags.patch

Lines changed: 0 additions & 23 deletions
This file was deleted.

doc/dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You can find installation instructions in the `build-*.md` file for your platfor
3636
| Dependency | Releases | Version used | Minimum required | Runtime |
3737
| --- | --- | --- | --- | --- |
3838
| [libnatpmp](../depends/packages/libnatpmp.mk) | [link](https://github.com/miniupnp/libnatpmp/) | commit [f2433be...](https://github.com/bitcoin/bitcoin/pull/29708) | | No |
39-
| [MiniUPnPc](../depends/packages/miniupnpc.mk) | [link](https://miniupnp.tuxfamily.org/) | [2.2.2](https://github.com/bitcoin/bitcoin/pull/20421) | 2.1 | No |
39+
| [MiniUPnPc](../depends/packages/miniupnpc.mk) | [link](https://miniupnp.tuxfamily.org/) | [2.2.7](https://github.com/bitcoin/bitcoin/pull/29707) | 2.1 | No |
4040

4141
### Notifications
4242
| Dependency | Releases | Version used | Minimum required | Runtime |

0 commit comments

Comments
 (0)