-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* (#8581) Add liboping * Fixed conan install errors - no dep on libev * removed obsolete comment * Fixed build break with requirements * Remove .pc file * Fixed more PEP8 errors * Updated URL * Unborked URL * Fix compiler version dependent patch * Block M1 Shared library build * Small change to stop MacOS /M1 shared build * Turn shared libs off for MacOS as well as Windows * Updated message * Disable Mac/M1 builds * Updated comment with build failure on Mac/M1 * Added issue # in comment * Last attempt to kick a build * remove elif * Update recipes/liboping/all/conanfile.py Updated Topics list Co-authored-by: Uilian Ries <uilianries@gmail.com> * Update recipes/liboping/all/conanfile.py Fixed Path Co-authored-by: Uilian Ries <uilianries@gmail.com> * Update recipes/liboping/all/test_package/conanfile.py Fixed cmake setup Co-authored-by: Uilian Ries <uilianries@gmail.com> * Update recipes/liboping/all/test_package/CMakeLists.txt Fixed test setup Co-authored-by: Uilian Ries <uilianries@gmail.com> * Update recipes/liboping/all/conanfile.py Co-authored-by: Uilian Ries <uilianries@gmail.com> Co-authored-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
d845b79
commit 5e1d52b
Showing
7 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sources: | ||
"1.10.0": | ||
url: "https://noping.cc/files/liboping-1.10.0.tar.gz" | ||
sha256: "c206b05743d0730814be3115b48abd0b00016677525153c78730da307aba0846" | ||
patches: | ||
"1.10.0": | ||
- patch_file: "patches/1.10.0-suppress_truncate.patch" | ||
base_path: "source_subfolder" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from conans import ConanFile, AutoToolsBuildEnvironment, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
|
||
|
||
class LibopingConan(ConanFile): | ||
name = "liboping" | ||
description = "A multi server ping library" | ||
topics = ("oping", "ping", "icmp") | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://noping.cc" | ||
license = ["LGPL-2.1", "GPL-2.0"] | ||
settings = "os", "arch", "compiler", "build_type" | ||
exports_sources = ["patches/**"] | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
_autotools = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _settings_build(self): | ||
return getattr(self, "settings_build", self.settings) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
del self.settings.compiler.libcxx | ||
del self.settings.compiler.cppstd | ||
|
||
def validate(self): | ||
if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": | ||
raise ConanInvalidConfiguration("liboping is not supported by Visual Studio") | ||
if self.settings.os == "Windows" and self.options.shared: | ||
raise ConanInvalidConfiguration("Liboping could not be built on {} as shared library".format(self.settings.os)) | ||
if self.settings.os == "Macos" and self.settings.arch == "armv8": | ||
# Build error - NO Access to a Mac/M1 - please fix when possible - see issue 8634 | ||
raise ConanInvalidConfiguration("Liboping cannot be built on a Mac/M1 at this time") | ||
|
||
def build_requirements(self): | ||
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): | ||
self.build_requires("msys2/cci.latest") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], | ||
destination=self._source_subfolder, strip_root=True) | ||
|
||
def _configure_autotools(self): | ||
if self._autotools: | ||
return self._autotools | ||
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||
yes_no = lambda v: "yes" if v else "no" | ||
args = [ | ||
"--enable-shared={}".format(yes_no(self.options.shared)), | ||
"--enable-static={}".format(yes_no(not self.options.shared)), | ||
"--without-ncurses", | ||
"--without-perl-bindings", | ||
] | ||
self._autotools.configure(args=args, configure_dir=self._source_subfolder) | ||
return self._autotools | ||
|
||
def _patch_sources(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
|
||
def build(self): | ||
self._patch_sources() | ||
autotools = self._configure_autotools() | ||
autotools.make() | ||
|
||
def package(self): | ||
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) | ||
autotools = self._configure_autotools() | ||
autotools.install() | ||
|
||
tools.rmdir(os.path.join(self.package_folder, "share")) | ||
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
|
||
def package_info(self): | ||
bindir = os.path.join(self.package_folder, "bin") | ||
self.output.info("Appending PATH environment variable: {}".format(bindir)) | ||
self.env_info.PATH.append(bindir) | ||
self.cpp_info.libs = ["oping"] | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("m") | ||
elif self.settings.os == "Windows": | ||
self.cpp_info.system_libs.append("ws2_32") |
18 changes: 18 additions & 0 deletions
18
recipes/liboping/all/patches/1.10.0-suppress_truncate.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- a/src/liboping.c 2022-01-04 12:15:14.312483115 -0700 | ||
+++ b/src/liboping.c 2022-01-04 12:16:40.031084749 -0700 | ||
@@ -203,8 +203,15 @@ | ||
static void ping_set_error (pingobj_t *obj, const char *function, | ||
const char *message) | ||
{ | ||
+#if __GNUC__ >= 7 | ||
+#pragma GCC diagnostic push | ||
+#pragma GCC diagnostic ignored "-Wformat-truncation" | ||
+#endif | ||
snprintf (obj->errmsg, sizeof (obj->errmsg), | ||
"%s: %s", function, message); | ||
+#if __GNUC__ >= 7 | ||
+#pragma GCC diagnostic pop | ||
+#endif | ||
obj->errmsg[sizeof (obj->errmsg) - 1] = 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package C) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(liboping CONFIG REQUIRED) | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} liboping::liboping) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "arch", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <oping.h> | ||
#include <stdio.h> | ||
|
||
int main() { | ||
printf("************* Testing liboping ***************\n"); | ||
pingobj_t *po; | ||
po = ping_construct(); | ||
if (po == NULL) { | ||
printf("\tFAIL\n"); | ||
return 1; | ||
} | ||
ping_destroy(po); | ||
printf("\tOK\n"); | ||
printf("***********************************************\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.10.0": | ||
folder: all |