diff options
author | David Robillard <d@drobilla.net> | 2015-02-07 01:05:13 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-02-07 01:05:13 +0000 |
commit | 82ab6f73fab060860addb30691d0e926b4723ee2 (patch) | |
tree | d468ccbcae5479161e3f2c899d9e302848ce4e8f | |
parent | 8dad2d6e0805d0db2cca66f5901235884aad92da (diff) | |
download | ingen-82ab6f73fab060860addb30691d0e926b4723ee2.tar.gz ingen-82ab6f73fab060860addb30691d0e926b4723ee2.tar.bz2 ingen-82ab6f73fab060860addb30691d0e926b4723ee2.zip |
Demodularize socket stuff.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5535 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | ingen/EngineBase.hpp | 5 | ||||
-rw-r--r-- | ingen/SocketReader.hpp (renamed from src/socket/SocketReader.hpp) | 11 | ||||
-rw-r--r-- | ingen/SocketWriter.hpp (renamed from src/socket/SocketWriter.hpp) | 10 | ||||
-rw-r--r-- | ingen/client/SocketClient.hpp (renamed from src/socket/SocketClient.hpp) | 40 | ||||
-rw-r--r-- | src/SocketReader.cpp (renamed from src/socket/SocketReader.cpp) | 7 | ||||
-rw-r--r-- | src/SocketWriter.cpp (renamed from src/socket/SocketWriter.cpp) | 7 | ||||
-rw-r--r-- | src/World.cpp | 1 | ||||
-rw-r--r-- | src/ingen/ingen.cpp | 12 | ||||
-rw-r--r-- | src/server/Engine.cpp | 19 | ||||
-rw-r--r-- | src/server/Engine.hpp | 6 | ||||
-rw-r--r-- | src/server/SocketServer.hpp (renamed from src/socket/SocketServer.hpp) | 21 | ||||
-rw-r--r-- | src/server/wscript | 3 | ||||
-rw-r--r-- | src/socket/ingen_socket_client.cpp | 68 | ||||
-rw-r--r-- | src/socket/ingen_socket_server.cpp | 152 | ||||
-rw-r--r-- | src/socket/wscript | 28 | ||||
-rw-r--r-- | src/wscript | 41 | ||||
-rw-r--r-- | wscript | 1 |
17 files changed, 114 insertions, 318 deletions
diff --git a/ingen/EngineBase.hpp b/ingen/EngineBase.hpp index ea0dfc11..ec6cee89 100644 --- a/ingen/EngineBase.hpp +++ b/ingen/EngineBase.hpp @@ -55,6 +55,11 @@ public: virtual void deactivate() = 0; /** + Begin listening on network sockets. + */ + virtual void listen() = 0; + + /** Return true iff events are waiting to be processed. */ virtual bool pending_events() = 0; diff --git a/src/socket/SocketReader.hpp b/ingen/SocketReader.hpp index 38afedef..12b3e88b 100644 --- a/src/socket/SocketReader.hpp +++ b/ingen/SocketReader.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> + Copyright 2007-2015 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -14,8 +14,8 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef INGEN_SOCKET_SOCKET_READER_HPP -#define INGEN_SOCKET_SOCKET_READER_HPP +#ifndef INGEN_SOCKET_READER_HPP +#define INGEN_SOCKET_READER_HPP #include <thread> @@ -27,8 +27,6 @@ namespace Ingen { class Interface; class World; -namespace Socket { - /** Calls Interface methods based on Turtle messages received via socket. */ class SocketReader { @@ -69,6 +67,5 @@ private: }; } // namespace Ingen -} // namespace Socket -#endif // INGEN_SOCKET_SOCKET_READER_HPP +#endif // INGEN_SOCKET_READER_HPP diff --git a/src/socket/SocketWriter.hpp b/ingen/SocketWriter.hpp index 1b3523d1..d8858dd0 100644 --- a/src/socket/SocketWriter.hpp +++ b/ingen/SocketWriter.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2012 David Robillard <http://drobilla.net/> + Copyright 2012-2015 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -14,8 +14,8 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef INGEN_SOCKET_SOCKET_WRITER_HPP -#define INGEN_SOCKET_SOCKET_WRITER_HPP +#ifndef INGEN_SOCKET_WRITER_HPP +#define INGEN_SOCKET_WRITER_HPP #include <stdint.h> @@ -29,7 +29,6 @@ #include "sratom/sratom.h" namespace Ingen { -namespace Socket { /** An Interface that writes Turtle messages to a socket. */ @@ -61,7 +60,6 @@ protected: SPtr<Raul::Socket> _socket; }; -} // namespace Socket } // namespace Ingen -#endif // INGEN_SOCKET_SOCKET_WRITER_HPP +#endif // INGEN_SOCKET_WRITER_HPP diff --git a/src/socket/SocketClient.hpp b/ingen/client/SocketClient.hpp index ae4b47d0..2b10adf0 100644 --- a/src/socket/SocketClient.hpp +++ b/ingen/client/SocketClient.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2012 David Robillard <http://drobilla.net/> + Copyright 2012-2015 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -14,14 +14,14 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef INGEN_SOCKET_SOCKET_CLIENT_HPP -#define INGEN_SOCKET_SOCKET_CLIENT_HPP +#ifndef INGEN_CLIENT_SOCKET_CLIENT_HPP +#define INGEN_CLIENT_SOCKET_CLIENT_HPP -#include "SocketReader.hpp" -#include "SocketWriter.hpp" +#include "ingen/SocketReader.hpp" +#include "ingen/SocketWriter.hpp" namespace Ingen { -namespace Socket { +namespace Client { /** The client side of an Ingen socket connection. */ class SocketClient : public SocketWriter @@ -44,12 +44,36 @@ public: _respondee = respondee; } + static SPtr<Ingen::Interface> + new_socket_interface(Ingen::World* world, + const Raul::URI& uri, + SPtr<Ingen::Interface> respondee) + { + const Raul::Socket::Type type = (uri.scheme() == "unix" + ? Raul::Socket::Type::UNIX + : Raul::Socket::Type::TCP); + + SPtr<Raul::Socket> sock(new Raul::Socket(type)); + if (!sock->connect(uri)) { + world->log().error(fmt("Failed to connect <%1%> (%2%)\n") + % sock->uri() % strerror(errno)); + return SPtr<Interface>(); + } + SocketClient* client = new SocketClient(*world, uri, sock, respondee); + return SPtr<Interface>(client); + } + + static void register_factories(World* world) { + world->add_interface_factory("unix", &new_socket_interface); + world->add_interface_factory("tcp", &new_socket_interface); + } + private: SPtr<Interface> _respondee; SocketReader _reader; }; -} // namespace Socket +} // namespace Client } // namespace Ingen -#endif // INGEN_SOCKET_SOCKET_CLIENT_HPP +#endif // INGEN_CLIENT_SOCKET_CLIENT_HPP diff --git a/src/socket/SocketReader.cpp b/src/SocketReader.cpp index 7e1a9e91..125d904f 100644 --- a/src/socket/SocketReader.cpp +++ b/src/SocketReader.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> + Copyright 2007-2015 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -20,15 +20,13 @@ #include "ingen/AtomReader.hpp" #include "ingen/Interface.hpp" #include "ingen/Log.hpp" +#include "ingen/SocketReader.hpp" #include "ingen/URIMap.hpp" #include "ingen/World.hpp" #include "sord/sordmm.hpp" #include "sratom/sratom.h" -#include "SocketReader.hpp" - namespace Ingen { -namespace Socket { SocketReader::SocketReader(Ingen::World& world, Interface& iface, @@ -187,4 +185,3 @@ SocketReader::run() } } // namespace Ingen -} // namespace Socket diff --git a/src/socket/SocketWriter.cpp b/src/SocketWriter.cpp index faed014c..8ce8354a 100644 --- a/src/socket/SocketWriter.cpp +++ b/src/SocketWriter.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2012 David Robillard <http://drobilla.net/> + Copyright 2012-2015 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -18,16 +18,14 @@ #include <sys/types.h> #include <sys/socket.h> +#include "ingen/SocketWriter.hpp" #include "ingen/URIMap.hpp" -#include "SocketWriter.hpp" - #ifndef MSG_NOSIGNAL # define MSG_NOSIGNAL 0 #endif namespace Ingen { -namespace Socket { static size_t socket_sink(const void* buf, size_t len, void* stream) @@ -95,5 +93,4 @@ SocketWriter::bundle_end() send(fd(), end, 1, MSG_NOSIGNAL); } -} // namespace Socket } // namespace Ingen diff --git a/src/World.cpp b/src/World.cpp index 5b7214a4..badbf353 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -267,6 +267,7 @@ World::load_module(const char* name) if (i != _impl->modules.end()) { return true; } + log().info(fmt("Loading %1% module\n") % name); Glib::Module* lib = ingen_load_module(log(), name); Ingen::Module* (*module_load)() = NULL; if (lib && lib->get_symbol("ingen_module_load", (void*&)module_load)) { diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp index f37608b9..6355c753 100644 --- a/src/ingen/ingen.cpp +++ b/src/ingen/ingen.cpp @@ -39,6 +39,9 @@ #ifdef WITH_BINDINGS #include "bindings/ingen_bindings.hpp" #endif +#ifdef HAVE_SOCKET +#include "ingen/client/SocketClient.hpp" +#endif using namespace std; using namespace Ingen; @@ -117,13 +120,9 @@ main(int argc, char** argv) "Unable to load server module"); ingen_try(bool(world->engine()), "Unable to create engine"); + world->engine()->listen(); engine_interface = world->interface(); - -#ifdef HAVE_SOCKET - ingen_try(world->load_module("socket_server"), - "Unable to load socket server module"); -#endif } // If we don't have a local engine interface (for GUI), use network @@ -131,8 +130,7 @@ main(int argc, char** argv) ingen_try(world->load_module("client"), "Unable to load client module"); #ifdef HAVE_SOCKET - ingen_try(world->load_module("socket_client"), - "Unable to load socket client module"); + Client::SocketClient::register_factories(world); #endif const char* const uri = conf.option("connect").ptr<char>(); ingen_try(Raul::URI::is_valid(uri), diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 76755a2c..c905eed2 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2013 David Robillard <http://drobilla.net/> + Copyright 2007-2015 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -14,6 +14,8 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "ingen_config.h" + #include <sys/mman.h> #include <limits> @@ -45,6 +47,9 @@ #include "ProcessContext.hpp" #include "ThreadManager.hpp" #include "Worker.hpp" +#ifdef HAVE_SOCKET +#include "SocketListener.hpp" +#endif using namespace std; @@ -67,6 +72,7 @@ Engine::Engine(Ingen::World* world) , _post_processor(new PostProcessor(*this)) , _root_graph(NULL) , _worker(new Worker(world->log(), event_queue_size())) + , _listener(NULL) , _process_context(*this) , _rand_engine(0) , _uniform_dist(0.0f, 1.0f) @@ -119,6 +125,9 @@ Engine::~Engine() _world->set_store(SPtr<Ingen::Store>()); +#ifdef HAVE_SOCKET + delete _listener; +#endif delete _pre_processor; delete _post_processor; delete _block_factory; @@ -135,6 +144,14 @@ Engine::~Engine() munlockall(); } +void +Engine::listen() +{ +#ifdef HAVE_SOCKET + _listener = new SocketListener(*this); +#endif +} + SPtr<Store> Engine::store() const { diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index 851b3127..ecc90c9b 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> + Copyright 2007-2015 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -48,6 +48,7 @@ class LV2Options; class PostProcessor; class PreProcessor; class ProcessContext; +class SocketListener; class Worker; /** @@ -78,6 +79,8 @@ public: SPtr<Interface> client); virtual bool unregister_client(const Raul::URI& uri); + void listen(); + /** Return a random [0..1] float with uniform distribution */ float frand() { return _uniform_dist(_rand_engine); } @@ -130,6 +133,7 @@ private: PostProcessor* _post_processor; GraphImpl* _root_graph; Worker* _worker; + SocketListener* _listener; ProcessContext _process_context; diff --git a/src/socket/SocketServer.hpp b/src/server/SocketServer.hpp index a977bdbc..5ebcaa6f 100644 --- a/src/socket/SocketServer.hpp +++ b/src/server/SocketServer.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> + Copyright 2007-2015 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -14,26 +14,27 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef INGEN_SOCKET_SOCKET_SERVER_HPP -#define INGEN_SOCKET_SOCKET_SERVER_HPP +#ifndef INGEN_SERVER_SOCKET_SERVER_HPP +#define INGEN_SERVER_SOCKET_SERVER_HPP #include "raul/Socket.hpp" -#include "../server/EventWriter.hpp" -#include "SocketReader.hpp" -#include "SocketWriter.hpp" +#include "ingen/SocketReader.hpp" +#include "ingen/SocketWriter.hpp" + +#include "EventWriter.hpp" namespace Ingen { -namespace Socket { +namespace Server { /** The server side of an Ingen socket connection. */ -class SocketServer : public Server::EventWriter, public SocketReader +class SocketServer : public EventWriter, public SocketReader { public: SocketServer(World& world, Server::Engine& engine, SPtr<Raul::Socket> sock) - : Server::EventWriter(engine) + : EventWriter(engine) , SocketReader(world, *this, sock) , _engine(engine) , _writer(new SocketWriter(world.uri_map(), @@ -57,4 +58,4 @@ private: } // namespace Ingen } // namespace Socket -#endif // INGEN_SOCKET_SOCKET_SERVER_HPP +#endif // INGEN_SERVER_SOCKET_SERVER_HPP diff --git a/src/server/wscript b/src/server/wscript index 76362fa5..9d1238a4 100644 --- a/src/server/wscript +++ b/src/server/wscript @@ -25,6 +25,7 @@ def build(bld): PortImpl.cpp PostProcessor.cpp PreProcessor.cpp + SocketListener.cpp Worker.cpp events/Connect.cpp events/CreateBlock.cpp @@ -53,7 +54,7 @@ def build(bld): name = 'libingen_server', target = 'ingen_server', install_path = '${LIBDIR}', - use = 'libingen', + use = 'libingen libingen_socket', cxxflags = bld.env.PTHREAD_CFLAGS, linkflags = bld.env.PTHREAD_LINKFLAGS) core_libs = 'GLIBMM LV2 LILV RAUL SERD SORD' diff --git a/src/socket/ingen_socket_client.cpp b/src/socket/ingen_socket_client.cpp deleted file mode 100644 index 61a175d4..00000000 --- a/src/socket/ingen_socket_client.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <errno.h> - -#include "ingen/Log.hpp" -#include "ingen/Module.hpp" -#include "ingen/World.hpp" -#include "raul/Socket.hpp" - -#include "SocketClient.hpp" - -namespace Ingen { -namespace Socket { - -static Raul::Socket::Type type_from_uri(const Raul::URI uri) { - return (uri.scheme() == "unix") - ? Raul::Socket::Type::UNIX - : Raul::Socket::Type::TCP; -} - -static SPtr<Ingen::Interface> -new_socket_interface(Ingen::World* world, - const Raul::URI& uri, - SPtr<Ingen::Interface> respondee) -{ - SPtr<Raul::Socket> sock(new Raul::Socket(type_from_uri(uri))); - if (!sock->connect(uri)) { - world->log().error(fmt("Failed to connect <%1%> (%2%)\n") - % sock->uri() % strerror(errno)); - return SPtr<Interface>(); - } - SocketClient* client = new SocketClient(*world, uri, sock, respondee); - return SPtr<Interface>(client); -} - -struct SocketClientModule : public Module { - void load(World* world) { - world->add_interface_factory("unix", &new_socket_interface); - world->add_interface_factory("tcp", &new_socket_interface); - } -}; - -} // namespace Socket -} // namespace Ingen - -extern "C" { - -Ingen::Module* -ingen_module_load() -{ - return new Ingen::Socket::SocketClientModule(); -} - -} // extern "C" diff --git a/src/socket/ingen_socket_server.cpp b/src/socket/ingen_socket_server.cpp deleted file mode 100644 index 5aff7179..00000000 --- a/src/socket/ingen_socket_server.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <errno.h> -#include <poll.h> - -#include <sstream> -#include <thread> - -#include "ingen/Configuration.hpp" -#include "ingen/Module.hpp" -#include "ingen/World.hpp" -#include "raul/Socket.hpp" - -#include "../server/Engine.hpp" -#include "../server/EventWriter.hpp" - -#include "SocketServer.hpp" - -#define UNIX_SCHEME "unix://" - -namespace Ingen { -namespace Socket { - -static void -ingen_listen(Ingen::World* world, - Raul::Socket* unix_sock, - Raul::Socket* net_sock) -{ - const std::string unix_path(world->conf().option("socket").ptr<char>()); - - SPtr<Server::Engine> engine = dynamic_ptr_cast<Server::Engine>( - world->engine()); - - // Bind UNIX socket - const Raul::URI unix_uri(UNIX_SCHEME + unix_path); - if (!unix_sock->bind(unix_uri) || !unix_sock->listen()) { - world->log().error("Failed to create UNIX socket\n"); - unix_sock->close(); - } else { - world->log().info(fmt("Listening on socket %1%\n") % unix_uri); - } - - // Bind TCP socket - const int port = world->conf().option("engine-port").get<int32_t>(); - std::ostringstream ss; - ss << "tcp://localhost:"; - ss << port; - if (!net_sock->bind(Raul::URI(ss.str())) || !net_sock->listen()) { - world->log().error("Failed to create TCP socket\n"); - net_sock->close(); - } else { - world->log().info(fmt("Listening on TCP port %1%\n") % port); - } - - if (unix_sock->fd() == -1 && net_sock->fd() == -1) { - return; // No sockets to listen to, exit thread - } - - struct pollfd pfds[2]; - int nfds = 0; - if (unix_sock->fd() != -1) { - pfds[nfds].fd = unix_sock->fd(); - pfds[nfds].events = POLLIN; - pfds[nfds].revents = 0; - ++nfds; - } - if (net_sock->fd() != -1) { - pfds[nfds].fd = net_sock->fd(); - pfds[nfds].events = POLLIN; - pfds[nfds].revents = 0; - ++nfds; - } - - while (true) { - // Wait for input to arrive at a socket - const int ret = poll(pfds, nfds, -1); - if (ret == -1) { - world->log().error(fmt("Poll error: %1%\n") % strerror(errno)); - break; - } else if ((pfds[0].revents & POLLHUP) || pfds[1].revents & POLLHUP) { - break; - } else if (ret == 0) { - world->log().error("Poll returned with no data\n"); - continue; - } - - if (pfds[0].revents & POLLIN) { - SPtr<Raul::Socket> conn = unix_sock->accept(); - if (conn) { - new SocketServer(*world, *engine, conn); - } - } - - if (pfds[1].revents & POLLIN) { - SPtr<Raul::Socket> conn = net_sock->accept(); - if (conn) { - new SocketServer(*world, *engine, conn); - } - } - } -} - -struct ServerModule : public Ingen::Module -{ - ServerModule() - : unix_sock(Raul::Socket::Type::UNIX) - , net_sock(Raul::Socket::Type::TCP) - {} - - ~ServerModule() { - unix_sock.shutdown(); - net_sock.shutdown(); - thread->join(); - unlink(unix_sock.uri().substr(strlen(UNIX_SCHEME)).c_str()); - } - - void load(World* world) { - thread = std::unique_ptr<std::thread>( - new std::thread(ingen_listen, world, &unix_sock, &net_sock)); - } - - Raul::Socket unix_sock; - Raul::Socket net_sock; - std::unique_ptr<std::thread> thread; -}; - -} // namespace Socket -} // namespace Ingen - -extern "C" { - -Ingen::Module* -ingen_module_load() -{ - return new Ingen::Socket::ServerModule(); -} - -} // extern "C" diff --git a/src/socket/wscript b/src/socket/wscript deleted file mode 100644 index 1ebc9f4c..00000000 --- a/src/socket/wscript +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -from waflib.extras import autowaf as autowaf - -def build(bld): - if bld.is_defined('HAVE_SOCKET'): - obj = bld(features = 'cxx cxxshlib', - source = ['SocketReader.cpp', - 'SocketWriter.cpp', - 'ingen_socket_server.cpp'], - includes = ['.', '../..'], - name = 'libingen_socket_server', - target = 'ingen_socket_server', - install_path = '${LIBDIR}', - use = 'libingen_server', - lib = ['pthread']) - autowaf.use_lib(bld, obj, 'GLIBMM SERD SORD SRATOM RAUL LV2') - - obj = bld(features = 'cxx cxxshlib', - source = ['SocketReader.cpp', - 'SocketWriter.cpp', - 'ingen_socket_client.cpp'], - includes = ['.', '../..'], - name = 'libingen_socket_client', - target = 'ingen_socket_client', - install_path = '${LIBDIR}', - use = 'libingen_server', - lib = ['pthread']) - autowaf.use_lib(bld, obj, 'GLIBMM SERD SORD SRATOM RAUL LV2') diff --git a/src/wscript b/src/wscript index 7aad0dae..fbca8fe9 100644 --- a/src/wscript +++ b/src/wscript @@ -1,23 +1,25 @@ #!/usr/bin/env python from waflib.extras import autowaf as autowaf -sources = [ - 'AtomReader.cpp', - 'AtomWriter.cpp', - 'ClashAvoider.cpp', - 'Configuration.cpp', - 'Forge.cpp', - 'LV2Features.cpp', - 'Log.cpp', - 'Resource.cpp', - 'Store.cpp', - 'URIMap.cpp', - 'URIs.cpp', - 'World.cpp', - 'runtime_paths.cpp', -] - def build(bld): + sources = [ + 'AtomReader.cpp', + 'AtomWriter.cpp', + 'ClashAvoider.cpp', + 'Configuration.cpp', + 'Forge.cpp', + 'LV2Features.cpp', + 'Log.cpp', + 'Resource.cpp', + 'Store.cpp', + 'URIMap.cpp', + 'URIs.cpp', + 'World.cpp', + 'runtime_paths.cpp' + ] + if bld.is_defined('HAVE_SOCKET'): + sources += [ 'SocketReader.cpp', 'SocketWriter.cpp' ] + obj = bld(features = 'cxx cxxshlib', source = sources, export_includes = ['..'], @@ -26,7 +28,9 @@ def build(bld): target = 'ingen', vnum = '0.0.0', install_path = '${LIBDIR}', - lib = ['dl']) + lib = ['dl'], + cxxflags = bld.env.PTHREAD_CFLAGS, + linkflags = bld.env.PTHREAD_LINKFLAGS) autowaf.use_lib(bld, obj, 'GLIBMM LV2 LILV RAUL SERD SORD SRATOM') if bld.env.BUILD_TESTS: @@ -38,6 +42,7 @@ def build(bld): target = 'ingen_profiled', install_path = '', lib = ['dl'] + bld.env.INGEN_TEST_LIBS, - cxxflags = bld.env.INGEN_TEST_CXXFLAGS) + cxxflags = bld.env.PTHREAD_CFLAGS + bld.env.INGEN_TEST_CXXFLAGS, + linkflags = bld.env.PTHREAD_LINKFLAGS) autowaf.use_lib(bld, obj, 'GLIBMM LV2 LILV RAUL SERD SORD SRATOM') @@ -182,7 +182,6 @@ def build(bld): bld.recurse('src/serialisation') bld.recurse('src/server') bld.recurse('src/client') - bld.recurse('src/socket') if bld.env.INGEN_BUILD_GUI: bld.recurse('src/gui') |