From 886ad07eb332125962cd712e49c20d9f045203a9 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Oct 2023 18:26:49 -0400 Subject: [PATCH 01/14] initial implementation --- CMakeLists.txt | 50 ++++++++++++++ README.md | 28 ++++++++ cmake/webutilConfig.cmake.in | 4 ++ include/xo/webutil/Alist.hpp | 43 ++++++++++++ include/xo/webutil/HttpEndpointDescr.hpp | 76 +++++++++++++++++++++ include/xo/webutil/StreamEndpointDescr.hpp | 78 ++++++++++++++++++++++ 6 files changed, 279 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 cmake/webutilConfig.cmake.in create mode 100644 include/xo/webutil/Alist.hpp create mode 100644 include/xo/webutil/HttpEndpointDescr.hpp create mode 100644 include/xo/webutil/StreamEndpointDescr.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..dcce42b2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,50 @@ +# xo-webutil/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(webutil VERSION 1.0) +enable_language(CXX) + +# common XO cmake macros (see proj/xo-cmake) +include(xo_macros/xo_cxx) +include(xo_macros/code-coverage) + +# ---------------------------------------------------------------- +# unit test setup (no unit tests yet, but want 'make tests' to do something) + +enable_testing() +# activate code coverage for all executables + libraries (when -DCODE_COVERAGE=ON) +add_code_coverage() + +# 1. assuming that /nix/store/ prefixes .hpp files belonging to gcc, catch2 etc. +# we're not interested in code coverage for these sources. +# 2. exclude the utest/ subdir, we don't need coverage on the unit tests themselves; +# rather, want coverage on the code that the unit tests exercise. +# +add_code_coverage_all_targets(EXCLUDE /nix/store/* utest/*) + +# ---------------------------------------------------------------- + +xo_toplevel_compile_options() + +# ---------------------------------------------------------------- + +# header-only library. +# see [[https://stackoverflow.com/questions/47718485/install-and-export-interface-only-library-cmake]] +# +xo_add_headeronly_library(webutil) + +# ---------------------------------------------------------------- +# standard install + +xo_install_library3(webutil ${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# provide find_package() support + +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# install bespoke targets, if any + +#install(TARGETS example DESTINATION bin/xo-webutil/example) diff --git a/README.md b/README.md new file mode 100644 index 00000000..a8eb8c77 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# webutil library (header-only) + +# dependencies + +- xo-cmake [github/Rconybea/xo-cmake](https://github.com/Rconybea/xo-cmake) + +# clone repo +``` +$ git clone git@github.com:Rconybea/xo-webutil.git +``` + +# build and install +``` +$ cd xo-webutil +$ BUILDDIR=build # for example +$ mkdir $BUILDDIR +$ cd $BUILDDIR +$ PREFIX=/usr/local # for example +$ cmake -DCMAKE_MODULE_PATH=${PREFIX}/share/cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} .. +$ make +$ make install +``` + +# LSP support +``` +$ cd xo-webutil +$ ln -s $BUILDDIR/compile_commands.json +``` diff --git a/cmake/webutilConfig.cmake.in b/cmake/webutilConfig.cmake.in new file mode 100644 index 00000000..c44284f2 --- /dev/null +++ b/cmake/webutilConfig.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/webutilTargets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/include/xo/webutil/Alist.hpp b/include/xo/webutil/Alist.hpp new file mode 100644 index 00000000..80fcaa20 --- /dev/null +++ b/include/xo/webutil/Alist.hpp @@ -0,0 +1,43 @@ +/* file Alist.hpp + * + * author: Roland Conybeare, Sep 2022 + */ + +#pragma once + +#include +#include +#include + +namespace xo { + namespace web { + /* assocation list, maps strings to strings + * use this for arguments to dynamic-endpoint-callbacks + */ + class Alist { + public: + Alist() = default; + + /* lookup association by name */ + std::string_view lookup(std::string n) const { + for (auto const & ix : this->assoc_v_) { + if (ix.first == n) { + return ix.second; + } + } + + return ""; + } /*lookup*/ + + void push_back(std::string n, std::string v) { + this->assoc_v_.push_back(std::make_pair(std::move(n), std::move(v))); + } + + private: + std::vector> assoc_v_; + }; /*Alist*/ + + } /*namespace web*/ +} /*namespace xo*/ + +/* end Alist.hpp */ diff --git a/include/xo/webutil/HttpEndpointDescr.hpp b/include/xo/webutil/HttpEndpointDescr.hpp new file mode 100644 index 00000000..79a7070f --- /dev/null +++ b/include/xo/webutil/HttpEndpointDescr.hpp @@ -0,0 +1,76 @@ +/* file EndpointDescr.hpp + * + * author: Roland Conybeare, Sep 2022 + */ + +#pragma once + +#include "web_util/Alist.hpp" +#include "refcnt/Refcounted.hpp" +#include "indentlog/print/tag.hpp" +#include "indentlog/print/tostr.hpp" +#include + +namespace xo { + namespace web { + /* a function that can deliver http content on demand. */ + using HttpEndpointFn = std::function; + + /* describes an http endpoint -- + * this comprises: + * - a uri pattern. + * - a function that can deliver http content on demand + */ + class HttpEndpointDescr { + public: + HttpEndpointDescr(std::string uri_pattern, + HttpEndpointFn endpoint_fn) + : uri_pattern_{std::move(uri_pattern)}, + endpoint_fn_{std::move(endpoint_fn)} + {} + + std::string const & uri_pattern() const { return uri_pattern_; } + HttpEndpointFn const & endpoint_fn() const { return endpoint_fn_; } + + void display(std::ostream & os) const { + using xo::xtag; + + os << ""; + } /*display*/ + + std::string display_string() const { return xo::tostr(*this); } + + private: + /* unique pattern in URI-space for this endpoint. + * for example + * .uri_pattern = /stem/${foo}/${bar} + * means this endpoint generates contents for uri's + * /stem/apple/banana + * /stem/aphid/green + * but not for + * /stem/apple/banana/carrot + */ + std::string uri_pattern_; + /* a function that can construct http output on demand + * .endpoint_fn(uri, alist, &os) + * writes http output to os. output is parameterized + * by name-value pairs in alist, and is prepared on behalf + * of .uri_pattern + * alist will report name-value pairs for each variable that + * appears in .uri_pattern (surrounded by ${..}) + */ + HttpEndpointFn endpoint_fn_; + }; /*HttpEndpointDescr*/ + + inline std::ostream & + operator<<(std::ostream & os, HttpEndpointDescr const & x) { + x.display(os); + return os; + } /*operator<<*/ + + } /*namespace web*/ +} /*namespace xo*/ + +/* end EndpointDescr.hpp */ diff --git a/include/xo/webutil/StreamEndpointDescr.hpp b/include/xo/webutil/StreamEndpointDescr.hpp new file mode 100644 index 00000000..fe86b135 --- /dev/null +++ b/include/xo/webutil/StreamEndpointDescr.hpp @@ -0,0 +1,78 @@ +/* file StreamEndpointDescr.hpp + * + * author: Roland Conybeare, Sep 2022 + */ + +#pragma once + +#include "web_util/Alist.hpp" +#include "callback/CallbackSet.hpp" +#include "refcnt/Refcounted.hpp" +#include "indentlog/print/tag.hpp" +#include "indentlog/print/tostr.hpp" +#include + +namespace xo { + namespace reactor { class AbstractSink; } + + namespace web { + /* a function that creates an event subscription */ + using StreamSubscribeFn = std::function const & ws_sink)>; + using StreamUnsubscribeFn = std::function; + + /* describes a stream endpoint + * this comprises + * - a uri pattern (matches stream name) + * - a function that establishes subscription + * (by attaching supplied WebsocketSink to an event source) + */ + class StreamEndpointDescr { + public: + StreamEndpointDescr(std::string uri_pattern, + StreamSubscribeFn subscribe_fn, + StreamUnsubscribeFn unsubscribe_fn) + : uri_pattern_{std::move(uri_pattern)}, + subscribe_fn_{std::move(subscribe_fn)}, + unsubscribe_fn_{std::move(unsubscribe_fn)} {} + + std::string const & uri_pattern() const { return uri_pattern_; } + StreamSubscribeFn const & subscribe_fn() const { return subscribe_fn_; } + StreamUnsubscribeFn const & unsubscribe_fn() const { return unsubscribe_fn_; } + + void display(std::ostream & os) const { + using xo::xtag; + + os << ""; + } /*display*/ + + std::string display_string() const { return xo::tostr(*this); } + + private: + /* unique pattern in URI-space for this endpoint + * for example + * .uri_pattern = /stem/${foo}/${bar} + * means this endpoint generates contents for uri's + * /stem/apple/banana + * /stem/aphid/green + * but not for + * /stem/apple/banana/carrot + */ + std::string uri_pattern_; + /* a function that subscribes to an event stream + * (by attaching a websocket sink) + */ + StreamSubscribeFn subscribe_fn_; + /* reverses effect of a particular call to .subscribe_fn */ + StreamUnsubscribeFn unsubscribe_fn_; + }; /*StreamEndpointDescr*/ + + inline std::ostream & + operator<<(std::ostream & os, StreamEndpointDescr const & x) { + x.display(os); + return os; + } /*operator<<*/ + + } /*namespace web*/ +} /*namespace xo*/ + +/* end StreamEndpointDescr.hpp */ From 8759357ec7730cf3eca5941dfe6d261d4bf08c6a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Oct 2023 18:27:14 -0400 Subject: [PATCH 02/14] + .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..abafa2ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# typical build directories +build From 9a23b29c12d53f773d6e46a45e7b3e1f95633821 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Oct 2023 18:43:04 -0400 Subject: [PATCH 03/14] cosmetic: formatting --- include/xo/webutil/Alist.hpp | 50 +++++----- include/xo/webutil/HttpEndpointDescr.hpp | 102 ++++++++++---------- include/xo/webutil/StreamEndpointDescr.hpp | 104 ++++++++++----------- 3 files changed, 128 insertions(+), 128 deletions(-) diff --git a/include/xo/webutil/Alist.hpp b/include/xo/webutil/Alist.hpp index 80fcaa20..ccb317b3 100644 --- a/include/xo/webutil/Alist.hpp +++ b/include/xo/webutil/Alist.hpp @@ -10,34 +10,34 @@ #include namespace xo { - namespace web { - /* assocation list, maps strings to strings - * use this for arguments to dynamic-endpoint-callbacks - */ - class Alist { - public: - Alist() = default; - - /* lookup association by name */ - std::string_view lookup(std::string n) const { - for (auto const & ix : this->assoc_v_) { - if (ix.first == n) { - return ix.second; - } - } + namespace web { + /* assocation list, maps strings to strings + * use this for arguments to dynamic-endpoint-callbacks + */ + class Alist { + public: + Alist() = default; - return ""; - } /*lookup*/ + /* lookup association by name */ + std::string_view lookup(std::string n) const { + for (auto const & ix : this->assoc_v_) { + if (ix.first == n) { + return ix.second; + } + } - void push_back(std::string n, std::string v) { - this->assoc_v_.push_back(std::make_pair(std::move(n), std::move(v))); - } + return ""; + } /*lookup*/ - private: - std::vector> assoc_v_; - }; /*Alist*/ - - } /*namespace web*/ + void push_back(std::string n, std::string v) { + this->assoc_v_.push_back(std::make_pair(std::move(n), std::move(v))); + } + + private: + std::vector> assoc_v_; + }; /*Alist*/ + + } /*namespace web*/ } /*namespace xo*/ /* end Alist.hpp */ diff --git a/include/xo/webutil/HttpEndpointDescr.hpp b/include/xo/webutil/HttpEndpointDescr.hpp index 79a7070f..97ff4cee 100644 --- a/include/xo/webutil/HttpEndpointDescr.hpp +++ b/include/xo/webutil/HttpEndpointDescr.hpp @@ -12,65 +12,65 @@ #include namespace xo { - namespace web { - /* a function that can deliver http content on demand. */ - using HttpEndpointFn = std::function; + namespace web { + /* a function that can deliver http content on demand. */ + using HttpEndpointFn = std::function; - /* describes an http endpoint -- - * this comprises: - * - a uri pattern. - * - a function that can deliver http content on demand - */ - class HttpEndpointDescr { - public: - HttpEndpointDescr(std::string uri_pattern, - HttpEndpointFn endpoint_fn) - : uri_pattern_{std::move(uri_pattern)}, - endpoint_fn_{std::move(endpoint_fn)} - {} + /* describes an http endpoint -- + * this comprises: + * - a uri pattern. + * - a function that can deliver http content on demand + */ + class HttpEndpointDescr { + public: + HttpEndpointDescr(std::string uri_pattern, + HttpEndpointFn endpoint_fn) + : uri_pattern_{std::move(uri_pattern)}, + endpoint_fn_{std::move(endpoint_fn)} + {} - std::string const & uri_pattern() const { return uri_pattern_; } - HttpEndpointFn const & endpoint_fn() const { return endpoint_fn_; } + std::string const & uri_pattern() const { return uri_pattern_; } + HttpEndpointFn const & endpoint_fn() const { return endpoint_fn_; } - void display(std::ostream & os) const { - using xo::xtag; + void display(std::ostream & os) const { + using xo::xtag; - os << ""; - } /*display*/ + os << ""; + } /*display*/ - std::string display_string() const { return xo::tostr(*this); } + std::string display_string() const { return xo::tostr(*this); } - private: - /* unique pattern in URI-space for this endpoint. - * for example - * .uri_pattern = /stem/${foo}/${bar} - * means this endpoint generates contents for uri's - * /stem/apple/banana - * /stem/aphid/green - * but not for - * /stem/apple/banana/carrot - */ - std::string uri_pattern_; - /* a function that can construct http output on demand - * .endpoint_fn(uri, alist, &os) - * writes http output to os. output is parameterized - * by name-value pairs in alist, and is prepared on behalf - * of .uri_pattern - * alist will report name-value pairs for each variable that - * appears in .uri_pattern (surrounded by ${..}) - */ - HttpEndpointFn endpoint_fn_; - }; /*HttpEndpointDescr*/ + private: + /* unique pattern in URI-space for this endpoint. + * for example + * .uri_pattern = /stem/${foo}/${bar} + * means this endpoint generates contents for uri's + * /stem/apple/banana + * /stem/aphid/green + * but not for + * /stem/apple/banana/carrot + */ + std::string uri_pattern_; + /* a function that can construct http output on demand + * .endpoint_fn(uri, alist, &os) + * writes http output to os. output is parameterized + * by name-value pairs in alist, and is prepared on behalf + * of .uri_pattern + * alist will report name-value pairs for each variable that + * appears in .uri_pattern (surrounded by ${..}) + */ + HttpEndpointFn endpoint_fn_; + }; /*HttpEndpointDescr*/ - inline std::ostream & - operator<<(std::ostream & os, HttpEndpointDescr const & x) { - x.display(os); - return os; - } /*operator<<*/ + inline std::ostream & + operator<<(std::ostream & os, HttpEndpointDescr const & x) { + x.display(os); + return os; + } /*operator<<*/ - } /*namespace web*/ + } /*namespace web*/ } /*namespace xo*/ /* end EndpointDescr.hpp */ diff --git a/include/xo/webutil/StreamEndpointDescr.hpp b/include/xo/webutil/StreamEndpointDescr.hpp index fe86b135..1b361610 100644 --- a/include/xo/webutil/StreamEndpointDescr.hpp +++ b/include/xo/webutil/StreamEndpointDescr.hpp @@ -5,7 +5,7 @@ #pragma once -#include "web_util/Alist.hpp" +#include "Alist.hpp" #include "callback/CallbackSet.hpp" #include "refcnt/Refcounted.hpp" #include "indentlog/print/tag.hpp" @@ -13,66 +13,66 @@ #include namespace xo { - namespace reactor { class AbstractSink; } + namespace reactor { class AbstractSink; } - namespace web { - /* a function that creates an event subscription */ - using StreamSubscribeFn = std::function const & ws_sink)>; - using StreamUnsubscribeFn = std::function; + namespace web { + /* a function that creates an event subscription */ + using StreamSubscribeFn = std::function const & ws_sink)>; + using StreamUnsubscribeFn = std::function; - /* describes a stream endpoint - * this comprises - * - a uri pattern (matches stream name) - * - a function that establishes subscription - * (by attaching supplied WebsocketSink to an event source) - */ - class StreamEndpointDescr { - public: - StreamEndpointDescr(std::string uri_pattern, - StreamSubscribeFn subscribe_fn, - StreamUnsubscribeFn unsubscribe_fn) - : uri_pattern_{std::move(uri_pattern)}, - subscribe_fn_{std::move(subscribe_fn)}, - unsubscribe_fn_{std::move(unsubscribe_fn)} {} + /* describes a stream endpoint + * this comprises + * - a uri pattern (matches stream name) + * - a function that establishes subscription + * (by attaching supplied WebsocketSink to an event source) + */ + class StreamEndpointDescr { + public: + StreamEndpointDescr(std::string uri_pattern, + StreamSubscribeFn subscribe_fn, + StreamUnsubscribeFn unsubscribe_fn) + : uri_pattern_{std::move(uri_pattern)}, + subscribe_fn_{std::move(subscribe_fn)}, + unsubscribe_fn_{std::move(unsubscribe_fn)} {} - std::string const & uri_pattern() const { return uri_pattern_; } - StreamSubscribeFn const & subscribe_fn() const { return subscribe_fn_; } - StreamUnsubscribeFn const & unsubscribe_fn() const { return unsubscribe_fn_; } + std::string const & uri_pattern() const { return uri_pattern_; } + StreamSubscribeFn const & subscribe_fn() const { return subscribe_fn_; } + StreamUnsubscribeFn const & unsubscribe_fn() const { return unsubscribe_fn_; } - void display(std::ostream & os) const { - using xo::xtag; + void display(std::ostream & os) const { + using xo::xtag; - os << ""; - } /*display*/ + os << ""; + } /*display*/ - std::string display_string() const { return xo::tostr(*this); } + std::string display_string() const { return xo::tostr(*this); } - private: - /* unique pattern in URI-space for this endpoint - * for example - * .uri_pattern = /stem/${foo}/${bar} - * means this endpoint generates contents for uri's - * /stem/apple/banana - * /stem/aphid/green - * but not for - * /stem/apple/banana/carrot - */ - std::string uri_pattern_; - /* a function that subscribes to an event stream - * (by attaching a websocket sink) - */ - StreamSubscribeFn subscribe_fn_; - /* reverses effect of a particular call to .subscribe_fn */ - StreamUnsubscribeFn unsubscribe_fn_; - }; /*StreamEndpointDescr*/ + private: + /* unique pattern in URI-space for this endpoint + * for example + * .uri_pattern = /stem/${foo}/${bar} + * means this endpoint generates contents for uri's + * /stem/apple/banana + * /stem/aphid/green + * but not for + * /stem/apple/banana/carrot + */ + std::string uri_pattern_; + /* a function that subscribes to an event stream + * (by attaching a websocket sink) + */ + StreamSubscribeFn subscribe_fn_; + /* reverses effect of a particular call to .subscribe_fn */ + StreamUnsubscribeFn unsubscribe_fn_; + }; /*StreamEndpointDescr*/ - inline std::ostream & - operator<<(std::ostream & os, StreamEndpointDescr const & x) { - x.display(os); - return os; - } /*operator<<*/ + inline std::ostream & + operator<<(std::ostream & os, StreamEndpointDescr const & x) { + x.display(os); + return os; + } /*operator<<*/ - } /*namespace web*/ + } /*namespace web*/ } /*namespace xo*/ /* end StreamEndpointDescr.hpp */ From 38b8f34b2884768172dfd2394b5f44694e31ff54 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Oct 2023 19:19:44 -0400 Subject: [PATCH 04/14] refactor: move impl into .cpp + fix include paths --- CMakeLists.txt | 19 ++++++++------- cmake/webutilConfig.cmake.in | 2 ++ include/xo/webutil/Alist.hpp | 14 ++--------- include/xo/webutil/HttpEndpointDescr.hpp | 20 +++++----------- include/xo/webutil/StreamEndpointDescr.hpp | 19 ++++----------- src/webutil/Alist.cpp | 28 ++++++++++++++++++++++ src/webutil/CMakeLists.txt | 14 +++++++++++ src/webutil/HttpEndpointDescr.cpp | 27 +++++++++++++++++++++ src/webutil/StreamEndpointDescr.cpp | 28 ++++++++++++++++++++++ 9 files changed, 122 insertions(+), 49 deletions(-) create mode 100644 src/webutil/Alist.cpp create mode 100644 src/webutil/CMakeLists.txt create mode 100644 src/webutil/HttpEndpointDescr.cpp create mode 100644 src/webutil/StreamEndpointDescr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dcce42b2..04cc53f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,20 +24,19 @@ add_code_coverage() add_code_coverage_all_targets(EXCLUDE /nix/store/* utest/*) # ---------------------------------------------------------------- +# common c++ settings + +# PROJECT_CXX_FLAGS: bespoke for this project - usually empty +set(PROJECT_CXX_FLAGS "") +#set(PROJECT_CXX_FLAGS "-fconcepts-diagnostics-depth=2") +add_definitions(${PROJECT_CXX_FLAGS}) xo_toplevel_compile_options() # ---------------------------------------------------------------- +# sources -# header-only library. -# see [[https://stackoverflow.com/questions/47718485/install-and-export-interface-only-library-cmake]] -# -xo_add_headeronly_library(webutil) - -# ---------------------------------------------------------------- -# standard install - -xo_install_library3(webutil ${PROJECT_NAME}Targets) +add_subdirectory(src/webutil) # ---------------------------------------------------------------- # provide find_package() support @@ -47,4 +46,6 @@ xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets # ---------------------------------------------------------------- # install bespoke targets, if any +xo_install_include_tree() + #install(TARGETS example DESTINATION bin/xo-webutil/example) diff --git a/cmake/webutilConfig.cmake.in b/cmake/webutilConfig.cmake.in index c44284f2..79a9df3d 100644 --- a/cmake/webutilConfig.cmake.in +++ b/cmake/webutilConfig.cmake.in @@ -1,4 +1,6 @@ @PACKAGE_INIT@ +include(CMakeFindDependencyMacro) +find_dependency(callback) include("${CMAKE_CURRENT_LIST_DIR}/webutilTargets.cmake") check_required_components("@PROJECT_NAME@") diff --git a/include/xo/webutil/Alist.hpp b/include/xo/webutil/Alist.hpp index ccb317b3..4bc5a305 100644 --- a/include/xo/webutil/Alist.hpp +++ b/include/xo/webutil/Alist.hpp @@ -19,19 +19,9 @@ namespace xo { Alist() = default; /* lookup association by name */ - std::string_view lookup(std::string n) const { - for (auto const & ix : this->assoc_v_) { - if (ix.first == n) { - return ix.second; - } - } + std::string_view lookup(std::string n) const; - return ""; - } /*lookup*/ - - void push_back(std::string n, std::string v) { - this->assoc_v_.push_back(std::make_pair(std::move(n), std::move(v))); - } + void push_back(std::string n, std::string v); private: std::vector> assoc_v_; diff --git a/include/xo/webutil/HttpEndpointDescr.hpp b/include/xo/webutil/HttpEndpointDescr.hpp index 97ff4cee..f3598cbb 100644 --- a/include/xo/webutil/HttpEndpointDescr.hpp +++ b/include/xo/webutil/HttpEndpointDescr.hpp @@ -5,11 +5,10 @@ #pragma once -#include "web_util/Alist.hpp" -#include "refcnt/Refcounted.hpp" -#include "indentlog/print/tag.hpp" -#include "indentlog/print/tostr.hpp" +#include "Alist.hpp" +#include "xo/refcnt/Refcounted.hpp" #include +#include namespace xo { namespace web { @@ -26,21 +25,14 @@ namespace xo { class HttpEndpointDescr { public: HttpEndpointDescr(std::string uri_pattern, - HttpEndpointFn endpoint_fn) - : uri_pattern_{std::move(uri_pattern)}, - endpoint_fn_{std::move(endpoint_fn)} - {} + HttpEndpointFn endpoint_fn); std::string const & uri_pattern() const { return uri_pattern_; } HttpEndpointFn const & endpoint_fn() const { return endpoint_fn_; } - void display(std::ostream & os) const { - using xo::xtag; + void display(std::ostream & os) const; - os << ""; - } /*display*/ - - std::string display_string() const { return xo::tostr(*this); } + std::string display_string() const; private: /* unique pattern in URI-space for this endpoint. diff --git a/include/xo/webutil/StreamEndpointDescr.hpp b/include/xo/webutil/StreamEndpointDescr.hpp index 1b361610..78053008 100644 --- a/include/xo/webutil/StreamEndpointDescr.hpp +++ b/include/xo/webutil/StreamEndpointDescr.hpp @@ -6,10 +6,8 @@ #pragma once #include "Alist.hpp" -#include "callback/CallbackSet.hpp" -#include "refcnt/Refcounted.hpp" -#include "indentlog/print/tag.hpp" -#include "indentlog/print/tostr.hpp" +#include "xo/callback/CallbackSet.hpp" +#include "xo/refcnt/Refcounted.hpp" #include namespace xo { @@ -30,22 +28,15 @@ namespace xo { public: StreamEndpointDescr(std::string uri_pattern, StreamSubscribeFn subscribe_fn, - StreamUnsubscribeFn unsubscribe_fn) - : uri_pattern_{std::move(uri_pattern)}, - subscribe_fn_{std::move(subscribe_fn)}, - unsubscribe_fn_{std::move(unsubscribe_fn)} {} + StreamUnsubscribeFn unsubscribe_fn); std::string const & uri_pattern() const { return uri_pattern_; } StreamSubscribeFn const & subscribe_fn() const { return subscribe_fn_; } StreamUnsubscribeFn const & unsubscribe_fn() const { return unsubscribe_fn_; } - void display(std::ostream & os) const { - using xo::xtag; + void display(std::ostream & os) const; - os << ""; - } /*display*/ - - std::string display_string() const { return xo::tostr(*this); } + std::string display_string() const; private: /* unique pattern in URI-space for this endpoint diff --git a/src/webutil/Alist.cpp b/src/webutil/Alist.cpp new file mode 100644 index 00000000..73905106 --- /dev/null +++ b/src/webutil/Alist.cpp @@ -0,0 +1,28 @@ +/* @file Alist.cpp */ + +#include "Alist.hpp" + +namespace xo { + namespace web { + /* lookup association by name */ + std::string_view + Alist::lookup(std::string n) const { + for (auto const & ix : this->assoc_v_) { + if (ix.first == n) { + return ix.second; + } + } + + return ""; + } /*lookup*/ + + void + Alist::push_back(std::string n, std::string v) { + this->assoc_v_.push_back(std::make_pair(std::move(n), std::move(v))); + } + } /*namespace web*/ +} /*namespace xo*/ + + + +/* end Alist.cpp */ diff --git a/src/webutil/CMakeLists.txt b/src/webutil/CMakeLists.txt new file mode 100644 index 00000000..57f96726 --- /dev/null +++ b/src/webutil/CMakeLists.txt @@ -0,0 +1,14 @@ +# webutil/CMakeLists.txt + +set(SELF_LIB webutil) +set(SELF_SRCS StreamEndpointDescr.cpp HttpEndpointDescr.cpp Alist.cpp) + +# reminder: can't be header-only library, because depends on non-header-only callback (bc of non-header-only refcnt) +xo_add_shared_library(${SELF_LIB} ${PROJECT_VERSION} 1 ${SELF_SRCS}) + +# ---------------------------------------------------------------- +# external dependencies + +xo_dependency(${SELF_LIB} callback) + +# end CMakeLists.txt diff --git a/src/webutil/HttpEndpointDescr.cpp b/src/webutil/HttpEndpointDescr.cpp new file mode 100644 index 00000000..fb9ab261 --- /dev/null +++ b/src/webutil/HttpEndpointDescr.cpp @@ -0,0 +1,27 @@ +/* @file HttpEndpointDescr.cpp */ + +#include "HttpEndpointDescr.hpp" +#include "xo/indentlog/print/tag.hpp" +#include "xo/indentlog/print/tostr.hpp" + +namespace xo { + namespace web { + HttpEndpointDescr::HttpEndpointDescr(std::string uri_pattern, + HttpEndpointFn endpoint_fn) + : uri_pattern_{std::move(uri_pattern)}, + endpoint_fn_{std::move(endpoint_fn)} + {} + + void + HttpEndpointDescr::display(std::ostream & os) const { + os << ""; + } /*display*/ + + std::string + HttpEndpointDescr::display_string() const { return tostr(*this); } + } /*namespace web*/ + +} /*namespace xo*/ + + +/* end HttpEndpointDescr.cpp */ diff --git a/src/webutil/StreamEndpointDescr.cpp b/src/webutil/StreamEndpointDescr.cpp new file mode 100644 index 00000000..03c2e961 --- /dev/null +++ b/src/webutil/StreamEndpointDescr.cpp @@ -0,0 +1,28 @@ +/* @file StreamEndpointDescr.cpp */ + +#include "StreamEndpointDescr.hpp" +#include "xo/indentlog/print/tag.hpp" +#include "xo/indentlog/print/tostr.hpp" + +namespace xo { + namespace web { + StreamEndpointDescr::StreamEndpointDescr(std::string uri_pattern, + StreamSubscribeFn subscribe_fn, + StreamUnsubscribeFn unsubscribe_fn) + : uri_pattern_{std::move(uri_pattern)}, + subscribe_fn_{std::move(subscribe_fn)}, + unsubscribe_fn_{std::move(unsubscribe_fn)} + {} + + void + StreamEndpointDescr::display(std::ostream & os) const { + os << ""; + } /*display*/ + + std::string + StreamEndpointDescr::display_string() const { return tostr(*this); } + } /*namespace web*/ +} /*namespace xo*/ + + +/* end StreamEndpointDescr.cpp */ From 937109896c1fac15779ae94e27bd18d93493cc5e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Oct 2023 19:20:36 -0400 Subject: [PATCH 05/14] ext .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index abafa2ca..3e50f879 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ +# lsp keeps state here +.cache +# symlink -> build/compile_commands.json should be created manually +compile_commands.json # typical build directories build From 2de57c1ec3643544d40b0781e29eeba3c74e32de Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Oct 2023 15:30:13 -0400 Subject: [PATCH 06/14] doc: README additions --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a8eb8c77..34463fb0 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,19 @@ # webutil library (header-only) -# dependencies +## Getting Started -- xo-cmake [github/Rconybea/xo-cmake](https://github.com/Rconybea/xo-cmake) +### build + install dependencies + +- xo-callback [github/Rconybea/xo-callback](https://github.com/Rconybea/xo-callback) + +### clone repo -# clone repo ``` $ git clone git@github.com:Rconybea/xo-webutil.git ``` -# build and install +### build and install + ``` $ cd xo-webutil $ BUILDDIR=build # for example @@ -21,7 +25,8 @@ $ make $ make install ``` -# LSP support +### LSP support + ``` $ cd xo-webutil $ ln -s $BUILDDIR/compile_commands.json From d312d8a5a49efa3ec4f22fd2e0e8c70f73414020 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Oct 2023 16:13:07 -0400 Subject: [PATCH 07/14] build: fix for header-only callback dep --- include/xo/webutil/StreamEndpointDescr.hpp | 2 +- src/webutil/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/xo/webutil/StreamEndpointDescr.hpp b/include/xo/webutil/StreamEndpointDescr.hpp index 78053008..53aa63c7 100644 --- a/include/xo/webutil/StreamEndpointDescr.hpp +++ b/include/xo/webutil/StreamEndpointDescr.hpp @@ -6,8 +6,8 @@ #pragma once #include "Alist.hpp" -#include "xo/callback/CallbackSet.hpp" #include "xo/refcnt/Refcounted.hpp" +#include "xo/callback/CallbackSet.hpp" #include namespace xo { diff --git a/src/webutil/CMakeLists.txt b/src/webutil/CMakeLists.txt index 57f96726..7d9f5665 100644 --- a/src/webutil/CMakeLists.txt +++ b/src/webutil/CMakeLists.txt @@ -9,6 +9,7 @@ xo_add_shared_library(${SELF_LIB} ${PROJECT_VERSION} 1 ${SELF_SRCS}) # ---------------------------------------------------------------- # external dependencies +xo_dependency(${SELF_LIB} refcnt) xo_dependency(${SELF_LIB} callback) # end CMakeLists.txt From 77a570f8a5c8b40cada66e35352dc7fc40d3b8ad Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Oct 2023 16:13:21 -0400 Subject: [PATCH 08/14] github: + workflow --- .github/workflows/main.yml | 117 +++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..8b3795c9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,117 @@ +name: build xo-callback + xo dependencies + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - name: checkout source + uses: actions/checkout@v3 + + - name: Install catch2 + # install catch2. see [[https://stackoverflow.com/questions/57982945/how-to-apt-get-install-in-a-github-actions-workflow]] + run: sudo apt-get install -y catch2 + + # ---------------------------------------------------------------- + + - name: Clone xo-cmake + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-cmake + path: repo/xo-cmake + + - name: Configure xo-cmake + run: cmake -B ${{github.workspace}}/build_xo-cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/xo-cmake + + - name: Build xo-cmake (trivial) + run: cmake --build ${{github.workspace}}/build_xo-cmake --config ${{env.BUILD_TYPE}} + + - name: Install xo-cmake + run: cmake --install ${{github.workspace}}/build_xo-cmake + + # ---------------------------------------------------------------- + + - name: Clone indentlog + uses: actions/checkout@v3 + with: + repository: Rconybea/indentlog + path: repo/indentlog + + - name: Configure indentlog + # configure cmake for indentlog in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_indentlog -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/indentlog + + - name: Build indentlog + run: cmake --build ${{github.workspace}}/build_indentlog --config ${{env.BUILD_TYPE}} + + - name: Install indentlog + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_indentlog + + # ---------------------------------------------------------------- + + - name: Clone refcnt + uses: actions/checkout@v3 + with: + repository: Rconybea/refcnt + path: repo/refcnt + + - name: Configure refcnt + # configure cmake for refcnt in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_refcnt -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/refcnt + + - name: Build refcnt + run: cmake --build ${{github.workspace}}/build_refcnt --config ${{env.BUILD_TYPE}} + + - name: Install refcnt + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_refcnt + + # ---------------------------------------------------------------- + + - name: Clone callback + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-callback + path: repo/callback + + - name: Configure callback + # configure cmake for callback in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_callback -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/callback + + - name: Build callback + run: cmake --build ${{github.workspace}}/build_callback --config ${{env.BUILD_TYPE}} + + - name: Install callback + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_callback + + # ---------------------------------------------------------------- + + - name: Configure self (webutil) + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build_webutil -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: Build self (webutil) + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build_webutil --config ${{env.BUILD_TYPE}} + + - name: Test self (webutil) + working-directory: ${{github.workspace}}/build_webutil + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{env.BUILD_TYPE}} From 6d970d4f3c944d69de69a4d15dccb8fbedfdf4be Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Oct 2023 16:16:14 -0400 Subject: [PATCH 09/14] drop false header-only claim ! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34463fb0..0d906d20 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# webutil library (header-only) +# webutil library ## Getting Started From 7c2d01c5f437ed01bdf72681036b33f40551bb6e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 19 Oct 2023 17:10:28 -0400 Subject: [PATCH 10/14] build: support symlink-enabled variation --- CMakeLists.txt | 7 ------- src/webutil/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04cc53f2..b63e290e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,10 +42,3 @@ add_subdirectory(src/webutil) # provide find_package() support xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) - -# ---------------------------------------------------------------- -# install bespoke targets, if any - -xo_install_include_tree() - -#install(TARGETS example DESTINATION bin/xo-webutil/example) diff --git a/src/webutil/CMakeLists.txt b/src/webutil/CMakeLists.txt index 7d9f5665..54fe2a88 100644 --- a/src/webutil/CMakeLists.txt +++ b/src/webutil/CMakeLists.txt @@ -4,7 +4,7 @@ set(SELF_LIB webutil) set(SELF_SRCS StreamEndpointDescr.cpp HttpEndpointDescr.cpp Alist.cpp) # reminder: can't be header-only library, because depends on non-header-only callback (bc of non-header-only refcnt) -xo_add_shared_library(${SELF_LIB} ${PROJECT_VERSION} 1 ${SELF_SRCS}) +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) # ---------------------------------------------------------------- # external dependencies From 260f3435e1f06a4b95a3af41e99a6ac543ea4909 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 15 Mar 2024 19:35:02 -0400 Subject: [PATCH 11/14] build: streamline CMAKE_MODULE_PATH interaction --- .gitignore | 2 +- CMakeLists.txt | 3 +-- cmake/xo-bootstrap-macros.cmake | 12 ++++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 cmake/xo-bootstrap-macros.cmake diff --git a/.gitignore b/.gitignore index 3e50f879..b1adb07b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ # symlink -> build/compile_commands.json should be created manually compile_commands.json # typical build directories -build +.build* diff --git a/CMakeLists.txt b/CMakeLists.txt index b63e290e..94fd52ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,7 @@ project(webutil VERSION 1.0) enable_language(CXX) # common XO cmake macros (see proj/xo-cmake) -include(xo_macros/xo_cxx) -include(xo_macros/code-coverage) +include(cmake/xo-bootstrap-macros.cmake) # ---------------------------------------------------------------- # unit test setup (no unit tests yet, but want 'make tests' to do something) diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..16644435 --- /dev/null +++ b/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,12 @@ +if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + # default to typical install location for xo-project-macros + set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake) +endif() + +message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") +message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo-project-macros) From 8c196a35a7b2d0d5dcd804167da9f104ba77e448 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 29 Mar 2024 14:33:41 -0400 Subject: [PATCH 12/14] build: suppress bootstrap message in submodule build --- cmake/xo-bootstrap-macros.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake index 16644435..96592216 100644 --- a/cmake/xo-bootstrap-macros.cmake +++ b/cmake/xo-bootstrap-macros.cmake @@ -3,8 +3,10 @@ if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "pr set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake) endif() -message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") -message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") +if (NOT XO_SUBMODULE_BUILD) + message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") + message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") +endif() # needs to have been installed somewhere on CMAKE_MODULE_PATH, # (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) From 7d1e10c09ba1630e61c3b26c47f85c529ba4abd6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Sep 2024 13:26:15 -0500 Subject: [PATCH 13/14] xo-webutil: build: update to latest xo-cmake macros --- CMakeLists.txt | 19 ++----------------- cmake/xo-bootstrap-macros.cmake | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94fd52ed..76c8795a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,24 +3,11 @@ cmake_minimum_required(VERSION 3.10) project(webutil VERSION 1.0) -enable_language(CXX) -# common XO cmake macros (see proj/xo-cmake) +include(GNUInstallDirs) include(cmake/xo-bootstrap-macros.cmake) -# ---------------------------------------------------------------- -# unit test setup (no unit tests yet, but want 'make tests' to do something) - -enable_testing() -# activate code coverage for all executables + libraries (when -DCODE_COVERAGE=ON) -add_code_coverage() - -# 1. assuming that /nix/store/ prefixes .hpp files belonging to gcc, catch2 etc. -# we're not interested in code coverage for these sources. -# 2. exclude the utest/ subdir, we don't need coverage on the unit tests themselves; -# rather, want coverage on the code that the unit tests exercise. -# -add_code_coverage_all_targets(EXCLUDE /nix/store/* utest/*) +xo_cxx_toplevel_options3() # ---------------------------------------------------------------- # common c++ settings @@ -30,8 +17,6 @@ set(PROJECT_CXX_FLAGS "") #set(PROJECT_CXX_FLAGS "-fconcepts-diagnostics-depth=2") add_definitions(${PROJECT_CXX_FLAGS}) -xo_toplevel_compile_options() - # ---------------------------------------------------------------- # sources diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake index 96592216..aba31169 100644 --- a/cmake/xo-bootstrap-macros.cmake +++ b/cmake/xo-bootstrap-macros.cmake @@ -1,14 +1,35 @@ -if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) - # default to typical install location for xo-project-macros - set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake) +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if ("${XO_CMAKE_CONFIG_EXECUTABLE}" STREQUAL "XO_CMAKE_CONFIG_EXECUTABLE-NOT_FOUND") + message(FATAL "could not find xo-cmake-config executable") endif() +message(STATUS "XO_CMAKE_CONFIG_EXECUTABLE=${XO_CMAKE_CONFIG_EXECUTABLE}") + if (NOT XO_SUBMODULE_BUILD) - message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") - message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() endif() # needs to have been installed somewhere on CMAKE_MODULE_PATH, # (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) # -include(xo_macros/xo-project-macros) +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() From 8e75838950e3e61a9f63136efd9d013a95bea0b1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Sep 2024 13:26:25 -0500 Subject: [PATCH 14/14] xo-webutil: bugfix: track ns change xo::ref::rp -> xo::rp --- include/xo/webutil/StreamEndpointDescr.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xo/webutil/StreamEndpointDescr.hpp b/include/xo/webutil/StreamEndpointDescr.hpp index 53aa63c7..93a2e77b 100644 --- a/include/xo/webutil/StreamEndpointDescr.hpp +++ b/include/xo/webutil/StreamEndpointDescr.hpp @@ -15,7 +15,7 @@ namespace xo { namespace web { /* a function that creates an event subscription */ - using StreamSubscribeFn = std::function const & ws_sink)>; + using StreamSubscribeFn = std::function const & ws_sink)>; using StreamUnsubscribeFn = std::function; /* describes a stream endpoint