Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cmake fiddling, dynamic loading of plugins, json config file

  • Loading branch information...
commit ef9a8910622c6cb88cd7554f84a9b7f5f85afe40 1 parent ad06e30
@RJ authored
View
83 playdar-daemon/CMakeLists.txt
@@ -1,6 +1,16 @@
PROJECT(playdar)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
-SET(CMAKE_MODULE_PATH "CMakeModules")
+
+SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
+SET(PLAYDAR_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+SET(SRC "${PLAYDAR_PATH}/src")
+SET(DEPS "${PLAYDAR_PATH}/deps")
+SET(RESOLVERS_DIR "${SRC}/resolvers")
+SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PLAYDAR_PATH}/bin")
+
+# Don't really do 'make install' properly yet:
+SET(CMAKE_INSTALL_PREFIX "/usr/local")
FIND_PACKAGE(Taglib 1.5.0 REQUIRED)
FIND_PACKAGE(Boost 1.35 REQUIRED COMPONENTS filesystem system regex thread program_options)
@@ -14,11 +24,11 @@ INCLUDE_DIRECTORIES(#${URIPARSER_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
${TAGLIB_INCLUDES}
/usr/local/include
- src
- deps/moost_http/include # our httpd server, from erikf's moost
- deps/sqlite3pp-read-only # cpp wrapper for sqlite api
- deps/json_spirit_v3.00 # json parser, using boost spirit
- deps/pdl-0.3.0/include # x-platform dynamic loading of libraries
+ ${SRC}
+ ${DEPS}/moost_http/include # our httpd server, from erikf's moost
+ ${DEPS}/sqlite3pp-read-only # cpp wrapper for sqlite api
+ ${DEPS}/json_spirit_v3.00 # json parser, using boost spirit
+ ${DEPS}/pdl-0.3.0/include # x-platform dynamic loading of libraries
)
# Always check local/lib first:
@@ -27,9 +37,6 @@ LINK_DIRECTORIES(/usr/local/lib)
SET(CMAKE_VERBOSE_MAKEFILE ON)
INCLUDE(InstallRequiredSystemLibraries)
-# binaries get installed here
-SET(CMAKE_INSTALL_PREFIX "/usr/local")
-SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
#add definitions, compiler switches, etc.
ADD_DEFINITIONS(-Wall -ggdb)
@@ -40,9 +47,9 @@ ADD_DEFINITIONS(-Wall -ggdb)
###########scanner
ADD_EXECUTABLE(scanner # EXCLUDE_FROM_ALL
- src/scanner/scanner.cpp
- src/library/library.cpp
- deps/sqlite3pp-read-only/sqlite3pp.cpp
+ ${SRC}/scanner/scanner.cpp
+ ${SRC}/library/library.cpp
+ ${DEPS}/sqlite3pp-read-only/sqlite3pp.cpp
)
TARGET_LINK_LIBRARIES(scanner
${SQLITE3_LIBRARIES}
@@ -54,34 +61,34 @@ TARGET_LINK_LIBRARIES(scanner
###########playdar
ADD_EXECUTABLE( playdar
- src/application/application.cpp
- src/resolvers/playable_item.cpp
- src/resolvers/resolver.cpp
- src/resolvers/resolver_service.cpp
- src/resolvers/rs_local_library.cpp
- src/library/library.cpp
- src/playdar/playdar_request_handler.cpp
- src/playdar/main.cpp
+ ${SRC}/application/application.cpp
+ ${SRC}/resolvers/playable_item.cpp
+ ${SRC}/resolvers/resolver.cpp
+ ${SRC}/resolvers/resolver_service.cpp
+ ${SRC}/resolvers/rs_local_library.cpp
+ ${SRC}/library/library.cpp
+ ${SRC}/playdar/playdar_request_handler.cpp
+ ${SRC}/playdar/main.cpp
# sqlite wrapper:
- deps/sqlite3pp-read-only/sqlite3pp.cpp
+ ${DEPS}/sqlite3pp-read-only/sqlite3pp.cpp
# json parser:
- deps/json_spirit_v3.00/json_spirit/json_spirit_reader.cpp
- deps/json_spirit_v3.00/json_spirit/json_spirit_value.cpp
- deps/json_spirit_v3.00/json_spirit/json_spirit_writer.cpp
+ ${DEPS}/json_spirit_v3.00/json_spirit/json_spirit_reader.cpp
+ ${DEPS}/json_spirit_v3.00/json_spirit/json_spirit_value.cpp
+ ${DEPS}/json_spirit_v3.00/json_spirit/json_spirit_writer.cpp
# moost http:
- deps/moost_http/src/http/filesystem_request_handler.cpp
- deps/moost_http/src/http/mime_types.cpp
- deps/moost_http/src/http/reply.cpp
- deps/moost_http/src/http/request_parser.cpp
+ ${DEPS}/moost_http/src/http/filesystem_request_handler.cpp
+ ${DEPS}/moost_http/src/http/mime_types.cpp
+ ${DEPS}/moost_http/src/http/reply.cpp
+ ${DEPS}/moost_http/src/http/request_parser.cpp
# Portable Dynamic Loader:
- deps/pdl-0.3.0/src/DynamicLibrary.cpp
- deps/pdl-0.3.0/src/DynamicLibraryManager.cpp
- deps/pdl-0.3.0/src/DynamicLoader.cpp
- deps/pdl-0.3.0/src/LoaderException.cpp
+ ${DEPS}/pdl-0.3.0/src/DynamicLibrary.cpp
+ ${DEPS}/pdl-0.3.0/src/DynamicLibraryManager.cpp
+ ${DEPS}/pdl-0.3.0/src/DynamicLoader.cpp
+ ${DEPS}/pdl-0.3.0/src/LoaderException.cpp
)
TARGET_LINK_LIBRARIES( playdar
@@ -100,3 +107,15 @@ TARGET_LINK_LIBRARIES( playdar
INSTALL(TARGETS scanner RUNTIME DESTINATION bin)
INSTALL(TARGETS playdar RUNTIME DESTINATION bin)
+#
+# Resolver Plugins
+#
+SET(LIBRARY_OUTPUT_PATH "${PLAYDAR_PATH}/plugins")
+
+FILE(GLOB PLUGINDIRS "${RESOLVERS_DIR}/*")
+FOREACH(PLUGDIR ${PLUGINDIRS})
+ IF(IS_DIRECTORY ${PLUGDIR})
+ MESSAGE( STATUS "Adding plugin directory: ${PLUGDIR}" )
+ ADD_SUBDIRECTORY(${PLUGDIR})
+ ENDIF(IS_DIRECTORY ${PLUGDIR})
+ENDFOREACH(PLUGDIR)
View
22 playdar-daemon/INSTALL.txt
@@ -58,11 +58,23 @@ Compile it:
-----------
0) Look in CMakeLists.txt at the include/library paths and make changes if
you've installed boost/something in unusual places.
+
1)
- $ cmake .
+ $ mkdir build
+ $ cd build
+ $ cmake ..
2)
$ make
+This will build the daemon with built-in local library resolver.
+To build other plugins:
+ $ make lan_udp
+ $ make gateway_script
+ $ make darknet
+
+Or to just build all additional resolver plugins:
+ $ make all
+
First Run and Scanning
----------------------
@@ -77,14 +89,10 @@ Now run the scanner to index your music:
Running Playdar
---------------
-Edit etc/playdar.ini and specify your name, private ip etc.
+Edit etc/playdar.conf and specify your name, private ip etc.
Run playdar from the same directory you built it in:
- $ ./bin/playdar -c ./etc/playdar.ini
-
-FWIW you can also override ini file options on command line like this:
-
- $ ./bin/playdar -c ./etc/playdar.ini --resolver.udp_lan.enabled no
+ $ ./bin/playdar -c ./etc/playdar.conf
Now hit up: http://localhost:8888/ to check it's running.
Make JSON requests yourself, go to /stats, or more importantly:
View
1  playdar-daemon/bin/plugins/README.txt
@@ -1 +0,0 @@
-Compiled plugins live here: shared libraries with a .resolver extension instead of .so/dll/dylib and no lib prefix
View
1  playdar-daemon/build/README.txt
@@ -0,0 +1 @@
+Run "cmake .." from this directory.
View
36 playdar-daemon/src/resolvers/darknet/CMakeLists.txt
@@ -1,33 +1,3 @@
-PROJECT(playdar)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
-
-SET(PLAYDAR_PATH "../../..")
-SET(CMAKE_INSTALL_PREFIX "${PLAYDAR_PATH}/plugins")
-SET(CMAKE_MODULE_PATH "${PLAYDAR_PATH}/CMakeModules")
-
-FIND_PACKAGE(Boost 1.35 REQUIRED COMPONENTS filesystem system regex thread)
-FIND_PACKAGE(OsspUuid)
-
-INCLUDE_DIRECTORIES(
- ${OSSPUUID_INCLUDE_DIR}
- ${Boost_INCLUDE_DIR}
- /usr/local/include
- /usr/include
- ${PLAYDAR_PATH}/deps/sqlite3pp-read-only
- ${PLAYDAR_PATH}/deps/json_spirit_v3.00
- ${PLAYDAR_PATH}/deps/pdl-0.3.0/include
- ${PLAYDAR_PATH}/src
- )
-
-#LINK_DIRECTORIES(/usr/local/lib) # for uriparser
-
-
-SET(CMAKE_VERBOSE_MAKEFILE ON)
-INCLUDE(InstallRequiredSystemLibraries)
-
-#add definitions, compiler switches, etc.
-ADD_DEFINITIONS(-Wall -ggdb)
-
ADD_LIBRARY( darknet SHARED
darknet.cpp
servent.cpp
@@ -40,7 +10,9 @@ ADD_LIBRARY( darknet SHARED
#
SET_TARGET_PROPERTIES( darknet PROPERTIES
PREFIX ""
- SUFFIX ".resolver")
+ SUFFIX ".resolver"
+ CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PLAYDAR_DIR}/plugins"
+ )
TARGET_LINK_LIBRARIES( darknet
@@ -50,5 +22,3 @@ TARGET_LINK_LIBRARIES( darknet
${Boost_FILESYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
)
-
-INSTALL(TARGETS darknet LIBRARY DESTINATION .)
View
33 playdar-daemon/src/resolvers/gateway_script/CMakeLists.txt
@@ -1,33 +1,4 @@
-PROJECT(playdar)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
-
-SET(PLAYDAR_PATH "../../..")
-SET(CMAKE_INSTALL_PREFIX "${PLAYDAR_PATH}/plugins")
-SET(CMAKE_MODULE_PATH "${PLAYDAR_PATH}/CMakeModules")
-
-FIND_PACKAGE(Boost 1.35 REQUIRED COMPONENTS filesystem system regex thread)
-FIND_PACKAGE(OsspUuid)
-
-INCLUDE_DIRECTORIES(
- ${OSSPUUID_INCLUDE_DIR}
- ${Boost_INCLUDE_DIR}
- /usr/local/include
- /usr/include
- ${PLAYDAR_PATH}/deps/sqlite3pp-read-only
- ${PLAYDAR_PATH}/deps/json_spirit_v3.00
- ${PLAYDAR_PATH}/deps/pdl-0.3.0/include
- ${PLAYDAR_PATH}/deps/boost.process
- ${PLAYDAR_PATH}/src
- )
-
-#LINK_DIRECTORIES(/usr/local/lib) # for uriparser
-
-
-SET(CMAKE_VERBOSE_MAKEFILE ON)
-INCLUDE(InstallRequiredSystemLibraries)
-
-#add definitions, compiler switches, etc.
-ADD_DEFINITIONS(-Wall -ggdb)
+INCLUDE_DIRECTORIES ( ${DEPS}/boost.process )
ADD_LIBRARY( gateway_script SHARED
gateway_script.cpp
@@ -50,5 +21,3 @@ TARGET_LINK_LIBRARIES( gateway_script
${Boost_FILESYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
)
-
-INSTALL(TARGETS gateway_script LIBRARY DESTINATION .)
View
5 playdar-daemon/src/resolvers/gateway_script/gateway_script.h
@@ -24,7 +24,10 @@ class gateway_script : public ResolverService
void init(playdar::Config * c, MyApplication * a);
void start_resolving(boost::shared_ptr<ResolverQuery> rq);
- std::string name() { return string("Gateway script: ")+m_scriptpath; }
+ std::string name()
+ {
+ return string("Gateway script: ")+m_scriptpath;
+ }
protected:
~gateway_script() throw() {}
View
28 playdar-daemon/src/resolvers/lan/CMakeLists.txt
@@ -1,29 +1,3 @@
-PROJECT(playdar)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
-
-SET(PLAYDAR_PATH "../../..")
-SET(CMAKE_INSTALL_PREFIX "${PLAYDAR_PATH}/plugins")
-SET(CMAKE_MODULE_PATH "${PLAYDAR_PATH}/CMakeModules")
-
-FIND_PACKAGE(Boost 1.35 REQUIRED COMPONENTS system thread)
-FIND_PACKAGE(OsspUuid)
-
-INCLUDE_DIRECTORIES(
- ${OSSPUUID_INCLUDE_DIR}
- ${Boost_INCLUDE_DIR}
- /usr/local/include
- /usr/include
- ${PLAYDAR_PATH}/deps/sqlite3pp-read-only
- ${PLAYDAR_PATH}/deps/json_spirit_v3.00
- ${PLAYDAR_PATH}/deps/pdl-0.3.0/include
- ${PLAYDAR_PATH}/src
- )
-
-SET(CMAKE_VERBOSE_MAKEFILE ON)
-INCLUDE(InstallRequiredSystemLibraries)
-
-ADD_DEFINITIONS(-Wall -ggdb)
-
ADD_LIBRARY( lan_udp SHARED
lan_udp.cpp
${PLAYDAR_PATH}/src/application/application.cpp
@@ -43,5 +17,3 @@ TARGET_LINK_LIBRARIES( lan_udp
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
)
-
-INSTALL(TARGETS lan_udp LIBRARY DESTINATION .)
View
6 playdar-daemon/src/resolvers/resolver.cpp
@@ -6,10 +6,6 @@
#include "resolvers/resolver.h"
#include "resolvers/rs_local_library.h"
-//#include "resolvers/rs_lan_udp.h"
-//#include "resolvers/rs_http_playdar.h"
-//#include "resolvers/rs_http_gateway_script.h"
-//#include "resolvers/darknet/rs_darknet.h"
#include "library/library.h"
#include <DynamicLoader.hpp>
@@ -96,7 +92,7 @@ Resolver::dispatch(boost::shared_ptr<ResolverQuery> rq, bool local_only/* = fals
}
if(!add_new_query(rq))
{
- cout<< "RESOLVER: Not dispatching "<<rq->id()<<" - already running." << endl;
+ //cout<< "RESOLVER: Not dispatching "<<rq->id()<<" - already running." << endl;
return rq->id();
}
cout << "RESOLVER: dispatch("<< rq->id() <<"): " << rq->str()
Please sign in to comment.
Something went wrong with that request. Please try again.