From acf810f8fd77ce393c704c90c2737e0eb37b7221 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sun, 31 Mar 2024 03:43:29 +0200 Subject: [PATCH 1/2] depends: gtest: update to 1.14.0, clean up package definition --- contrib/depends/funcs.mk | 12 ++++++++++++ contrib/depends/packages/gtest.mk | 32 ++++++++----------------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/contrib/depends/funcs.mk b/contrib/depends/funcs.mk index e08669c98..83dc22f3c 100644 --- a/contrib/depends/funcs.mk +++ b/contrib/depends/funcs.mk @@ -172,6 +172,18 @@ endif ifneq ($($(1)_ldflags),) $(1)_autoconf += LDFLAGS="$$($(1)_ldflags)" endif + +$(1)_cmake=env CC="$$($(1)_cc)" \ + CFLAGS="$$($(1)_cppflags) $$($(1)_cflags)" \ + CXX="$$($(1)_cxx)" \ + CXXFLAGS="$$($(1)_cppflags) $$($(1)_cxxflags)" \ + LDFLAGS="$$($(1)_ldflags)" \ + cmake -DCMAKE_INSTALL_PREFIX:PATH="$$($($(1)_type)_prefix)" $$($(1)_config_opts) +ifneq ($(host),$(build)) +$(1)_cmake += -DCMAKE_SYSTEM_NAME=$($(host_os)_cmake_system) +$(1)_cmake += -DCMAKE_C_COMPILER_TARGET=$(host) +$(1)_cmake += -DCMAKE_CXX_COMPILER_TARGET=$(host) +endif endef define int_add_cmds diff --git a/contrib/depends/packages/gtest.mk b/contrib/depends/packages/gtest.mk index 1208d7c03..c87b31471 100644 --- a/contrib/depends/packages/gtest.mk +++ b/contrib/depends/packages/gtest.mk @@ -1,39 +1,23 @@ package=gtest -$(package)_version=1.8.1 +$(package)_version=1.14.0 $(package)_download_path=https://github.com/google/googletest/archive/ -$(package)_download_file=release-$($(package)_version).tar.gz +$(package)_download_file=v$($(package)_version).tar.gz $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c -$(package)_cxxflags=-std=c++11 +$(package)_sha256_hash=8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7 +$(package)_cxxflags=-std=c++14 $(package)_cxxflags_linux=-fPIC define $(package)_config_cmds - cd googletest && \ - CC="$(host_prefix)/native/bin/$($(package)_cc)" \ - CXX="$(host_prefix)/native/bin/$($(package)_cxx)" \ - AR="$(host_prefix)/native/bin/$($(package)_ar)" \ - RANLIB="$(host_prefix)/native/bin/$($(package)_ranlib)" \ - LIBTOOL="$(host_prefix)/native/bin/$($(package)_libtool)" \ - CXXFLAGS="$($(package)_cxxflags)" \ - CCFLAGS="$($(package)_ccflags)" \ - CPPFLAGS="$($(package)_cppflags)" \ - CFLAGS="$($(package)_cflags) $($(package)_cppflags)" \ - LDLAGS="$($(package)_ldflags)" \ - cmake -DCMAKE_INSTALL_PREFIX=$(build_prefix) \ - -DTOOLCHAIN_PREFIX=$(host_toolchain) \ - -DCMAKE_AR="$(host_prefix)/native/bin/$($(package)_ar)" \ - -DCMAKE_RANLIB="$(host_prefix)/native/bin/$($(package)_ranlib)" \ - -DCMAKE_CXX_FLAGS_DEBUG=ON + $($(package)_cmake) -S . -B . endef -# -DCMAKE_TOOLCHAIN_FILE=$(HOST)/share/toolchain.cmake define $(package)_build_cmds - cd googletest && CC="$(host_prefix)/native/bin/$($(package)_cc)" $(MAKE) + $(MAKE) endef define $(package)_stage_cmds mkdir $($(package)_staging_prefix_dir)/lib $($(package)_staging_prefix_dir)/include &&\ - cp googletest/libgtest.a $($(package)_staging_prefix_dir)/lib/ &&\ - cp googletest/libgtest_main.a $($(package)_staging_prefix_dir)/lib/ &&\ + cp lib/libgtest.a $($(package)_staging_prefix_dir)/lib/ &&\ + cp lib/libgtest_main.a $($(package)_staging_prefix_dir)/lib/ &&\ cp -a googletest/include/* $($(package)_staging_prefix_dir)/include/ endef From 91faf9f06ef9d7a99229a483c080717d7558945c Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sun, 31 Mar 2024 18:24:37 +0200 Subject: [PATCH 2/2] build: miniupnpc: remove submodule, add to depends, update to 2.2.7 --- .github/workflows/build.yml | 4 ++-- .gitmodules | 3 --- CMakeLists.txt | 8 +++++++- README.md | 9 +++++---- contrib/depends/packages/miniupnpc.mk | 24 ++++++++++++++++++++++++ contrib/depends/packages/packages.mk | 2 +- external/CMakeLists.txt | 18 ------------------ external/miniupnp | 1 - src/p2p/CMakeLists.txt | 2 +- src/p2p/net_node.inl | 6 +++--- 10 files changed, 43 insertions(+), 34 deletions(-) create mode 100644 contrib/depends/packages/miniupnpc.mk delete mode 160000 external/miniupnp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 15c0ad966..01d3ea969 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ env: REMOVE_BUNDLED_PACKAGES : sudo rm -rf /usr/local BUILD_DEFAULT_LINUX: | cmake -S . -B build -D ARCH="default" -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Release && cmake --build build -j3 - APT_INSTALL_LINUX: 'sudo apt -y install build-essential cmake libboost-all-dev miniupnpc libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libzmq3-dev libsodium-dev libhidapi-dev libnorm-dev libusb-1.0-0-dev libpgm-dev libprotobuf-dev protobuf-compiler ccache' + APT_INSTALL_LINUX: 'sudo apt -y install build-essential cmake libboost-all-dev libminiupnpc-dev libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libzmq3-dev libsodium-dev libhidapi-dev libnorm-dev libusb-1.0-0-dev libpgm-dev libprotobuf-dev protobuf-compiler ccache' APT_SET_CONF: | echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom @@ -68,7 +68,7 @@ jobs: - uses: msys2/setup-msys2@v2 with: update: true - install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-ccache mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-libusb mingw-w64-x86_64-unbound git + install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-ccache mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-libusb mingw-w64-x86_64-unbound mingw-w64-x86_64-miniupnpc git - shell: msys2 {0} run: | curl -O https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-protobuf-c-1.4.1-1-any.pkg.tar.zst diff --git a/.gitmodules b/.gitmodules index 721cce3b4..31c6921e5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "external/miniupnp"] - path = external/miniupnp - url = https://github.com/miniupnp/miniupnp [submodule "external/rapidjson"] path = external/rapidjson url = https://github.com/Tencent/rapidjson diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ffdaeb55..a3ed3979d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,7 +367,6 @@ if(NOT MANUAL_SUBMODULES) endfunction () message(STATUS "Checking submodules") - check_submodule(external/miniupnp) check_submodule(external/rapidjson) check_submodule(external/trezor-common) check_submodule(external/randomx) @@ -599,6 +598,9 @@ if (WIN32) list(APPEND OPENSSL_LIBRARIES ws2_32 crypt32) endif() +find_package(Miniupnpc REQUIRED) +message(STATUS "Using Miniupnpc include dir at ${MINIUPNP_INCLUDE_DIRS}") + find_package(HIDAPI) add_definition_if_library_exists(c memset_s "string.h" HAVE_MEMSET_S) @@ -690,6 +692,10 @@ include_directories(${LMDB_INCLUDE}) include_directories(${LIBUNWIND_INCLUDE}) link_directories(${LIBUNWIND_LIBRARY_DIRS}) +# Final setup for miniupnpc +include_directories(${MINIUPNP_INCLUDE_DIRS}) +link_directories(${MINIUPNP_LIBRARIES}) + # Final setup for hid if (HIDAPI_FOUND) message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}") diff --git a/README.md b/README.md index 5bde48dd9..2f60d71e6 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ library archives (`.a`). | libnorm[2] | ? | NO | `libnorm-dev` | | | | YES | For ZeroMQ | | libunbound | 1.4.16 | NO | `libunbound-dev` | `unbound` | `unbound-devel` | `unbound-devel` | NO | DNS resolver | | libsodium | ? | NO | `libsodium-dev` | `libsodium` | `libsodium-devel` | `libsodium-devel` | NO | cryptography | +| miniupnpc | 2.2.0 | NO | `libminiupnpc-dev` | `miniupnpc` | `miniupnpc-devel` | `miniupnpc-devel` | NO | UPNP mapping | | libunwind | any | NO | `libunwind8-dev` | `libunwind` | `libunwind-devel` | `libunwind-devel` | YES | Stack traces | | liblzma | any | NO | `liblzma-dev` | `xz` | `liblzma-devel` | `xz-devel` | YES | For libunwind | | libreadline | 6.3.0 | NO | `libreadline6-dev` | `readline` | `readline-devel` | `readline-devel` | YES | Input editing | @@ -205,17 +206,17 @@ then: Install all dependencies at once on Debian/Ubuntu: ``` -sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz +sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev libminiupnpc-dev python3 ccache doxygen graphviz ``` Install all dependencies at once on Arch: ``` -sudo pacman -Syu --needed base-devel cmake boost openssl zeromq libpgm unbound libsodium libunwind xz readline expat gtest python3 ccache doxygen graphviz qt5-tools hidapi libusb protobuf systemd +sudo pacman -Syu --needed base-devel cmake boost openssl zeromq libpgm unbound libsodium libunwind xz readline expat gtest python3 ccache doxygen graphviz qt5-tools hidapi libusb protobuf systemd miniupnpc ``` Install all dependencies at once on Fedora: ``` -sudo dnf install gcc gcc-c++ cmake pkgconf boost-devel openssl-devel zeromq-devel openpgm-devel unbound-devel libsodium-devel libunwind-devel xz-devel readline-devel expat-devel gtest-devel ccache doxygen graphviz qt5-linguist hidapi-devel libusbx-devel protobuf-devel protobuf-compiler systemd-devel +sudo dnf install gcc gcc-c++ cmake pkgconf boost-devel openssl-devel zeromq-devel openpgm-devel unbound-devel libsodium-devel libunwind-devel xz-devel readline-devel expat-devel gtest-devel ccache doxygen graphviz qt5-linguist hidapi-devel libusbx-devel protobuf-devel protobuf-compiler systemd-devel miniupnpc-devel ``` Install all dependencies at once on openSUSE: @@ -233,7 +234,7 @@ brew update && brew bundle --file=contrib/brew/Brewfile FreeBSD 12.1 one-liner required to build dependencies: ``` -pkg install git gmake cmake pkgconf boost-libs libzmq4 libsodium unbound +pkg install git gmake cmake pkgconf boost-libs libzmq4 libsodium unbound miniupnpc ``` ### Cloning the repository diff --git a/contrib/depends/packages/miniupnpc.mk b/contrib/depends/packages/miniupnpc.mk new file mode 100644 index 000000000..90816a113 --- /dev/null +++ b/contrib/depends/packages/miniupnpc.mk @@ -0,0 +1,24 @@ +package=miniupnpc +$(package)_version=2.2.7 +$(package)_download_path=https://miniupnp.tuxfamily.org/files/ +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=b0c3a27056840fd0ec9328a5a9bac3dc5e0ec6d2e8733349cf577b0aa1e70ac1 +$(package)_build_subdir=build + +define $(package)_set_vars +$(package)_config_opts = -DUPNPC_BUILD_SAMPLE=OFF -DUPNPC_BUILD_SHARED=OFF +$(package)_config_opts += -DUPNPC_BUILD_STATIC=ON -DUPNPC_BUILD_TESTS=OFF +$(package)_config_opts_mingw32 += -DMINIUPNPC_TARGET_WINDOWS_VERSION=0x0601 +endef + +define $(package)_config_cmds + $($(package)_cmake) -S .. -B . +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + cmake --install . --prefix $($(package)_staging_prefix_dir) +endef diff --git a/contrib/depends/packages/packages.mk b/contrib/depends/packages/packages.mk index 14561964f..68d88cd72 100644 --- a/contrib/depends/packages/packages.mk +++ b/contrib/depends/packages/packages.mk @@ -1,4 +1,4 @@ -packages:=boost openssl zeromq expat unbound sodium +packages:=boost openssl zeromq expat unbound sodium miniupnpc hardware_packages := hidapi protobuf libusb hardware_native_packages := native_protobuf diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 8deadc7ba..0f37ac301 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -35,24 +35,6 @@ # ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with # others. -find_package(Miniupnpc REQUIRED) - -message(STATUS "Using in-tree miniupnpc") -set(UPNPC_NO_INSTALL TRUE CACHE BOOL "Disable miniupnp installation" FORCE) -add_subdirectory(miniupnp/miniupnpc) -set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external") -set_property(TARGET libminiupnpc-static PROPERTY POSITION_INDEPENDENT_CODE ON) -if(MSVC) - set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267") -elseif(NOT MSVC) - set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value") -endif() -if(CMAKE_SYSTEM_NAME MATCHES "NetBSD") - set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -D_NETBSD_SOURCE") -endif() - -set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE) - find_package(Unbound) if(NOT UNBOUND_INCLUDE_DIR) diff --git a/external/miniupnp b/external/miniupnp deleted file mode 160000 index 544e6fcc7..000000000 --- a/external/miniupnp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 544e6fcc73c5ad9af48a8985c94f0f1d742ef2e0 diff --git a/src/p2p/CMakeLists.txt b/src/p2p/CMakeLists.txt index bd2345979..58eaf9c64 100644 --- a/src/p2p/CMakeLists.txt +++ b/src/p2p/CMakeLists.txt @@ -41,7 +41,7 @@ target_link_libraries(p2p version cryptonote_core net - ${UPNP_LIBRARIES} + ${MINIUPNP_LIBRARIES} ${Boost_CHRONO_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 815c1b354..40205f50c 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -58,9 +58,9 @@ #include "cryptonote_core/cryptonote_core.h" #include "net/parse.h" -#include -#include -#include +#include +#include +#include #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "net.p2p"