mpv icon indicating copy to clipboard operation
mpv copied to clipboard

disable fork usage when building for tvOS

Open JLehman17 opened this issue 2 years ago • 3 comments

This fixes builds for tvOS which are currently broken because fork is unavailable. See https://github.com/mpv-player/mpv/issues/5331

JLehman17 avatar Oct 27 '22 19:10 JLehman17

Looks good but please make sure the commit message matches the contribution guidelines. Also I don't know if building for tvOS is possible with meson currently but you may want to make the change there too.

sfan5 avatar Oct 28 '22 06:10 sfan5

meson doesn't have a tvOS detection because it literally was unused in waf. I think when wm4 made some changes to subprocesses and all that he nuked all usage of the tvOS detection but never actually removed the option so it always just did nothing.

Anyways as for implementing this in meson, ideally you could just use host_machine.system() like android does, but unfortunately, it looks like that will return darwin for all apple OSes (macOS, iOS, or tvOS; see https://github.com/mesonbuild/meson/issues/6361 and https://github.com/mesonbuild/meson/issues/7944). So you'll just have to use the same kind of custom check like waf currently use.

Dudemanguy avatar Oct 28 '22 14:10 Dudemanguy

@rcombs' version might be cleaner:

https://github.com/plexinc/mpv/commit/0c17d248116fc8647a1638e059f6e07bb238c8fd

cc https://github.com/mpv-player/mpv/issues/9171#issuecomment-981809660

tmm1 avatar Nov 06 '22 17:11 tmm1

@Dudemanguy host_machine.system() is not really the proper way to do this tbh, it is kind of a mistake people started to use it for iOS imho which results in a quite messed up situation that some projects expect it to be darwin and some expect ios in there. Hopefully eventually this will be properly cleaned up with API changes in meson to handle it properly…

For now the best way to do this is manually by leveraging TargetConditionals.h:

#include <TargetConditionals.h>
#if TARGET_OS_TV
// Compiling for tvOS
#endif

so in meson you could do:

if host_machine.system() == 'darwin'

    # Check if compiling for iOS
    have_ios = cc.get_define('TARGET_OS_IPHONE',
        prefix: '#include <TargetConditionals.h>') == '1'

    # Check if compiling for tvOS
    have_tvos = cc.get_define('TARGET_OS_TV',
        prefix: '#include <TargetConditionals.h>') == '1'

    # If none of the above, assume compiling for macOS
    have_osx = not have_ios and not have_tvos

else
    have_ios = false
    have_tvos = false
    have_osx = false
endif

ePirat avatar Jun 28 '23 11:06 ePirat

host_machine.system() is not really the proper way to do this tbh

That's why I said "ideally".

Dudemanguy avatar Jun 28 '23 13:06 Dudemanguy