Forums » Tutorial and setups »
Need help: Compile and test tvheadend from an IDE?
Added by Sean Warner about 2 years ago
I know how to download the Tvheadend code from GitHub, build it locally and get it running.
Now I'd like to play around with making changes to the source code and testing those changes.
Can anyone give step by step instructions about how to set up the source code in an IDE? I use Codelite in Manjaro for instance although I'm not very knowledgeable or experienced so I need help at least to get a working project/workspace set up.
General instructions for any IDE on any platform would also be helpful!
Cheers,
Flex
Replies (15)
RE: Need help: Compile and test tvheadend from an IDE? - Added by Jonas Lang about 2 years ago
Have you forked the project and created your own branch yet. Just follow these instructions and that should get you going
https://www.tomasbeuzen.com/post/git-fork-branch-pull/
RE: Need help: Compile and test tvheadend from an IDE? - Added by Sean Warner about 2 years ago
@Jonas Lang
Thank you but I don't intend on contributing any code to GitHub yet I just need help setting up the code in an IDE.
I don't think I need any help with the GitHub side of things.
Any help much appreciated.
Flex
RE: Need help: Compile and test tvheadend from an IDE? - Added by saen acro about 2 years ago
https://visualstudio.microsoft.com
enough for basic usage.
RE: Need help: Compile and test tvheadend from an IDE? - Added by Jonas Lang about 2 years ago
Sean Warner wrote:
@Jonas Lang
Thank you but I don't intend on contributing any code to GitHub yet I just need help setting up the code in an IDE.
I don't think I need any help with the GitHub side of things.
Any help much appreciated.
Flex
Maybe it would be best to tell us what you do know. There’s a wide choice of code editors out there. Are you looking for an open source or proprietary solution.
RE: Need help: Compile and test tvheadend from an IDE? - Added by Sean Warner about 2 years ago
Thank you both.
I mentioned in my first post that I have Codelite that I use on Manjaro. So I don't need help with choice of IDE unless there is one best suited to editing and compiling Tvheadend source code.
Just some pointers on how to load up Tvheadend source code into an IDE and how to compile it from there. Not sure how to make my question more clear.
Hoping to avoid another week of endless googling is why I'm asking.
Thank you,
Flex
RE: Need help: Compile and test tvheadend from an IDE? - Added by Jonas Lang about 2 years ago
Is this what you’re looking for. Assuming you’ve cloned the project you now have the project stored locally to do what you will with.
Just edit the code and your build process is aimed at you locally stored version of the project. You already have the code stored locally in the relevant folders, just load the file you need to edit, save the edit in the location you loaded it from, run build and you have your own edited version of TVH. https://docs.github.com/en/get-started/getting-started-with-git/associating-text-editors-with-git
RE: Need help: Compile and test tvheadend from an IDE? - Added by Sean Warner about 2 years ago
Well thanks for the suggestion but no that isn't what I'm looking for.
If you have ever used an Integrated Development Environment you know its strength is the syntax highlighting, code auto-completion and integrating all the source code files in the UI so you can browse them all together as they are intended. For your approach I might as well just use notepad (kate or nano) but they don't offer the benefits of an IDE.
I have another question... it's related. If I edit the sources in CodeLite running on Manjaro on my x86 intel laptop I will then need to cross-compile for my Ubuntu 22.04.1 (arm64) since I want to run tvheadend on that OS on a Pi 4. Any advice how to do that?
Can a tvheadend developer or someone experienced with this advise?
Thank you,
Flex
RE: Need help: Compile and test tvheadend from an IDE? - Added by Jonas Lang about 2 years ago
I know exactly what an IDE is and yes I’ve worked on a number of them over the years.
It’s already been suggested you use VS Studio.
I’ve asked you a number of questions which for whatever reason have chosen not to answer so on that basis I’ll comment no further. Good look engaging with that “developer”.
RE: Need help: Compile and test tvheadend from an IDE? - Added by Adrian Smith about 2 years ago
For what it's worth, I have previously had success using Visual Studio Code on Windows to edit and build Tvheadend source stored on a NAS running Debian. Essentially I have set up the VSCode "Remote Development" model:
https://code.visualstudio.com/docs/remote/remote-overview
https://www.digitalocean.com/community/tutorials/how-to-use-visual-studio-code-for-remote-development-via-the-remote-ssh-plugin
It all works okay but, I seem to remember, it was a pain to get set up and configured. Can't provide step-by-step instructions I'm afraid as I did it quite some time ago but, at least, I can vouch for this as a working setup.
RE: Need help: Compile and test tvheadend from an IDE? - Added by Sean Warner about 2 years ago
@Adrian Smith
This is the kind of help I need... thank you!
It seems it makes more sense to just use Visual Studio code (VSC) as the IDE because it has so many features, is cross platform and there are lots of useful tutorials out there.
Thank you for the links. I have installed VSC in Manjaro on my laptop and can ssh to the tvheadend sources directory I cloned from GitHub to Ubuntu on the Pi 4.
I installed the Remote-SSH and the "C/C++ Extension Pack" plugins. I can edit the tvheadend source code that's in Ubuntu Server on the Pi 4 from Manjaro on my laptop with intellisense and syntax highlighting!
Now I just need to figure out how to set it up to compile and debug tvheadend from within VSC. Anyone with helpful advice who would like to chip in is much appreciated!
Flex
RE: Need help: Compile and test tvheadend from an IDE? - Added by Adrian Smith about 2 years ago
Sean Warner wrote:
Now I just need to figure out how to set it up to compile and debug tvheadend from within VSC. Anyone with helpful advice who would like to chip in is much appreciated!
I can help with the compile bit. However, I've have never run Tvheadend in debug mode from within VSC.
To set up VSC to compile you'll need to run the "configure" and a test "make" locally on your Pi 4 first. Once that's done you just need to configure a default build task in VSC. I've just tried to recreate mine through the VSC menus and its seems very convoluted. This process basically creates a ".vscode" directory at the root of your source files and then a "tasks.json" file inside that. I'm attaching mine which is a simple task to run "make" via the remote SSH connection.
Once that's all in place you can simply do a "Terminal/Run Build Task" from the VSC menu and the compile should take place on the Pi 4.
Hope that helps.
Adrian.
tasks.json (411 Bytes) tasks.json |
RE: Need help: Compile and test tvheadend from an IDE? - Added by Adrian Smith about 2 years ago
Okay, so I couldn't resist having a little play re. the debugging.
First thing I needed to do was install the gdb debugger on my Debian machine (apt-get install gdb).
Then I needed a "launch configuration" for VSC. I'm attaching both a revised tasks.json (just renamed the task to make things clearer) and a launch.json. With both of these in the ".vscode" directory at the root of my source code I am able to set a breakpoint in the "main" routine in "main.c" and then do a "Run/Start Debugging" in VSC. After recompiling the code (the preLaunchTask in launch.json refers back to the name of the build task in tasks.json), Tvheadend is launched and execution stops at my breakpoint. Variable inspection etc. in VSC seems to work fine.
Hopefully this will help you to get up and running.
Adrian.
launch.json (871 Bytes) launch.json | |||
tasks.json (226 Bytes) tasks.json |
RE: Need help: Compile and test tvheadend from an IDE? - Added by Sean Warner about 2 years ago
@Adrian Smith
You turned it all around you genius! I've wanted to get this working for MONTHS!
I've finally got a development environment where I can edit, debug and build tvheadend code.
No need to cross compile, I can do it all on the Pi but from my laptop!
Previously I had this working on the Pi with the Autobuild script but a useful step forward in my understanding was going through the compile steps manually and understanding how that creates the .config.mk file with all the build options and compiler flags that VSC will need to use. That was explained here by Dave Pickles https://tvheadend.org/boards/4/topics/47932?r=48009#message-48009
Eventually I'm gonna write up a big how-to for all of this.
Next step is to make a compound Task in VSC to do these three steps one after another each time I click “Run Build Task”:
1) make clean
2) ./configure <list of build options>
3) make -j$(nproc)
Thank you!
Flex
RE: Need help: Compile and test tvheadend from an IDE? - Added by Sean Warner about 2 years ago
Here is the compound task I made that runs these three steps in sequence each time you build from VSCode. E.g: Ctrl + Shift + B
1. make distclean
2. ./configure <list of required build options>
3. make -j$(nproc)
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run Make distclean command",
"type": "shell",
"command": "make distclean",
"problemMatcher": [],
"group": "build"
},
{
"label": "Run Config script",
"type": "shell",
"command": "./configure",
"args": [
"--enable-hdhomerun_client",
"--disable-hdhomerun_static",
"--disable-dvbscan",
"--enable-libav",
"--disable-ffmpeg_static",
"--enable-libx264",
"--disable-libx264_static",
"--enable-libx265",
"--disable-libx265_static",
"--enable-libvpx",
"--disable-libvpx_static",
"--enable-libtheora",
"--disable-libtheora_static",
"--enable-libvorbis",
"--disable-libvorbis_static",
"--enable-libfdkaac",
"--disable-libfdkaac_static",
"--enable-libopus",
"--disable-libopus_static",
"--enable-vaapi",
"--enable-nvenc",
"--enable-omx",
"--enable-dvbcsa",
"--enable-dvben50221",
"--enable-libsystemd_daemon",
"--enable-pcre2",
"--enable-pngquant",
"--enable-ddci",
"--python=/usr/bin/python3"
],
"problemMatcher": [],
"group": "build"
},
{
"label": "Run Make command",
"type": "shell",
"command": "make",
"args": [
"-j$(nproc)"
],
"problemMatcher": [],
"group": "build"
},
{
"label": "Build TVH",
"dependsOrder": "sequence",
"dependsOn": [
"Run Make distclean command",
"Run Config script",
"Run Make command"
],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Cheers,
Flex
RE: Need help: Compile and test tvheadend from an IDE? - Added by Adrian Smith about 2 years ago
Sean Warner wrote:
@Adrian Smith
You turned it all around you genius! I've wanted to get this working for MONTHS!
I've finally got a development environment where I can edit, debug and build tvheadend code.
No need to cross compile, I can do it all on the Pi but from my laptop!
You're very welcome. Glad I could help. I look forward to your step-by-step guide.