From 0b0fd98a9157818c8e86bcc4e3ab92fb212b2db9 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Sat, 22 May 2021 12:35:42 -0700 Subject: [PATCH 01/23] init --- recipes/fast-dds/all/conandata.yml | 4 ++ recipes/fast-dds/all/conanfile.py | 101 +++++++++++++++++++++++++++++ recipes/fast-dds/config.yml | 3 + 3 files changed, 108 insertions(+) create mode 100644 recipes/fast-dds/all/conandata.yml create mode 100644 recipes/fast-dds/all/conanfile.py create mode 100644 recipes/fast-dds/config.yml diff --git a/recipes/fast-dds/all/conandata.yml b/recipes/fast-dds/all/conandata.yml new file mode 100644 index 0000000000000..1523e39f714d7 --- /dev/null +++ b/recipes/fast-dds/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.3.2": + url: "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.3.2.tar.gz" + sha256: "4D8183CF4D37C3DE9E6FD28D2850DD08023A9079001C4880B23C95F0D8C0B5CE" diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py new file mode 100644 index 0000000000000..9a531c0043ee5 --- /dev/null +++ b/recipes/fast-dds/all/conanfile.py @@ -0,0 +1,101 @@ +from conans import ConanFile, CMake, tools +import os +from conans.tools import load +from conans.errors import ConanInvalidConfiguration +from pathlib import Path +import textwrap + +class FastDDSConan(ConanFile): + + name = "fast-dds" + license = "Apache-2.0" + version = "2.3.2" + homepage = "https://fast-dds.docs.eprosima.com/" + url = "https://github.com/conan-io/conan-center-index" + description = "The most complete DDS - Proven: Plenty of success cases." + topics = ("Memory","Allocator") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False] + } + default_options = { + "shared": False + } + generators = "cmake", "cmake_find_package" + _cmake = None + + @property + def _pkg_cmake(self): + return os.path.join( + self.package_folder, + "lib", + "foonathan_memory", + "cmake" + ) + + @property + def _pkg_lib(self): + return os.path.join( + self.package_folder, + "lib" + ) + + @property + def _pkg_share(self): + return os.path.join( + self.package_folder, + "share" + ) + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def _get_configured_cmake(self): + if self._cmake: + pass + else: + self._cmake = CMake(self) + self._cmake.definitions["BUILD_MEMORY_TOOLS"] = False + self._cmake.configure( + source_dir = self._source_subfolder + ) + return self._cmake + + def requirements(self): + self.requires("tinyxml2/7.1.0") + self.requires("asio/1.11.0@bincrafters/stable") + self.requires("fast-cdr/1.0.21") + self.requires("foo-mem-ven/1.1.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) + + def build(self): + + cmake = self._get_configured_cmake() + cmake.build() + + def package(self): + cmake = self._get_configured_cmake() + cmake.install() + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + lib = tools.relative_dirs(self._pkg_lib)[0] + lib_new = lib.replace("-0.6.2-dbg","") \ + .replace("-0.6.2","") + tools.rename( + os.path.join(self._pkg_lib,lib), + os.path.join(self._pkg_lib,lib_new) + ) + tools.rmdir(self._pkg_cmake) + tools.rmdir(self._pkg_share) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "foonathan_memory" + self.cpp_info.names["cmake_find_multi_package"] = "foonathan_memory" + self.cpp_info.libs = ["foonathan_memory"] diff --git a/recipes/fast-dds/config.yml b/recipes/fast-dds/config.yml new file mode 100644 index 0000000000000..aee8de619ec30 --- /dev/null +++ b/recipes/fast-dds/config.yml @@ -0,0 +1,3 @@ +versions: + "2.3.2": + folder: all From 025a4abe4329396664cb42eb87715a070d045398 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Sun, 23 May 2021 01:43:08 -0700 Subject: [PATCH 02/23] compile success, link fails --- recipes/fast-dds/all/conandata.yml | 4 ++ recipes/fast-dds/all/conanfile.py | 38 +++++++++++-------- .../all/patches/2.3.2-0001-add-conan.patch | 13 +++++++ 3 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 recipes/fast-dds/all/patches/2.3.2-0001-add-conan.patch diff --git a/recipes/fast-dds/all/conandata.yml b/recipes/fast-dds/all/conandata.yml index 1523e39f714d7..fb20ec39d1b29 100644 --- a/recipes/fast-dds/all/conandata.yml +++ b/recipes/fast-dds/all/conandata.yml @@ -2,3 +2,7 @@ sources: "2.3.2": url: "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.3.2.tar.gz" sha256: "4D8183CF4D37C3DE9E6FD28D2850DD08023A9079001C4880B23C95F0D8C0B5CE" +patches: + "2.3.2": + - base_path: "source_subfolder" + patch_file: "patches/2.3.2-0001-add-conan.patch" \ No newline at end of file diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 9a531c0043ee5..391d18539c787 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -13,13 +13,15 @@ class FastDDSConan(ConanFile): homepage = "https://fast-dds.docs.eprosima.com/" url = "https://github.com/conan-io/conan-center-index" description = "The most complete DDS - Proven: Plenty of success cases." - topics = ("Memory","Allocator") + topics = ("DDS","Middleware","IPC") settings = "os", "compiler", "build_type", "arch" options = { - "shared": [True, False] + "shared": [True, False], + "with_ssl": [True, False] } default_options = { - "shared": False + "shared": True, + "with_ssl": False } generators = "cmake", "cmake_find_package" _cmake = None @@ -54,6 +56,8 @@ def _source_subfolder(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.options.shared: + self.options["fast-cdr"].shared = True def _get_configured_cmake(self): if self._cmake: @@ -61,6 +65,7 @@ def _get_configured_cmake(self): else: self._cmake = CMake(self) self._cmake.definitions["BUILD_MEMORY_TOOLS"] = False + self._cmake.definitions["NO_TLS"] = True self._cmake.configure( source_dir = self._source_subfolder ) @@ -72,11 +77,19 @@ def requirements(self): self.requires("fast-cdr/1.0.21") self.requires("foo-mem-ven/1.1.0") + def _patch_sources(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + def imports(self): + self.copy("*") + def build(self): + self._patch_sources() cmake = self._get_configured_cmake() cmake.build() @@ -85,17 +98,12 @@ def package(self): cmake = self._get_configured_cmake() cmake.install() self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - lib = tools.relative_dirs(self._pkg_lib)[0] - lib_new = lib.replace("-0.6.2-dbg","") \ - .replace("-0.6.2","") - tools.rename( - os.path.join(self._pkg_lib,lib), - os.path.join(self._pkg_lib,lib_new) - ) - tools.rmdir(self._pkg_cmake) - tools.rmdir(self._pkg_share) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "foonathan_memory" - self.cpp_info.names["cmake_find_multi_package"] = "foonathan_memory" - self.cpp_info.libs = ["foonathan_memory"] + self.cpp_info.names["cmake_find_package"] = "fast-dds" + self.cpp_info.names["cmake_find_multi_package"] = "fast-dds" + self.cpp_info.libs = ["fastrtps"] + self.cpp_info.requires = [ + "fastcdr::fastcdr", + "tinyxml2::tinyxml2" + ] diff --git a/recipes/fast-dds/all/patches/2.3.2-0001-add-conan.patch b/recipes/fast-dds/all/patches/2.3.2-0001-add-conan.patch new file mode 100644 index 0000000000000..09eccdb11c55c --- /dev/null +++ b/recipes/fast-dds/all/patches/2.3.2-0001-add-conan.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8a9cb0209..7a970b481 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -88,6 +88,8 @@ else() + else() + cmake_policy(SET CMP0048 NEW) + project(fastrtps VERSION "${LIB_VERSION_STR}" LANGUAGES C CXX) ++ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) ++ conan_basic_setup() + endif() + endif() + From 061712947770e729e70121e6704bf11635efee5d Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Sun, 23 May 2021 12:24:00 -0700 Subject: [PATCH 03/23] idk --- recipes/fast-dds/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 391d18539c787..7d489791de96b 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -57,7 +57,7 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC if self.options.shared: - self.options["fast-cdr"].shared = True + self.options["fast-cdr"].shared = False def _get_configured_cmake(self): if self._cmake: @@ -66,6 +66,7 @@ def _get_configured_cmake(self): self._cmake = CMake(self) self._cmake.definitions["BUILD_MEMORY_TOOLS"] = False self._cmake.definitions["NO_TLS"] = True + self._cmake.definitions["EPROSIMA_INSTALLER_MINION"] = False self._cmake.configure( source_dir = self._source_subfolder ) From fb234478648f3b8bc4299694e76ec1c3bd5d940f Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Mon, 24 May 2021 02:20:06 -0700 Subject: [PATCH 04/23] allow true --- recipes/fast-dds/all/conanfile.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 7d489791de96b..9a52b940a6e0e 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -57,7 +57,7 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC if self.options.shared: - self.options["fast-cdr"].shared = False + self.options["fast-cdr"].shared = True def _get_configured_cmake(self): if self._cmake: @@ -86,9 +86,6 @@ def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) - def imports(self): - self.copy("*") - def build(self): self._patch_sources() From 76921b472efd13ba2ec3db84f67eaf601a03a826 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Tue, 15 Jun 2021 11:14:59 -0700 Subject: [PATCH 05/23] add patches --- recipes/fast-dds/all/conanfile.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 9a52b940a6e0e..132b91800523e 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -25,6 +25,7 @@ class FastDDSConan(ConanFile): } generators = "cmake", "cmake_find_package" _cmake = None + exports_sources = ["patches/**"] @property def _pkg_cmake(self): @@ -56,8 +57,6 @@ def _source_subfolder(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self.options.shared: - self.options["fast-cdr"].shared = True def _get_configured_cmake(self): if self._cmake: @@ -76,7 +75,7 @@ def requirements(self): self.requires("tinyxml2/7.1.0") self.requires("asio/1.11.0@bincrafters/stable") self.requires("fast-cdr/1.0.21") - self.requires("foo-mem-ven/1.1.0") + self.requires("foonathan-memory/0.7.0") def _patch_sources(self): for patch in self.conan_data["patches"][self.version]: @@ -102,6 +101,8 @@ def package_info(self): self.cpp_info.names["cmake_find_multi_package"] = "fast-dds" self.cpp_info.libs = ["fastrtps"] self.cpp_info.requires = [ - "fastcdr::fastcdr", - "tinyxml2::tinyxml2" + "fast-cdr::fast-cdr", + "tinyxml2::tinyxml2", + "asio::asio", + "foonathan-memory::foonathan-memory" ] From 53c0bbaac4055831d6808c21a70c6a4ad5351ca3 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Wed, 16 Jun 2021 08:07:11 -0700 Subject: [PATCH 06/23] working status --- recipes/fast-dds/all/CMakeLists.txt | 7 + recipes/fast-dds/all/conandata.yml | 4 - recipes/fast-dds/all/conanfile.py | 119 ++++++---- .../all/patches/2.3.2-0001-add-conan.patch | 13 -- .../fast-dds/all/test_package/CMakeLists.txt | 7 + .../HelloWorldExample/CMakeLists.txt | 23 ++ .../HelloWorldExample/HelloWorld.cxx | 207 ++++++++++++++++++ .../HelloWorldExample/HelloWorld.h | 206 +++++++++++++++++ .../HelloWorldExample/HelloWorld.idl | 5 + .../HelloWorldPubSubTypes.cxx | 133 +++++++++++ .../HelloWorldExample/HelloWorldPubSubTypes.h | 57 +++++ .../HelloWorldExample/HelloWorldPublisher.cpp | 167 ++++++++++++++ .../HelloWorldExample/HelloWorldPublisher.h | 62 ++++++ .../HelloWorldSubscriber.cpp | 127 +++++++++++ .../HelloWorldExample/HelloWorldSubscriber.h | 87 ++++++++ .../HelloWorldExample/HelloWorld_main.cpp | 60 +++++ .../test_package/HelloWorldExample/Makefile | 102 +++++++++ .../fast-dds/all/test_package/conanfile.py | 17 ++ 18 files changed, 1347 insertions(+), 56 deletions(-) create mode 100644 recipes/fast-dds/all/CMakeLists.txt delete mode 100644 recipes/fast-dds/all/patches/2.3.2-0001-add-conan.patch create mode 100644 recipes/fast-dds/all/test_package/CMakeLists.txt create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.cxx create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.idl create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.cxx create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.h create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.cpp create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.h create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp create mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/Makefile create mode 100644 recipes/fast-dds/all/test_package/conanfile.py diff --git a/recipes/fast-dds/all/CMakeLists.txt b/recipes/fast-dds/all/CMakeLists.txt new file mode 100644 index 0000000000000..d17aaff199b4a --- /dev/null +++ b/recipes/fast-dds/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/fast-dds/all/conandata.yml b/recipes/fast-dds/all/conandata.yml index fb20ec39d1b29..1523e39f714d7 100644 --- a/recipes/fast-dds/all/conandata.yml +++ b/recipes/fast-dds/all/conandata.yml @@ -2,7 +2,3 @@ sources: "2.3.2": url: "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.3.2.tar.gz" sha256: "4D8183CF4D37C3DE9E6FD28D2850DD08023A9079001C4880B23C95F0D8C0B5CE" -patches: - "2.3.2": - - base_path: "source_subfolder" - patch_file: "patches/2.3.2-0001-add-conan.patch" \ No newline at end of file diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 132b91800523e..bab704982c935 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -5,104 +5,145 @@ from pathlib import Path import textwrap + class FastDDSConan(ConanFile): name = "fast-dds" license = "Apache-2.0" - version = "2.3.2" homepage = "https://fast-dds.docs.eprosima.com/" url = "https://github.com/conan-io/conan-center-index" - description = "The most complete DDS - Proven: Plenty of success cases." - topics = ("DDS","Middleware","IPC") + description = "The most complete OSS DDS implementation for embedded systems." + topics = ("DDS", "Middleware", "IPC") settings = "os", "compiler", "build_type", "arch" options = { "shared": [True, False], + "fPIC": [True, False], "with_ssl": [True, False] } default_options = { - "shared": True, + "shared": False, + "fPIC": True, "with_ssl": False } generators = "cmake", "cmake_find_package" _cmake = None - exports_sources = ["patches/**"] + exports_sources = ["CMakeLists.txt"] @property - def _pkg_cmake(self): + def _pkg_share(self): return os.path.join( self.package_folder, - "lib", - "foonathan_memory", - "cmake" + "share" ) - + @property - def _pkg_lib(self): + def _pkg_tools(self): return os.path.join( self.package_folder, - "lib" + "tools" ) @property - def _pkg_share(self): + def _pkg_bin(self): return os.path.join( self.package_folder, - "share" + "bin" ) @property def _source_subfolder(self): return "source_subfolder" + def configure(self): + if self.options.shared: + del self.options.fPIC + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - - def _get_configured_cmake(self): - if self._cmake: - pass - else: - self._cmake = CMake(self) - self._cmake.definitions["BUILD_MEMORY_TOOLS"] = False - self._cmake.definitions["NO_TLS"] = True - self._cmake.definitions["EPROSIMA_INSTALLER_MINION"] = False - self._cmake.configure( - source_dir = self._source_subfolder - ) + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self) + self._cmake.definitions["BUILD_MEMORY_TOOLS"] = False + self._cmake.definitions["NO_TLS"] = not self.options.with_ssl + self._cmake.definitions["SECURITY"] = self.options.with_ssl + self._cmake.definitions["EPROSIMA_INSTALLER_MINION"] = False + self._cmake.configure() return self._cmake def requirements(self): self.requires("tinyxml2/7.1.0") - self.requires("asio/1.11.0@bincrafters/stable") + self.requires("asio/1.18.2") self.requires("fast-cdr/1.0.21") self.requires("foonathan-memory/0.7.0") - - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + if self.options.with_ssl: + self.requires("openssl/1.1.1k") def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def build(self): - self._patch_sources() - - cmake = self._get_configured_cmake() + cmake = self._configure_cmake() cmake.build() def package(self): - cmake = self._get_configured_cmake() + cmake = self._configure_cmake() cmake.install() + tools.rmdir(self._pkg_share) + # tmp because you cannot move bin to bin/discovery directly + tools.mkdir(os.path.join(self.package_folder,"tmp")) + tools.rename( + src=self._pkg_bin, + dst=os.path.join(self.package_folder,"tmp","discovery") + ) + tools.mkdir(self._pkg_bin) + tools.rename( + src=os.path.join(self.package_folder,"tmp","discovery"), + dst=os.path.join(self._pkg_bin,"discovery") + ) + tools.rmdir(os.path.join(self.package_folder,"tmp")) + tools.rename( + src=self._pkg_tools, + dst=os.path.join(self._pkg_bin,"tools") + ) self.copy("LICENSE", src=self._source_subfolder, dst="licenses") def package_info(self): - self.cpp_info.names["cmake_find_package"] = "fast-dds" - self.cpp_info.names["cmake_find_multi_package"] = "fast-dds" - self.cpp_info.libs = ["fastrtps"] - self.cpp_info.requires = [ + self.cpp_info.names["cmake_find_package"] = "fastdds" + self.cpp_info.names["cmake_find_multi_package"] = "fastdds" + # component fastrtps + self.cpp_info.components["fastrtps"].name = "fastrtps" + self.cpp_info.components["fastrtps"].libs = ["fastrtps"] + self.cpp_info.components["fastrtps"].requires = [ "fast-cdr::fast-cdr", "tinyxml2::tinyxml2", "asio::asio", "foonathan-memory::foonathan-memory" ] + self.cpp_info.components["fastrtps"].system_libs = [ + "pthread", + "rt", + "dl" + ] + # component fast-discovery + self.cpp_info.components["fast-discovery"].name = "fast-discovery" + self.cpp_info.components["fast-discovery"].requires = [ + "fastrtps" + ] + if self.settings.os in ["Linux","Macos","Neutrino"]: + self.cpp_info.components["fast-discovery"].system_libs = [ + "pthread", + "rt" + ] + self.cpp_info.components["fast-discovery"].bindirs = [os.path.join("bin","discovery")] + bin_path = os.path.join(self.package_folder, "bin","discovery") + self.output.info("Appending PATH env var for fast-dds::fast-discovery with : {}".format(bin_path)), + self.env_info.PATH.append(bin_path) + # component tools + self.cpp_info.components["tools"].name = "tools" + self.cpp_info.components["tools"].bindirs = [os.path.join("bin","tools")] + bin_path = os.path.join(self.package_folder, "bin","tools") + self.output.info("Appending PATH env var for fast-dds::tools with : {}".format(bin_path)), + self.env_info.PATH.append(bin_path) diff --git a/recipes/fast-dds/all/patches/2.3.2-0001-add-conan.patch b/recipes/fast-dds/all/patches/2.3.2-0001-add-conan.patch deleted file mode 100644 index 09eccdb11c55c..0000000000000 --- a/recipes/fast-dds/all/patches/2.3.2-0001-add-conan.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8a9cb0209..7a970b481 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -88,6 +88,8 @@ else() - else() - cmake_policy(SET CMP0048 NEW) - project(fastrtps VERSION "${LIB_VERSION_STR}" LANGUAGES C CXX) -+ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -+ conan_basic_setup() - endif() - endif() - diff --git a/recipes/fast-dds/all/test_package/CMakeLists.txt b/recipes/fast-dds/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..27d0159d8d5c4 --- /dev/null +++ b/recipes/fast-dds/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(HelloWorldExample) diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt b/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt new file mode 100644 index 0000000000000..2c97cfe1344ea --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +find_package(fastcdr REQUIRED) +find_package(foonathan_memory REQUIRED) +find_package(fastdds REQUIRED) + +file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CXX "*.cxx") +file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CPP "*.cpp") + +add_executable(test_package ${HELLOWORLD_EXAMPLE_SOURCES_CXX} ${HELLOWORLD_EXAMPLE_SOURCES_CPP}) +target_link_libraries(test_package fastdds::fastrtps) diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.cxx b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.cxx new file mode 100644 index 0000000000000..b850b450127bf --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.cxx @@ -0,0 +1,207 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "HelloWorld.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +HelloWorld::HelloWorld() +{ + // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@1622f1b + m_index = 0; + // m_message com.eprosima.idl.parser.typecode.StringTypeCode@70e8f8e + m_message =""; + +} + +HelloWorld::~HelloWorld() +{ + + +} + +HelloWorld::HelloWorld(const HelloWorld &x) +{ + m_index = x.m_index; + m_message = x.m_message; +} + +HelloWorld::HelloWorld(HelloWorld &&x) +{ + m_index = x.m_index; + m_message = std::move(x.m_message); +} + +HelloWorld& HelloWorld::operator=(const HelloWorld &x) +{ + + m_index = x.m_index; + m_message = x.m_message; + + return *this; +} + +HelloWorld& HelloWorld::operator=(HelloWorld &&x) +{ + + m_index = x.m_index; + m_message = std::move(x.m_message); + + return *this; +} + +size_t HelloWorld::getMaxCdrSerializedSize(size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1; + + + return current_alignment - initial_alignment; +} + +size_t HelloWorld::getCdrSerializedSize(const HelloWorld& data, size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; + + + return current_alignment - initial_alignment; +} + +void HelloWorld::serialize(eprosima::fastcdr::Cdr &scdr) const +{ + + scdr << m_index; + scdr << m_message; +} + +void HelloWorld::deserialize(eprosima::fastcdr::Cdr &dcdr) +{ + + dcdr >> m_index; + dcdr >> m_message; +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void HelloWorld::index(uint32_t _index) +{ +m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t HelloWorld::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& HelloWorld::index() +{ + return m_index; +} + +/*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ +void HelloWorld::message(const std::string &_message) +{ +m_message = _message; +} + +/*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ +void HelloWorld::message(std::string &&_message) +{ +m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::string& HelloWorld::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::string& HelloWorld::message() +{ + return m_message; +} + +size_t HelloWorld::getKeyMaxCdrSerializedSize(size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool HelloWorld::isKeyDefined() +{ + return false; +} + +void HelloWorld::serializeKey(eprosima::fastcdr::Cdr &scdr) const +{ + (void) scdr; + + +} diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h new file mode 100644 index 0000000000000..5b94c7c9dc81b --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h @@ -0,0 +1,206 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _HELLOWORLD_H_ +#define _HELLOWORLD_H_ + +// TODO Poner en el contexto. + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif +#else +#define eProsima_user_DllExport +#endif + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(HelloWorld_SOURCE) +#define HelloWorld_DllAPI __declspec( dllexport ) +#else +#define HelloWorld_DllAPI __declspec( dllimport ) +#endif // HelloWorld_SOURCE +#else +#define HelloWorld_DllAPI +#endif +#else +#define HelloWorld_DllAPI +#endif // _WIN32 + +namespace eprosima +{ + namespace fastcdr + { + class Cdr; + } +} + + +/*! + * @brief This class represents the structure HelloWorld defined by the user in the IDL file. + * @ingroup HELLOWORLD + */ +class HelloWorld +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport HelloWorld(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~HelloWorld(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld(const HelloWorld &x); + + /*! + * @brief Move constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld(HelloWorld &&x); + + /*! + * @brief Copy assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator=(const HelloWorld &x); + + /*! + * @brief Move assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator=(HelloWorld &&x); + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index(uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message(const std::string &_message); + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message(std::string &&_message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::string& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::string& message(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize(size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize(const HelloWorld& data, size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const; + +private: + uint32_t m_index; + std::string m_message; +}; + +#endif // _HELLOWORLD_H_ \ No newline at end of file diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.idl b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.idl new file mode 100644 index 0000000000000..0fd2c355aeefa --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.idl @@ -0,0 +1,5 @@ +struct HelloWorld +{ + unsigned long index; + string message; +}; diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.cxx b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.cxx new file mode 100644 index 0000000000000..89e89cc8581e8 --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.cxx @@ -0,0 +1,133 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "HelloWorldPubSubTypes.h" + +using namespace eprosima::fastrtps; +using namespace eprosima::fastrtps::rtps; + +HelloWorldPubSubType::HelloWorldPubSubType() +{ + setName("HelloWorld"); + m_typeSize = static_cast(HelloWorld::getMaxCdrSerializedSize()) + 4 /*encapsulation*/; + m_isGetKeyDefined = HelloWorld::isKeyDefined(); + size_t keyLength = HelloWorld::getKeyMaxCdrSerializedSize()>16 ? HelloWorld::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +HelloWorldPubSubType::~HelloWorldPubSubType() +{ + if(m_keyBuffer!=nullptr) + free(m_keyBuffer); +} + +bool HelloWorldPubSubType::serialize(void *data, SerializedPayload_t *payload) +{ + HelloWorld *p_type = static_cast(data); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + p_type->serialize(ser); // Serialize the object: + } + catch(eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + payload->length = static_cast(ser.getSerializedDataLength()); //Get the serialized length + return true; +} + +bool HelloWorldPubSubType::deserialize(SerializedPayload_t* payload, void* data) +{ + HelloWorld* p_type = static_cast(data); //Convert DATA to pointer of your type + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + try + { + p_type->deserialize(deser); //Deserialize the object: + } + catch(eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function HelloWorldPubSubType::getSerializedSizeProvider(void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4 /*encapsulation*/; + }; +} + +void* HelloWorldPubSubType::createData() +{ + return reinterpret_cast(new HelloWorld()); +} + +void HelloWorldPubSubType::deleteData(void* data) +{ + delete(reinterpret_cast(data)); +} + +bool HelloWorldPubSubType::getKey(void *data, InstanceHandle_t* handle, bool force_md5) +{ + if(!m_isGetKeyDefined) + return false; + HelloWorld* p_type = static_cast(data); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer),HelloWorld::getKeyMaxCdrSerializedSize()); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); // Object that serializes the data. + p_type->serializeKey(ser); + if(force_md5 || HelloWorld::getKeyMaxCdrSerializedSize()>16) { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for(uint8_t i = 0;i<16;++i) { + handle->value[i] = m_md5.digest[i]; + } + } + else { + for(uint8_t i = 0;i<16;++i) { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h new file mode 100644 index 0000000000000..c5576f0437c1a --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h @@ -0,0 +1,57 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _HELLOWORLD_PUBSUBTYPES_H_ +#define _HELLOWORLD_PUBSUBTYPES_H_ + +#include +#include + +#include "HelloWorld.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error Generated HelloWorld is not compatible with current installed Fast-RTPS. Please, regenerate it with fastrtpsgen. +#endif + +/*! + * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. + * @ingroup HELLOWORLD + */ +class HelloWorldPubSubType : public eprosima::fastrtps::TopicDataType { +public: + typedef HelloWorld type; + + eProsima_user_DllExport HelloWorldPubSubType(); + + eProsima_user_DllExport virtual ~HelloWorldPubSubType(); + eProsima_user_DllExport virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override; + eProsima_user_DllExport virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override; + eProsima_user_DllExport virtual std::function getSerializedSizeProvider(void* data) override; + eProsima_user_DllExport virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle, + bool force_md5 = false) override; + eProsima_user_DllExport virtual void* createData() override; + eProsima_user_DllExport virtual void deleteData(void * data) override; + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _HELLOWORLD_PUBSUBTYPES_H_ \ No newline at end of file diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp new file mode 100644 index 0000000000000..19117e460a63f --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp @@ -0,0 +1,167 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file HelloWorldPublisher.cpp + * + */ + +#include "HelloWorldPublisher.h" +#include +#include +#include +#include +#include + +#include + +using namespace eprosima::fastrtps; +using namespace eprosima::fastrtps::rtps; + +HelloWorldPublisher::HelloWorldPublisher() + : mp_participant(nullptr) + , mp_publisher(nullptr) +{ +} + +bool HelloWorldPublisher::init() +{ + m_Hello.index(0); + m_Hello.message("HelloWorld"); + ParticipantAttributes PParam; + PParam.rtps.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SIMPLE; + PParam.rtps.builtin.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = true; + PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter = true; + PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationWriterANDSubscriptionReader = true; + PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite; + PParam.rtps.setName("Participant_pub"); + mp_participant = Domain::createParticipant(PParam); + + if (mp_participant == nullptr) + { + return false; + } + //REGISTER THE TYPE + + Domain::registerType(mp_participant, &m_type); + + //CREATE THE PUBLISHER + PublisherAttributes Wparam; + Wparam.topic.topicKind = NO_KEY; + Wparam.topic.topicDataType = "HelloWorld"; + Wparam.topic.topicName = "HelloWorldTopic"; + Wparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS; + Wparam.topic.historyQos.depth = 30; + Wparam.topic.resourceLimitsQos.max_samples = 50; + Wparam.topic.resourceLimitsQos.allocated_samples = 20; + Wparam.times.heartbeatPeriod.seconds = 2; + Wparam.times.heartbeatPeriod.nanosec = 200 * 1000 * 1000; + Wparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS; + mp_publisher = Domain::createPublisher(mp_participant, Wparam, (PublisherListener*)&m_listener); + if (mp_publisher == nullptr) + { + return false; + } + + return true; + +} + +HelloWorldPublisher::~HelloWorldPublisher() +{ + // TODO Auto-generated destructor stub + Domain::removeParticipant(mp_participant); +} + +void HelloWorldPublisher::PubListener::onPublicationMatched( + Publisher* /*pub*/, + MatchingInfo& info) +{ + if (info.status == MATCHED_MATCHING) + { + n_matched++; + firstConnected = true; + std::cout << "Publisher matched" << std::endl; + } + else + { + n_matched--; + std::cout << "Publisher unmatched" << std::endl; + } +} + +void HelloWorldPublisher::runThread( + uint32_t samples, + uint32_t sleep) +{ + if (samples == 0) + { + while (!stop) + { + if (publish(false)) + { + std::cout << "Message: " << m_Hello.message() << " with index: " << m_Hello.index() << " SENT" << + std::endl; + } + std::this_thread::sleep_for(std::chrono::milliseconds(sleep)); + } + } + else + { + for (uint32_t i = 0; i < samples; ++i) + { + if (!publish()) + { + --i; + } + else + { + std::cout << "Message: " << m_Hello.message() << " with index: " << m_Hello.index() << " SENT" << + std::endl; + } + std::this_thread::sleep_for(std::chrono::milliseconds(sleep)); + } + } +} + +void HelloWorldPublisher::run( + uint32_t samples, + uint32_t sleep) +{ + stop = false; + std::thread thread(&HelloWorldPublisher::runThread, this, samples, sleep); + if (samples == 0) + { + std::cout << "Publisher running. Please press enter to stop the Publisher at any time." << std::endl; + std::cin.ignore(); + stop = true; + } + else + { + std::cout << "Publisher running " << samples << " samples." << std::endl; + } + thread.join(); +} + +bool HelloWorldPublisher::publish( + bool waitForListener) +{ + if (m_listener.firstConnected || !waitForListener || m_listener.n_matched > 0) + { + m_Hello.index(m_Hello.index() + 1); + mp_publisher->write((void*)&m_Hello); + return true; + } + return false; +} diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.h b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.h new file mode 100644 index 0000000000000..a863ae25a0d3b --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.h @@ -0,0 +1,62 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file HelloWorldPublisher.h + * + */ + +#ifndef HELLOWORLDPUBLISHER_H_ +#define HELLOWORLDPUBLISHER_H_ + +#include "HelloWorldPubSubTypes.h" + +#include +#include +#include + + +#include "HelloWorld.h" + +class HelloWorldPublisher { +public: + HelloWorldPublisher(); + virtual ~HelloWorldPublisher(); + //!Initialize + bool init(); + //!Publish a sample + bool publish(bool waitForListener = true); + //!Run for number samples + void run(uint32_t number, uint32_t sleep); +private: + HelloWorld m_Hello; + eprosima::fastrtps::Participant* mp_participant; + eprosima::fastrtps::Publisher* mp_publisher; + bool stop; + class PubListener:public eprosima::fastrtps::PublisherListener + { + public: + PubListener():n_matched(0),firstConnected(false){}; + ~PubListener(){}; + void onPublicationMatched(eprosima::fastrtps::Publisher* pub, eprosima::fastrtps::rtps::MatchingInfo& info); + int n_matched; + bool firstConnected; + }m_listener; + void runThread(uint32_t number, uint32_t sleep); + HelloWorldPubSubType m_type; +}; + + + +#endif /* HELLOWORLDPUBLISHER_H_ */ diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.cpp new file mode 100644 index 0000000000000..80bf66f05b9b5 --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.cpp @@ -0,0 +1,127 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file HelloWorldSubscriber.cpp + * + */ + +#include "HelloWorldSubscriber.h" +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps; +using namespace eprosima::fastrtps::rtps; + +HelloWorldSubscriber::HelloWorldSubscriber() + : mp_participant(nullptr) + , mp_subscriber(nullptr) +{ +} + +bool HelloWorldSubscriber::init() +{ + ParticipantAttributes PParam; + PParam.rtps.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SIMPLE; + PParam.rtps.builtin.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = true; + PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter = true; + PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationWriterANDSubscriptionReader = true; + PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite; + PParam.rtps.setName("Participant_sub"); + mp_participant = Domain::createParticipant(PParam); + if (mp_participant == nullptr) + { + return false; + } + + //REGISTER THE TYPE + + Domain::registerType(mp_participant, &m_type); + //CREATE THE SUBSCRIBER + SubscriberAttributes Rparam; + Rparam.topic.topicKind = NO_KEY; + Rparam.topic.topicDataType = "HelloWorld"; + Rparam.topic.topicName = "HelloWorldTopic"; + Rparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS; + Rparam.topic.historyQos.depth = 30; + Rparam.topic.resourceLimitsQos.max_samples = 50; + Rparam.topic.resourceLimitsQos.allocated_samples = 20; + Rparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS; + Rparam.qos.m_durability.kind = TRANSIENT_LOCAL_DURABILITY_QOS; + mp_subscriber = Domain::createSubscriber(mp_participant, Rparam, (SubscriberListener*)&m_listener); + + if (mp_subscriber == nullptr) + { + return false; + } + + + return true; +} + +HelloWorldSubscriber::~HelloWorldSubscriber() +{ + // TODO Auto-generated destructor stub + Domain::removeParticipant(mp_participant); +} + +void HelloWorldSubscriber::SubListener::onSubscriptionMatched( + Subscriber* /*sub*/, + MatchingInfo& info) +{ + if (info.status == MATCHED_MATCHING) + { + n_matched++; + std::cout << "Subscriber matched" << std::endl; + } + else + { + n_matched--; + std::cout << "Subscriber unmatched" << std::endl; + } +} + +void HelloWorldSubscriber::SubListener::onNewDataMessage( + Subscriber* sub) +{ + if (sub->takeNextData((void*)&m_Hello, &m_info)) + { + if (m_info.sampleKind == ALIVE) + { + this->n_samples++; + // Print your structure data here. + std::cout << "Message " << m_Hello.message() << " " << m_Hello.index() << " RECEIVED" << std::endl; + } + } + +} + +void HelloWorldSubscriber::run() +{ + std::cout << "Subscriber running. Please press enter to stop the Subscriber" << std::endl; + std::cin.ignore(); +} + +void HelloWorldSubscriber::run( + uint32_t number) +{ + std::cout << "Subscriber running until " << number << "samples have been received" << std::endl; + while (number > this->m_listener.n_samples) + { + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } +} diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.h b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.h new file mode 100644 index 0000000000000..2d0f4b09e1dc3 --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.h @@ -0,0 +1,87 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file HelloWorldSubscriber.h + * + */ + +#ifndef HELLOWORLDSUBSCRIBER_H_ +#define HELLOWORLDSUBSCRIBER_H_ + +#include "HelloWorldPubSubTypes.h" + +#include +#include +#include +#include + + + + +#include "HelloWorld.h" + +class HelloWorldSubscriber +{ +public: + + HelloWorldSubscriber(); + virtual ~HelloWorldSubscriber(); + //!Initialize the subscriber + bool init(); + //!RUN the subscriber + void run(); + //!Run the subscriber until number samples have been received. + void run( + uint32_t number); + +private: + + eprosima::fastrtps::Participant* mp_participant; + eprosima::fastrtps::Subscriber* mp_subscriber; + +public: + + class SubListener : public eprosima::fastrtps::SubscriberListener + { + public: + + SubListener() + : n_matched(0) + , n_samples(0) + { + } + + ~SubListener() + { + } + + void onSubscriptionMatched( + eprosima::fastrtps::Subscriber* sub, + eprosima::fastrtps::rtps::MatchingInfo& info); + void onNewDataMessage( + eprosima::fastrtps::Subscriber* sub); + HelloWorld m_Hello; + eprosima::fastrtps::SampleInfo_t m_info; + int n_matched; + uint32_t n_samples; + } + m_listener; + +private: + + HelloWorldPubSubType m_type; +}; + +#endif /* HELLOWORLDSUBSCRIBER_H_ */ diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp new file mode 100644 index 0000000000000..69ded07de7dfb --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp @@ -0,0 +1,60 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file HelloWorld_main.cpp + * + */ + +#include "HelloWorldPublisher.h" +#include "HelloWorldSubscriber.h" + +#include +#include + +using namespace eprosima; +using namespace fastrtps; +using namespace rtps; +int main(int argc, char **argv) +{ + std::cout << "Starting " << std::endl; + int type = 1; + int count = 1; + long sleep = 1; + + switch (type) + { + case 1: + { + HelloWorldPublisher mypub; + if (mypub.init()) + { + mypub.run(count, sleep); + } + break; + } + case 2: + { + HelloWorldSubscriber mysub; + if (mysub.init()) + { + mysub.run(); + } + break; + } + } + Domain::stopAll(); + Log::Reset(); + return 0; +} diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/Makefile b/recipes/fast-dds/all/test_package/HelloWorldExample/Makefile new file mode 100644 index 0000000000000..615002f781d84 --- /dev/null +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/Makefile @@ -0,0 +1,102 @@ +# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +CPP=g++ +LN=g++ +AR=ar +CP=cp +SYSLIBS= -ldl -lnsl -lm -lpthread -lrt +DEFINES= +COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11 + +## CHOOSE HERE BETWEEN 32 and 64 bit architecture + +##32 BIT ARCH: +#COMMON_CFLAGS+= -m32 -fpic +#LDFLAGS=-m32 + +#64BIT ARCH: +COMMON_CFLAGS+= -m64 -fpic +LDFLAGS=-m64 + +CFLAGS = $(COMMON_CFLAGS) -O2 + +INCLUDES= -I. + +LIBS = -lfastcdr -lfastrtps $(shell test -x "$$(which pkg-config)" && pkg-config libssl libcrypto --libs --silence-errors) $(SYSLIBS) + +DIRECTORIES= output.dir bin.dir + +all: $(DIRECTORIES) HelloWorldExample + +HELLOWORLDEXAMPLE_TARGET= bin/HelloWorldExample + +HELLOWORLDEXAMPLE_SRC_CXXFILES= + +HELLOWORLDEXAMPLE_SRC_CPPFILES= HelloWorldExample/HelloWorld.cxx \ + HelloWorldExample/HelloWorldPubSubTypes.cxx \ + HelloWorldExample/HelloWorldPublisher.cpp \ + HelloWorldExample/HelloWorldSubscriber.cpp \ + HelloWorldExample/HelloWorld_main.cpp + + +# Project sources are copied to the current directory +HELLOWORLDEXAMPLE_SRCS= $(HELLOWORLDEXAMPLE_SRC_CXXFILES) $(HELLOWORLDEXAMPLE_SRC_CPPFILES) + +# Source directories +HELLOWORLDEXAMPLE_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(HELLOWORLDEXAMPLE_SRCS)), $(srcdir)) +HELLOWORLDEXAMPLE_SOURCES_DIRS= $(shell echo $(HELLOWORLDEXAMPLE_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ") + +HELLOWORLDEXAMPLE_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(HELLOWORLDEXAMPLE_SRCS))), output/$(obj)) +HELLOWORLDEXAMPLE_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(HELLOWORLDEXAMPLE_SRCS))), output/$(dep)) + +OBJS+= $(HELLOWORLDEXAMPLE_OBJS) +DEPS+= $(HELLOWORLDEXAMPLE_DEPS) + +HelloWorldExample: $(HELLOWORLDEXAMPLE_TARGET) + +$(HELLOWORLDEXAMPLE_TARGET): $(HELLOWORLDEXAMPLE_OBJS) + $(LN) $(LDFLAGS) -o $(HELLOWORLDEXAMPLE_TARGET) $(HELLOWORLDEXAMPLE_OBJS) $(LIBS) + +vpath %.cxx $(HELLOWORLDEXAMPLE_SOURCES_DIRS) +vpath %.cpp $(HELLOWORLDEXAMPLE_SOURCES_DIRS) + +output/%.cxx.o:%.cxx + @echo Calculating dependencies $< + @$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d) + @echo Compiling $< + @$(CC) $(CFLAGS) $(INCLUDES) $< -o $@ + +output/%.cpp.o:%.cpp + @echo Calculating dependencies $< + @$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d) + @echo Compiling $< + @$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@ + +.PHONY: HelloWorldExample + +clean: + @rm -f $(OBJS) + @rm -f $(DEPS) + +ifneq ($(MAKECMDGOALS), clean) +-include $(DEPS) +endif + +%.dir : + @echo "Checking directory $*" + @if [ ! -d $* ]; then \ + echo "Making directory $*"; \ + mkdir -p $* ; \ + fi; diff --git a/recipes/fast-dds/all/test_package/conanfile.py b/recipes/fast-dds/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1d0bdd3779793 --- /dev/null +++ b/recipes/fast-dds/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) From aef792de74d0d521cda36a34e00231fa6a7a6e8a Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Wed, 16 Jun 2021 11:38:02 -0700 Subject: [PATCH 07/23] without args --- .../HelloWorldExample/HelloWorldPublisher.cpp | 2 +- .../HelloWorldExample/HelloWorld_main.cpp | 65 +++++++++++++------ 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp index 19117e460a63f..00a0a5d087120 100644 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp @@ -121,7 +121,7 @@ void HelloWorldPublisher::runThread( { for (uint32_t i = 0; i < samples; ++i) { - if (!publish()) + if (!publish(false)) { --i; } diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp index 69ded07de7dfb..268360fc5f8d3 100644 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp @@ -26,33 +26,60 @@ using namespace eprosima; using namespace fastrtps; using namespace rtps; -int main(int argc, char **argv) +int main() { - std::cout << "Starting " << std::endl; - int type = 1; - int count = 1; - long sleep = 1; + std::cout << "Starting "<< std::endl; + + int argc = 2; + const char *argv[2] = {"", "subscribe"}; - switch (type) - { - case 1: + int type = 1; + int count = 10; + long sleep = 100; + if(argc > 1) { - HelloWorldPublisher mypub; - if (mypub.init()) + if(strcmp(argv[1],"publisher")==0) { - mypub.run(count, sleep); + type = 1; + if (argc >= 3) + { + count = atoi(argv[2]); + if (argc == 4) + { + sleep = atoi(argv[3]); + } + } } - break; + else if(strcmp(argv[1],"subscriber")==0) + type = 2; } - case 2: + else { - HelloWorldSubscriber mysub; - if (mysub.init()) - { - mysub.run(); - } - break; + std::cout << "publisher OR subscriber argument needed" << std::endl; + Log::Reset(); + return 0; } + + switch(type) + { + case 1: + { + HelloWorldPublisher mypub; + if(mypub.init()) + { + mypub.run(count, sleep); + } + break; + } + case 2: + { + HelloWorldSubscriber mysub; + if(mysub.init()) + { + mysub.run(); + } + break; + } } Domain::stopAll(); Log::Reset(); From d7e70881ce3132783521cb7ac3807ce3892ff214 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Thu, 17 Jun 2021 12:11:33 -0700 Subject: [PATCH 08/23] add fix for find package in containers --- recipes/fast-dds/all/conandata.yml | 4 +++ recipes/fast-dds/all/conanfile.py | 12 ++++++-- ....3.2-0001-fix-find-asio-and-tinyxml2.patch | 28 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 recipes/fast-dds/all/patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch diff --git a/recipes/fast-dds/all/conandata.yml b/recipes/fast-dds/all/conandata.yml index 1523e39f714d7..87b1380fe91ab 100644 --- a/recipes/fast-dds/all/conandata.yml +++ b/recipes/fast-dds/all/conandata.yml @@ -2,3 +2,7 @@ sources: "2.3.2": url: "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.3.2.tar.gz" sha256: "4D8183CF4D37C3DE9E6FD28D2850DD08023A9079001C4880B23C95F0D8C0B5CE" +patches: + "2.3.2": + - base_path: "source_subfolder" + patch_file: "patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch" diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index bab704982c935..d29289d5f13d8 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -27,7 +27,7 @@ class FastDDSConan(ConanFile): } generators = "cmake", "cmake_find_package" _cmake = None - exports_sources = ["CMakeLists.txt"] + exports_sources = ["patches/*","CMakeLists.txt"] @property def _pkg_share(self): @@ -54,6 +54,10 @@ def _pkg_bin(self): def _source_subfolder(self): return "source_subfolder" + def _patch_sources(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + def configure(self): if self.options.shared: del self.options.fPIC @@ -85,6 +89,7 @@ def source(self): destination=self._source_subfolder) def build(self): + self._patch_sources() cmake = self._configure_cmake() cmake.build() @@ -118,8 +123,8 @@ def package_info(self): self.cpp_info.components["fastrtps"].libs = ["fastrtps"] self.cpp_info.components["fastrtps"].requires = [ "fast-cdr::fast-cdr", - "tinyxml2::tinyxml2", "asio::asio", + "tinyxml2::tinyxml2", "foonathan-memory::foonathan-memory" ] self.cpp_info.components["fastrtps"].system_libs = [ @@ -130,7 +135,8 @@ def package_info(self): # component fast-discovery self.cpp_info.components["fast-discovery"].name = "fast-discovery" self.cpp_info.components["fast-discovery"].requires = [ - "fastrtps" + "fastrtps", + "tinyxml2::tinyxml2", ] if self.settings.os in ["Linux","Macos","Neutrino"]: self.cpp_info.components["fast-discovery"].system_libs = [ diff --git a/recipes/fast-dds/all/patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch b/recipes/fast-dds/all/patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch new file mode 100644 index 0000000000000..4530f0222378b --- /dev/null +++ b/recipes/fast-dds/all/patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch @@ -0,0 +1,28 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8a9cb0209..400c681e7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -225,8 +225,8 @@ if(NOT BUILD_SHARED_LIBS) + endif() + + eprosima_find_package(fastcdr REQUIRED) +-eprosima_find_thirdparty(Asio asio VERSION 1.10.8) +-eprosima_find_thirdparty(TinyXML2 tinyxml2) ++eprosima_find_thirdparty(asio REQUIRED) ++eprosima_find_thirdparty(tinyxml2 REQUIRED) + + find_package(foonathan_memory REQUIRED) + message(STATUS "Found foonathan_memory: ${foonathan_memory_DIR}") +diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt +index 04d313bf2..c7d64f04d 100644 +--- a/src/cpp/CMakeLists.txt ++++ b/src/cpp/CMakeLists.txt +@@ -455,7 +455,7 @@ elseif(NOT EPROSIMA_INSTALLER) + # Link library to external libraries. + target_link_libraries(${PROJECT_NAME} ${PRIVACY} fastcdr foonathan_memory + ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} +- ${TINYXML2_LIBRARY} ++ tinyxml2::tinyxml2 + $<$:OpenSSL::SSL$OpenSSL::Crypto> + $<$:iphlpapi$Shlwapi> + ${THIRDPARTY_BOOST_LINK_LIBS} From 2e2faf4f72f6cb1d8902b752490d7519197796c1 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 01:31:39 -0700 Subject: [PATCH 09/23] added alias --- recipes/fast-dds/all/conanfile.py | 46 ++++++++++++++++--- .../HelloWorldExample/CMakeLists.txt | 3 +- .../HelloWorldExample/HelloWorld_main.cpp | 2 +- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index d29289d5f13d8..d823f6e473372 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -50,6 +50,32 @@ def _pkg_bin(self): "bin" ) + @property + def _module_subfolder(self): + return os.path.join( + "lib", + "cmake" + ) + + @property + def _module_file_rel_path(self): + return os.path.join( + self._module_subfolder, + "conan-target-properties.cmake" + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + @property def _source_subfolder(self): return "source_subfolder" @@ -114,24 +140,32 @@ def package(self): dst=os.path.join(self._pkg_bin,"tools") ) self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"fastrtps": "fastdds::fastrtps"} + ) def package_info(self): self.cpp_info.names["cmake_find_package"] = "fastdds" self.cpp_info.names["cmake_find_multi_package"] = "fastdds" # component fastrtps self.cpp_info.components["fastrtps"].name = "fastrtps" - self.cpp_info.components["fastrtps"].libs = ["fastrtps"] + self.cpp_info.components["fastrtps"].libs = tools.collect_libs(self) self.cpp_info.components["fastrtps"].requires = [ "fast-cdr::fast-cdr", "asio::asio", "tinyxml2::tinyxml2", "foonathan-memory::foonathan-memory" ] - self.cpp_info.components["fastrtps"].system_libs = [ - "pthread", - "rt", - "dl" - ] + if self.settings.os in ["Linux","Macos","Neutrino"]: + self.cpp_info.components["fastrtps"].system_libs = [ + "pthread", + "rt", + "dl" + ] + self.cpp_info.components["fastrtps"].builddirs.append(self._module_subfolder) + self.cpp_info.components["fastrtps"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["fastrtps"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] # component fast-discovery self.cpp_info.components["fast-discovery"].name = "fast-discovery" self.cpp_info.components["fast-discovery"].requires = [ diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt b/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt index 2c97cfe1344ea..50d99519836e5 100644 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt @@ -20,4 +20,5 @@ file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CXX "*.cxx") file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CPP "*.cpp") add_executable(test_package ${HELLOWORLD_EXAMPLE_SOURCES_CXX} ${HELLOWORLD_EXAMPLE_SOURCES_CPP}) -target_link_libraries(test_package fastdds::fastrtps) +# validate the alias +target_link_libraries(test_package fastrtps) diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp index 268360fc5f8d3..108719be20ad2 100644 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp @@ -34,7 +34,7 @@ int main() const char *argv[2] = {"", "subscribe"}; int type = 1; - int count = 10; + int count = 9; long sleep = 100; if(argc > 1) { From 75e8e402dda28ca72fcbc5f76c643ed4edc58ab0 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 01:37:41 -0700 Subject: [PATCH 10/23] link against windows system libs --- recipes/fast-dds/all/conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index d823f6e473372..947c2a3adca57 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -163,6 +163,11 @@ def package_info(self): "rt", "dl" ] + elif self.settings.os == "Windows": + self.cpp_info.components["fastrtps"].system_libs = [ + "iphlpapi", + "shlwapi" + ] self.cpp_info.components["fastrtps"].builddirs.append(self._module_subfolder) self.cpp_info.components["fastrtps"].build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.components["fastrtps"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] From 2857abd69557bd256fd6a6b02974a2cc41e896dd Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 05:39:51 -0700 Subject: [PATCH 11/23] changed for hooks --- .../all/test_package/HelloWorldExample/CMakeLists.txt | 4 ++-- .../fast-dds/all/test_package/HelloWorldExample/HelloWorld.h | 2 +- .../test_package/HelloWorldExample/HelloWorldPubSubTypes.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt b/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt index 50d99519836e5..477113c6f080a 100644 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -find_package(fastcdr REQUIRED) -find_package(foonathan_memory REQUIRED) +cmake_minimum_required(VERSION 3.1) + find_package(fastdds REQUIRED) file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CXX "*.cxx") diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h index 5b94c7c9dc81b..380f487456147 100644 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h @@ -203,4 +203,4 @@ class HelloWorld std::string m_message; }; -#endif // _HELLOWORLD_H_ \ No newline at end of file +#endif // _HELLOWORLD_H_ diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h index c5576f0437c1a..7afa612cc5925 100644 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h +++ b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h @@ -54,4 +54,4 @@ class HelloWorldPubSubType : public eprosima::fastrtps::TopicDataType { unsigned char* m_keyBuffer; }; -#endif // _HELLOWORLD_PUBSUBTYPES_H_ \ No newline at end of file +#endif // _HELLOWORLD_PUBSUBTYPES_H_ From 84a3525dca4174c83c02403d0f3963c96777f7cd Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 05:51:36 -0700 Subject: [PATCH 12/23] adapted for windows 100% run --- recipes/fast-dds/all/conanfile.py | 61 ++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 947c2a3adca57..4734b5ad75daf 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -5,7 +5,6 @@ from pathlib import Path import textwrap - class FastDDSConan(ConanFile): name = "fast-dds" @@ -27,7 +26,7 @@ class FastDDSConan(ConanFile): } generators = "cmake", "cmake_find_package" _cmake = None - exports_sources = ["patches/*","CMakeLists.txt"] + exports_sources = ["patches/**", "CMakeLists.txt"] @property def _pkg_share(self): @@ -91,10 +90,10 @@ def configure(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - + def _configure_cmake(self): if not self._cmake: - self._cmake = CMake(self) + self._cmake = CMake(self) self._cmake.definitions["BUILD_MEMORY_TOOLS"] = False self._cmake.definitions["NO_TLS"] = not self.options.with_ssl self._cmake.definitions["SECURITY"] = self.options.with_ssl @@ -114,6 +113,15 @@ def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + if self.settings.os == "Windows": + if ("MT" in self.settings.compiler.runtime and self.options.shared): + # This combination leads to an fast-dds error when linking + # linking dynamic '*.dll' and static MT runtime + raise ConanInvalidConfiguration("Mixing a dll eprosima library with a static runtime is a bad idea") + def build(self): self._patch_sources() cmake = self._configure_cmake() @@ -124,22 +132,40 @@ def package(self): cmake.install() tools.rmdir(self._pkg_share) # tmp because you cannot move bin to bin/discovery directly - tools.mkdir(os.path.join(self.package_folder,"tmp")) + tools.mkdir(os.path.join(self.package_folder, "tmp")) tools.rename( src=self._pkg_bin, - dst=os.path.join(self.package_folder,"tmp","discovery") + dst=os.path.join(self.package_folder, "tmp", "discovery") ) tools.mkdir(self._pkg_bin) tools.rename( - src=os.path.join(self.package_folder,"tmp","discovery"), - dst=os.path.join(self._pkg_bin,"discovery") + src=os.path.join(self.package_folder, "tmp", "discovery"), + dst=os.path.join(self._pkg_bin, "discovery") ) - tools.rmdir(os.path.join(self.package_folder,"tmp")) + # DLL on windows on bin level + if self.settings.os == "Windows" and self.options.shared: + dll_name = "fastrtps-{major}.{minor}.dll".format( + major=self.version.split(".")[0], + minor=self.version.split(".")[1] + ) + tools.rename( + src=os.path.join(self._pkg_bin, "discovery", dll_name), + dst=os.path.join(self._pkg_bin, dll_name) + ) + tools.rmdir(os.path.join(self.package_folder, "tmp")) tools.rename( src=self._pkg_tools, - dst=os.path.join(self._pkg_bin,"tools") + dst=os.path.join(self._pkg_bin, "tools") ) self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + tools.remove_files_by_mask( + directory=os.path.join(self.package_folder, "lib"), + pattern="*.pdb" + ) + tools.remove_files_by_mask( + directory=os.path.join(self.package_folder, "bin"), + pattern="*.pdb" + ) self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"fastrtps": "fastdds::fastrtps"} @@ -148,7 +174,7 @@ def package(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "fastdds" self.cpp_info.names["cmake_find_multi_package"] = "fastdds" - # component fastrtps + # component fastrtps self.cpp_info.components["fastrtps"].name = "fastrtps" self.cpp_info.components["fastrtps"].libs = tools.collect_libs(self) self.cpp_info.components["fastrtps"].requires = [ @@ -157,7 +183,7 @@ def package_info(self): "tinyxml2::tinyxml2", "foonathan-memory::foonathan-memory" ] - if self.settings.os in ["Linux","Macos","Neutrino"]: + if self.settings.os in ["Linux", "Macos", "Neutrino"]: self.cpp_info.components["fastrtps"].system_libs = [ "pthread", "rt", @@ -168,6 +194,7 @@ def package_info(self): "iphlpapi", "shlwapi" ] + self.cpp_info.components["fastrtps"].defines.append("FASTRTPS_DYN_LINK") self.cpp_info.components["fastrtps"].builddirs.append(self._module_subfolder) self.cpp_info.components["fastrtps"].build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.components["fastrtps"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] @@ -177,18 +204,18 @@ def package_info(self): "fastrtps", "tinyxml2::tinyxml2", ] - if self.settings.os in ["Linux","Macos","Neutrino"]: + if self.settings.os in ["Linux", "Macos", "Neutrino"]: self.cpp_info.components["fast-discovery"].system_libs = [ "pthread", "rt" ] - self.cpp_info.components["fast-discovery"].bindirs = [os.path.join("bin","discovery")] - bin_path = os.path.join(self.package_folder, "bin","discovery") + self.cpp_info.components["fast-discovery"].bindirs = [os.path.join("bin", "discovery")] + bin_path = os.path.join(self.package_folder, "bin", "discovery") self.output.info("Appending PATH env var for fast-dds::fast-discovery with : {}".format(bin_path)), self.env_info.PATH.append(bin_path) # component tools self.cpp_info.components["tools"].name = "tools" - self.cpp_info.components["tools"].bindirs = [os.path.join("bin","tools")] - bin_path = os.path.join(self.package_folder, "bin","tools") + self.cpp_info.components["tools"].bindirs = [os.path.join("bin", "tools")] + bin_path = os.path.join(self.package_folder, "bin", "tools") self.output.info("Appending PATH env var for fast-dds::tools with : {}".format(bin_path)), self.env_info.PATH.append(bin_path) From cab9911a0e329164b408519acb5aa94554ad2b7d Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 06:15:55 -0700 Subject: [PATCH 13/23] Add atomic as dependency --- recipes/fast-dds/all/conanfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 4734b5ad75daf..f9adfcb920b0e 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -194,7 +194,10 @@ def package_info(self): "iphlpapi", "shlwapi" ] - self.cpp_info.components["fastrtps"].defines.append("FASTRTPS_DYN_LINK") + if self.options.shared: + self.cpp_info.components["fastrtps"].defines.append("FASTRTPS_DYN_LINK") + if self.settings.os == "Linux": + self.cpp_info.components["fastrtps"].system_libs.append("atomic") self.cpp_info.components["fastrtps"].builddirs.append(self._module_subfolder) self.cpp_info.components["fastrtps"].build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.components["fastrtps"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] From 8116fdf0b8cc25dcaf4e0df46670c799ed7bf487 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 08:28:21 -0700 Subject: [PATCH 14/23] force C++11 and check gcc version --- recipes/fast-dds/all/CMakeLists.txt | 3 +++ recipes/fast-dds/all/conanfile.py | 11 ++++++++--- recipes/fast-dds/all/test_package/CMakeLists.txt | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/recipes/fast-dds/all/CMakeLists.txt b/recipes/fast-dds/all/CMakeLists.txt index d17aaff199b4a..1781a215e018d 100644 --- a/recipes/fast-dds/all/CMakeLists.txt +++ b/recipes/fast-dds/all/CMakeLists.txt @@ -4,4 +4,7 @@ project(cmake_wrapper) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + add_subdirectory("source_subfolder") diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index f9adfcb920b0e..1e2e3c389237c 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -1,8 +1,6 @@ from conans import ConanFile, CMake, tools import os -from conans.tools import load from conans.errors import ConanInvalidConfiguration -from pathlib import Path import textwrap class FastDDSConan(ConanFile): @@ -114,14 +112,21 @@ def source(self): destination=self._source_subfolder) def validate(self): - if self.settings.compiler.get_safe("cppstd"): + os = self.settings.os + compiler = self.settings.compiler + version = tools.Version(self.settings.compiler.version) + if compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 11) + if os == "Linux" and compiler == "gcc" and version < "5": + raise ConanInvalidConfiguration( + "Using Fast-DDS with gcc on Linux requires gcc 5 or higher.") if self.settings.os == "Windows": if ("MT" in self.settings.compiler.runtime and self.options.shared): # This combination leads to an fast-dds error when linking # linking dynamic '*.dll' and static MT runtime raise ConanInvalidConfiguration("Mixing a dll eprosima library with a static runtime is a bad idea") + def build(self): self._patch_sources() cmake = self._configure_cmake() diff --git a/recipes/fast-dds/all/test_package/CMakeLists.txt b/recipes/fast-dds/all/test_package/CMakeLists.txt index 27d0159d8d5c4..e4521014fa782 100644 --- a/recipes/fast-dds/all/test_package/CMakeLists.txt +++ b/recipes/fast-dds/all/test_package/CMakeLists.txt @@ -4,4 +4,7 @@ project(PackageTest CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + add_subdirectory(HelloWorldExample) From 7a01e15f6c6112c6e533bc6b7eb398f101ea8360 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 08:46:43 -0700 Subject: [PATCH 15/23] fix : c++11 require cmake 3.1 --- recipes/fast-dds/all/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/fast-dds/all/CMakeLists.txt b/recipes/fast-dds/all/CMakeLists.txt index 1781a215e018d..477562d4c9986 100644 --- a/recipes/fast-dds/all/CMakeLists.txt +++ b/recipes/fast-dds/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) From 59ec565b9a484047d52680feb5c34fbacd7fff62 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 11:20:55 -0700 Subject: [PATCH 16/23] adapted ccompiler check --- recipes/fast-dds/all/conanfile.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 1e2e3c389237c..a104613fcbe20 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -120,6 +120,13 @@ def validate(self): if os == "Linux" and compiler == "gcc" and version < "5": raise ConanInvalidConfiguration( "Using Fast-DDS with gcc on Linux requires gcc 5 or higher.") + if os == "Linux" and compiler == "clang" and version < "5.0": + raise ConanInvalidConfiguration( + "Using Fast-DDS with gcc on Linux requires clang 5 or higher.") + if os == "Windows" and compiler == "Visual Studio" and version < "16": + raise ConanInvalidConfiguration( + "Fast-DDS was tested on Windows with VS Compiler 16") + if self.settings.os == "Windows": if ("MT" in self.settings.compiler.runtime and self.options.shared): # This combination leads to an fast-dds error when linking @@ -190,7 +197,10 @@ def package_info(self): ] if self.settings.os in ["Linux", "Macos", "Neutrino"]: self.cpp_info.components["fastrtps"].system_libs = [ - "pthread", + "pthread" + ] + if self.settings.os == "Linux": + self.cpp_info.components["fastrtps"].system_libs = [ "rt", "dl" ] @@ -214,7 +224,10 @@ def package_info(self): ] if self.settings.os in ["Linux", "Macos", "Neutrino"]: self.cpp_info.components["fast-discovery"].system_libs = [ - "pthread", + "pthread" + ] + if self.settings.os in ["Linux"]: + self.cpp_info.components["fast-discovery"].system_libs = [ "rt" ] self.cpp_info.components["fast-discovery"].bindirs = [os.path.join("bin", "discovery")] From ea11a7922e1e520ea9c67516d23f33c612f33f59 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 13:10:23 -0700 Subject: [PATCH 17/23] validate existence --- recipes/fast-dds/all/conanfile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index a104613fcbe20..e4a8267e5e1bb 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -160,10 +160,11 @@ def package(self): major=self.version.split(".")[0], minor=self.version.split(".")[1] ) - tools.rename( - src=os.path.join(self._pkg_bin, "discovery", dll_name), - dst=os.path.join(self._pkg_bin, dll_name) - ) + if os.path.exists(os.path.join(self._pkg_bin, "discovery", dll_name)): + tools.rename( + src=os.path.join(self._pkg_bin, "discovery", dll_name), + dst=os.path.join(self._pkg_bin, dll_name) + ) tools.rmdir(os.path.join(self.package_folder, "tmp")) tools.rename( src=self._pkg_tools, From a161e6a854ca26652eee47a353c0813edc1ccd50 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Fri, 18 Jun 2021 23:21:29 -0700 Subject: [PATCH 18/23] reduce complexity + add openssl as requires --- recipes/fast-dds/all/conanfile.py | 54 ++++++------------------------- 1 file changed, 10 insertions(+), 44 deletions(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index e4a8267e5e1bb..e5e639e408109 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -122,7 +122,7 @@ def validate(self): "Using Fast-DDS with gcc on Linux requires gcc 5 or higher.") if os == "Linux" and compiler == "clang" and version < "5.0": raise ConanInvalidConfiguration( - "Using Fast-DDS with gcc on Linux requires clang 5 or higher.") + "Using Fast-DDS with clang on Linux requires clang 5 or higher.") if os == "Windows" and compiler == "Visual Studio" and version < "16": raise ConanInvalidConfiguration( "Fast-DDS was tested on Windows with VS Compiler 16") @@ -143,34 +143,11 @@ def package(self): cmake = self._configure_cmake() cmake.install() tools.rmdir(self._pkg_share) - # tmp because you cannot move bin to bin/discovery directly - tools.mkdir(os.path.join(self.package_folder, "tmp")) - tools.rename( - src=self._pkg_bin, - dst=os.path.join(self.package_folder, "tmp", "discovery") - ) - tools.mkdir(self._pkg_bin) - tools.rename( - src=os.path.join(self.package_folder, "tmp", "discovery"), - dst=os.path.join(self._pkg_bin, "discovery") - ) - # DLL on windows on bin level - if self.settings.os == "Windows" and self.options.shared: - dll_name = "fastrtps-{major}.{minor}.dll".format( - major=self.version.split(".")[0], - minor=self.version.split(".")[1] - ) - if os.path.exists(os.path.join(self._pkg_bin, "discovery", dll_name)): - tools.rename( - src=os.path.join(self._pkg_bin, "discovery", dll_name), - dst=os.path.join(self._pkg_bin, dll_name) - ) - tools.rmdir(os.path.join(self.package_folder, "tmp")) + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") tools.rename( src=self._pkg_tools, dst=os.path.join(self._pkg_bin, "tools") ) - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") tools.remove_files_by_mask( directory=os.path.join(self.package_folder, "lib"), pattern="*.pdb" @@ -203,7 +180,8 @@ def package_info(self): if self.settings.os == "Linux": self.cpp_info.components["fastrtps"].system_libs = [ "rt", - "dl" + "dl", + "atomic" ] elif self.settings.os == "Windows": self.cpp_info.components["fastrtps"].system_libs = [ @@ -212,32 +190,20 @@ def package_info(self): ] if self.options.shared: self.cpp_info.components["fastrtps"].defines.append("FASTRTPS_DYN_LINK") - if self.settings.os == "Linux": - self.cpp_info.components["fastrtps"].system_libs.append("atomic") + if self.options.with_ssl: + self.cpp_info.components["fastrtps"].requires.append("openssl::openssl") self.cpp_info.components["fastrtps"].builddirs.append(self._module_subfolder) self.cpp_info.components["fastrtps"].build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.components["fastrtps"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] # component fast-discovery self.cpp_info.components["fast-discovery"].name = "fast-discovery" - self.cpp_info.components["fast-discovery"].requires = [ - "fastrtps", - "tinyxml2::tinyxml2", - ] - if self.settings.os in ["Linux", "Macos", "Neutrino"]: - self.cpp_info.components["fast-discovery"].system_libs = [ - "pthread" - ] - if self.settings.os in ["Linux"]: - self.cpp_info.components["fast-discovery"].system_libs = [ - "rt" - ] - self.cpp_info.components["fast-discovery"].bindirs = [os.path.join("bin", "discovery")] - bin_path = os.path.join(self.package_folder, "bin", "discovery") + self.cpp_info.components["fast-discovery"].bindirs = ["bin"] + bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var for fast-dds::fast-discovery with : {}".format(bin_path)), self.env_info.PATH.append(bin_path) # component tools self.cpp_info.components["tools"].name = "tools" - self.cpp_info.components["tools"].bindirs = [os.path.join("bin", "tools")] - bin_path = os.path.join(self.package_folder, "bin", "tools") + self.cpp_info.components["tools"].bindirs = [os.path.join("bin","tools")] + bin_path = os.path.join(self._pkg_bin, "tools") self.output.info("Appending PATH env var for fast-dds::tools with : {}".format(bin_path)), self.env_info.PATH.append(bin_path) From 1dfdaa66742996c5d4551d930781ce2a9280e182 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Mon, 28 Jun 2021 02:34:53 -0700 Subject: [PATCH 19/23] reduce compexity --- .../fast-dds/all/test_package/CMakeLists.txt | 13 +- .../HelloWorldExample/CMakeLists.txt | 24 --- .../HelloWorldExample/HelloWorldPublisher.cpp | 167 ------------------ .../HelloWorldExample/HelloWorldPublisher.h | 62 ------- .../HelloWorldSubscriber.cpp | 127 ------------- .../HelloWorldExample/HelloWorldSubscriber.h | 87 --------- .../HelloWorldExample/HelloWorld_main.cpp | 87 --------- .../test_package/HelloWorldExample/Makefile | 102 ----------- .../fast-dds/all/test_package/conanfile.py | 1 - .../{HelloWorldExample => msg}/HelloWorld.cxx | 0 .../{HelloWorldExample => msg}/HelloWorld.h | 0 .../{HelloWorldExample => msg}/HelloWorld.idl | 0 .../HelloWorldPubSubTypes.cxx | 0 .../HelloWorldPubSubTypes.h | 0 .../all/test_package/test_package.cpp | 57 ++++++ 15 files changed, 67 insertions(+), 660 deletions(-) delete mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt delete mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp delete mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.h delete mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.cpp delete mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.h delete mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp delete mode 100644 recipes/fast-dds/all/test_package/HelloWorldExample/Makefile rename recipes/fast-dds/all/test_package/{HelloWorldExample => msg}/HelloWorld.cxx (100%) rename recipes/fast-dds/all/test_package/{HelloWorldExample => msg}/HelloWorld.h (100%) rename recipes/fast-dds/all/test_package/{HelloWorldExample => msg}/HelloWorld.idl (100%) rename recipes/fast-dds/all/test_package/{HelloWorldExample => msg}/HelloWorldPubSubTypes.cxx (100%) rename recipes/fast-dds/all/test_package/{HelloWorldExample => msg}/HelloWorldPubSubTypes.h (100%) create mode 100644 recipes/fast-dds/all/test_package/test_package.cpp diff --git a/recipes/fast-dds/all/test_package/CMakeLists.txt b/recipes/fast-dds/all/test_package/CMakeLists.txt index e4521014fa782..c20ee536c524b 100644 --- a/recipes/fast-dds/all/test_package/CMakeLists.txt +++ b/recipes/fast-dds/all/test_package/CMakeLists.txt @@ -4,7 +4,14 @@ project(PackageTest CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +find_package(fastdds REQUIRED) -add_subdirectory(HelloWorldExample) +add_executable(test_package + test_package.cpp + msg/HelloWorld.cxx + msg/HelloWorldPubSubTypes.cxx +) + +target_link_libraries(test_package + fastrtps +) diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt b/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt deleted file mode 100644 index 477113c6f080a..0000000000000 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required(VERSION 3.1) - -find_package(fastdds REQUIRED) - -file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CXX "*.cxx") -file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CPP "*.cpp") - -add_executable(test_package ${HELLOWORLD_EXAMPLE_SOURCES_CXX} ${HELLOWORLD_EXAMPLE_SOURCES_CPP}) -# validate the alias -target_link_libraries(test_package fastrtps) diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp deleted file mode 100644 index 00a0a5d087120..0000000000000 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorldPublisher.cpp - * - */ - -#include "HelloWorldPublisher.h" -#include -#include -#include -#include -#include - -#include - -using namespace eprosima::fastrtps; -using namespace eprosima::fastrtps::rtps; - -HelloWorldPublisher::HelloWorldPublisher() - : mp_participant(nullptr) - , mp_publisher(nullptr) -{ -} - -bool HelloWorldPublisher::init() -{ - m_Hello.index(0); - m_Hello.message("HelloWorld"); - ParticipantAttributes PParam; - PParam.rtps.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SIMPLE; - PParam.rtps.builtin.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = true; - PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter = true; - PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationWriterANDSubscriptionReader = true; - PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite; - PParam.rtps.setName("Participant_pub"); - mp_participant = Domain::createParticipant(PParam); - - if (mp_participant == nullptr) - { - return false; - } - //REGISTER THE TYPE - - Domain::registerType(mp_participant, &m_type); - - //CREATE THE PUBLISHER - PublisherAttributes Wparam; - Wparam.topic.topicKind = NO_KEY; - Wparam.topic.topicDataType = "HelloWorld"; - Wparam.topic.topicName = "HelloWorldTopic"; - Wparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS; - Wparam.topic.historyQos.depth = 30; - Wparam.topic.resourceLimitsQos.max_samples = 50; - Wparam.topic.resourceLimitsQos.allocated_samples = 20; - Wparam.times.heartbeatPeriod.seconds = 2; - Wparam.times.heartbeatPeriod.nanosec = 200 * 1000 * 1000; - Wparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS; - mp_publisher = Domain::createPublisher(mp_participant, Wparam, (PublisherListener*)&m_listener); - if (mp_publisher == nullptr) - { - return false; - } - - return true; - -} - -HelloWorldPublisher::~HelloWorldPublisher() -{ - // TODO Auto-generated destructor stub - Domain::removeParticipant(mp_participant); -} - -void HelloWorldPublisher::PubListener::onPublicationMatched( - Publisher* /*pub*/, - MatchingInfo& info) -{ - if (info.status == MATCHED_MATCHING) - { - n_matched++; - firstConnected = true; - std::cout << "Publisher matched" << std::endl; - } - else - { - n_matched--; - std::cout << "Publisher unmatched" << std::endl; - } -} - -void HelloWorldPublisher::runThread( - uint32_t samples, - uint32_t sleep) -{ - if (samples == 0) - { - while (!stop) - { - if (publish(false)) - { - std::cout << "Message: " << m_Hello.message() << " with index: " << m_Hello.index() << " SENT" << - std::endl; - } - std::this_thread::sleep_for(std::chrono::milliseconds(sleep)); - } - } - else - { - for (uint32_t i = 0; i < samples; ++i) - { - if (!publish(false)) - { - --i; - } - else - { - std::cout << "Message: " << m_Hello.message() << " with index: " << m_Hello.index() << " SENT" << - std::endl; - } - std::this_thread::sleep_for(std::chrono::milliseconds(sleep)); - } - } -} - -void HelloWorldPublisher::run( - uint32_t samples, - uint32_t sleep) -{ - stop = false; - std::thread thread(&HelloWorldPublisher::runThread, this, samples, sleep); - if (samples == 0) - { - std::cout << "Publisher running. Please press enter to stop the Publisher at any time." << std::endl; - std::cin.ignore(); - stop = true; - } - else - { - std::cout << "Publisher running " << samples << " samples." << std::endl; - } - thread.join(); -} - -bool HelloWorldPublisher::publish( - bool waitForListener) -{ - if (m_listener.firstConnected || !waitForListener || m_listener.n_matched > 0) - { - m_Hello.index(m_Hello.index() + 1); - mp_publisher->write((void*)&m_Hello); - return true; - } - return false; -} diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.h b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.h deleted file mode 100644 index a863ae25a0d3b..0000000000000 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPublisher.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorldPublisher.h - * - */ - -#ifndef HELLOWORLDPUBLISHER_H_ -#define HELLOWORLDPUBLISHER_H_ - -#include "HelloWorldPubSubTypes.h" - -#include -#include -#include - - -#include "HelloWorld.h" - -class HelloWorldPublisher { -public: - HelloWorldPublisher(); - virtual ~HelloWorldPublisher(); - //!Initialize - bool init(); - //!Publish a sample - bool publish(bool waitForListener = true); - //!Run for number samples - void run(uint32_t number, uint32_t sleep); -private: - HelloWorld m_Hello; - eprosima::fastrtps::Participant* mp_participant; - eprosima::fastrtps::Publisher* mp_publisher; - bool stop; - class PubListener:public eprosima::fastrtps::PublisherListener - { - public: - PubListener():n_matched(0),firstConnected(false){}; - ~PubListener(){}; - void onPublicationMatched(eprosima::fastrtps::Publisher* pub, eprosima::fastrtps::rtps::MatchingInfo& info); - int n_matched; - bool firstConnected; - }m_listener; - void runThread(uint32_t number, uint32_t sleep); - HelloWorldPubSubType m_type; -}; - - - -#endif /* HELLOWORLDPUBLISHER_H_ */ diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.cpp deleted file mode 100644 index 80bf66f05b9b5..0000000000000 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorldSubscriber.cpp - * - */ - -#include "HelloWorldSubscriber.h" -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps; -using namespace eprosima::fastrtps::rtps; - -HelloWorldSubscriber::HelloWorldSubscriber() - : mp_participant(nullptr) - , mp_subscriber(nullptr) -{ -} - -bool HelloWorldSubscriber::init() -{ - ParticipantAttributes PParam; - PParam.rtps.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol_t::SIMPLE; - PParam.rtps.builtin.discovery_config.use_SIMPLE_EndpointDiscoveryProtocol = true; - PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter = true; - PParam.rtps.builtin.discovery_config.m_simpleEDP.use_PublicationWriterANDSubscriptionReader = true; - PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite; - PParam.rtps.setName("Participant_sub"); - mp_participant = Domain::createParticipant(PParam); - if (mp_participant == nullptr) - { - return false; - } - - //REGISTER THE TYPE - - Domain::registerType(mp_participant, &m_type); - //CREATE THE SUBSCRIBER - SubscriberAttributes Rparam; - Rparam.topic.topicKind = NO_KEY; - Rparam.topic.topicDataType = "HelloWorld"; - Rparam.topic.topicName = "HelloWorldTopic"; - Rparam.topic.historyQos.kind = KEEP_LAST_HISTORY_QOS; - Rparam.topic.historyQos.depth = 30; - Rparam.topic.resourceLimitsQos.max_samples = 50; - Rparam.topic.resourceLimitsQos.allocated_samples = 20; - Rparam.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS; - Rparam.qos.m_durability.kind = TRANSIENT_LOCAL_DURABILITY_QOS; - mp_subscriber = Domain::createSubscriber(mp_participant, Rparam, (SubscriberListener*)&m_listener); - - if (mp_subscriber == nullptr) - { - return false; - } - - - return true; -} - -HelloWorldSubscriber::~HelloWorldSubscriber() -{ - // TODO Auto-generated destructor stub - Domain::removeParticipant(mp_participant); -} - -void HelloWorldSubscriber::SubListener::onSubscriptionMatched( - Subscriber* /*sub*/, - MatchingInfo& info) -{ - if (info.status == MATCHED_MATCHING) - { - n_matched++; - std::cout << "Subscriber matched" << std::endl; - } - else - { - n_matched--; - std::cout << "Subscriber unmatched" << std::endl; - } -} - -void HelloWorldSubscriber::SubListener::onNewDataMessage( - Subscriber* sub) -{ - if (sub->takeNextData((void*)&m_Hello, &m_info)) - { - if (m_info.sampleKind == ALIVE) - { - this->n_samples++; - // Print your structure data here. - std::cout << "Message " << m_Hello.message() << " " << m_Hello.index() << " RECEIVED" << std::endl; - } - } - -} - -void HelloWorldSubscriber::run() -{ - std::cout << "Subscriber running. Please press enter to stop the Subscriber" << std::endl; - std::cin.ignore(); -} - -void HelloWorldSubscriber::run( - uint32_t number) -{ - std::cout << "Subscriber running until " << number << "samples have been received" << std::endl; - while (number > this->m_listener.n_samples) - { - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - } -} diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.h b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.h deleted file mode 100644 index 2d0f4b09e1dc3..0000000000000 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldSubscriber.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorldSubscriber.h - * - */ - -#ifndef HELLOWORLDSUBSCRIBER_H_ -#define HELLOWORLDSUBSCRIBER_H_ - -#include "HelloWorldPubSubTypes.h" - -#include -#include -#include -#include - - - - -#include "HelloWorld.h" - -class HelloWorldSubscriber -{ -public: - - HelloWorldSubscriber(); - virtual ~HelloWorldSubscriber(); - //!Initialize the subscriber - bool init(); - //!RUN the subscriber - void run(); - //!Run the subscriber until number samples have been received. - void run( - uint32_t number); - -private: - - eprosima::fastrtps::Participant* mp_participant; - eprosima::fastrtps::Subscriber* mp_subscriber; - -public: - - class SubListener : public eprosima::fastrtps::SubscriberListener - { - public: - - SubListener() - : n_matched(0) - , n_samples(0) - { - } - - ~SubListener() - { - } - - void onSubscriptionMatched( - eprosima::fastrtps::Subscriber* sub, - eprosima::fastrtps::rtps::MatchingInfo& info); - void onNewDataMessage( - eprosima::fastrtps::Subscriber* sub); - HelloWorld m_Hello; - eprosima::fastrtps::SampleInfo_t m_info; - int n_matched; - uint32_t n_samples; - } - m_listener; - -private: - - HelloWorldPubSubType m_type; -}; - -#endif /* HELLOWORLDSUBSCRIBER_H_ */ diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp b/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp deleted file mode 100644 index 108719be20ad2..0000000000000 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld_main.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file HelloWorld_main.cpp - * - */ - -#include "HelloWorldPublisher.h" -#include "HelloWorldSubscriber.h" - -#include -#include - -using namespace eprosima; -using namespace fastrtps; -using namespace rtps; -int main() -{ - std::cout << "Starting "<< std::endl; - - int argc = 2; - const char *argv[2] = {"", "subscribe"}; - - int type = 1; - int count = 9; - long sleep = 100; - if(argc > 1) - { - if(strcmp(argv[1],"publisher")==0) - { - type = 1; - if (argc >= 3) - { - count = atoi(argv[2]); - if (argc == 4) - { - sleep = atoi(argv[3]); - } - } - } - else if(strcmp(argv[1],"subscriber")==0) - type = 2; - } - else - { - std::cout << "publisher OR subscriber argument needed" << std::endl; - Log::Reset(); - return 0; - } - - switch(type) - { - case 1: - { - HelloWorldPublisher mypub; - if(mypub.init()) - { - mypub.run(count, sleep); - } - break; - } - case 2: - { - HelloWorldSubscriber mysub; - if(mysub.init()) - { - mysub.run(); - } - break; - } - } - Domain::stopAll(); - Log::Reset(); - return 0; -} diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/Makefile b/recipes/fast-dds/all/test_package/HelloWorldExample/Makefile deleted file mode 100644 index 615002f781d84..0000000000000 --- a/recipes/fast-dds/all/test_package/HelloWorldExample/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -CPP=g++ -LN=g++ -AR=ar -CP=cp -SYSLIBS= -ldl -lnsl -lm -lpthread -lrt -DEFINES= -COMMON_CFLAGS= -c -Wall -D__LITTLE_ENDIAN__ -std=c++11 - -## CHOOSE HERE BETWEEN 32 and 64 bit architecture - -##32 BIT ARCH: -#COMMON_CFLAGS+= -m32 -fpic -#LDFLAGS=-m32 - -#64BIT ARCH: -COMMON_CFLAGS+= -m64 -fpic -LDFLAGS=-m64 - -CFLAGS = $(COMMON_CFLAGS) -O2 - -INCLUDES= -I. - -LIBS = -lfastcdr -lfastrtps $(shell test -x "$$(which pkg-config)" && pkg-config libssl libcrypto --libs --silence-errors) $(SYSLIBS) - -DIRECTORIES= output.dir bin.dir - -all: $(DIRECTORIES) HelloWorldExample - -HELLOWORLDEXAMPLE_TARGET= bin/HelloWorldExample - -HELLOWORLDEXAMPLE_SRC_CXXFILES= - -HELLOWORLDEXAMPLE_SRC_CPPFILES= HelloWorldExample/HelloWorld.cxx \ - HelloWorldExample/HelloWorldPubSubTypes.cxx \ - HelloWorldExample/HelloWorldPublisher.cpp \ - HelloWorldExample/HelloWorldSubscriber.cpp \ - HelloWorldExample/HelloWorld_main.cpp - - -# Project sources are copied to the current directory -HELLOWORLDEXAMPLE_SRCS= $(HELLOWORLDEXAMPLE_SRC_CXXFILES) $(HELLOWORLDEXAMPLE_SRC_CPPFILES) - -# Source directories -HELLOWORLDEXAMPLE_SOURCES_DIRS_AUX= $(foreach srcdir, $(dir $(HELLOWORLDEXAMPLE_SRCS)), $(srcdir)) -HELLOWORLDEXAMPLE_SOURCES_DIRS= $(shell echo $(HELLOWORLDEXAMPLE_SOURCES_DIRS_AUX) | tr " " "\n" | sort | uniq | tr "\n" " ") - -HELLOWORLDEXAMPLE_OBJS = $(foreach obj,$(notdir $(addsuffix .o, $(HELLOWORLDEXAMPLE_SRCS))), output/$(obj)) -HELLOWORLDEXAMPLE_DEPS = $(foreach dep,$(notdir $(addsuffix .d, $(HELLOWORLDEXAMPLE_SRCS))), output/$(dep)) - -OBJS+= $(HELLOWORLDEXAMPLE_OBJS) -DEPS+= $(HELLOWORLDEXAMPLE_DEPS) - -HelloWorldExample: $(HELLOWORLDEXAMPLE_TARGET) - -$(HELLOWORLDEXAMPLE_TARGET): $(HELLOWORLDEXAMPLE_OBJS) - $(LN) $(LDFLAGS) -o $(HELLOWORLDEXAMPLE_TARGET) $(HELLOWORLDEXAMPLE_OBJS) $(LIBS) - -vpath %.cxx $(HELLOWORLDEXAMPLE_SOURCES_DIRS) -vpath %.cpp $(HELLOWORLDEXAMPLE_SOURCES_DIRS) - -output/%.cxx.o:%.cxx - @echo Calculating dependencies $< - @$(CC) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cxx.o=%.cxx.d) - @echo Compiling $< - @$(CC) $(CFLAGS) $(INCLUDES) $< -o $@ - -output/%.cpp.o:%.cpp - @echo Calculating dependencies $< - @$(CPP) $(CFLAGS) -MM $(CFLAGS) $(INCLUDES) $< | sed "s/^.*:/output\/&/g" > $(@:%.cpp.o=%.cpp.d) - @echo Compiling $< - @$(CPP) $(CFLAGS) $(INCLUDES) $< -o $@ - -.PHONY: HelloWorldExample - -clean: - @rm -f $(OBJS) - @rm -f $(DEPS) - -ifneq ($(MAKECMDGOALS), clean) --include $(DEPS) -endif - -%.dir : - @echo "Checking directory $*" - @if [ ! -d $* ]; then \ - echo "Making directory $*"; \ - mkdir -p $* ; \ - fi; diff --git a/recipes/fast-dds/all/test_package/conanfile.py b/recipes/fast-dds/all/test_package/conanfile.py index 1d0bdd3779793..23ba95e79f465 100644 --- a/recipes/fast-dds/all/test_package/conanfile.py +++ b/recipes/fast-dds/all/test_package/conanfile.py @@ -1,7 +1,6 @@ from conans import ConanFile, CMake, tools import os - class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake", "cmake_find_package" diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.cxx b/recipes/fast-dds/all/test_package/msg/HelloWorld.cxx similarity index 100% rename from recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.cxx rename to recipes/fast-dds/all/test_package/msg/HelloWorld.cxx diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h b/recipes/fast-dds/all/test_package/msg/HelloWorld.h similarity index 100% rename from recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.h rename to recipes/fast-dds/all/test_package/msg/HelloWorld.h diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.idl b/recipes/fast-dds/all/test_package/msg/HelloWorld.idl similarity index 100% rename from recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorld.idl rename to recipes/fast-dds/all/test_package/msg/HelloWorld.idl diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.cxx b/recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.cxx similarity index 100% rename from recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.cxx rename to recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.cxx diff --git a/recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h b/recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.h similarity index 100% rename from recipes/fast-dds/all/test_package/HelloWorldExample/HelloWorldPubSubTypes.h rename to recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.h diff --git a/recipes/fast-dds/all/test_package/test_package.cpp b/recipes/fast-dds/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..fe2ff9f06fe79 --- /dev/null +++ b/recipes/fast-dds/all/test_package/test_package.cpp @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include +#include + + +#include "msg/HelloWorld.h" +#include "msg/HelloWorldPubSubTypes.h" + +int main() +{ + // Define msg to send + HelloWorld hello; + hello.index(0); + hello.message("HelloWorld"); + + eprosima::fastrtps::Participant *participant; + eprosima::fastrtps::Publisher *publisher; + + eprosima::fastrtps::ParticipantAttributes PParam; + PParam.rtps.setName("Participant_pub"); + participant = eprosima::fastrtps::Domain::createParticipant(PParam); + + if (participant == nullptr) + { + return 1; + } + + HelloWorldPubSubType type; + + eprosima::fastrtps::Domain::registerType(participant, &type); + + //CREATE THE PUBLISHER + eprosima::fastrtps::PublisherAttributes Wparam; + Wparam.topic.topicKind = eprosima::fastrtps::rtps::TopicKind_t::NO_KEY; + Wparam.topic.topicDataType = "HelloWorld"; + Wparam.topic.topicName = "HelloWorldTopic"; + Wparam.topic.historyQos.kind = eprosima::fastrtps::KEEP_LAST_HISTORY_QOS; + Wparam.topic.historyQos.depth = 30; + Wparam.topic.resourceLimitsQos.max_samples = 50; + Wparam.topic.resourceLimitsQos.allocated_samples = 20; + Wparam.times.heartbeatPeriod.seconds = 2; + Wparam.times.heartbeatPeriod.nanosec = 200 * 1000 * 1000; + publisher = eprosima::fastrtps::Domain::createPublisher(participant, Wparam); + if (publisher == nullptr) + { + return 1; + } + + publisher->write((void*)&hello); + + eprosima::fastrtps::Domain::removeParticipant(participant); + + return 0; +} From 768f742dfc87c9b6c781b9751f90de8153c01561 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Mon, 28 Jun 2021 02:36:20 -0700 Subject: [PATCH 20/23] Followed PR requirements, add more from templates --- recipes/fast-dds/all/CMakeLists.txt | 3 -- recipes/fast-dds/all/conanfile.py | 55 ++++++++++++++--------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/recipes/fast-dds/all/CMakeLists.txt b/recipes/fast-dds/all/CMakeLists.txt index 477562d4c9986..8b9014fcee176 100644 --- a/recipes/fast-dds/all/CMakeLists.txt +++ b/recipes/fast-dds/all/CMakeLists.txt @@ -4,7 +4,4 @@ project(cmake_wrapper) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - add_subdirectory("source_subfolder") diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index e5e639e408109..a740faa8561a2 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -60,6 +60,19 @@ def _module_file_rel_path(self): self._module_subfolder, "conan-target-properties.cmake" ) + + @property + def _minimum_cpp_standard(self): + return 11 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "5", + "clang": "5.0", + "apple-clang": "5.0", + } @staticmethod def _create_cmake_module_alias_targets(module_file, targets): @@ -112,26 +125,21 @@ def source(self): destination=self._source_subfolder) def validate(self): - os = self.settings.os - compiler = self.settings.compiler - version = tools.Version(self.settings.compiler.version) - if compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) - if os == "Linux" and compiler == "gcc" and version < "5": - raise ConanInvalidConfiguration( - "Using Fast-DDS with gcc on Linux requires gcc 5 or higher.") - if os == "Linux" and compiler == "clang" and version < "5.0": - raise ConanInvalidConfiguration( - "Using Fast-DDS with clang on Linux requires clang 5 or higher.") - if os == "Windows" and compiler == "Visual Studio" and version < "16": - raise ConanInvalidConfiguration( - "Fast-DDS was tested on Windows with VS Compiler 16") - + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) if self.settings.os == "Windows": if ("MT" in self.settings.compiler.runtime and self.options.shared): # This combination leads to an fast-dds error when linking # linking dynamic '*.dll' and static MT runtime - raise ConanInvalidConfiguration("Mixing a dll eprosima library with a static runtime is a bad idea") + raise ConanInvalidConfiguration("Mixing a dll {} library with a static runtime is a bad idea".format(self.name)) def build(self): @@ -174,20 +182,11 @@ def package_info(self): "foonathan-memory::foonathan-memory" ] if self.settings.os in ["Linux", "Macos", "Neutrino"]: - self.cpp_info.components["fastrtps"].system_libs = [ - "pthread" - ] + self.cpp_info.components["fastrtps"].system_libs.append("pthread") if self.settings.os == "Linux": - self.cpp_info.components["fastrtps"].system_libs = [ - "rt", - "dl", - "atomic" - ] + self.cpp_info.components["fastrtps"].system_libs.extend(["rt", "dl", "atomic"]) elif self.settings.os == "Windows": - self.cpp_info.components["fastrtps"].system_libs = [ - "iphlpapi", - "shlwapi" - ] + self.cpp_info.components["fastrtps"].system_libs.extend(["iphlpapi","shlwapi"]) if self.options.shared: self.cpp_info.components["fastrtps"].defines.append("FASTRTPS_DYN_LINK") if self.options.with_ssl: From b9fb19ec4795f4ef7c903a9c76bdba3626c9062e Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Mon, 28 Jun 2021 04:24:15 -0700 Subject: [PATCH 21/23] adapt compiler check and add boost as requirement --- recipes/fast-dds/all/conanfile.py | 10 ++++++---- recipes/fast-dds/all/test_package/CMakeLists.txt | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index a740faa8561a2..1fb33530536b5 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -68,10 +68,10 @@ def _minimum_cpp_standard(self): @property def _minimum_compilers_version(self): return { - "Visual Studio": "16", + "Visual Studio": "14", "gcc": "5", - "clang": "5.0", - "apple-clang": "5.0", + "clang": "3.9", + "apple-clang": "8", } @staticmethod @@ -117,6 +117,7 @@ def requirements(self): self.requires("asio/1.18.2") self.requires("fast-cdr/1.0.21") self.requires("foonathan-memory/0.7.0") + self.requires("boost/1.73.0") if self.options.with_ssl: self.requires("openssl/1.1.1k") @@ -179,7 +180,8 @@ def package_info(self): "fast-cdr::fast-cdr", "asio::asio", "tinyxml2::tinyxml2", - "foonathan-memory::foonathan-memory" + "foonathan-memory::foonathan-memory", + "boost::boost" ] if self.settings.os in ["Linux", "Macos", "Neutrino"]: self.cpp_info.components["fastrtps"].system_libs.append("pthread") diff --git a/recipes/fast-dds/all/test_package/CMakeLists.txt b/recipes/fast-dds/all/test_package/CMakeLists.txt index c20ee536c524b..33450e84a9e7a 100644 --- a/recipes/fast-dds/all/test_package/CMakeLists.txt +++ b/recipes/fast-dds/all/test_package/CMakeLists.txt @@ -12,6 +12,8 @@ add_executable(test_package msg/HelloWorldPubSubTypes.cxx ) +set_property(TARGET test_package PROPERTY CXX_STANDARD 11) + target_link_libraries(test_package fastrtps ) From a3af6996a0d8d3105eacf7944483ae16fe0fa783 Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Mon, 28 Jun 2021 23:04:15 -0700 Subject: [PATCH 22/23] Retrigger CI --- recipes/fast-dds/all/test_package/test_package.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/fast-dds/all/test_package/test_package.cpp b/recipes/fast-dds/all/test_package/test_package.cpp index fe2ff9f06fe79..89ac973375f14 100644 --- a/recipes/fast-dds/all/test_package/test_package.cpp +++ b/recipes/fast-dds/all/test_package/test_package.cpp @@ -5,7 +5,6 @@ #include #include - #include "msg/HelloWorld.h" #include "msg/HelloWorldPubSubTypes.h" From 97b799770e357c70ce5a0d37a4476617530d022a Mon Sep 17 00:00:00 2001 From: dotchris90 Date: Wed, 30 Jun 2021 00:57:54 -0700 Subject: [PATCH 23/23] Rise number to avoid partly C++11 implementations --- recipes/fast-dds/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py index 1fb33530536b5..8c3b540be9e20 100644 --- a/recipes/fast-dds/all/conanfile.py +++ b/recipes/fast-dds/all/conanfile.py @@ -68,7 +68,7 @@ def _minimum_cpp_standard(self): @property def _minimum_compilers_version(self): return { - "Visual Studio": "14", + "Visual Studio": "16", "gcc": "5", "clang": "3.9", "apple-clang": "8",