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

Boost requirement #41

Closed
RagnarDa opened this issue Apr 15, 2019 · 13 comments
Closed

Boost requirement #41

RagnarDa opened this issue Apr 15, 2019 · 13 comments
Assignees
Milestone

Comments

@RagnarDa
Copy link

Nice work! How much would be needed to remove the boost dependency?

@daniele77
Copy link
Owner

Thank you.
The CLI library uses boost asio to provide the remote session feature, and to get the async engine.
IMHO is almost impossible to remove the dependency.

@nightlark
Copy link

I recently replaced Boost.Asio (to get rid of the dependency on the compiled Boost.System library it uses) in a project. It was really straightforward, since Asio is pretty much a drop-in replacement aside from changing the namespace for functions and using things like std::error instead of the boost::system error.

@daniele77
Copy link
Owner

Great. I knew already Asio, maybe I'm gonna do some experiment in a branch.
Thank you very much!

@berge2007
Copy link

berge2007 commented Aug 10, 2019

you can drop the parser too and build interactivity upon this: https://github.com/CLIUtils/CLI11

@qsc-jhndnn
Copy link

It was pretty straightforward to remove any boost requirement from cli.h - just replacement of boost::lexical_cast with a simple std::istringstream version. I was then able to hook it up to my own socket server. I've attached a diff - note that this has only been tested with VS2015 and then only slightly - YMMV. But it might be a good starting point for officially removing the boost requirement - or at least making it optional.
deboost.txt

@daniele77
Copy link
Owner

@jhndnnqsc yes, as one can see from your patch, removing boost from cli.h is easy enough (I already knew: I used boost lexical_cast just to cut some LOC because I already had the boost dependency used in the telnet server).

I guess the hard work would be removing boost from the telnet server. I won't put an implementation of mine because really don't want to face all the issues with multiplatform socket programming.
Instead, a good idea could be to use Asio as a replacement of Boost.Asio (as suggested by @nightlark ), but to get some benefit I should be able to embed Asio in my library (providing Asio license allows me to do so: I see Asio comes with Boost License. Does that mean I can embed the Asio sources directly in my library?)

@nightlark
Copy link

The Boost Software License has less requirements to comply with the license than BSD (at least 2 and 3 clause variants), and doesn't have the vagueness regarding binaries that the MIT license has.

It let's you copy/use/modify the software for anything you want (commercial or non-commercial) without a fee, so it can be copied/redistributed (git submodule or git subtree might make managing a copy of Asio in your repository easier).

To follow the copyright notice requirements:

  • a copy of the license must be included with copies/redistributions of the source code
  • executables/binary copies ("machine-executable object code generated by a source language processor") do not require the license be included
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

@qsc-jhndnn
Copy link

I think removing the boost requirement from cli.h is useful even if you do have to supply your own telnet or ssh server. At least in my case - I already have a libevent based telnet server in my software and don't wish to add a boost requirement just to hook up to my server.

@daniele77
Copy link
Owner

Ok, I'll see what I can do here. The ideal solution for me would be: make the cli using a generic communication server (not necessarily telnet, BTW) that could be:

  • the boost version currently provided by the library OR
  • implemented by the library user.

The boost server will be implemented in a separated header file so the boost dependency will disappear if it's not used.

What do you think? Could be a good solution for you?

@qsc-jhndnn
Copy link

qsc-jhndnn commented Sep 6, 2019

I think that would work. If what was passed into Session was a wrapper for a socket that could either contain a boost socket or some other socket that implemented the same functionality I think that would work for me.

As a data point, here's an idea of what my socket interface looks like that I would like to swap the boost implementation for

class tcp_socket_t
{
public:
enum event_e { ev_connected, ev_reconnect, ev_data, ev_closed, ev_error, ev_timeout, ev_login_failed };
enum eol_e { eol_any, eol_crlf, eol_crlf_strict, eol_lf, eol_null, eol_custom };
public:
tcp_socket_t(...);
virtual ~tcp_socket_t();
bool is_connected() const;
void disconnect();
void write(const std::string& data);
void disconnect();
sigc::signal<void, tcp_socket_t*, event_e> signal;
virtual std::string read(int count); // nonblocking
std::string peek(int count); // nonblocking
virtual bool read_line(std::string& line, eol_e eol, const char* custom, size_t len); // nonblocking
};

@daniele77
Copy link
Owner

@jhndnnqsc well, actually I was oriented more towards an interface of higher level than sockets, e.g., transform Server and Session classes into interfaces.
In this way, one implementation could be the current BoostServer / BoostSession and the user can provide its own not based on boost.

@qsc-jhndnn
Copy link

That would work as well. As long as code like what's in remotecli.h can be shared since you've already figured out the tricky bits of dealing with a telnet connection and it'd be great to reuse those.

@connorjak
Copy link

It looks like using Asio standalone instead of boost/asio has been mentioned but not conversed about; that would be a drop-in replacement for all the networking features from what I was able to see in the code. Asio has a TINY compile time compared to full boost.

Another option for vcpkg users is to segment the remote cli features into a module, so you could vcpkg install cli or cli[with_remote].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants