-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
tcpcat library publish #24062
Merged
Merged
tcpcat library publish #24062
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1203dd0
tcpcat 1.0.0 publish
ydcpp b1b9937
fix linter errors
ydcpp 59f340d
Simplify recipe and test_package
AbrilRBS b512607
updated ASIO dependency usage and upstream version number
ydcpp bc471c4
CI test error fix
ydcpp 305b9aa
updated upstream version to 1.0.2
ydcpp 8a877de
added CMakeDeps for find_package to work properly
ydcpp 6dd37a2
updated for tcpcat 1.0.3
ydcpp f7c1da0
updated topics and asio requirement version
ydcpp 1de0ac8
updated upstream to 1.0.4 with fixes
ydcpp 55c270c
updated package folder name
ydcpp 28cb3dd
Ensure CXX is valid in Conan 1
AbrilRBS 990e08f
reorder
AbrilRBS 6cec5a2
Update recipes/ydcpp-tcpcat/all/test_package/CMakeLists.txt
AbrilRBS 8b5b463
Disable msvc shared builds for now until upstream exports some symbols
AbrilRBS 7ac0657
Add missing m system lib
AbrilRBS b841ae2
Simplify
AbrilRBS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,4 @@ | ||
sources: | ||
"1.0.4": | ||
url: "https://github.com/ydcpp/tcpcat/archive/refs/tags/1.0.4.tar.gz" | ||
sha256: "3413e74eab0a1bf7927b747e393b1931e8a516ee769642ce89c558a93e00e38b" |
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,97 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps, cmake_layout | ||
from conan.tools.microsoft import is_msvc | ||
from conan.tools.files import copy, get | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.scm import Version | ||
import os | ||
|
||
|
||
class TcpcatConan(ConanFile): | ||
name = "ydcpp-tcpcat" | ||
|
||
# Optional metadata | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/ydcpp/tcpcat" | ||
description = "Simple C++ TCP Server and Client library." | ||
topics = ("network", "tcp", "tcp-server", "tcp-client") | ||
|
||
# Binary configuration | ||
package_type = "library" | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "7", | ||
"Visual Studio": "16", | ||
"msvc": "192", | ||
"clang": "7", | ||
"apple-clang": "12" | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
self.options.rm_safe("fPIC") | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
# Upstream meant to support Windows Shared builds, but they don't currently export any symbols | ||
# Disable for now until fixed. As this is an upstream issue they want fixed, we don't set | ||
# package_type = "static-library" in the configure() method so that users have a clear message error for now | ||
if is_msvc(self) and self.options.shared: | ||
raise ConanInvalidConfiguration(f"{self.ref} does not currently support Windows shared builds due to an upstream issue") | ||
|
||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration( | ||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." | ||
) | ||
|
||
def requirements(self): | ||
self.requires("asio/1.30.2", transitive_headers = True) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
tc = CMakeToolchain(self) | ||
if not self.settings.get_safe("compiler.cppstd"): | ||
tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd | ||
tc.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")) | ||
copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["ydcpp-tcpcat"] | ||
self.cpp_info.set_property("cmake_target_name", "ydcpp-tcpcat") | ||
if self.settings.os in ("Linux", "FreeBSD"): | ||
self.cpp_info.system_libs.append("m") |
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,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(PackageTest CXX) | ||
|
||
add_executable(test_package test_package.cpp) | ||
|
||
find_package(ydcpp-tcpcat CONFIG REQUIRED) | ||
target_link_libraries(test_package ydcpp-tcpcat) | ||
AbrilRBS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
target_compile_features(test_package PRIVATE cxx_std_17) |
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,26 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, cmake_layout | ||
from conan.tools.build import can_run | ||
|
||
|
||
class tcpcatTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "CMakeDeps", "CMakeToolchain" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def test(self): | ||
if can_run(self): | ||
cmd = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(cmd, env="conanrun") |
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,11 @@ | ||
#include <tcpcat/tcpcat.h> | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
int main() | ||
{ | ||
tcpcat::TcpSession session(nullptr, nullptr, 0); | ||
std::cout << "session id: " << session.GetId() << std::endl; | ||
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.0.4": | ||
folder: all |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm missing something, because the project already does it: https://github.com/ydcpp/tcpcat/blob/1.0.4/CMakeLists.txt#L16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I actually didn't catch that - let's just try with your test package changes, see if that fixes everything :)