[mythtv] CMake
Scott Theisen
scott.the.elm at gmail.com
Tue Jul 16 23:11:25 UTC 2024
On 7/15/24 18:01, David Hampton via mythtv-dev wrote:
> On Fri, 2024-07-12 at 17:51 -0400, Scott Theisen wrote:
>> On 7/12/24 14:37, David Hampton via mythtv-dev wrote:
>>> On Fri, 2024-07-12 at 04:02 +0000, Gary Buhrmaster wrote:
>>>> On Fri, Jul 12, 2024 at 2:14 AM Scott Theisen
>>>> <scott.the.elm at gmail.com> wrote:
...
>>>>> Is there a way to only build, but not install, the plugins?
>>> I tried a couple of experiments this morning. It could be done
>>> with an
>>> option at the top level, but it wouldn't be the prettiest given
>>> where/how the cmake ExternalProject allows substitution. It seems
>>> like
>>> the CMakefile would need to provide an alternative ExternalProject
>>> that
>>> doesn't perform an install, and then build one or the other of
>>> those
>>> projects based on an option. To switch from installing to not
>>> installing the plugins you would also have to do a complete rebuild
>>> from the top level.
>>
>> I have never used any of the plugins and I don't really care if they
>> are installed as long as they don't do anything or can be easily
>> uninstalled right after installing.
> If you don't want to build the plugins, there's already an option for
> that. You could perform most of your builds with out compiling the
> plugins, and then perform a final build with plugins at the end to see
> if anything broke.
I do want to build the plugins, however, so that any change always
compiles everything. I want to know if any changes I make require
changes to the plugins so those changes can be in the same commit, not a
separate later commit.
Since I already want a build that doesn't install anything, I think
something like this might work:
cmake --preset qt5 -DMYTH_BUILD_PLUGINS=OFF
cmake --preset qt5 -B build-no-install
-DCMAKE_INSTALL_PREFIX=./build-no-install/install
and usually run
cmake --build build-no-install
and run
cmake --build build-qt5
when I want to run that version of MythTV.
>> for installed plugins. If that could be disabled or if each plugin
>> must be explicitly enabled, I don't think it would matter if they are
>> installed.
> Mythfrontend looks for plugins and calls their initialization routine.
> That puts entries into the menu to call the plugins. I don't think
> anything else happens until you select a plugin supplied menu item.
I looked in mythfrontend and I did not see any code that would allow
disabling loading the plugins.
>
>>>>> Can you build but not install the project? (e.g. when making
>>>>> further changes to the code while running a test with different
>>>>> changes.)
>>>
>>> Once you've built/installed the super-project the first time, you
>>> can
>>> easily compile just the MythTV sub-project. This is described in
>>> the
>>> README.CMake.md file. You can compile just the mythtv directory
>>> from
>>> the top level:
>>>
>>> $ cmake --build <build-dir>/MythTV-prefix/src/MythTV-build
>>> $ cmake --install <build-dir>/MythTV-prefix/src/MythTV-build
>>>
>>> Or you can change into the MythTV build directory and compile from
>>> there.
>>>
>>> $ cd <build-dir>/MythTV-prefix/src/MythTV-build
>>> $ cmake --build .
>>> $ cmake --install .
>>>
>>> Or if you're working on FFmpeg:
>>>
>>> $ cd <build-dir>/FFmpeg-prefix/src/FFmpeg-build
>>> $ cmake --build .
>>> $ cmake --install .
>>
>> require a rebuild of and possible changes to MythTV and changes in
>> MythTV would require a rebuild of and possible changes to the
>> plugins.
>>
>> So I'm not sure building only one part really makes sense.
> I normally never need to build anything that lives under
> mythtv/external. I'd rather build those libraries once and then reuse
> them until the end of days. Unless, of course, someone else changes
> one of those libraries. If that happens I blow away my install
> directory, recompile everything once, and then reuse all the newly
> generated libraries for as long as I possibly can. I *never* want to
> compile anything other than the mythtv and mythplugins directories if I
> don't absolutely have to. I think this makes perfect sense.
>
Since we are already using ccache, does skipping building
mythtv/external really save any time?
Even if we weren't using ccache, shouldn't the build system see that the
files are unchanged and skip them?
...
>
>>> A big part of the reason for my choosing the sub-project design for
>>> MythTV is that linux/android/win builds are all done exactly the
>>> same
>>> way. The difference between these builds comes down to the number
>>> of
>>> sub-projects and the arguments to the sub-projects. It also
>>> becomes
>>> almost trivial to replace an embedded library with a system
>>> library.
>>> And yes, I was thinking of FFmpeg and exiv2 when I chose this
>>> design
>>> and chose to build those libraries as separate sub-projects instead
>>> of
>>> as part of the mythtv sub-project.
>>>
>>> I do understand that this is different from the current make
>>> implementation that builds all of the libraries and MythTV together
>>> in
>>> one fell swoop, and then installs them. I think its better in some
>>> ways. For example, with this design you only have to compile and
>>> install the mythtv version of FFmpeg once, and all subsequent
>>> builds
>>> (even complete rebuilds) will treat that installed version of
>>> mythtv
>>> FFmpeg as a system library. For everyone other than you and Peter
>>> who
>>> are actually modifying FFmpeg, I consider that a win. Its easy
>>> enough
>>> to force a rebuild of mythtv FFmpeg any time you want. Just delete
>>> the
>>> installed mythtv FFmpeg and rebuild the super-project.
>> A top level build would also build and install a modified FFmpeg,
>> replacing the previously installed version, right?
> No. A new top level build will discover the previously installed
> mythtv FFmpeg and use that. You need to delete the previously
> installed mythtv FFmpeg if you want to rebuild it. Everything else is
> reused where possible. The only sub-projects that are always rebuilt
> when you recreate a top level build are the mythtv and mythplugins sub-
> projects. (It would be simple enough to add FFmpeg to this list.) I
> love the fact that deleting and re-creating a build directory will
> reuse all the previously built libraries and configure itself to only
> compile the mythtv bits.
I was talking about running `cmake --build build-qt5` from the top level
directory after modifying FFmpeg (or anything in mythtv/external).
Regardless, shouldn't the build system check that the library source has
not changed since it was last installed?
...
>
> If you want a single build target to compile FFmpeg / libexiv2 /
> libmythbluray / libmythdvdnav / libudfread / nv-codec-headers / mythtv
> it could be done, but it would require collapsing those six sub-
> projects into a single sub-project. I think that's the wrong approach
> and would be moving backwards for MythTV.
You listed seven things. I don't think you need to collapse them into a
single sub-project; couldn't you create a new super-project above them
that includes all of them, so they remain individual sub-projects and
their API boundaries are respected?
> Everything under
> mythtv/external should be ripped out and replaced by patches against
> original sources. MythTV should no longer ship the source code for any
> library that it uses. It should use system libraries if at all
> possible, and if not, it should use package maintainer's source code
> with locally applied patches. This is something that's trivial for
> cmake to do, and hard for make to do. I'm hoping that all your FFmpeg
> work will help us get to this point with FFmpeg where it can be ripped
> out of the MythTV sources.
Not all systems have the required libraries available as packages
(libudfread is not widely available, EL 8 does not have official
packages for libbluray) or the version is too old (libexiv2 0.28 is
needed for C++17 support).
See https://www.mythtv.org/wiki/External_libraries
git diff --shortstat `git hash-object -t tree /dev/null` -- FFmpeg
7816 files changed, 1907223 insertions(+)
git diff --shortstat `git hash-object -t tree /dev/null` -- libexiv2/
223 files changed, 105819 insertions(+)
git diff --shortstat `git hash-object -t tree /dev/null` -- libmythbluray/
880 files changed, 102024 insertions(+)
git diff --shortstat `git hash-object -t tree /dev/null` -- libmythdvdnav/
56 files changed, 19995 insertions(+)
git diff --shortstat `git hash-object -t tree /dev/null` -- libudfread/
15 files changed, 3741 insertions(+)
git diff --shortstat `git hash-object -t tree /dev/null` --
nv-codec-headers/
10 files changed, 5872 insertions(+)
Only FFmpeg and libmythdvdnav are modified.
libmythbluray was formerly modified, but changes where made to MythTV to
enable using it unmodified. Similar changes could probably be made
regarding libmythdvdnav.
nv-codec-headers replaces the Nvidia CUDA library headers allowing
libavutil/hwcontext_cuda.h to compile and enables MythTV to use NVDEC.
I do have our FFmpeg changes rebased onto FFmpeg/release/5.1, but I am
still trying to create meaningful history/commits for mpegts-mythtv.
While applying patches sounds nice in theory, I'm not sure how well it
would work since different versions could break the patches or require
different or other patches.
...
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20240716/fd33ac1f/attachment.htm>
More information about the mythtv-dev
mailing list