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 all 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"
70 changes: 70 additions & 0 deletions recipes/dnet/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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"
package_type = "library"
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):
if self.options.shared:
self.options.rm_safe("fPIC")
# This is a pure C project
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

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.append(os.path.join("include", "dnet"))

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;
}
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"
Loading