Skip to content

Commit

Permalink
Add cmake build system
Browse files Browse the repository at this point in the history
* closes #30
  • Loading branch information
bgeVam committed Jun 7, 2017
1 parent 669fbcc commit c045d07
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
86 changes: 86 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/)
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
11 changes: 11 additions & 0 deletions data/com.github.bgeVam.pycastr.appdata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2017 Georg Bernold <Contact me on Github: github.com/bgeVam> -->
<component type="desktop">
<id>com.github.bgeVam.pycastr.desktop</id>
<metadata_license>CC0</metadata_license>
<name>pycastr</name>
<summary>Cast your audio/video to kodi clients</summary>
<description>
<p>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.</p>
</description>
</component>
4 changes: 2 additions & 2 deletions pycastr.desktop → data/com.github.bgeVam.pycastr.desktop
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion data/icons/pycastr-status-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion data/icons/pycastr-status-on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 0 additions & 21 deletions install.sh

This file was deleted.

6 changes: 3 additions & 3 deletions src/pycastr-gtk/ClientService.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions uninstall.sh

This file was deleted.

0 comments on commit c045d07

Please sign in to comment.