Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 13
Develop PVR addons with new cmake build system
#1
Information 
We have changed the build system for PVR addons. Now they are built with cmake and every addon has its own repository.
CMake (http://www.cmake.org/Wiki/CMake) generates the build environment required for a particular platform.

Team-Kodi provides the infrastructure to build PVR addons for the supported plattforms. The addons are maintained in their
own repositories from where the build process loads them. The repository is specified in a .txt file in the Kodi source
tree. For the pvr.demo addon this is in home/xbmc/progs/src/xbmc/project/cmake/addons/addons/pvr.demo/pvr.demo.txt.
You can clone this repository to any location of your system. You also need to clone the Kodi repository which contains
common files, libs, and API for the addons.

For setup of an development environment follow these steps. The examples are with absolute paths. You can substitute
the path to match your systems.

Linux:

Although in-tree buildings works well, it is recommended to build an addon outside Kodi's tree. I have created a folder "build" in the source tree of the addon.

Change to addon's build folder:
Code:
cd /home/xbmc/progs/src/pvr.demo/build

generate build environment with config for debugging
Code:
cmake -DADDONS_TO_BUILD=pvr.demo -DADDON_SRC_PREFIX=/home/xbmc/progs/src -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/xbmc/progs/src/xbmc/addons -DPACKAGE_ZIP=1 /home/xbmc/progs/src/xbmc/project/cmake/addons

Setup Development Environment.

Setup your IDE. I use Eclipse and just need to load the sources into my Kodi workspace.
This is done by creating a new project form an existing makefile project.

Now the addon can be built by this command. I have added it to the project settings of my Eclipse project
Code:
make -C /home/xbmc/progs/src/pvr.demo/build


Windows:

Change to addons folder:
Code:
cd D:\Projects\xbmx\xbmc\project\cmake\addons\build

Generate build environment with config for debugging. This command generates a Visual Studio 2013 solution.
Code:
cmake -DADDONS_TO_BUILD="pvr.demo" -DADDON_SRC_PREFIX="D:\Projects" -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 12"  -DCMAKE_USER_MAKE_RULES_OVERRIDE="D:\Projects\xbmx\xbmc\project\cmake\scripts\windows\c-flag-overrides.cmake" -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX="D:\Projects\xbmx\xbmc\project\cmake\scripts\windows\cxx-flag-overrides.cmake" -DCMAKE_INSTALL_PREFIX="D:\Projects\xbmx\xbmc\addons" -DBUILD_DIR="D:\Projects\xbmx\xbmc\project\cmake\addons\build" -DPACKAGE_ZIP=1 "D:\Projects\xbmx\xbmc\project\cmake\addons"

Open Visual Studio, load and build this solution:
Code:
D:\Projects\xbmx\xbmc\project\cmake\addons\build\kodi-addons.sln

Setup Development Environment.

Open Visual Studio, load Kodi solution. Then add existing solution:
Code:
D:\Projects\xbmx\xbmc\project\cmake\addons\build\pvr.demo-prefix\src\pvr.demo-build\pvr.demo.sln

Create post-build step. Required to copy files for debugging

Create Post-Build Event in Visual Studio
Code:
tbd

For a more convenient method see post #9, credits to Montellese who provided this script.
Reply
#2
Thanks for the instructions! Much appreciated!

Imho they're missing the generation of Toolchain.cmake which, among other things, includes compiler flags (e.g. enable C++11) and should be passed to the initial cmake call.
Code:
cd ./xbmc/tools/depends && ./bootstrap && ./configure --prefix=/opt/xbmc-depends
... will generate and copy the Toolchain.cmake to /opt/xbmc-depends/<arch>/share/Toolchain.cmake

This file should then be passed to cmake using -DCMAKE_TOOLCHAIN_FILE=/opt/xbmc-depends/<arch>/share/Toolchain.cmake

You shouldn't generate the build environment inside your source folder. Usually cmake complains if you do this. Best practice is something like this:
Code:
mkdir /home/xbmc-build
cd /home/xbmc-build
cmake -DADDONS_TO_BUILD=pvr.demo -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=/opt/xbmc-depends/<arch>/share/Toolchain.cmake /home/xbmc/progs/src/xbmc/project/cmake/addons
Edit: Just to make this clearer. Out-of-source builds are recommended by cmake. However in-source builds will work fine.
Reply
#3
As long as you are not cross compiling you won't need those steps, right? The steps in post #1 worked for native builds on Linux and Windows.

C++11 flag does not need depends: https://github.com/Montellese/xbmc/commi...e10f6ad04d
Reply
#4
Thanks for all your hard work on this FernetMenta, montellese, spiff, wsnipex et. al. When I've gotten game and peripheral add-ons fully in sync I'll post here how everything works.
Reply
#5
(2015-02-21, 23:36)FernetMenta Wrote: As long as you are not cross compiling you won't need those steps, right? The steps in post #1 worked for native builds on Linux and Windows.

C++11 flag does not need depends: https://github.com/Montellese/xbmc/commi...e10f6ad04d

Correct. You only need Toolchain and config.site when cross compiling. Not needed for linux and windows.
For all other platforms, you must configure unified depends and build native tools first.
Reply
#6
(2015-02-21, 23:18)manül Wrote: Thanks for the instructions! Much appreciated!

Imho they're missing the generation of Toolchain.cmake which, among other things, includes compiler flags (e.g. enable C++11) and should be passed to the initial cmake call.
Code:
cd ./xbmc/tools/depends && ./bootstrap && ./configure --prefix=/opt/xbmc-depends
... will generate and copy the Toolchain.cmake to /opt/xbmc-depends/<arch>/share/Toolchain.cmake

This file should then be passed to cmake using -DCMAKE_TOOLCHAIN_FILE=/opt/xbmc-depends/<arch>/share/Toolchain.cmake


[/code]

binary addons now have their own Toolchain and config.site files: https://github.com/Montellese/xbmc/commi...8b09b2d88b

they also need to be mangled a little before build, which is done when doing make -C depends/target/xbmc-pvr-addons
https://github.com/Montellese/xbmc/commi...48db0beR60
Reply
#7
(2015-02-21, 22:58)FernetMenta Wrote: Generate build environment with config for debugging. This command generates a Visual Studio 2013 solution.
Code:
cmake -DADDONS_TO_BUILD=pvr.demo -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 12"
You're missing some important cmake flags here, see tools/buildsteps/win32/make-addons.bat. Most important are CMAKE_USER_MAKE_RULES_OVERRIDE and CMAKE_USER_MAKE_RULES_OVERRIDE_CXX because otherwise you build with the wrong compiler flags. Maybe we can put together a batch script for developers.

(2015-02-21, 22:58)FernetMenta Wrote: Create post-build step. After the addon has been built we want it to be copied to the
addons folder where Kodi searches for addons at runtime.

Create Post-Build Event in Visual Studio
Code:
robocopy D:\Projects\xbmx\xbmc\project\cmake\addons\output\addons\lib\kodi\addons D:\Projects\xbmx\xbmc\addons /s /NP
robocopy D:\Projects\xbmx\xbmc\project\cmake\addons\output\addons\share\kodi\addons D:\Projects\xbmx\xbmc\addons /s /NP
if errorlevel 1 exit 0 else exit %errorlevel%
Just try setting a different ADDON_INSTALL_PATH when calling cmake i.e. set it to D:\Projects\xbmx\xbmc\addons in your case (see make-addons.bat for that as well).
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#8
Thanks! I have updated post #1
Reply
#9
I've adjusted the existing make-addons.bat used to build binary addons on win32 during the whole build process to a version that can be used to create the build environment for Visual Studio with debug building. Copy https://gist.github.com/Montellese/149ecbd5ca20941d2be4 into tools/buildsteps/win32 and execute it from there. If you want to execute it from somewhere else you need to adjust the default value of WORKDIR in the batch file. Available options are
  • clean to simply clean the whole generated buildsystem
  • <addon-id> to only generate the buildsystem for that addon
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#10
Regarding Linux, correct me if I'm wrong, the guide is for compiling with Kodi's tree (outside of it but still using it as a source).

What about building without Kodi's tree ? I failed compiling both pvr.hts and pvr.vdr.vnsi with kodi-platfrom and Kodi 15.0a1 installed on my system.

I've got no experiecnce with cmake but I expected from the cmake script to auto locate Kodi's headers but it failed to find libXBMC_codec.h even when I manually set KODI_INCLUDE_DIR.
Code:
cmake -DCMAKE_BUILD_TYPE=Release -DKODI_INCLUDE_DIR="/usr/share/kodi/addons/library.xbmc.codec"

so I had to manually set the paths in CMAKE_CXX_FLAGS
Code:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-I/usr/share/kodi/addons/library.xbmc.codec -I/usr/include/kodi"

but then I get build error about class redefinition (only now I'm starting to learn about cpp)
Code:
[ 84%] Building CXX object CMakeFiles/pvr.hts.dir/src/HTSPDemuxer.cpp.o
In file included from /tmp/pvr.hts-master/src/xbmc_codec_descriptor.hpp:23:0,
                 from /tmp/pvr.hts-master/src/HTSPDemuxer.cpp:35:
/usr/share/kodi/addons/library.xbmc.codec/libXBMC_codec.h:37:7: error: redefinition of ‘class CHelper_libXBMC_codec’
class CHelper_libXBMC_codec
       ^
In file included from /tmp/pvr.hts-master/src/client.h:28:0,
                 from /tmp/pvr.hts-master/src/Tvheadend.h:24,
                 from /tmp/pvr.hts-master/src/HTSPDemuxer.cpp:22:
/usr/include/kodi/libXBMC_codec.h:37:7: error: previous definition of ‘class CHelper_libXBMC_codec’
class CHelper_libXBMC_codec
       ^
CMakeFiles/pvr.hts.dir/build.make:146: recipe for target 'CMakeFiles/pvr.hts.dir/src/HTSPDemuxer.cpp.o' failed
make[2]: *** [CMakeFiles/pvr.hts.dir/src/HTSPDemuxer.cpp.o] Error 1
CMakeFiles/Makefile2:91: recipe for target 'CMakeFiles/pvr.hts.dir/all' failed
make[1]: *** [CMakeFiles/pvr.hts.dir/all] Error 2
Makefile:137: recipe for target 'all' failed
make: *** [all] Error 2
Reply
#11
When building in Windows is something needed to set the prefix? I followed the steps in post #1 and it creates a .dll but the folder layout is

cmake\addons\pvr.nextpvr-prefix

I assume that should be the commit reference from pvr.nextpvr.txt

Martin
Reply
#12
The buildsystem currently doesn't really work standalone and needs to be used as it is integrated in the Kodi codebase. The goal is to get it completely separated (apart from the header files) but right now it isn't.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#13
(2015-03-03, 09:01)Montellese Wrote: The buildsystem currently doesn't really work standalone and needs to be used as it is integrated in the Kodi codebase. The goal is to get it completely separated (apart from the header files) but right now it isn't.

just to clarify: This is only valid for windows and cross compiled platforms. Linux does work standalone.

@dhead: please pastebin the full output. If you have kodi installed in a standard prefix (/usr, /usr/local), it should just work.
Reply
#14
@wsnipex

http://pastebin.com/hGTDMNRw
Reply
#15
1) don't set any include paths (i get that it's a test)
2) pvr.hts master is broken - it shall include kodi/libXBMC_codec.h not libXBMC_codec.h - naughty hudo Wink in the mean time you can build mine; https://github.com/notspiff/pvr.hts
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 13

Logout Mark Read Team Forum Stats Members Help
Develop PVR addons with new cmake build system0
This forum uses Lukasz Tkacz MyBB addons.