2017-08-13 03:24:00 +02:00
|
|
|
from pythonforandroid.toolchain import Recipe, current_directory
|
|
|
|
from pythonforandroid.logger import info, debug, shprint, warning
|
2019-03-30 21:58:45 +01:00
|
|
|
from os.path import join, isdir, isfile
|
2017-08-13 03:24:00 +02:00
|
|
|
from os import environ
|
|
|
|
import sh
|
2019-03-30 21:58:45 +01:00
|
|
|
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
class VlcRecipe(Recipe):
|
|
|
|
version = '3.0.0'
|
|
|
|
url = None
|
|
|
|
name = 'vlc'
|
|
|
|
|
|
|
|
depends = []
|
|
|
|
|
|
|
|
port_git = 'http://git.videolan.org/git/vlc-ports/android.git'
|
2019-03-30 21:58:45 +01:00
|
|
|
# vlc_git = 'http://git.videolan.org/git/vlc.git'
|
2017-08-13 03:24:00 +02:00
|
|
|
ENV_LIBVLC_AAR = 'LIBVLC_AAR'
|
2019-03-30 21:58:45 +01:00
|
|
|
aars = {} # for future use of multiple arch
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
def prebuild_arch(self, arch):
|
2022-12-02 21:15:34 +01:00
|
|
|
super().prebuild_arch(arch)
|
2017-08-13 03:24:00 +02:00
|
|
|
build_dir = self.get_build_dir(arch.arch)
|
|
|
|
port_dir = join(build_dir, 'vlc-port-android')
|
|
|
|
if self.ENV_LIBVLC_AAR in environ:
|
2019-03-30 21:58:45 +01:00
|
|
|
aar = environ.get(self.ENV_LIBVLC_AAR)
|
|
|
|
if isdir(aar):
|
|
|
|
aar = join(aar, 'libvlc-{}.aar'.format(self.version))
|
|
|
|
if not isfile(aar):
|
|
|
|
warning("Error: {} is not valid libvlc-<ver>.aar bundle".format(aar))
|
2017-08-13 03:24:00 +02:00
|
|
|
info("check {} environment!".format(self.ENV_LIBVLC_AAR))
|
|
|
|
exit(1)
|
2019-03-30 21:58:45 +01:00
|
|
|
self.aars[arch] = aar
|
2017-08-13 03:24:00 +02:00
|
|
|
else:
|
|
|
|
aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar')
|
|
|
|
self.aars[arch] = aar = join(aar_path, 'libvlc-{}.aar'.format(self.version))
|
2019-03-30 21:58:45 +01:00
|
|
|
warning("HINT: set path to precompiled libvlc-<ver>.aar bundle "
|
|
|
|
"in {} environment!".format(self.ENV_LIBVLC_AAR))
|
|
|
|
info("libvlc-<ver>.aar should build "
|
|
|
|
"from sources at {}".format(port_dir))
|
|
|
|
if not isfile(join(port_dir, 'compile.sh')):
|
2017-08-13 03:24:00 +02:00
|
|
|
info("clone vlc port for android sources from {}".format(
|
|
|
|
self.port_git))
|
|
|
|
shprint(sh.git, 'clone', self.port_git, port_dir,
|
2019-03-30 21:58:45 +01:00
|
|
|
_tail=20, _critical=True)
|
|
|
|
# now "git clone ..." is a part of compile.sh
|
|
|
|
# vlc_dir = join(port_dir, 'vlc')
|
|
|
|
# if not isfile(join(vlc_dir, 'Makefile.am')):
|
|
|
|
# info("clone vlc sources from {}".format(self.vlc_git))
|
|
|
|
# shprint(sh.git, 'clone', self.vlc_git, vlc_dir,
|
|
|
|
# _tail=20, _critical=True)
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
def build_arch(self, arch):
|
2022-12-02 21:15:34 +01:00
|
|
|
super().build_arch(arch)
|
2017-08-13 03:24:00 +02:00
|
|
|
build_dir = self.get_build_dir(arch.arch)
|
|
|
|
port_dir = join(build_dir, 'vlc-port-android')
|
|
|
|
aar = self.aars[arch]
|
2019-03-30 21:58:45 +01:00
|
|
|
if not isfile(aar):
|
2017-08-13 03:24:00 +02:00
|
|
|
with current_directory(port_dir):
|
|
|
|
env = dict(environ)
|
|
|
|
env.update({
|
|
|
|
'ANDROID_ABI': arch.arch,
|
|
|
|
'ANDROID_NDK': self.ctx.ndk_dir,
|
|
|
|
'ANDROID_SDK': self.ctx.sdk_dir,
|
|
|
|
})
|
|
|
|
info("compiling vlc from sources")
|
|
|
|
debug("environment: {}".format(env))
|
2019-03-30 21:58:45 +01:00
|
|
|
if not isfile(join('bin', 'VLC-debug.apk')):
|
|
|
|
shprint(sh.Command('./compile.sh'), _env=env,
|
2017-08-13 03:24:00 +02:00
|
|
|
_tail=50, _critical=True)
|
2019-03-30 21:58:45 +01:00
|
|
|
shprint(sh.Command('./compile-libvlc.sh'), _env=env,
|
|
|
|
_tail=50, _critical=True)
|
2017-08-13 03:24:00 +02:00
|
|
|
shprint(sh.cp, '-a', aar, self.ctx.aars_dir)
|
|
|
|
|
2019-03-30 21:58:45 +01:00
|
|
|
|
2017-08-13 03:24:00 +02:00
|
|
|
recipe = VlcRecipe()
|