From c045d076d41931c472a5105154c6dd8ae3298f38 Mon Sep 17 00:00:00 2001 From: bgeVam Date: Tue, 6 Jun 2017 17:00:22 +0200 Subject: [PATCH] Add cmake build system * closes #30 --- .gitignore | 1 + CMakeLists.txt | 86 +++++++++++++++++++ README.md | 36 +++++--- data/com.github.bgeVam.pycastr.appdata.xml | 11 +++ .../com.github.bgeVam.pycastr.desktop | 4 +- data/icons/pycastr-status-off.svg | 2 +- data/icons/pycastr-status-on.svg | 2 +- install.sh | 21 ----- src/pycastr-gtk/ClientService.vala | 6 +- uninstall.sh | 8 -- 10 files changed, 127 insertions(+), 50 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 data/com.github.bgeVam.pycastr.appdata.xml rename pycastr.desktop => data/com.github.bgeVam.pycastr.desktop (54%) delete mode 100755 install.sh delete mode 100755 uninstall.sh diff --git a/.gitignore b/.gitignore index e69de29..567609b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2c3eb82 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,86 @@ + # project name + project (com.github.bgeVam.pycastr) + + # the oldest stable cmake version we support + cmake_minimum_required (VERSION 2.6) + + # tell cmake where its modules can be found in our project directory + list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/src) + + # where we install data directory (if we have any) + set (DATADIR "${CMAKE_INSTALL_PREFIX}/share") + + # what to call that directory where we install data too + set (PKGDATADIR "${DATADIR}/com.github.bgeVam.pycastr") + + set (EXEC_NAME "com.github.bgeVam.pycastr") + set (RELEASE_NAME "pycastr") + set (VERSION "0.1") + set (VERSION_INFO "alpha") + + # we're about to use pkgconfig to make sure dependencies are installed so let's find pkgconfig first + find_package(PkgConfig) + + # now let's actually check for the required dependencies + pkg_check_modules(DEPS REQUIRED + gtk+-3.0 + gee-0.8 + appindicator3-0.1 + libnotify + python3 + ) + + add_definitions(${DEPS_CFLAGS}) + link_libraries(${DEPS_LIBRARIES}) + link_directories(${DEPS_LIBRARY_DIRS}) + + # make sure we have vala + find_package(Vala REQUIRED) + # make sure we use vala + include(ValaVersion) + # make sure it's the desired version of vala + ensure_vala_version("0.22.0" MINIMUM) + + # files we want to compile + include(ValaPrecompile) + vala_precompile(VALA_C ${EXEC_NAME} + src/pycastr-gtk/Client.vala + src/pycastr-gtk/ClientService.vala + src/pycastr-gtk/PycastrGtk.vala + src/pycastr-gtk/PycastrIndicator.vala + + # tell what libraries to use when compiling + PACKAGES + gtk+-3.0 + gee-0.8 + appindicator3-0.1 + libnotify + ) + + # tell cmake what to call the executable we just made + add_executable(${EXEC_NAME} ${VALA_C}) + + # install the python dependencies + file(MAKE_DIRECTORY /tmp/pycastr) + file(COPY src/pycastr.py DESTINATION /tmp/pycastr/src) + # TODO add python-pip3 as requirement + install(CODE "execute_process (COMMAND pip3 install netdisco)") + install(CODE "execute_process (COMMAND pip3 install kodi-json)") + + # install icons and update cache + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/pycastr-status-on.svg DESTINATION ${DATADIR}/icons/hicolor/24x24/apps/) + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/pycastr-status-off.svg DESTINATION ${DATADIR}/icons/hicolor/24x24/apps/) + install(CODE "execute_process(COMMAND gtk-update-icon-cache -f -q -t ${DATADIR}/icons/hicolor ERROR_QUIET)") + + # install the binaries we just made + install (TARGETS ${EXEC_NAME} RUNTIME DESTINATION bin) + + # install our .desktop file so the Applications menu will see it + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/com.github.bgeVam.pycastr.desktop DESTINATION ${DATADIR}/applications/) + + # install our .appdata.xml file so AppCenter will see it + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/com.github.bgeVam.pycastr.appdata.xml DESTINATION ${DATADIR}/metainfo/) + + # add our .desktop file to the autostart + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/com.github.bgeVam.pycastr.desktop DESTINATION ~/.config/autostart/) diff --git a/README.md b/README.md index 499ca41..f96214e 100644 --- a/README.md +++ b/README.md @@ -25,32 +25,40 @@ NOTE: Two dummy clients are added as examples in pycastr.py. Sometimes client di The original icons used by pycastr may be found in [Google's material design icon repository](https://github.com/google/material-design-icons "material design icons repository"). -## Install +## Compile and Install -**Requirements** +**Install with Cmake** -* vlc -* python -* [python-kodijson](https://github.com/jcsaaddupuy/python-kodijson) +For advanced instructions please take a look at [the elementary os developer guidelines](https://elementary.io/en/docs/code/getting-started#building-and-installing-with-cmake). -Just run install.sh as super user +Please start with cloning or downloading the repository. + +1. Create a build directory ``` -sudo ./install.sh +mkdir build ``` -## Uninstall - -Just run uninstall.sh as super user +2. Change to build directory ``` -sudo ./uninstall.sh +cd build/ ``` -## Compile Indicator +3. Prepare to build the app + +``` +cmake -DCMAKE_INSTALL_PREFIX=/usr ../ +``` -Compile Indicator with +4. Build the app ``` -valac *.vala --pkg gee-1.0 --pkg appindicator-0.1 --pkg gtk+-3.0 --pkg libnotify -o PycastrIndicator +make +``` + +5. Install the app + ``` +sudo make install +``` \ No newline at end of file diff --git a/data/com.github.bgeVam.pycastr.appdata.xml b/data/com.github.bgeVam.pycastr.appdata.xml new file mode 100644 index 0000000..c1cc2a4 --- /dev/null +++ b/data/com.github.bgeVam.pycastr.appdata.xml @@ -0,0 +1,11 @@ + + + + com.github.bgeVam.pycastr.desktop + CC0 + pycastr + Cast your audio/video to kodi clients + +

Pycastr is a neat tool to cast your audio/video to kodi clients. This enables you to mirror your system's desktop on your TV or stream your audio to your hifi system.

+
+
\ No newline at end of file diff --git a/pycastr.desktop b/data/com.github.bgeVam.pycastr.desktop similarity index 54% rename from pycastr.desktop rename to data/com.github.bgeVam.pycastr.desktop index 88caf07..f6df061 100644 --- a/pycastr.desktop +++ b/data/com.github.bgeVam.pycastr.desktop @@ -1,8 +1,8 @@ [Desktop Entry] Name=Pycastr GenericName=Audio/Video Streamer -Comment=Cast your audio/video to upnp clients -Exec=/opt/pycastr/src/pycastr-gtk/PycastrIndicator +Comment=Cast your audio/video to kodi clients +Exec=com.github.bgeVam.pycastr Terminal=false Type=Application Icon=pycastr-status-on diff --git a/data/icons/pycastr-status-off.svg b/data/icons/pycastr-status-off.svg index 4d5cf94..58e8367 100644 --- a/data/icons/pycastr-status-off.svg +++ b/data/icons/pycastr-status-off.svg @@ -1,4 +1,4 @@ - + diff --git a/data/icons/pycastr-status-on.svg b/data/icons/pycastr-status-on.svg index 2ef5f5e..a879c38 100644 --- a/data/icons/pycastr-status-on.svg +++ b/data/icons/pycastr-status-on.svg @@ -1,4 +1,4 @@ - + diff --git a/install.sh b/install.sh deleted file mode 100755 index 33cde2e..0000000 --- a/install.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Move sources -sudo mkdir /opt/pycastr/ -sudo cp -r src/ /opt/pycastr/ -sudo cp data/icons/pycastr_* /usr/share/icons/hicolor/256x256/apps/ -sudo cp data/icons/pycastr* /usr/share/icons/hicolor/256x256/apps/ -sudo cp data/icons/pycastr-* /usr/share/icons/hicolor/scalable/apps/ - -gtk-update-icon-cache - -# Install dependencies -#sudo apt-get update -sudo apt-get -y install vlc -sudo apt-get -y install python3 -sudo apt-get -y install python3-pip -pip3 install netdisco -pip3 install kodi-json - -# Prepare autostart -cp pycastr.desktop ~/.config/autostart -sudo update-desktop-database \ No newline at end of file diff --git a/src/pycastr-gtk/ClientService.vala b/src/pycastr-gtk/ClientService.vala index fc8d112..e1a8b06 100644 --- a/src/pycastr-gtk/ClientService.vala +++ b/src/pycastr-gtk/ClientService.vala @@ -59,7 +59,7 @@ class ClientService int standard_input; int standard_output; int standard_error; - Process.spawn_async_with_pipes ("/opt/pycastr/src/", + Process.spawn_async_with_pipes ("/tmp/pycastr/src/", spawn_args, spawn_env, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, @@ -131,7 +131,7 @@ class ClientService string[] spawn_args = {"python3", "pycastr.py", "cast-start", "-C" + client.get_ip(), (include_screen) ? null : "--audio-only"}; string[] spawn_env = Environ.get (); Pid child_pid; - Process.spawn_async ("/opt/pycastr/src/", + Process.spawn_async ("/tmp/pycastr/src/", spawn_args, spawn_env, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, @@ -151,7 +151,7 @@ class ClientService string[] spawn_args = {"python3", "pycastr.py", "cast-stop"}; string[] spawn_env = Environ.get (); Pid child_pid; - Process.spawn_async ("/opt/pycastr/src/", + Process.spawn_async ("/tmp/pycastr/src/", spawn_args, spawn_env, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, diff --git a/uninstall.sh b/uninstall.sh deleted file mode 100755 index f0c3066..0000000 --- a/uninstall.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -sudo rm -rf /opt/pycastr/ - -sudo rm ~/.config/autostart/pycastr.desktop - -sudo rm /usr/share/icons/hicolor/256x256/apps/pycastr*.svg -sudo rm /usr/share/icons/hicolor/scalable/apps/pycastr*.svg \ No newline at end of file