diff --git a/recipes/recipes_emscripten/ffmpeg/build.sh b/recipes/recipes_emscripten/ffmpeg/build.sh index 317a44dfd5..b348970575 100644 --- a/recipes/recipes_emscripten/ffmpeg/build.sh +++ b/recipes/recipes_emscripten/ffmpeg/build.sh @@ -12,19 +12,20 @@ export PYTHON="${BUILD_PREFIX}/bin/python3" # Makefile variable of the same name. unset SUBDIR -export CFLAGS="-I${PREFIX}/include ${CFLAGS:-}" -export LDFLAGS="-L${PREFIX}/lib ${LDFLAGS:-}" +export CFLAGS="-I${PREFIX}/include -pthread ${CFLAGS:-}" +export LDFLAGS="-L${PREFIX}/lib -pthread ${LDFLAGS:-}" # llvm-nm avoids the broken packaged emnm Python launcher. ./configure \ --prefix="${PREFIX}" \ - --target-os=none --arch=x86_32 --enable-cross-compile \ - --disable-asm --disable-stripping --disable-programs \ + --target-os=none --arch=wasm --enable-cross-compile \ + --disable-stripping \ --disable-doc --disable-debug --disable-runtime-cpudetect \ - --disable-autodetect --disable-pthreads --disable-w32threads \ + --disable-autodetect --enable-pthreads --disable-w32threads \ --disable-os2threads --disable-ffplay --disable-network \ --enable-static --disable-shared \ --enable-gpl --enable-version3 \ + --enable-ffmpeg --enable-ffprobe \ --nm=llvm-nm --ar=emar --ranlib=emranlib \ --cc=emcc --cxx=em++ --objcc=emcc --dep-cc=emcc \ --enable-avcodec --enable-avformat --enable-avutil \ @@ -32,8 +33,23 @@ export LDFLAGS="-L${PREFIX}/lib ${LDFLAGS:-}" --enable-avfilter --enable-avdevice \ --enable-protocol=file -make -j"${CPU_COUNT:-4}" -make install +make EXESUF=.js -j"${CPU_COUNT:-4}" +make EXESUF=.js install + +# FFmpeg's Emscripten link creates *_g.wasm and copies only the JavaScript +# launcher during install. Give each launcher a stable adjacent wasm file. +for tool in ffmpeg ffprobe; do + if [[ ! -s "${tool}_g.wasm" || ! -s "${PREFIX}/bin/${tool}.js" ]]; then + echo "error: ${tool} CLI was not built; expected ${tool}_g.wasm and ${PREFIX}/bin/${tool}.js" >&2 + exit 1 + fi + install -Dm755 "${tool}_g.wasm" "${PREFIX}/bin/${tool}.wasm" + sed -i "s/${tool}_g\\.wasm/${tool}.wasm/g" "${PREFIX}/bin/${tool}.js" + if [[ ! -s "${PREFIX}/bin/${tool}.wasm" ]]; then + echo "error: failed to install ${PREFIX}/bin/${tool}.wasm" >&2 + exit 1 + fi +done install -Dm644 "${RECIPE_DIR}/cmake/FFmpegConfig.cmake" \ "${PREFIX}/lib/cmake/FFmpeg/FFmpegConfig.cmake" diff --git a/recipes/recipes_emscripten/ffmpeg/build_tests.sh b/recipes/recipes_emscripten/ffmpeg/build_tests.sh index 0723989d19..8d428638a2 100644 --- a/recipes/recipes_emscripten/ffmpeg/build_tests.sh +++ b/recipes/recipes_emscripten/ffmpeg/build_tests.sh @@ -5,7 +5,23 @@ echo "==========================================" echo "Building FFmpeg tests..." echo "==========================================" +raw_test_type="${1:?usage: build_tests.sh libs or cli}" +test_type="${raw_test_type%\}}" + +if [[ "${test_type}" == "cli" ]]; then + node "${PREFIX}/bin/ffmpeg.js" -version + node "${PREFIX}/bin/ffprobe.js" -version + exit 0 +fi + +if [[ "${test_type}" != "libs" ]]; then + echo "error: unknown test type: ${test_type}" >&2 + exit 2 +fi + export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH:-}" +export CFLAGS="${CFLAGS:-}" +export LDFLAGS="${LDFLAGS:-}" mkdir -p build_tests cd build_tests diff --git a/recipes/recipes_emscripten/ffmpeg/recipe.yaml b/recipes/recipes_emscripten/ffmpeg/recipe.yaml index 93c7560736..9a04e7f6b5 100644 --- a/recipes/recipes_emscripten/ffmpeg/recipe.yaml +++ b/recipes/recipes_emscripten/ffmpeg/recipe.yaml @@ -2,57 +2,111 @@ context: name: ffmpeg version: 8.1.2 -package: - name: ${{ name }} +recipe: + name: ffmpeg version: ${{ version }} +build: + number: 2 + source: - url: https://ffmpeg.org/releases/${{ name }}-${{ version }}.tar.xz - sha256: 464beb5e7bf0c311e68b45ae2f04e9cc2af88851abb4082231742a74d97b524c + - url: https://ffmpeg.org/releases/${{ name }}-${{ version }}.tar.xz + sha256: 464beb5e7bf0c311e68b45ae2f04e9cc2af88851abb4082231742a74d97b524c -build: - number: 0 - script: build.sh +outputs: + - staging: + name: ffmpeg-build + requirements: + build: + - ${{ compiler('c') }} + - ${{ compiler('cxx') }} + - make + - pkg-config + host: [] + build: + script: build.sh -requirements: - build: - - ${{ compiler('c') }} - - ${{ compiler('cxx') }} - - make - - pkg-config - host: [] - run: [] + - package: + name: ffmpeg + version: ${{ version }} + inherit: ffmpeg-build + build: + files: + include: + - lib/libavcodec.a + - lib/libavformat.a + - lib/libavutil.a + - lib/libswscale.a + - lib/libswresample.a + - lib/libavfilter.a + - lib/libavdevice.a + - lib/pkgconfig/*.pc + - lib/cmake/FFmpeg/** + - include/** + tests: + - package_contents: + lib: + - libavcodec.a + - libavformat.a + - libavutil.a + - libswscale.a + - libswresample.a + - libavfilter.a + - libavdevice.a + include: + - libavcodec/avcodec.h + - libavformat/avformat.h + - libavutil/avutil.h + - libswscale/swscale.h + - libswresample/swresample.h + - libavfilter/avfilter.h + files: + - lib/cmake/FFmpeg/FFmpegConfig.cmake + - script: + - bash build_tests.sh libs + requirements: + build: + - ${{ compiler('c') }} + - ${{ compiler('cxx') }} + - cmake + - ninja + files: + recipe: + - build_tests.sh + - tests/ -tests: -- package_contents: - lib: - - libavcodec.a - - libavformat.a - - libavutil.a - - libswscale.a - - libswresample.a - - libavfilter.a - - libavdevice.a - include: - - libavcodec/avcodec.h - - libavformat/avformat.h - - libavutil/avutil.h - - libswscale/swscale.h - - libswresample/swresample.h - - libavfilter/avfilter.h -- script: - - build_tests.sh - requirements: + - package: + name: ffmpeg-cli + version: ${{ version }} + inherit: ffmpeg-build build: - - ${{ compiler('c') }} - - ${{ compiler('cxx') }} - - cmake - - ninja - - nodejs - files: - recipe: - - build_tests.sh - - tests/ + files: + include: + - bin/ffmpeg.js + - bin/ffmpeg.wasm + - bin/ffprobe.js + - bin/ffprobe.wasm + requirements: + run: + - ffmpeg =${{ version }} + tests: + - package_contents: + bin: + - ffmpeg + - ffprobe + files: + - bin/ffmpeg.js + - bin/ffmpeg.wasm + - bin/ffprobe.js + - bin/ffprobe.wasm + - script: + - bash build_tests.sh cli + requirements: + build: + - nodejs + files: + recipe: + - build_tests.sh about: homepage: https://ffmpeg.org/