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

foxglove-websocket: add version 0.0.1 #8662

Merged
Merged
4 changes: 4 additions & 0 deletions recipes/foxglove-websocket/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
0.0.1:
url: https://github.com/foxglove/ws-protocol/archive/refs/tags/releases/cpp/v0.0.1.tar.gz
sha256: 94766f44973f0c0ce7e87039b9ef9d5b4a8bc73727047568170ac61262625c9b
38 changes: 38 additions & 0 deletions recipes/foxglove-websocket/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os


class FoxgloveWebSocketConan(ConanFile):
name = "foxglove-websocket"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/foxglove/ws-protocol"
description = "A C++ server implementation of the Foxglove WebSocket Protocol"
license = "MIT"
topics = ("foxglove", "websocket")

settings = ("os", "compiler", "build_type", "arch")
requires = ("nlohmann_json/3.10.5", "websocketpp/0.8.2")
generators = "cmake"

_source_root = "source_root"
_source_package_path = os.path.join(_source_root, "cpp", "foxglove-websocket")

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

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, "17")
if (self.settings.compiler == "gcc" or self.settings.compiler == "clang") and tools.Version(self.settings.compiler.version) <= 5:
raise ConanInvalidConfiguration("Compiler version is not supported, c++17 support is required")

def configure(self):
self.options["websocketpp"].asio = "standalone"
Copy link
Member

Choose a reason for hiding this comment

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

Okay. The default value is "boost", without it, this package would be invalid.


def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_package_path)
self.copy("include/*", src=self._source_package_path)

def package_id(self):
self.info.header_only()
8 changes: 8 additions & 0 deletions recipes/foxglove-websocket/all/test_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 CXX)

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

add_executable(test_package test_package.cpp)
target_link_libraries(test_package ${CONAN_LIBS})
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking quickly you'll need to configure C++17 here ... here's an example

set_target_properties(example PROPERTIES CXX_STANDARD 17)

I'll take a better look tomorrow of theres anything else I can find

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that helped for setting the language standard but still running into problems with the standard library version.

17 changes: 17 additions & 0 deletions recipes/foxglove-websocket/all/test_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", "arch", "compiler", "build_type")
generators = "cmake"

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)
11 changes: 11 additions & 0 deletions recipes/foxglove-websocket/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <string_view>
#include <foxglove/websocket/server.hpp>

int main() {
foxglove::websocket::Server server{0, "example"};
server.getEndpoint().set_timer(0, [&](std::error_code const& ec) {
server.stop();
});
server.run();
return 0;
}
3 changes: 3 additions & 0 deletions recipes/foxglove-websocket/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
0.0.1:
folder: all