-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2440 from Cheaterman/add_libvpx_recipe
Add libvpx recipe, reference it in ffpyplayer_codecs and ffmpeg
- Loading branch information
Showing
5 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from pythonforandroid.recipe import Recipe | ||
from pythonforandroid.toolchain import current_directory, shprint | ||
from os.path import join, realpath | ||
from multiprocessing import cpu_count | ||
import sh | ||
|
||
|
||
TARGETS = { | ||
'armeabi-v7a': 'armv7-android-gcc', | ||
'arm64-v8a': 'arm64-android-gcc', | ||
} | ||
|
||
|
||
class VPXRecipe(Recipe): | ||
version = '1.9.0' | ||
url = 'https://github.com/webmproject/libvpx/archive/v{version}.tar.gz' | ||
|
||
patches = [ | ||
# See https://git.io/Jq50q | ||
join('patches', '0001-android-force-neon-runtime.patch'), | ||
] | ||
|
||
def get_recipe_env(self, arch=None): | ||
env = super().get_recipe_env(arch) | ||
cxx_include_dir = join( | ||
self.ctx.ndk_dir, | ||
'toolchains', | ||
'llvm', | ||
'prebuilt', | ||
'linux-x86_64', | ||
'sysroot', | ||
'usr', | ||
'include', | ||
'c++', | ||
'v1', | ||
) | ||
env['CXXFLAGS'] += f' -I{cxx_include_dir}' | ||
if 'arm64' not in arch.arch: | ||
env['AS'] = arch.command_prefix + '-as' | ||
return env | ||
|
||
def build_arch(self, arch): | ||
with current_directory(self.get_build_dir(arch.arch)): | ||
env = self.get_recipe_env(arch) | ||
flags = [ | ||
'--target=' + TARGETS[arch.arch], | ||
'--enable-pic', | ||
'--enable-vp8', | ||
'--enable-vp9', | ||
'--enable-static', | ||
'--enable-small', | ||
'--disable-shared', | ||
'--disable-examples', | ||
'--disable-unit-tests', | ||
'--disable-tools', | ||
'--disable-docs', | ||
'--disable-install-docs', | ||
'--disable-realtime-only', | ||
f'--prefix={realpath(".")}', | ||
] | ||
configure = sh.Command('./configure') | ||
shprint(configure, *flags, _env=env) | ||
shprint(sh.make, '-j', str(cpu_count()), _env=env) | ||
shprint(sh.make, 'install', _env=env) | ||
|
||
|
||
recipe = VPXRecipe() |
25 changes: 25 additions & 0 deletions
25
pythonforandroid/recipes/libvpx/patches/0001-android-force-neon-runtime.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff -u -r ../libvpx-1.6.1/vpx_ports/arm_cpudetect.c ./vpx_ports/arm_cpudetect.c | ||
--- ../libvpx-1.6.1/vpx_ports/arm_cpudetect.c 2017-01-12 21:27:27.000000000 +0100 | ||
+++ ./vpx_ports/arm_cpudetect.c 2017-01-29 23:55:05.399283897 +0100 | ||
@@ -92,20 +92,17 @@ | ||
} | ||
|
||
#elif defined(__ANDROID__) /* end _MSC_VER */ | ||
-#include <cpu-features.h> | ||
|
||
int arm_cpu_caps(void) { | ||
int flags; | ||
int mask; | ||
- uint64_t features; | ||
if (!arm_cpu_env_flags(&flags)) { | ||
return flags; | ||
} | ||
mask = arm_cpu_env_mask(); | ||
- features = android_getCpuFeatures(); | ||
|
||
#if HAVE_NEON || HAVE_NEON_ASM | ||
- if (features & ANDROID_CPU_ARM_FEATURE_NEON) flags |= HAS_NEON; | ||
+ flags |= HAS_NEON; | ||
#endif /* HAVE_NEON || HAVE_NEON_ASM */ | ||
return flags & mask; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import unittest | ||
from tests.recipes.recipe_lib_test import BaseTestForMakeRecipe | ||
|
||
|
||
class TestLibVPXRecipe(BaseTestForMakeRecipe, unittest.TestCase): | ||
""" | ||
An unittest for recipe :mod:`~pythonforandroid.recipes.libvpx` | ||
""" | ||
recipe_name = "libvpx" | ||
sh_command_calls = ["./configure"] |