diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 787e36c..fc947da 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -50,6 +50,11 @@ jobs: run: | sudo chmod +x bundle_full.sh ./bundle_full.sh + - name: Bundle (encoders-gpl) + working-directory: ./buildscripts + run: | + sudo chmod +x bundle_encoders-gpl.sh + ./bundle_encoders-gpl.sh - uses: actions/upload-artifact@v3.1.2 with: name: artifact diff --git a/LICENSE b/LICENSE index 81d2ff3..cfaa955 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,5 @@ +For the "default" and "full" flavors, the following license applies: + Copyright (c) 2016 Ilya Zhuravlev Copyright (c) 2016 sfan5 @@ -6,3 +8,20 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For the "encoders-gpl" flavor, the following license applies: + +Copyright (C) 2023 Callum Moffat + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/buildscripts/build.sh b/buildscripts/build.sh index e6cd296..7f248f4 100755 --- a/buildscripts/build.sh +++ b/buildscripts/build.sh @@ -46,6 +46,11 @@ loadarch () { export prefix_dir="$PWD/prefix/$prefix_name" export native_dir="$PWD/../libmpv/src/main/jniLibs/$prefix_name" export CC=$cc_triple-clang + if [[ "$1" == arm* ]]; then + export AS="$CC" + else + export AS="nasm" + fi export CXX=$cc_triple-clang++ export AR=llvm-ar export RANLIB=llvm-ranlib diff --git a/buildscripts/bundle_default.sh b/buildscripts/bundle_default.sh index 4b8c1a8..e53ba6e 100755 --- a/buildscripts/bundle_default.sh +++ b/buildscripts/bundle_default.sh @@ -70,7 +70,7 @@ zip -r "default-armeabi-v7a.jar" lib/armeabi-v7a zip -r "default-x86.jar" lib/x86 zip -r "default-x86_64.jar" lib/x86_64 -mkdir ../../../../../../../../../../output +mkdir -p ../../../../../../../../../../output cp *.jar ../../../../../../../../../../output diff --git a/buildscripts/bundle_encoders-gpl.sh b/buildscripts/bundle_encoders-gpl.sh new file mode 100755 index 0000000..fa3489e --- /dev/null +++ b/buildscripts/bundle_encoders-gpl.sh @@ -0,0 +1,85 @@ +# -------------------------------------------------- +set -euxo pipefail + +export ENCODERS_GPL=1 + +if [ -d deps ]; then + sudo rm -r deps +fi +if [ -d prefix ]; then + sudo rm -r prefix +fi + +./download.sh +./patch-encoders-gpl.sh + +# -------------------------------------------------- + +rm scripts/ffmpeg.sh +cp flavors/encoders-gpl.sh scripts/ffmpeg.sh + +# -------------------------------------------------- + +./build.sh + +# -------------------------------------------------- + +cd deps/media-kit-android-helper + +sudo chmod +x gradlew +./gradlew assembleRelease + +unzip -o app/build/outputs/apk/release/app-release.apk -d app/build/outputs/apk/release + +ln -sf "$(pwd)/app/build/outputs/apk/release/lib/arm64-v8a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/arm64-v8a" +ln -sf "$(pwd)/app/build/outputs/apk/release/lib/armeabi-v7a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/armeabi-v7a" +ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86" +ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86_64/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86_64" + +cd ../.. + +# -------------------------------------------------- + +cd deps/media_kit/media_kit_native_event_loop + +flutter create --org com.alexmercerind --template plugin_ffi --platforms=android . + +if ! grep -q android "pubspec.yaml"; then + printf " android:\n ffiPlugin: true\n" >> pubspec.yaml +fi + +flutter pub get + +cp -a ../../mpv/libmpv/. src/include/ + +cd example + +flutter clean +flutter build apk --release + +unzip -o build/app/outputs/apk/release/app-release.apk -d build/app/outputs/apk/release + +cd build/app/outputs/apk/release/ + +# -------------------------------------------------- + +rm -r lib/*/libapp.so +rm -r lib/*/libflutter.so + +zip -r "encoders-gpl-arm64-v8a.jar" lib/arm64-v8a +zip -r "encoders-gpl-armeabi-v7a.jar" lib/armeabi-v7a +zip -r "encoders-gpl-x86.jar" lib/x86 +zip -r "encoders-gpl-x86_64.jar" lib/x86_64 + +mkdir -p ../../../../../../../../../../output + +cp *.jar ../../../../../../../../../../output + +md5sum *.jar + +cd ../../../../../../../../.. + +# -------------------------------------------------- + +zip -r debug-symbols-encoders-gpl.zip prefix/*/lib +cp debug-symbols-encoders-gpl.zip ../output diff --git a/buildscripts/bundle_full.sh b/buildscripts/bundle_full.sh index 1a16858..2c1d53d 100644 --- a/buildscripts/bundle_full.sh +++ b/buildscripts/bundle_full.sh @@ -70,7 +70,7 @@ zip -r "full-armeabi-v7a.jar" lib/armeabi-v7a zip -r "full-x86.jar" lib/x86 zip -r "full-x86_64.jar" lib/x86_64 -mkdir ../../../../../../../../../../output +mkdir -p ../../../../../../../../../../output cp *.jar ../../../../../../../../../../output diff --git a/buildscripts/flavors/default.sh b/buildscripts/flavors/default.sh index c935904..1dad7b3 100644 --- a/buildscripts/flavors/default.sh +++ b/buildscripts/flavors/default.sh @@ -29,7 +29,6 @@ cpuflags= --extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \ \ --disable-gpl \ - --disable-asm \ --disable-nonfree \ --enable-version3 \ --enable-static \ diff --git a/buildscripts/flavors/encoders-gpl.sh b/buildscripts/flavors/encoders-gpl.sh new file mode 100644 index 0000000..c7ec6d6 --- /dev/null +++ b/buildscripts/flavors/encoders-gpl.sh @@ -0,0 +1,128 @@ +#!/bin/bash -e + +. ../../include/depinfo.sh +. ../../include/path.sh + +if [ "$1" == "build" ]; then + true +elif [ "$1" == "clean" ]; then + rm -rf _build$ndk_suffix + exit 0 +else + exit 255 +fi + +mkdir -p _build$ndk_suffix +cd _build$ndk_suffix + +cpu=armv7-a +[[ "$ndk_triple" == "aarch64"* ]] && cpu=armv8-a +[[ "$ndk_triple" == "x86_64"* ]] && cpu=generic +[[ "$ndk_triple" == "i686"* ]] && cpu="i686 --disable-asm" + +cpuflags= +[[ "$ndk_triple" == "arm"* ]] && cpuflags="$cpuflags -mfpu=neon -mcpu=cortex-a8" + +../configure \ + --target-os=android --enable-cross-compile --cross-prefix=$ndk_triple- --ar=$AR --cc=$CC --ranlib=$RANLIB \ + --arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config \ + --extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \ + --pkg-config-flags="--static" \ + \ + --disable-nonfree \ + --enable-version3 \ + --enable-static \ + --disable-shared \ + --disable-vulkan \ + --disable-iconv \ + --disable-stripping \ + --pkg-config-flags=--static \ + \ + --enable-decoders \ + --enable-encoders \ + --enable-libvorbis \ + --enable-libvpx \ + --enable-gpl \ + --enable-libx264 \ + --enable-muxers \ + --enable-demuxers \ + --enable-parsers \ + \ + --disable-protocols \ + --disable-devices \ + --disable-doc \ + --disable-avdevice \ + --disable-postproc \ + --disable-programs \ + --disable-gray \ + --disable-swscale-alpha \ + \ + --enable-jni \ + --enable-bsfs \ + --enable-mediacodec \ + \ + --disable-dxva2 \ + --disable-vaapi \ + --disable-vdpau \ + --disable-bzlib \ + --disable-linux-perf \ + --disable-videotoolbox \ + --disable-audiotoolbox \ + \ + --enable-small \ + --enable-hwaccels \ + --enable-optimizations \ + --enable-runtime-cpudetect \ + \ + --enable-mbedtls \ + \ + --enable-libdav1d \ + \ + --enable-libxml2 \ + \ + --enable-avutil \ + --enable-avcodec \ + --enable-avfilter \ + --enable-avformat \ + --enable-swscale \ + --enable-swresample \ + \ + \ + \ + --enable-filters \ + \ + --enable-protocol=async \ + --enable-protocol=cache \ + --enable-protocol=crypto \ + --enable-protocol=data \ + --enable-protocol=ffrtmphttp \ + --enable-protocol=file \ + --enable-protocol=ftp \ + --enable-protocol=hls \ + --enable-protocol=http \ + --enable-protocol=httpproxy \ + --enable-protocol=https \ + --enable-protocol=pipe \ + --enable-protocol=rtmp \ + --enable-protocol=rtmps \ + --enable-protocol=rtmpt \ + --enable-protocol=rtmpts \ + --enable-protocol=rtp \ + --enable-protocol=subfile \ + --enable-protocol=tcp \ + --enable-protocol=tls \ + --enable-protocol=srt \ + \ + --enable-network \ + +make -j$cores +make DESTDIR="$prefix_dir" install + +ln -sf "$prefix_dir"/lib/libswresample.so "$native_dir" +ln -sf "$prefix_dir"/lib/libpostproc.so "$native_dir" +ln -sf "$prefix_dir"/lib/libavutil.so "$native_dir" +ln -sf "$prefix_dir"/lib/libavcodec.so "$native_dir" +ln -sf "$prefix_dir"/lib/libavformat.so "$native_dir" +ln -sf "$prefix_dir"/lib/libswscale.so "$native_dir" +ln -sf "$prefix_dir"/lib/libavfilter.so "$native_dir" +ln -sf "$prefix_dir"/lib/libavdevice.so "$native_dir" diff --git a/buildscripts/flavors/full.sh b/buildscripts/flavors/full.sh index 2a36846..eec5182 100644 --- a/buildscripts/flavors/full.sh +++ b/buildscripts/flavors/full.sh @@ -29,7 +29,6 @@ cpuflags= --extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \ \ --disable-gpl \ - --disable-asm \ --disable-nonfree \ --enable-version3 \ --enable-static \ diff --git a/buildscripts/include/depinfo.sh b/buildscripts/include/depinfo.sh index 744461a..60253cf 100755 --- a/buildscripts/include/depinfo.sh +++ b/buildscripts/include/depinfo.sh @@ -15,6 +15,9 @@ v_dav1d=1.2.0 v_libxml2=2.10.3 v_ffmpeg=6.0 v_mpv=master +v_libogg=1.3.5 +v_libvorbis=1.3.7 +v_libvpx=1.13 ## Dependency tree @@ -22,11 +25,20 @@ v_mpv=master dep_mbedtls=() dep_dav1d=() -dep_ffmpeg=(mbedtls dav1d libxml2) +dep_libvorbis=(libogg) +if [ -n "$ENCODERS_GPL" ]; then + dep_ffmpeg=(mbedtls dav1d libxml2 libvorbis libvpx libx264) +else + dep_ffmpeg=(mbedtls dav1d libxml2) +fi dep_freetype2=() dep_fribidi=() dep_harfbuzz=() dep_libass=(freetype fribidi harfbuzz) dep_lua=() dep_shaderc=() -dep_mpv=(ffmpeg libass) +if [ -n "$ENCODERS_GPL" ]; then + dep_mpv=(ffmpeg libass fftools_ffi) +else + dep_mpv=(ffmpeg libass) +fi diff --git a/buildscripts/include/download-deps.sh b/buildscripts/include/download-deps.sh index 719ee8a..50695ad 100755 --- a/buildscripts/include/download-deps.sh +++ b/buildscripts/include/download-deps.sh @@ -15,6 +15,18 @@ mkdir -p deps && cd deps # libxml2 [ ! -d libxml2 ] && git clone --depth 1 --branch v$v_libxml2 --recursive https://gitlab.gnome.org/GNOME/libxml2.git libxml2 +# libogg +[ ! -d libogg ] && $WGET https://github.com/xiph/ogg/releases/download/v${v_libogg}/libogg-${v_libogg}.tar.gz && tar -xf libogg-${v_libogg}.tar.gz && mv libogg-${v_libogg} libogg && rm libogg-${v_libogg}.tar.gz + +# libvorbis +[ ! -d libvorbis ] && $WGET https://github.com/xiph/vorbis/releases/download/v${v_libvorbis}/libvorbis-${v_libvorbis}.tar.gz && tar -xf libvorbis-${v_libvorbis}.tar.gz && mv libvorbis-${v_libvorbis} libvorbis && rm libvorbis-${v_libvorbis}.tar.gz + +# libvpx +[ ! -d libvpx ] && git clone --depth 1 --branch meson-$v_libvpx https://gitlab.freedesktop.org/gstreamer/meson-ports/libvpx.git + +# libx264 +[ ! -d libx264 ] && git clone --depth 1 https://code.videolan.org/videolan/x264.git --branch master libx264 + # ffmpeg [ ! -d ffmpeg ] && git clone --depth 1 --branch n$v_ffmpeg https://github.com/FFmpeg/FFmpeg.git ffmpeg @@ -42,6 +54,9 @@ HEREDOC # [ ! -d mpv ] && git clone --depth 1 --branch v$v_mpv https://github.com/mpv-player/mpv.git mpv [ ! -d mpv ] && git clone --depth 1 --branch $v_mpv https://github.com/mpv-player/mpv.git mpv +# fftools_ffi +[ ! -d fftools_ffi ] && git clone --depth 1 --branch main https://github.com/moffatman/fftools-ffi.git fftools_ffi + # media-kit-android-helper [ ! -d media-kit-android-helper ] && git clone --depth 1 --single-branch --branch main https://github.com/media-kit/media-kit-android-helper.git diff --git a/buildscripts/patch-encoders-gpl.sh b/buildscripts/patch-encoders-gpl.sh new file mode 100755 index 0000000..2352eba --- /dev/null +++ b/buildscripts/patch-encoders-gpl.sh @@ -0,0 +1,21 @@ +#!/bin/bash -e + +PATCHES=(patches-encoders-gpl/*) +ROOT=$(pwd) + +for dep_path in "${PATCHES[@]}"; do + if [ -d "$dep_path" ]; then + patches=($dep_path/*) + dep=$(echo $dep_path |cut -d/ -f 2) + cd deps/$dep + echo Patching $dep + git reset --hard + for patch in "${patches[@]}"; do + echo Applying $patch + git apply "$ROOT/$patch" + done + cd $ROOT + fi +done + +exit 0 diff --git a/buildscripts/patches-encoders-gpl/ffmpeg b/buildscripts/patches-encoders-gpl/ffmpeg new file mode 120000 index 0000000..e2bf6e7 --- /dev/null +++ b/buildscripts/patches-encoders-gpl/ffmpeg @@ -0,0 +1 @@ +../patches/ffmpeg \ No newline at end of file diff --git a/buildscripts/patches-encoders-gpl/libx264/fix_x86_asm.patch b/buildscripts/patches-encoders-gpl/libx264/fix_x86_asm.patch new file mode 100644 index 0000000..b5630b2 --- /dev/null +++ b/buildscripts/patches-encoders-gpl/libx264/fix_x86_asm.patch @@ -0,0 +1,13 @@ +diff --git a/configure b/configure +index e242e73c..219381ab 100755 +--- a/configure ++++ b/configure +@@ -738,7 +739,7 @@ LDFLAGS="$LDFLAGS $libm" + + stack_alignment=4 + case $host_cpu in +- i*86) ++ *86) + ARCH="X86" + AS="${AS-nasm}" + AS_EXT=".asm" diff --git a/buildscripts/patches-encoders-gpl/mpv/depend_on_fftools_ffi.patch b/buildscripts/patches-encoders-gpl/mpv/depend_on_fftools_ffi.patch new file mode 100644 index 0000000..adcfa84 --- /dev/null +++ b/buildscripts/patches-encoders-gpl/mpv/depend_on_fftools_ffi.patch @@ -0,0 +1,48 @@ +diff --git a/meson.build b/meson.build +index ce1fce2..6049156 100644 +--- a/meson.build ++++ b/meson.build +@@ -23,6 +23,9 @@ libavutil = dependency('libavutil', version: '>= 56.70.100') + libswresample = dependency('libswresample', version: '>= 3.9.100') + libswscale = dependency('libswscale', version: '>= 5.9.100') + ++# fftools-ffi ++libfftools_ffi = dependency('fftools-ffi') ++ + libass = dependency('libass', version: '>= 0.12.2') + pthreads = dependency('threads') + +@@ -35,7 +38,8 @@ dependencies = [libass, + libavutil, + libswresample, + libswscale, +- pthreads] ++ pthreads, ++ libfftools_ffi] + + # Keeps track of all enabled/disabled features + features = { +@@ -246,7 +250,10 @@ sources = files( + ## tree_allocator + 'ta/ta.c', + 'ta/ta_talloc.c', +- 'ta/ta_utils.c' ++ 'ta/ta_utils.c', ++ ++ ## fftools-ffi hack ++ 'fftools-ffi.c' + ) + + +diff --git a/fftools-ffi.c b/fftools-ffi.c +new file mode 100644 +index 0000000..6cd4258 +--- /dev/null ++++ b/fftools-ffi.c +@@ -0,0 +1,6 @@ ++#include "fftools-ffi/dart_api.h" ++ ++void* a = FFToolsFFIInitialize; ++void* b = FFToolsFFIExecuteFFmpeg; ++void* c = FFToolsFFIExecuteFFprobe; ++void* d = FFToolsCancel; diff --git a/buildscripts/patches-encoders-gpl/mpv/mpv_lavc_set_java_vm.patch b/buildscripts/patches-encoders-gpl/mpv/mpv_lavc_set_java_vm.patch new file mode 120000 index 0000000..1b46060 --- /dev/null +++ b/buildscripts/patches-encoders-gpl/mpv/mpv_lavc_set_java_vm.patch @@ -0,0 +1 @@ +../../patches/mpv/mpv_lavc_set_java_vm.patch \ No newline at end of file diff --git a/buildscripts/scripts/fftools_ffi.sh b/buildscripts/scripts/fftools_ffi.sh new file mode 100755 index 0000000..a8e6b19 --- /dev/null +++ b/buildscripts/scripts/fftools_ffi.sh @@ -0,0 +1,22 @@ +#!/bin/bash -e + +. ../../include/depinfo.sh +. ../../include/path.sh + +build=_build$ndk_suffix + +if [ "$1" == "build" ]; then + true +elif [ "$1" == "clean" ]; then + rm -rf $build + exit 0 +else + exit 255 +fi + +unset CC CXX # meson wants these unset + +CFLAGS=-fPIC CXXFLAGS=-fPIC meson setup $build --cross-file "$prefix_dir"/crossfile.txt + +ninja -C $build -j$cores +DESTDIR="$prefix_dir" ninja -C $build install diff --git a/buildscripts/scripts/libogg.build b/buildscripts/scripts/libogg.build new file mode 100644 index 0000000..16cfd10 --- /dev/null +++ b/buildscripts/scripts/libogg.build @@ -0,0 +1,17 @@ +# https://mesonbuild.com/External-Project-module.html + +project('libogg', 'c') + +mod = import('unstable-external_project') + +p = mod.add_project('configure', + configure_options : [ + '--prefix=@PREFIX@', + '--disable-shared', + '--enable-static', + ], + verbose: true, +) + +libogg_dep = p.dependency('libogg') +meson.override_dependency('libogg', libogg_dep) diff --git a/buildscripts/scripts/libogg.sh b/buildscripts/scripts/libogg.sh new file mode 100755 index 0000000..c100114 --- /dev/null +++ b/buildscripts/scripts/libogg.sh @@ -0,0 +1,24 @@ +#!/bin/bash -e + +. ../../include/depinfo.sh +. ../../include/path.sh + +build=_build$ndk_suffix + +if [ "$1" == "build" ]; then + true +elif [ "$1" == "clean" ]; then + rm -rf $build + exit 0 +else + exit 255 +fi + +cp ../../scripts/libogg.build meson.build + +unset CC CXX # meson wants these unset + +CFLAGS=-fPIC CXXFLAGS=-fPIC meson setup $build --cross-file "$prefix_dir"/crossfile.txt -Ddefault_library=static + +meson compile -C $build libogg +DESTDIR="$prefix_dir" ninja -C $build install diff --git a/buildscripts/scripts/libvorbis.build b/buildscripts/scripts/libvorbis.build new file mode 100644 index 0000000..4755ea7 --- /dev/null +++ b/buildscripts/scripts/libvorbis.build @@ -0,0 +1,17 @@ +# https://mesonbuild.com/External-Project-module.html + +project('libvorbis', 'c') + +mod = import('unstable-external_project') + +p = mod.add_project('configure', + configure_options : [ + '--prefix=@PREFIX@', + '--enable-static', + '--disable-shared', + ], + verbose: true, +) + +libvorbis_dep = p.dependency('libvorbis') +meson.override_dependency('libvorbis', libvorbis_dep) diff --git a/buildscripts/scripts/libvorbis.sh b/buildscripts/scripts/libvorbis.sh new file mode 100755 index 0000000..5933f27 --- /dev/null +++ b/buildscripts/scripts/libvorbis.sh @@ -0,0 +1,26 @@ +#!/bin/bash -e + +. ../../include/depinfo.sh +. ../../include/path.sh + +build=_build$ndk_suffix + +if [ "$1" == "build" ]; then + true +elif [ "$1" == "clean" ]; then + rm -rf $build + exit 0 +else + exit 255 +fi + +cp ../../scripts/libvorbis.build meson.build +# -mno-ieee-fp is not supported by clang +sed s/\-mno\-ieee\-fp// -i {configure,configure.ac} + +unset CC CXX # meson wants these unset + +CFLAGS=-fPIC CXXFLAGS=-fPIC meson setup $build --cross-file "$prefix_dir"/crossfile.txt -Ddefault_library=static + +meson compile -C $build libvorbis +DESTDIR="$prefix_dir" ninja -C $build install diff --git a/buildscripts/scripts/libvpx.sh b/buildscripts/scripts/libvpx.sh new file mode 100755 index 0000000..c3d0449 --- /dev/null +++ b/buildscripts/scripts/libvpx.sh @@ -0,0 +1,22 @@ +#!/bin/bash -e + +. ../../include/depinfo.sh +. ../../include/path.sh + +build=_build$ndk_suffix + +if [ "$1" == "build" ]; then + true +elif [ "$1" == "clean" ]; then + rm -rf $build + exit 0 +else + exit 255 +fi + +unset CC CXX # meson wants these unset + +meson setup $build --cross-file "$prefix_dir"/crossfile.txt -Ddefault_library=static -Dcpu_features_path="$ANDROID_HOME/ndk/$v_ndk/sources/android/cpufeatures" + +ninja -C $build -j$cores +DESTDIR="$prefix_dir" ninja -C $build install diff --git a/buildscripts/scripts/libx264.build b/buildscripts/scripts/libx264.build new file mode 100644 index 0000000..776ac2f --- /dev/null +++ b/buildscripts/scripts/libx264.build @@ -0,0 +1,26 @@ +# https://mesonbuild.com/External-Project-module.html + +project('libx264', 'c') + +mod = import('unstable-external_project') + +configure_options = [ + '--prefix=@PREFIX@', + '--disable-shared', + '--enable-static', + '--disable-cli', + '--enable-pic' +] + +if host_machine.cpu() == 'i686' + # See https://github.com/android/ndk/issues/693 + configure_options += '--disable-asm' +endif + +p = mod.add_project('configure', + configure_options : configure_options, + verbose: true +) + +libx264_dep = p.dependency('libx264') +meson.override_dependency('libx264', libx264_dep) diff --git a/buildscripts/scripts/libx264.sh b/buildscripts/scripts/libx264.sh new file mode 100755 index 0000000..eb597a2 --- /dev/null +++ b/buildscripts/scripts/libx264.sh @@ -0,0 +1,26 @@ +#!/bin/bash -e + +. ../../include/depinfo.sh +. ../../include/path.sh + +build=_build$ndk_suffix + +if [ "$1" == "build" ]; then + true +elif [ "$1" == "clean" ]; then + rm -rf $build + exit 0 +else + exit 255 +fi + +cp ../../scripts/libx264.build meson.build + +unset CC CXX # meson wants these unset + +mkdir $build + +meson setup $build --cross-file "$prefix_dir"/crossfile.txt --prefix="$prefix_dir" + +meson compile -C $build libx264 +meson install -C $build