Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnet: add 1.16.3 #16372

Merged
merged 11 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/dnet/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.17.0":
url: "https://github.com/ofalk/libdnet/archive/refs/tags/libdnet-1.17.0.tar.gz"
sha256: "6be1ed0763151ede4c9665a403f1c9d974b2ffab2eacdb26b22078e461aae1dc"
76 changes: 76 additions & 0 deletions recipes/dnet/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rmdir
import os


required_conan_version = ">=1.56.0"


class dnetConan(ConanFile):
name = "dnet"
description = "Provides a simplified, portable interface to several low-level networking routines."
homepage = "https://github.com/ofalk/libdnet"
topics = ("dnet", "libdnet", "libdumbnet")
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
options = {
xakod marked this conversation as resolved.
Show resolved Hide resolved
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True
}
settings = "os", "arch", "compiler", "build_type"


def layout(self):
cmake_layout(self, src_folder="src")

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
self.options.rm_safe("fPIC")
try:
del self.settings.compiler.libcxx
except Exception:
pass
try:
del self.settings.compiler.cppstd
except Exception:
pass
xakod marked this conversation as resolved.
Show resolved Hide resolved

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)

tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self,"LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.configure()
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.libs.append("dnet")
self.cpp_info.includedirs = ["include"]

self.cpp_info.includedirs.extend(["include/dnet"])
xakod marked this conversation as resolved.
Show resolved Hide resolved

if self.settings.os == 'Windows':
self.cpp_info.system_libs = ['Iphlpapi', 'wsock32']
7 changes: 7 additions & 0 deletions recipes/dnet/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

find_package(dnet REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE dnet::dnet)
26 changes: 26 additions & 0 deletions recipes/dnet/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run("{} {}".format(bin_path, "127.0.0.1"), env="conanrun")
39 changes: 39 additions & 0 deletions recipes/dnet/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <dnet/dnet.h>
#include <dnet/config.h>
#include <dnet/err.h>

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
#include <unistd.h>
#elif defined(_WIN32)
#include <io.h>
#endif

void addr_usage(void)
{
fprintf(stderr, "Usage: dnet addr <address> ...\n");
exit(1);
}

int main(int argc, char *argv[])
{
struct addr addr;
int c, len;

if (argc == 1 || *(argv[1]) == '-')
addr_usage();

for (c = 1; c < argc; c++) {
if (addr_aton(argv[c], &addr) < 0)
addr_usage();

len = addr.addr_bits / 8;

if (write(1, addr.addr_data8, len) != len)
err(1, "write");
}
return 0;
}
8 changes: 8 additions & 0 deletions recipes/dnet/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_v1_package can be dropped already for new recipes

17 changes: 17 additions & 0 deletions recipes/dnet/all/test_v1_package/conanfile.py
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", "build_type", "arch"
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("{} {}".format(bin_path, "127.0.0.1"), run_environment=True)
3 changes: 3 additions & 0 deletions recipes/dnet/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.17.0":
folder: "all"