From f2cce5f38f4031bf1a4b4919ec90e4e8f8c66a77 Mon Sep 17 00:00:00 2001 From: LaserEyess Date: Sat, 12 Nov 2022 09:27:07 -0500 Subject: [PATCH] waf: remove waf as a build system Remove waf entirely in favor of meson as the only supported build system. Waf was officially deprecated in 0.36.0, and has not been preferred over meson since 0.35.0. --- .github/workflows/build.yml | 51 +- .gitignore | 39 - DOCS/build-system-differences.md | 71 -- DOCS/waf-buildsystem.rst | 157 ---- README.md | 38 +- TOOLS/__init__.py | 0 bootstrap.py | 56 -- ci/build-freebsd.sh | 24 - ci/build-macos.sh | 39 +- ci/build-mingw64.sh | 19 +- ci/build-msys2.sh | 86 +- ci/build-tumbleweed.sh | 44 +- libmpv/client.h | 1 - libmpv/mpv.def | 52 -- version.py | 5 +- waftools/__init__.py | 2 - waftools/checks/__init__.py | 0 waftools/checks/custom.py | 180 ---- waftools/checks/generic.py | 221 ----- waftools/clang_compilation_database.py | 87 -- waftools/dependencies.py | 224 ----- waftools/deps_parser.py | 211 ----- waftools/detections/__init__.py | 0 waftools/detections/compiler.py | 92 -- waftools/detections/compiler_swift.py | 203 ----- waftools/detections/devices.py | 31 - waftools/features.py | 74 -- waftools/fragments/audiounit.c | 15 - waftools/fragments/cocoa.m | 16 - waftools/fragments/coreaudio.c | 15 - waftools/fragments/gl_x11.c | 15 - waftools/fragments/iconv.c | 30 - waftools/fragments/pthreads.c | 6 - waftools/fragments/sse.c | 18 - waftools/fragments/touchbar.m | 7 - waftools/fragments/wasapi.c | 16 - waftools/generators/__init__.py | 0 waftools/generators/headers.py | 45 - waftools/generators/sources.py | 95 -- waftools/inflector.py | 22 - waftools/syms.py | 52 -- waftools/waf_customizations.py | 60 -- wscript | 1152 ------------------------ wscript_build.py | 826 ----------------- 44 files changed, 61 insertions(+), 4336 deletions(-) delete mode 100644 DOCS/build-system-differences.md delete mode 100644 DOCS/waf-buildsystem.rst delete mode 100644 TOOLS/__init__.py delete mode 100755 bootstrap.py delete mode 100644 libmpv/mpv.def delete mode 100644 waftools/__init__.py delete mode 100644 waftools/checks/__init__.py delete mode 100644 waftools/checks/custom.py delete mode 100644 waftools/checks/generic.py delete mode 100644 waftools/clang_compilation_database.py delete mode 100644 waftools/dependencies.py delete mode 100644 waftools/deps_parser.py delete mode 100644 waftools/detections/__init__.py delete mode 100644 waftools/detections/compiler.py delete mode 100644 waftools/detections/compiler_swift.py delete mode 100644 waftools/detections/devices.py delete mode 100644 waftools/features.py delete mode 100644 waftools/fragments/audiounit.c delete mode 100644 waftools/fragments/cocoa.m delete mode 100644 waftools/fragments/coreaudio.c delete mode 100644 waftools/fragments/gl_x11.c delete mode 100644 waftools/fragments/iconv.c delete mode 100644 waftools/fragments/pthreads.c delete mode 100644 waftools/fragments/sse.c delete mode 100644 waftools/fragments/touchbar.m delete mode 100644 waftools/fragments/wasapi.c delete mode 100644 waftools/generators/__init__.py delete mode 100644 waftools/generators/headers.py delete mode 100644 waftools/generators/sources.py delete mode 100644 waftools/inflector.py delete mode 100644 waftools/syms.py delete mode 100644 waftools/waf_customizations.py delete mode 100644 wscript delete mode 100644 wscript_build.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34c123d2e8..0bc1f83a5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,6 @@ jobs: sudo apt-get update sudo apt-get install -y autoconf automake pkg-config g++-mingw-w64 gcc-multilib python3-pip ninja-build nasm sudo python3 -m pip install meson - ./bootstrap.py - name: Build libraries run: | @@ -43,18 +42,6 @@ jobs: run: | cat ./build/meson-logs/meson-log.txt - - name: Build with waf - id: build_waf - run: | - ./ci/build-mingw64.sh waf - env: - TARGET: ${{ matrix.target }} - - - name: Print waf log - if: ${{ failure() && steps.build_waf.outcome == 'failure' }} - run: | - cat ./build_waf/config.log - - uses: actions/upload-artifact@v3 with: name: mpv-${{ matrix.target }} @@ -85,7 +72,7 @@ jobs: - name: Build with meson id: build run: | - ./ci/build-macos.sh meson + ./ci/build-macos.sh env: CC: "${{ matrix.cc }}" TRAVIS_OS_NAME: "${{ matrix.os }}" @@ -105,19 +92,6 @@ jobs: run: | cat ./build/meson-logs/testlog.txt - - name: Build with waf - id: build_waf - run: | - ./ci/build-macos.sh waf - env: - CC: "${{ matrix.cc }}" - TRAVIS_OS_NAME: "${{ matrix.os }}" - - - name: Print waf log - if: ${{ failure() && steps.build_waf.outcome == 'failure' }} - run: | - cat ./build_waf/config.log - linux: runs-on: "ubuntu-22.04" container: @@ -134,14 +108,13 @@ jobs: - name: Install dependencies run: | - ./bootstrap.py # workaround to avoid "fatal: unsafe repository" error git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Build with meson id: build run: | - ./ci/build-tumbleweed.sh meson + ./ci/build-tumbleweed.sh - name: Print meson log if: ${{ failure() && steps.build.outcome == 'failure' }} @@ -158,16 +131,6 @@ jobs: run: | cat ./build/meson-logs/testlog.txt - - name: Build with waf - id: build_waf - run: | - ./ci/build-tumbleweed.sh waf - - - name: Print waf log - if: ${{ failure() && steps.build_waf.outcome == 'failure' }} - run: | - cat ./build_waf/config.log - freebsd: runs-on: macos-12 # until https://github.com/actions/runner/issues/385 steps: @@ -286,13 +249,3 @@ jobs: if: ${{ failure() && steps.tests.outcome == 'failure' }} run: | cat ./build/meson-logs/testlog.txt - - - name: Build with waf - id: build_waf - run: | - ./ci/build-msys2.sh waf - - - name: Print waf log - if: ${{ failure() && steps.build_waf.outcome == 'failure' }} - run: | - cat ./build_waf/config.log diff --git a/.gitignore b/.gitignore index 29e15d9fd1..0bec5eac13 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1 @@ -*.o -*.a -*.d -*.exe -*.pyc -.depend - -/config.h -/config.mak -/config.log -/mpv -/mpv.app -/version.h -/input/input_conf.h -/tags -/TAGS -/video/out/x11_icon.inc -/demux/ebml_defs.c -/demux/ebml_types.h -/sub/osd_font.h -/player/lua/*.inc -/player/builtin_conf.inc -/DOCS/man/mpv.1 -/DOCS/man/mpv.aux -/DOCS/man/mpv.log -/DOCS/man/mpv.out -/DOCS/man/mpv.pdf -/DOCS/man/mpv.toc - -/waf -/waf-* -/waf3-* -/build -/.waf* -/.lock-waf_* - -/old_build -/Makefile - /subprojects diff --git a/DOCS/build-system-differences.md b/DOCS/build-system-differences.md deleted file mode 100644 index da5b76e408..0000000000 --- a/DOCS/build-system-differences.md +++ /dev/null @@ -1,71 +0,0 @@ -# Differences Between Meson and Waf - -mpv currently supports two different build systems: waf and meson. In general, -option names between both build systems are mostly the same. In most cases, -``--enable-foo`` in waf becomes ``-Dfoo=enabled`` in meson. Likewise, -``--disable-foo`` becomes ``-Dfoo=disabled``. For the rest of this document, -Waf options will be noted as ``--foo`` while meson options are noted as -``foo``. - -## Universal Options - -Meson has several [universal options](https://mesonbuild.com/Builtin-options.html#universal-options) -that you get for free. In some cases, these overlapped with custom waf options. - -* ``--libmpv-static`` and ``--libmpv-shared`` were combined into one option: - ``libmpv``. Use ``default_library`` to control if you want to build static or - shared libraries. -* Waf had a boolean ``--optimize`` option. In meson, this is a universal option, - ``optimization``, which can take several different values. In mpv's meson - build, the default is ``2``. -* Instead of ``--debug-build``, meson simply calls it ``debug``. It is enabled - by default. - -## Changed Options - -* The legacy lua names (``52``, ``52deb``, etc.) for ``--lua`` are not - supported in the meson build. Instead, pass the generic pkg-config values - such as ``lua52``, ``lua5.2``, etc. -* ``--lgpl`` was changed to ``gpl``. If ``gpl`` is false, the build is LGPL2.1+. -* ``--tests`` was removed since unit tests now explicitly require meson to run - -### Boolean Options - -The following options are all booleans that accept ``true`` or ``false`` -instead of ``enabled`` or ``disabled``. - -* ``build-date`` -* ``cplayer`` -* ``gpl`` -* ``libmpv`` -* ``ta-leak-report`` -* ``tests`` - -## Removed Options - -There are options removed with no equivalent in the meson build. - -* ``--asm`` was removed since it doesn't do anything. -* ``--android`` was removed since meson knows if the machine is android. -* ``--clang-compilation-database`` was removed. Meson can do this on its own - by invoking ninja (``ninja -t compdb``). -* ``--tvos`` was removed since it doesn't do anything. -* ``--static-build`` was removed. Use ``default_library``. -* ``--swift-static`` was removed. The swift library always dynamically links. - -## Renamed Options - -These are some other options that were renamed. - -* ``--gl-wayland`` was renamed to ``egl-wayland``. -* ``--swift`` was renamed to ``swift-build``. - -## Other - -* The meson build supports passing the ``SOURCE_DATE_EPOCH`` environment variable -during the compilation step for those who want reproducibility without having to -disable the build date. -* The ``Configuration`` line shown by ``mpv -v`` does not show everything passed on -cli since meson does not have any easy way to access a user's argv. Instead, it -simply shows whatever the value of ``prefix`` is regardless if it was specified -or not. diff --git a/DOCS/waf-buildsystem.rst b/DOCS/waf-buildsystem.rst deleted file mode 100644 index 7949d09a37..0000000000 --- a/DOCS/waf-buildsystem.rst +++ /dev/null @@ -1,157 +0,0 @@ -waf build system overview -========================= - -mpv's new build system is based on waf and it should completely replace the -custom ./configure + Makefile based system inherited from MPlayer. - -Goals and the choice of waf -=========================== - -The new system comes with some goals, which can be summed up as: be as good as -the old one at what it did well (customizability) and fix some of it's major -shortcomings: - -1) The build system must be uniform in how it handles any single feature check. - Repetition and boilerplate have to be avoided. - - When adding a new feature using the old configure, one had to add a fair - amount of code to the shell script to do option parsing, detection of the - feature and declaration of variables for the Makefile to pickup. The worst - part is this pieces are spread apart in the configure and copy pasted for - any single case. That brings us to.. - -2) --enable-feature has to be overridden by the user and helps them understand that - they have libraries missing and should install them for the feature to be - enabled. - -3) Must be customizable, hackable, pleasant to the developer eyes and to work - with in general. - -4) Must have separate configuration and build steps. - -Goal 2 comes as a given on pretty much any build system, since autotools made -this behaviour very popular among users (and rightly so). - -Goal 1+3 were somewhat harder to accomplish as it looks like all of the build -systems we evaluated (waf included!) had problems with them. For reference we -had proof of concept build systems with waf, CMake and autotools. - -What puts waf apart from CMake and autotools, is that projects using it use -Python to program their build system. Also while the Waf Book shows really -simple API usages, you can write your own build system on top of waf that is -tailored to the project's specific needs. - -mpv's custom configure step on top of waf -========================================= - -To some extents mpv has a custom build system written on top of waf. This -document will not go over the standard waf behaviour as that is documented in -the `Waf book `_. - -All of the configuration process is handled with a declarative approach. Lists -of dictionaries define the checks, and some custom Python code traverses these -lists and depending on the check definition it calls into the actual waf API. - -A simple example using pkg-config would be:: - - { - 'name': '--vdpau', - 'desc': 'VDPAU acceleration', - 'deps': [ 'x11' ], - 'func': check_pkg_config('vdpau', '>= 0.2'), - } - -This defines a feature called ``vdpau`` which can be enabled or disabled by -the users with configure flags (that's the meaning of ``--``). This feature -depends on another feature whose name is ``x11``, and the autodetection check -consists of running ``pkg-config`` and looking for ``vdpau`` with version -``>= 0.2``. If the check succeeds a ``#define HAVE_VDPAU 1`` will be added to -``config.h``, if not ``#define HAVE_VDPAU 0`` will be added. - -The defines names are automatically prepended with ``HAVE_``, capitalized and -special characters are replaced with underscores. This happens in -``waftools/inflectors.py``. - -Mandatory fields: ------------------ - -``name``: indicates the unique identifier used by the custom dependency code -to refer to a feature. If the unique identifier is prepended with ``--`` -the build system will also generate options for ``./waf configure`` so that -the feature can be enabled and disabled. - -``desc``: this is the textual representation of the feature used in the -interactions with the users. - -``func``: function that will perform the check. These functions are defined in -``waftools/checks``. The reusable checks are all functions that return -functions. The return functions will then be applied using waf's configuration -context. - -The source code for the reusable checks is a bit convoluted, but it should be -easy to pick up their usage from the ``wscript``. Their signature mirrors -the semantics of some of the shell functions used in mplayer. - -If someone expresses some interest, I will extend this document with official -documentation for each check function. - -Optional fields ---------------- - -``deps``: list of dependencies of this feature. It is a list of names of -other features as defined in the ``name`` field (minus the eventual leading -``--``). All of the dependencies must be satisfied. If they are not the check -will be skipped without even running ``func``. - -``deps_any``: like deps but it is satisfied even if only one of the dependencies -is satisfied. You can think of ``deps`` as a 'and' condition and ``deps_any`` -as a 'or' condition. - -``deps_neg``: like deps but it is satisfied when none of the dependencies is -satisfied. - -``req``: defaults to False. If set to True makes this feature a hard -dependency of mpv (configuration will fail if autodetection fails). If set to -True you must also provide ``fmsg``. - -``fmsg``: string with the failure message in case a required dependency is not -satisfied. - -``os_specific_checks``: this takes a dictionary that has ``os-`` dependencies -as keys (such as ``os-win32``), and by values has another dictionary that is -merged on top of the current feature definition only for that specific OS. -For example:: - - { - 'name': '--pthreads', - 'desc': 'POSIX threads', - 'func': check_pthreads, - 'os_specific_checks': { - 'os-win32': { - 'func': check_pthreads_w32_static. - } - } - } - -will override the value of ``func`` with ``check_pthreads_w32_static`` only -if the target OS of the build is Windows. - -``groups``: groups a dependency with another one. This can be used to disabled -all the grouped dependencies with one ``--disable-``. At the moment this is -only used for OpenGL backends, where you want to disable them when -``--disable-gl`` is passed to the configure. - -mpv's custom build step on top of waf -===================================== - -Build step is pretty much vanilla waf. The only difference being that the list -of source files can contain both strings or tuples. If a tuple is found, -the second element in the tuple will be used to match the features detected -in the configure step (the ``name`` field described above). If this feature -was not enabled during configure, the source file will not be compiled in. - -All of the custom Python for this is inside the function ``filtered_sources`` -contained in the file ``waftools/dependencies.py``. - -Also ``dependencies_use`` and ``dependencies_includes`` collect cflags and -ldflags that were generated from the features checks in the configure step. diff --git a/README.md b/README.md index e2a275e17a..f45c2697c0 100644 --- a/README.md +++ b/README.md @@ -73,17 +73,8 @@ Changes to the default key bindings are indicated in Compiling with full features requires development files for several -external libraries. One of the two build systems supported by mpv is required: -[meson](https://mesonbuild.com/index.html) or [waf](https://waf.io/). Meson -can be obtained from your distro or PyPI. Waf can be downloaded by using the -`./bootstrap.py` script. It will get the latest version of waf that was tested -with mpv. Some documentation about the differences between the build systems are -located in [build-system-differences][build-system-differences]. - -**Note**: Building with waf is considered *deprecated* and will be removed in the -future. - -### Meson +external libraries. Mpv requires [meson](https://mesonbuild.com/index.html) +to build. Meson can be obtained from your distro or PyPI. After creating your build directory (e.g. `meson setup build`), you can view a list of all the build options via `meson configure build`. You could also just simply @@ -96,30 +87,6 @@ Example: meson compile -C build meson install -C build -### Waf - -For a list of the available build options use `./waf configure --help`. If -you think you have support for some feature installed but configure fails to -detect it, the file `build/config.log` may contain information about the -reasons for the failure. - -NOTE: To avoid cluttering the output with unreadable spam, `--help` only shows -one of the two switches for each option. If the option is autodetected or -enabled by default, the `--disable-***` switch is printed; if the option is -disabled by default, the `--enable-***` switch is printed. Either way, you can -use `--enable-***` or `--disable-**` regardless of what is printed by `--help`. - -To build the software you can use `./waf build`: the result of the compilation -will be located in `build/mpv`. You can use `./waf install` to install mpv -to the *prefix* after it is compiled. - -Example: - - ./bootstrap.py - ./waf configure - ./waf - ./waf install - Essential dependencies (incomplete list): - gcc or clang @@ -233,4 +200,3 @@ Most activity happens on the IRC channel and the github issue tracker. [api-changes]: https://github.com/mpv-player/mpv/blob/master/DOCS/client-api-changes.rst [restore-old-bindings]: https://github.com/mpv-player/mpv/blob/master/etc/restore-old-bindings.conf [contribute.md]: https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md -[build-system-differences]: https://github.com/mpv-player/mpv/blob/master/DOCS/build-system-differences.md diff --git a/TOOLS/__init__.py b/TOOLS/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bootstrap.py b/bootstrap.py deleted file mode 100755 index 143851135c..0000000000 --- a/bootstrap.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 - -# This script simply downloads waf to the current directory - -import os, sys, stat, hashlib, subprocess -from urllib.request import urlopen, URLError - -WAFRELEASE = "waf-2.0.25" -WAFURLS = ["https://waf.io/" + WAFRELEASE, - "https://www.freehackers.org/~tnagy/release/" + WAFRELEASE] -SHA256HASH = "21199cd220ccf60434133e1fd2ab8c8e5217c3799199c82722543970dc8e38d5" - -if os.path.exists("waf"): - wafver = subprocess.check_output([sys.executable, './waf', '--version']).decode() - if WAFRELEASE.split('-')[1] == wafver.split(' ')[1]: - print("Found 'waf', skipping download.") - sys.exit(0) - -if "--no-download" in sys.argv[1:]: - print("Did not find {} and no download was requested.".format(WAFRELEASE)) - sys.exit(1) - -waf = None - -for WAFURL in WAFURLS: - try: - print("Downloading {}...".format(WAFURL)) - waf = urlopen(WAFURL).read() - break - except URLError as err: - print("Download failed! ({})".format(err)) - -if not waf: - print("Could not download {}.".format(WAFRELEASE)) - - sys.exit(1) - -if SHA256HASH == hashlib.sha256(waf).hexdigest(): - # Upstream waf is not changing the default interpreter during - # 2.0.x line due to compatibility reasons apparently. So manually - # convert it to use python3 (the script works with both). - expected = b"#!/usr/bin/env python\n" - assert waf.startswith(expected) - waf = b"#!/usr/bin/env python3\n" + waf[len(expected):] - with open("waf", "wb") as wf: - wf.write(waf) - - os.chmod("waf", os.stat("waf").st_mode | stat.S_IXUSR) - print("Checksum verified.") -else: - print("The checksum of the downloaded file does not match!") - print(" - got: {}".format(hashlib.sha256(waf).hexdigest())) - print(" - expected: {}".format(SHA256HASH)) - print("Please download and verify the file manually.") - - sys.exit(1) diff --git a/ci/build-freebsd.sh b/ci/build-freebsd.sh index 39afe57f2d..67fdb2747a 100755 --- a/ci/build-freebsd.sh +++ b/ci/build-freebsd.sh @@ -24,27 +24,3 @@ meson setup build \ meson compile -C build ./build/mpv -v --no-config - -if [ ! -e "./waf" ] ; then - python3 ./bootstrap.py -fi - -python3 ./waf configure \ - --out=build_waf \ - --enable-libmpv-shared \ - --enable-lua \ - --enable-egl-drm \ - --enable-openal \ - --enable-sdl2 \ - --enable-sndio \ - --enable-vdpau \ - --enable-vulkan \ - --enable-oss-audio \ - $(pkg info -q v4l_compat && echo --enable-dvbin) \ - $(pkg info -q libdvdnav && echo --enable-dvdnav) \ - $(pkg info -q libcdio-paranoia && echo --enable-cdda) \ - $(pkg info -q pipewire && echo --enable-pipewire) \ - $NULL - -python3 ./waf build -./build_waf/mpv -v --no-config diff --git a/ci/build-macos.sh b/ci/build-macos.sh index 3b3255b8a6..14b3a1b934 100755 --- a/ci/build-macos.sh +++ b/ci/build-macos.sh @@ -10,34 +10,13 @@ if [[ -d "./build/${MPV_VARIANT}" ]] ; then rm -rf "./build/${MPV_VARIANT}" fi -if [[ $1 = "meson" ]]; then - PKG_CONFIG_PATH="${FFMPEG_SYSROOT}/lib/pkgconfig/" CC="${CC}" CXX="${CXX}" \ - meson setup build \ - -Dprefix="${MPV_INSTALL_PREFIX}" \ - -D{libmpv,tests}=true \ - -D{gl,iconv,lcms2,lua,jpeg,plain-gl,zlib}=enabled \ - -D{cocoa,coreaudio,gl-cocoa,macos-cocoa-cb,macos-touchbar,videotoolbox-gl}=enabled +PKG_CONFIG_PATH="${FFMPEG_SYSROOT}/lib/pkgconfig/" CC="${CC}" CXX="${CXX}" \ +meson setup build \ + -Dprefix="${MPV_INSTALL_PREFIX}" \ + -D{libmpv,tests}=true \ + -D{gl,iconv,lcms2,lua,jpeg,plain-gl,zlib}=enabled \ + -D{cocoa,coreaudio,gl-cocoa,macos-cocoa-cb,macos-touchbar,videotoolbox-gl}=enabled - meson compile -C build -j4 - meson install -C build - ./build/mpv -v --no-config -fi - -if [[ $1 = "waf" ]]; then - if [[ ! -e "./waf" ]] ; then - python3 ./bootstrap.py - fi - - PKG_CONFIG_PATH="${FFMPEG_SYSROOT}/lib/pkgconfig/" CC="${CC}" CXX="${CXX}" python3 \ - ./waf configure \ - --out=build_waf \ - --variant="${MPV_VARIANT}" \ - --prefix="${MPV_INSTALL_PREFIX}" \ - --enable-{gl,iconv,lcms2,libmpv-shared,lua,jpeg,plain-gl,zlib} \ - --enable-{cocoa,coreaudio,gl-cocoa,macos-cocoa-cb,macos-touchbar,videotoolbox-gl} \ - --swift-flags="${CI_SWIFT_FLAGS}" - - python3 ./waf build --variant="${MPV_VARIANT}" -j4 - python3 ./waf install --variant="${MPV_VARIANT}" - ${MPV_INSTALL_PREFIX}/bin/mpv -v --no-config -fi +meson compile -C build -j4 +meson install -C build +./build/mpv -v --no-config diff --git a/ci/build-mingw64.sh b/ci/build-mingw64.sh index 0b3c930be1..5dadcde646 100755 --- a/ci/build-mingw64.sh +++ b/ci/build-mingw64.sh @@ -198,21 +198,12 @@ LDFLAGS+=" -L'$prefix_dir/lib'" export CFLAGS LDFLAGS rm -rf build -if [ "$1" = "meson" ]; then - meson setup build --cross-file "$prefix_dir/crossfile" \ - --buildtype debugoptimized \ - -Dlibmpv=true -Dlua=luajit \ - -D{shaderc,spirv-cross,d3d11,libplacebo,libplacebo-next}=enabled +meson setup build --cross-file "$prefix_dir/crossfile" \ + --buildtype debugoptimized \ + -Dlibmpv=true -Dlua=luajit \ + -D{shaderc,spirv-cross,d3d11,libplacebo,libplacebo-next}=enabled - meson compile -C build -elif [ "$1" = "waf" ]; then - PKG_CONFIG=pkg-config ./waf configure \ - --out=build_waf \ - --enable-libmpv-shared --lua=luajit \ - --enable-{shaderc,spirv-cross,d3d11,libplacebo,libplacebo-next} - - ./waf build -fi +meson compile -C build if [ "$2" = pack ]; then mkdir -p artifact diff --git a/ci/build-msys2.sh b/ci/build-msys2.sh index 5f83370077..2a17a8465e 100755 --- a/ci/build-msys2.sh +++ b/ci/build-msys2.sh @@ -1,60 +1,30 @@ #!/bin/sh -e -if [ "$1" = "meson" ]; then - python3.11 -m venv venv - source ./venv/bin/activate - python -m pip install meson - meson setup build \ - -D cdda=enabled \ - -D d3d-hwaccel=enabled \ - -D d3d11=enabled \ - -D dvdnav=enabled \ - -D egl-angle-lib=enabled \ - -D egl-angle-win32=enabled \ - -D jpeg=enabled \ - -D lcms2=enabled \ - -D libarchive=enabled \ - -D libbluray=enabled \ - -D libmpv=true \ - -D libplacebo=enabled \ - -D lua=enabled \ - -D pdf-build=enabled \ - -D rubberband=enabled \ - -D shaderc=enabled \ - -D spirv-cross=enabled \ - -D tests=true \ - -D uchardet=enabled \ - -D vapoursynth=enabled \ - -D vulkan=enabled - meson compile -C build - cp ./build/generated/mpv.com ./build - ./build/mpv.com -v --no-config -fi - -if [ "$1" = "waf" ]; then - ./bootstrap.py - ./waf configure \ - --out=build_waf \ - --enable-cdda \ - --enable-d3d-hwaccel \ - --enable-d3d11 \ - --enable-dvdnav \ - --enable-egl-angle-lib \ - --enable-egl-angle-win32 \ - --enable-jpeg \ - --enable-lcms2 \ - --enable-libarchive \ - --enable-libbluray \ - --enable-libmpv-shared \ - --enable-libplacebo \ - --enable-pdf-build \ - --enable-rubberband \ - --enable-shaderc \ - --enable-spirv-cross \ - --enable-uchardet \ - --enable-vapoursynth \ - --enable-lua \ - --enable-vulkan - ./waf build - ./build_waf/mpv.com -v --no-config -fi +python3.11 -m venv venv +source ./venv/bin/activate +python -m pip install meson +meson setup build \ + -D cdda=enabled \ + -D d3d-hwaccel=enabled \ + -D d3d11=enabled \ + -D dvdnav=enabled \ + -D egl-angle-lib=enabled \ + -D egl-angle-win32=enabled \ + -D jpeg=enabled \ + -D lcms2=enabled \ + -D libarchive=enabled \ + -D libbluray=enabled \ + -D libmpv=true \ + -D libplacebo=enabled \ + -D lua=enabled \ + -D pdf-build=enabled \ + -D rubberband=enabled \ + -D shaderc=enabled \ + -D spirv-cross=enabled \ + -D tests=true \ + -D uchardet=enabled \ + -D vapoursynth=enabled \ + -D vulkan=enabled +meson compile -C build +cp ./build/generated/mpv.com ./build +./build/mpv.com -v --no-config diff --git a/ci/build-tumbleweed.sh b/ci/build-tumbleweed.sh index 11a13f597c..6dd7f608d7 100755 --- a/ci/build-tumbleweed.sh +++ b/ci/build-tumbleweed.sh @@ -1,34 +1,16 @@ #!/bin/sh set -e -if [ "$1" = "meson" ]; then - meson setup build \ - -Dcdda=enabled \ - -Ddvbin=enabled \ - -Ddvdnav=enabled \ - -Dlibarchive=enabled \ - -Dlibmpv=true \ - -Dmanpage-build=enabled \ - -Dpipewire=enabled \ - -Dshaderc=enabled \ - -Dtests=true \ - -Dvulkan=enabled - meson compile -C build - ./build/mpv -v --no-config -fi - -if [ "$1" = "waf" ]; then - python3 ./waf configure \ - --out=build_waf \ - --enable-cdda \ - --enable-dvbin \ - --enable-dvdnav \ - --enable-libarchive \ - --enable-libmpv-shared \ - --enable-manpage-build \ - --enable-pipewire \ - --enable-shaderc \ - --enable-vulkan - python3 ./waf build - ./build_waf/mpv -v --no-config -fi +meson setup build \ + -Dcdda=enabled \ + -Ddvbin=enabled \ + -Ddvdnav=enabled \ + -Dlibarchive=enabled \ + -Dlibmpv=true \ + -Dmanpage-build=enabled \ + -Dpipewire=enabled \ + -Dshaderc=enabled \ + -Dtests=true \ + -Dvulkan=enabled +meson compile -C build +./build/mpv -v --no-config diff --git a/libmpv/client.h b/libmpv/client.h index b9697eb741..2d1b0f74e3 100644 --- a/libmpv/client.h +++ b/libmpv/client.h @@ -26,7 +26,6 @@ #include #include -/* New symbols must still be added to libmpv/mpv.def. */ #ifdef _WIN32 #define MPV_EXPORT __declspec(dllexport) #elif defined(__GNUC__) || defined(__clang__) diff --git a/libmpv/mpv.def b/libmpv/mpv.def deleted file mode 100644 index 232490d44d..0000000000 --- a/libmpv/mpv.def +++ /dev/null @@ -1,52 +0,0 @@ -mpv_abort_async_command -mpv_client_api_version -mpv_client_id -mpv_client_name -mpv_command -mpv_command_async -mpv_command_node -mpv_command_node_async -mpv_command_ret -mpv_command_string -mpv_create -mpv_create_client -mpv_create_weak_client -mpv_destroy -mpv_error_string -mpv_event_to_node -mpv_event_name -mpv_free -mpv_free_node_contents -mpv_get_property -mpv_get_property_async -mpv_get_property_osd_string -mpv_get_property_string -mpv_get_time_us -mpv_get_wakeup_pipe -mpv_hook_add -mpv_hook_continue -mpv_initialize -mpv_load_config_file -mpv_observe_property -mpv_render_context_create -mpv_render_context_free -mpv_render_context_get_info -mpv_render_context_render -mpv_render_context_report_swap -mpv_render_context_set_parameter -mpv_render_context_set_update_callback -mpv_render_context_update -mpv_request_event -mpv_request_log_messages -mpv_set_option -mpv_set_option_string -mpv_set_property -mpv_set_property_async -mpv_set_property_string -mpv_set_wakeup_callback -mpv_stream_cb_add_ro -mpv_terminate_destroy -mpv_unobserve_property -mpv_wait_async_requests -mpv_wait_event -mpv_wakeup diff --git a/version.py b/version.py index cec74c252c..e90394dfa1 100755 --- a/version.py +++ b/version.py @@ -6,16 +6,15 @@ import time from datetime import datetime,timezone from shutil import which -from subprocess import check_output, DEVNULL +from subprocess import check_output srcdir = os.path.dirname(os.path.abspath(sys.argv[0])) git_dir = os.path.join(srcdir, ".git") git = which('git') if git and os.path.exists(git_dir): - # stdin is set to DEVNULL to workaround waf preforking issues version = check_output([git, "-C", srcdir, "describe", "--always", "--tags", - "--dirty"], stdin=DEVNULL, encoding="UTF-8") + "--dirty"], encoding="UTF-8") version = version[1:].strip() else: version_path = os.path.join(srcdir, "VERSION") diff --git a/waftools/__init__.py b/waftools/__init__.py deleted file mode 100644 index 6f804bce35..0000000000 --- a/waftools/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 diff --git a/waftools/checks/__init__.py b/waftools/checks/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/waftools/checks/custom.py b/waftools/checks/custom.py deleted file mode 100644 index 844d708c91..0000000000 --- a/waftools/checks/custom.py +++ /dev/null @@ -1,180 +0,0 @@ -from waftools import inflector -from waftools.checks.generic import * -from waflib import Utils -from distutils.version import StrictVersion -import os - -__all__ = ["check_pthreads", "check_iconv", "check_lua", - "check_cocoa", "check_wl_protocols", "check_swift", - "check_egl_provider", "check_platform"] - -pthreads_program = load_fragment('pthreads.c') - -def check_pthread_flag(ctx, dependency_identifier): - checks = [ - check_cc(fragment = pthreads_program, cflags = '-pthread'), - check_cc(fragment = pthreads_program, cflags = '-pthread', - linkflags = '-pthread') ] - - for fn in checks: - if fn(ctx, dependency_identifier): - return True - return False - -def check_pthreads(ctx, dependency_identifier): - if ctx.dependency_satisfied('win32-internal-pthreads'): - h = ctx.path.find_node('osdep/win32/include').abspath() - # define IN_WINPTHREAD to workaround mingw stupidity (we never want it - # to define features specific to its own pthread stuff) - ctx.env.CFLAGS += ['-isystem', h, '-I', h, '-DIN_WINPTHREAD'] - return True - if check_pthread_flag(ctx, dependency_identifier): - return True - platform_cflags = { - 'linux': '-D_REENTRANT', - 'freebsd': '-D_THREAD_SAFE', - 'netbsd': '-D_THREAD_SAFE', - 'openbsd': '-D_THREAD_SAFE', - }.get(ctx.env.DEST_OS, '') - libs = ['pthreadGC2', 'pthread'] - checkfn = check_cc(fragment=pthreads_program, cflags=platform_cflags) - checkfn_nocflags = check_cc(fragment=pthreads_program) - for fn in [checkfn, checkfn_nocflags]: - if check_libs(libs, fn)(ctx, dependency_identifier): - return True - return False - -def check_iconv(ctx, dependency_identifier): - iconv_program = load_fragment('iconv.c') - libdliconv = " ".join(ctx.env.LIB_LIBDL + ['iconv']) - libs = ['iconv', libdliconv] - args = {'fragment': iconv_program} - if ctx.env.DEST_OS == 'openbsd' or ctx.env.DEST_OS == 'freebsd': - args['cflags'] = '-I/usr/local/include' - args['linkflags'] = '-L/usr/local/lib' - elif ctx.env.DEST_OS == 'win32': - args['linkflags'] = " ".join(['-L' + x for x in ctx.env.LIBRARY_PATH]) - checkfn = check_cc(**args) - return check_libs(libs, checkfn)(ctx, dependency_identifier) - -def check_lua(ctx, dependency_identifier): - # mainline lua 5.1/5.2 doesn't have a .pc file, so each distro chooses - # a different name, either non-versioned (lua.pc) or lua5x/lua5.x/lua-5.x - # and we need to check them all. luadef* are the non-versioned .pc files, - # and the rest represent the .pc file exactly e.g. --lua=lua-5.1 - # The non lua* names are legacy in mpv configure, and kept for compat. - lua_versions = [ - ( 'luadef52','lua >= 5.2.0 lua < 5.3.0' ), # package "lua" - ( '52', 'lua >= 5.2.0 lua < 5.3.0' ), - ( 'lua52', 'lua52 >= 5.2.0'), - ( '52arch', 'lua52 >= 5.2.0'), # Arch - ( 'lua5.2', 'lua5.2 >= 5.2.0'), - ( '52deb', 'lua5.2 >= 5.2.0'), # debian - ( 'lua-5.2','lua-5.2 >= 5.2.0'), - ( '52fbsd', 'lua-5.2 >= 5.2.0'), # FreeBSD - ( 'luajit', 'luajit >= 2.0.0' ), - ( 'luadef51','lua >= 5.1.0 lua < 5.2.0'), # package "lua" - ( '51', 'lua >= 5.1.0 lua < 5.2.0'), - ( 'lua51', 'lua51 >= 5.1.0'), - ( '51obsd', 'lua51 >= 5.1.0'), # OpenBSD - ( 'lua5.1', 'lua5.1 >= 5.1.0'), - ( '51deb', 'lua5.1 >= 5.1.0'), # debian - ( 'lua-5.1','lua-5.1 >= 5.1.0'), - ( '51fbsd', 'lua-5.1 >= 5.1.0'), # FreeBSD - ] - - if ctx.options.LUA_VER: - lua_versions = \ - [lv for lv in lua_versions if lv[0] == ctx.options.LUA_VER] - - for lua_version, pkgconfig_query in lua_versions: - display_version = lua_version - lua_version = inflector.sanitize_id(lua_version) - if check_pkg_config(pkgconfig_query, uselib_store=lua_version) \ - (ctx, dependency_identifier): - # XXX: this is a bit of a hack, ask waf developers if I can copy - # the uselib_store to 'lua' - ctx.mark_satisfied(lua_version) - ctx.add_optional_message(dependency_identifier, - 'version found: ' + display_version) - return True - return False - -def check_wl_protocols(ctx, dependency_identifier): - def fn(ctx, dependency_identifier): - ret = check_pkg_config_datadir("wayland-protocols", ">= 1.25") - ret = ret(ctx, dependency_identifier) - if ret != None: - ctx.env.WL_PROTO_DIR = ret.split()[0] - return ret - return fn(ctx, dependency_identifier) - -def check_cocoa(ctx, dependency_identifier): - fn = check_cc( - fragment = load_fragment('cocoa.m'), - compile_filename = 'test.m', - framework_name = ['Cocoa', 'IOKit', 'OpenGL', 'QuartzCore'], - includes = [ctx.srcnode.abspath()], - linkflags = '-fobjc-arc') - - res = fn(ctx, dependency_identifier) - if res and ctx.env.MACOS_SDK: - # on macOS we explicitly need to set the SDK path, otherwise it can lead - # to linking warnings or errors - ctx.env.append_value('LAST_LINKFLAGS', [ - '-isysroot', ctx.env.MACOS_SDK, - '-L/usr/lib', - '-L/usr/local/lib' - ]) - - return res - -def check_swift(version): - def fn(ctx, dependency_identifier): - minVer = StrictVersion(version) - if ctx.env.SWIFT_VERSION: - if StrictVersion(ctx.env.SWIFT_VERSION) >= minVer: - ctx.add_optional_message(dependency_identifier, - 'version found: ' + str(ctx.env.SWIFT_VERSION)) - return True - ctx.add_optional_message(dependency_identifier, - "'swift >= " + str(minVer) + "' not found, found " + - str(ctx.env.SWIFT_VERSION or None)) - return False - return fn - -def check_egl_provider(minVersion=None, name='egl', check=None): - def fn(ctx, dependency_identifier, **kw): - if not hasattr(ctx, 'egl_provider'): - egl_provider_check = check or check_pkg_config(name) - if egl_provider_check(ctx, dependency_identifier): - ctx.egl_provider = name - for ver in ['1.5', '1.4', '1.3', '1.2', '1.1', '1.0']: - stmt = 'int x[EGL_VERSION_{0}]'.format(ver.replace('.','_')) - check_stmt = check_statement(['EGL/egl.h'], stmt) - if check_stmt(ctx, dependency_identifier): - ctx.egl_provider_version = StrictVersion(ver) - break - return True - else: - return False - else: - minVersionSV = minVersion and StrictVersion(minVersion) - if not minVersionSV or ctx.egl_provider_version and \ - ctx.egl_provider_version >= minVersionSV: - defkey = inflector.define_key(dependency_identifier) - ctx.define(defkey, 1) - return True - else: - return False - return fn - -# Strictly for matching the platform names to what -# the meson build calls them. -def check_platform(ctx): - if ctx.env.DEST_OS == "win32": - return "windows" - elif ctx.dependency_satisfied("android"): - return "android" - else: - return ctx.env.DEST_OS diff --git a/waftools/checks/generic.py b/waftools/checks/generic.py deleted file mode 100644 index 114f4522b7..0000000000 --- a/waftools/checks/generic.py +++ /dev/null @@ -1,221 +0,0 @@ -import os -import inflector -from distutils.version import StrictVersion -from waflib.ConfigSet import ConfigSet -from waflib import Utils - -__all__ = [ - "check_pkg_config", "check_pkg_config_mixed", "check_pkg_config_mixed_all", - "check_pkg_config_cflags", "check_cc", "check_statement", "check_libs", - "check_headers", "compose_checks", "any_check", "check_true", "any_version", - "load_fragment", "check_stub", "check_ctx_vars", "check_program", - "check_pkg_config_datadir", "check_macos_sdk", "check_preprocessor"] - -any_version = None - -def even(n): - return n % 2 == 0 - -def __define_options__(dependency_identifier): - return inflector.define_dict(dependency_identifier) - -def __merge_options__(dependency_identifier, *args): - options_accu = inflector.storage_dict(dependency_identifier) - options_accu['mandatory'] = False - [options_accu.update(arg) for arg in args if arg] - return options_accu - -def _filter_cc_arguments(ctx, opts): - if ctx.env.DEST_OS != Utils.unversioned_sys_platform(): - # cross compiling, remove execute=True if present - if opts.get('execute'): - opts['execute'] = False - return opts - -def check_program(name, var): - def fn(ctx, dependency_identifier): - return ctx.find_program(name, var=var, mandatory=False) - return fn - -def check_libs(libs, function): - libs = [None] + libs - def fn(ctx, dependency_identifier): - for lib in libs: - kwargs = lib and {'lib': lib} or {} - if function(ctx, dependency_identifier, **kwargs): - return True - return False - return fn - -def check_preprocessor(header, expression, **kw_ext): - def fn(ctx, dependency_identifier, **kw): - headers = header - if not isinstance(headers, list): - headers = [header] - hs = "\n".join(["#include <{0}>".format(h) for h in headers]) - fragment = ("{0}\n" - "#if !({1})\n#error\n#endif\n" - "int main(int argc, char **argv)\n" - "{{ return 0; }}").format(hs, expression) - opts = __merge_options__(dependency_identifier, - {'fragment':fragment}, - __define_options__(dependency_identifier), - kw_ext, kw) - return ctx.check_cc(**_filter_cc_arguments(ctx, opts)) - return fn - -def check_statement(header, statement, **kw_ext): - def fn(ctx, dependency_identifier, **kw): - headers = header - if not isinstance(headers, list): - headers = [header] - hs = "\n".join(["#include <{0}>".format(h) for h in headers]) - fragment = ("{0}\n" - "int main(int argc, char **argv)\n" - "{{ {1}; return 0; }}").format(hs, statement) - opts = __merge_options__(dependency_identifier, - {'fragment':fragment}, - __define_options__(dependency_identifier), - kw_ext, kw) - return ctx.check_cc(**_filter_cc_arguments(ctx, opts)) - return fn - -def check_cc(**kw_ext): - def fn(ctx, dependency_identifier, **kw): - options = __merge_options__(dependency_identifier, - __define_options__(dependency_identifier), - kw_ext, kw) - return ctx.check_cc(**_filter_cc_arguments(ctx, options)) - return fn - -def check_pkg_config(*args, **kw_ext): - return _check_pkg_config([], ["--libs", "--cflags"], *args, **kw_ext) - -def check_pkg_config_mixed(_dyn_libs, *args, **kw_ext): - return _check_pkg_config([_dyn_libs], ["--libs", "--cflags"], *args, **kw_ext) - -def check_pkg_config_mixed_all(*all_args, **kw_ext): - args = [all_args[i] for i in [n for n in range(0, len(all_args)) if n % 3]] - return _check_pkg_config(all_args[::3], ["--libs", "--cflags"], *args, **kw_ext) - -def check_pkg_config_cflags(*args, **kw_ext): - return _check_pkg_config([], ["--cflags"], *args, **kw_ext) - -def check_pkg_config_datadir(*args, **kw_ext): - return _check_pkg_config([], ["--variable=pkgdatadir"], *args, **kw_ext) - -def _check_pkg_config(_dyn_libs, _pkgc_args, *args, **kw_ext): - def fn(ctx, dependency_identifier, **kw): - argsl = list(args) - packages = args[::2] - verchecks = args[1::2] - sargs = [] - pkgc_args = _pkgc_args - dyn_libs = {} - for i in range(0, len(packages)): - if i < len(verchecks): - sargs.append(packages[i] + ' ' + verchecks[i]) - else: - sargs.append(packages[i]) - if _dyn_libs and _dyn_libs[i]: - dyn_libs[packages[i]] = _dyn_libs[i] - if ctx.dependency_satisfied('static-build') and not dyn_libs: - pkgc_args += ["--static"] - - defaults = { - 'path': ctx.env.PKG_CONFIG, - 'package': " ".join(packages), - 'args': sargs + pkgc_args } - opts = __merge_options__(dependency_identifier, defaults, kw_ext, kw) - - # Warning! Megahack incoming: when parsing flags in `parse_flags` waf - # uses append_unique. This appends the flags only if they aren't - # already present in the list. This causes breakage if one checks for - # multiple pkg-config packages in a single call as stuff like -lm is - # added only at its first occurrence. - original_append_unique = ConfigSet.append_unique - ConfigSet.append_unique = ConfigSet.append_value - result = ctx.check_cfg(**opts) - ConfigSet.append_unique = original_append_unique - - defkey = inflector.define_key(dependency_identifier) - if result: - ctx.define(defkey, 1) - for x in dyn_libs.keys(): - ctx.env['LIB_'+x] += dyn_libs[x] - else: - ctx.add_optional_message(dependency_identifier, - "'{0}' not found".format(" ".join(sargs))) - ctx.undefine(defkey) - return result - return fn - -def check_headers(*headers, **kw_ext): - def undef_others(ctx, headers, found): - not_found_hs = set(headers) - {found} - for not_found_h in not_found_hs: - ctx.undefine(inflector.define_key(not_found_h)) - - def fn(ctx, dependency_identifier): - for header in headers: - defaults = {'header_name': header, 'features': 'c cprogram'} - options = __merge_options__(dependency_identifier, defaults, kw_ext) - if ctx.check(**options): - undef_others(ctx, headers, header) - ctx.define(inflector.define_key(dependency_identifier), 1) - return True - undef_others(ctx, headers, None) - return False - return fn - -def check_true(ctx, dependency_identifier): - ctx.define(inflector.define_key(dependency_identifier), 1) - return True - -def check_ctx_vars(*variables): - def fn(ctx, dependency_identifier): - missing = [] - for variable in variables: - if variable not in ctx.env: - missing.append(variable) - - if any(missing): - ctx.add_optional_message(dependency_identifier, - 'missing {0}'.format(', '.join(missing))) - return False - else: - return True - - return fn - -def check_stub(ctx, dependency_identifier): - ctx.undefine(inflector.define_key(dependency_identifier)) - return False - -def compose_checks(*checks): - def fn(ctx, dependency_identifier): - return all([check(ctx, dependency_identifier) for check in checks]) - return fn - -def any_check(*checks): - def fn(ctx, dependency_identifier): - return any(check(ctx, dependency_identifier) for check in checks) - return fn - -def load_fragment(fragment): - file_path = os.path.join(os.path.dirname(__file__), '..', 'fragments', - fragment) - fp = open(file_path,"r") - fragment_code = fp.read() - fp.close() - return fragment_code - -def check_macos_sdk(version): - def fn(ctx, dependency_identifier): - if ctx.env.MACOS_SDK_VERSION: - if StrictVersion(ctx.env.MACOS_SDK_VERSION) >= StrictVersion(version): - ctx.define(inflector.define_key(dependency_identifier), 1) - return True - return False - - return fn diff --git a/waftools/clang_compilation_database.py b/waftools/clang_compilation_database.py deleted file mode 100644 index 666471f07e..0000000000 --- a/waftools/clang_compilation_database.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -# Christoph Koke, 2013 -# Original source: waflib/extras/clang_compilation_database.py from -# waf git 5e4b86b81df3 (New BSD License) - -""" -Writes the c and cpp compile commands into build/compile_commands.json -see http://clang.llvm.org/docs/JSONCompilationDatabase.html - -Usage: - - def configure(conf): - conf.load('compiler_cxx') - ... - conf.load('clang_compilation_database') -""" - -import sys, os, json, shlex, pipes -from waflib import Logs, TaskGen, Task - -Task.Task.keep_last_cmd = True - -@TaskGen.feature('c', 'cxx') -@TaskGen.after_method('process_use') -def collect_compilation_db_tasks(self): - "Add a compilation database entry for compiled tasks" - try: - clang_db = self.bld.clang_compilation_database_tasks - except AttributeError: - clang_db = self.bld.clang_compilation_database_tasks = [] - self.bld.add_post_fun(write_compilation_database) - - tup = tuple(y for y in [Task.classes.get(x) for x in ('c', 'cxx')] if y) - for task in getattr(self, 'compiled_tasks', []): - if isinstance(task, tup): - clang_db.append(task) - -def write_compilation_database(ctx): - "Write the clang compilation database as JSON" - database_file = ctx.bldnode.make_node('compile_commands.json') - Logs.info('Build commands will be stored in %s', database_file.path_from(ctx.path)) - try: - root = json.load(database_file) - except IOError: - root = [] - clang_db = {x['file']: x for x in root} - for task in getattr(ctx, 'clang_compilation_database_tasks', []): - try: - cmd = task.last_cmd - except AttributeError: - continue - directory = getattr(task, 'cwd', ctx.variant_dir) - f_node = task.inputs[0] - filename = os.path.relpath(f_node.abspath(), directory) - entry = { - "directory": directory, - "arguments": cmd, - "file": filename, - } - clang_db[filename] = entry - root = list(clang_db.values()) - database_file.write(json.dumps(root, indent=2)) - -# Override the runnable_status function to do a dummy/dry run when the file doesn't need to be compiled. -# This will make sure compile_commands.json is always fully up to date. -# Previously you could end up with a partial compile_commands.json if the build failed. -for x in ('c', 'cxx'): - if x not in Task.classes: - continue - - t = Task.classes[x] - - def runnable_status(self): - def exec_command(cmd, **kw): - pass - - run_status = self.old_runnable_status() - if run_status == Task.SKIP_ME: - setattr(self, 'old_exec_command', getattr(self, 'exec_command', None)) - setattr(self, 'exec_command', exec_command) - self.run() - setattr(self, 'exec_command', getattr(self, 'old_exec_command', None)) - return run_status - - setattr(t, 'old_runnable_status', getattr(t, 'runnable_status', None)) - setattr(t, 'runnable_status', runnable_status) diff --git a/waftools/dependencies.py b/waftools/dependencies.py deleted file mode 100644 index cbe4555cae..0000000000 --- a/waftools/dependencies.py +++ /dev/null @@ -1,224 +0,0 @@ -from waflib.Errors import ConfigurationError, WafError -from waflib.Configure import conf -from waflib.Build import BuildContext -from waflib.Logs import pprint -import deps_parser -import inflector - -class DependencyError(Exception): - pass - -class Dependency(object): - def __init__(self, ctx, known_deps, satisfied_deps, dependency): - self.ctx = ctx - self.known_deps = known_deps - self.satisfied_deps = satisfied_deps - self.identifier, self.desc = dependency['name'], dependency['desc'] - self.attributes = self.__parse_attributes__(dependency) - - known_deps.add(self.identifier) - - if 'deps' in self.attributes: - self.ctx.ensure_dependency_is_known(self.attributes['deps']) - - def __parse_attributes__(self, dependency): - if 'os_specific_checks' in dependency: - all_chks = dependency['os_specific_checks'] - chks = [check for check in all_chks if check in self.satisfied_deps] - if any(chks): - return all_chks[chks[0]] - return dependency - - def check(self): - self.ctx.start_msg('Checking for {0}'.format(self.desc)) - - try: - self.check_group_disabled() - self.check_disabled() - self.check_dependencies() - except DependencyError: - # No check was run, since the prerequisites of the dependency are - # not satisfied. Make sure the define is 'undefined' so that we - # get a `#define YYY 0` in `config.h`. - self.ctx.undefine(inflector.define_key(self.identifier)) - self.fatal_if_needed() - return - - self.check_autodetect_func() - - def check_group_disabled(self): - if 'groups' in self.attributes: - groups = self.attributes['groups'] - disabled = (self.enabled_option(g) == False for g in groups) - if any(disabled): - self.skip() - raise DependencyError - - def check_disabled(self): - if self.enabled_option() == False: - self.skip() - raise DependencyError - - if self.enabled_option() == True: - self.attributes['req'] = True - self.attributes['fmsg'] = "You manually enabled the feature '{0}', but \ -the autodetection check failed.".format(self.identifier) - - def check_dependencies(self): - if 'deps' in self.attributes: - ok, why = deps_parser.check_dependency_expr(self.attributes['deps'], - self.satisfied_deps) - if not ok: - self.skip(why) - raise DependencyError - - def check_autodetect_func(self): - if self.attributes['func'](self.ctx, self.identifier): - self.success(self.identifier) - else: - self.fail() - self.ctx.undefine(inflector.define_key(self.identifier)) - self.fatal_if_needed() - - def enabled_option(self, identifier=None): - try: - return getattr(self.ctx.options, self.enabled_option_repr(identifier)) - except AttributeError: - pass - return None - - def enabled_option_repr(self, identifier): - return "enable_{0}".format(identifier or self.identifier) - - def success(self, depname): - self.ctx.mark_satisfied(depname) - self.ctx.end_msg(self.__message__('yes')) - - def fail(self, reason='no'): - self.ctx.end_msg(self.__message__(reason), 'RED') - - def fatal_if_needed(self): - if self.enabled_option() == False: - return - if self.attributes.get('req', False): - raise ConfigurationError(self.attributes.get('fmsg', 'Unsatisfied requirement')) - - def skip(self, reason='disabled', color='YELLOW'): - self.ctx.end_msg(self.__message__(reason), color) - - def __message__(self, message): - optional_message = self.ctx.deps_msg.get(self.identifier) - if optional_message: - return "{0} ({1})".format(message, optional_message) - else: - return message - -def configure(ctx): - def __detect_target_os_dependency__(ctx): - target = "os-{0}".format(ctx.env.DEST_OS) - ctx.start_msg('Detected target OS:') - ctx.end_msg(target) - ctx.known_deps.add(target) - ctx.satisfied_deps.add(target) - - ctx.deps_msg = {} - ctx.known_deps = set() - ctx.satisfied_deps = set() - __detect_target_os_dependency__(ctx) - -@conf -def ensure_dependency_is_known(ctx, depnames): - def check(ast): - if isinstance(ast, deps_parser.AstSym): - if (not ast.name.startswith('os-')) and ast.name not in ctx.known_deps: - raise ConfigurationError( - "error in dependencies definition: dependency {0} in" - " {1} is unknown.".format(ast.name, depnames)) - elif isinstance(ast, deps_parser.AstOp): - for sub in ast.sub: - check(sub) - else: - assert False - check(deps_parser.parse_expr(depnames)) - -@conf -def mark_satisfied(ctx, dependency_identifier): - ctx.satisfied_deps.add(dependency_identifier) - -@conf -def add_optional_message(ctx, dependency_identifier, message): - ctx.deps_msg[dependency_identifier] = message - -@conf -def parse_dependencies(ctx, dependencies): - def __check_dependency__(ctx, dependency): - Dependency(ctx, - ctx.known_deps, - ctx.satisfied_deps, - dependency).check() - - [__check_dependency__(ctx, dependency) for dependency in dependencies] - -@conf -def dependency_satisfied(ctx, dependency_identifier): - ctx.ensure_dependency_is_known(dependency_identifier) - ok, _ = deps_parser.check_dependency_expr(dependency_identifier, - ctx.satisfied_deps) - return ok - -@conf -def store_dependencies_lists(ctx): - ctx.env.known_deps = list(ctx.known_deps) - ctx.env.satisfied_deps = list(ctx.satisfied_deps) - -@conf -def unpack_dependencies_lists(ctx): - ctx.known_deps = set(ctx.env.known_deps) - ctx.satisfied_deps = set(ctx.env.satisfied_deps) - -def filtered_sources(ctx, sources): - def __source_file__(source): - if isinstance(source, tuple): - return source[0] - else: - return source - - def __check_filter__(dependency): - return dependency_satisfied(ctx, dependency) - - def __unpack_and_check_filter__(source): - try: - _, dependency = source - return __check_filter__(dependency) - except ValueError: - return True - - return [__source_file__(source) for source in sources \ - if __unpack_and_check_filter__(source)] - -""" -Like filtered_sources(), but pick only the first entry that matches, and -return its filename. -""" -def pick_first_matching_dep(ctx, deps): - files = filtered_sources(ctx, deps) - if len(files) > 0: - return files[0] - else: - raise DependencyError - -def env_fetch(tx): - def fn(ctx): - deps = ctx.env.satisfied_deps - lists = [ctx.env[tx(dep)] for dep in deps if (tx(dep) in ctx.env)] - return [item for sublist in lists for item in sublist] - return fn - -def dependencies_use(ctx): - return [inflector.storage_key(dep) for dep in sorted(ctx.env.satisfied_deps)] - -BuildContext.filtered_sources = filtered_sources -BuildContext.pick_first_matching_dep = pick_first_matching_dep -BuildContext.dependencies_use = dependencies_use -BuildContext.dependencies_includes = env_fetch(lambda x: "INCLUDES_{0}".format(x)) -BuildContext.dependency_satisfied = dependency_satisfied diff --git a/waftools/deps_parser.py b/waftools/deps_parser.py deleted file mode 100644 index eef3b6f9e8..0000000000 --- a/waftools/deps_parser.py +++ /dev/null @@ -1,211 +0,0 @@ - -class ParseError(Exception): - pass - -class AstOp(object): - def __init__(self, op, sub): - self.op = op - self.sub = sub - - def __repr__(self): - if len(self.sub) == 1: - return self.op + str(self.sub[0]) - return "(" + (" " + self.op + " ").join([str(x) for x in self.sub]) + ")" - -class AstSym(object): - def __init__(self, name): - assert type(name) is type("") - self.name = name - - def __repr__(self): - return self.name - -Arity = { "!": 1, "&&": 2, "||": 2 } -Precedence = { "!": 3, "&&": 2, "||": 1 } -Tokens = list(Arity.keys()) + ["(", ")"] - -# return (token, rest), or (None, "") if nothing left -def read_tok(expr): - expr = expr.strip() - for t in Tokens: - if expr.startswith(t): - return (t, expr[len(t):]) - if expr == "": - return (None, "") - sym = "" - while len(expr) and ((expr[0].lower() >= 'a' and expr[0].lower() <= 'z') or - (expr[0] >= '0' and expr[0] <= '9') or - (expr[0] in ["_", "-", "."])): - sym += expr[0] - expr = expr[1:] - if len(sym): - return sym, expr - raise ParseError("unknown token in '%s'" % expr) - -def parse_expr(expr): - opstack = [] - outstack = [] - def out(sym): - if sym in Arity: - sub = [] - for i in range(Arity[sym]): - if len(outstack) == 0: - raise ParseError("missing operator argument") - sub.insert(0, outstack.pop()) - outstack.append(AstOp(sym, sub)) - elif sym == "(": - raise ParseError("missing closing ')'") - elif not isinstance(sym, AstSym): - raise ParseError("bogus symbol '%s'" % sym) - else: - outstack.append(sym) - while True: - tok, expr = read_tok(expr) - if tok is None: - break - if tok in Arity: - while len(opstack) and opstack[-1] != '(' and \ - Precedence[opstack[-1]] > Precedence[tok]: - out(opstack.pop()) - opstack.append(tok) - elif tok == "(": - opstack.append(tok) - elif tok == ")": - while True: - if not len(opstack): - raise ParseError("missing '(' for ')'") - sym = opstack.pop() - if sym == "(": - break - out(sym) - else: - out(AstSym(tok)) # Assume a terminal - while len(opstack): - out(opstack.pop()) - if len(outstack) != 1: - raise ParseError("empty expression or extra symbols (%s)" % outstack) - return outstack.pop() - -def convert_dnf(ast): - - # no nested ! (negation normal form) - def simplify_negation(ast): - if isinstance(ast, AstOp): - if ast.op == "!": - sub = ast.sub[0] - if isinstance(sub, AstOp): - if sub.op == "!": - return sub.sub[0] - elif sub.op in ["&&", "||"]: - sub.op = "||" if sub.op == "&&" else "&&" - sub.sub = [AstOp("!", [x]) for x in sub.sub] - return simplify_negation(sub) - else: - ast.sub = [simplify_negation(x) for x in ast.sub] - return ast - - # a && (b && c) => a && b && c - def flatten(ast): - if isinstance(ast, AstOp): - can_flatten = ast.op in ["&&", "||"] - nsub = [] - for sub in ast.sub: - sub = flatten(sub) - if isinstance(sub, AstOp) and sub.op == ast.op and can_flatten: - nsub.extend(sub.sub) - else: - nsub.append(sub) - ast.sub = nsub - if len(ast.sub) == 1 and can_flatten: - return ast.sub[0] - return ast - - # a && (b || c) && d => (a && d && b) || (a && d && c) - def redist(ast): - def recombine(a, stuff): - return AstOp("||", [AstOp("&&", [a, n]) for n in stuff]) - if isinstance(ast, AstOp): - ast.sub = [flatten(redist(x)) for x in ast.sub] - if ast.op == "&&": - for sub in ast.sub: - if isinstance(sub, AstOp) and sub.op == "||": - if len(ast.sub) == 1: - return redist(sub) - other = None - for n in ast.sub: - if n is not sub: - if other is None: - other = n - else: - other = flatten(AstOp("&&", [other, n])) - return flatten(redist(recombine(other, sub.sub))) - return ast - - return redist(flatten(simplify_negation(ast))) - -# Returns (success_as_bool, failure_reason_as_string) -def check_dependency_expr(expr, deps): - ast = parse_expr(expr) - def eval_ast(ast): - if isinstance(ast, AstSym): - return ast.name in deps - elif isinstance(ast, AstOp): - vals = [eval_ast(x) for x in ast.sub] - if ast.op == "&&": - return vals[0] and vals[1] - elif ast.op == "||": - return vals[0] or vals[1] - elif ast.op == "!": - return not vals[0] - assert False - if eval_ast(ast): - return True, None - - # Now the same thing again, but more complicated, and informing what is - # missing. - ast = convert_dnf(ast) - - # ast now is a or-combined list of and-combined deps. Each dep can have a - # negation (marking a conflict). Each case of and-combined deps is a way - # to satisfy the deps expression. Instead of dumping full information, - # distinguish the following cases, and only mention the one that applies, - # in order: - # 1. the first missing dep of a case that has missing deps only - # 2. the first conflicting dep at all - - def get_sub_list(node, op): - if isinstance(node, AstOp) and node.op == op: - return node.sub - else: - return [node] - - conflict_dep = None - missing_dep = None - - for group in get_sub_list(ast, "||"): - group_conflict = None - group_missing_dep = None - for elem in get_sub_list(group, "&&"): - neg = False - if isinstance(elem, AstOp) and elem.op == "!": - neg = True - elem = elem.sub[0] - if not isinstance(elem, AstSym): - continue # broken DNF? - name = elem.name - present = name in deps - if (not present) and (not neg) and (group_missing_dep is None): - group_missing_dep = name - if present and neg and (group_conflict is None): - group_conflict = name - if (missing_dep is None) and (group_conflict is None): - missing_dep = group_missing_dep - if conflict_dep is None: - conflict_dep = group_conflict - - reason = "unknown" - if missing_dep is not None: - reason = "%s not found" % (missing_dep) - elif conflict_dep is not None: - reason = "%s found" % (conflict_dep) - return False, reason diff --git a/waftools/detections/__init__.py b/waftools/detections/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/waftools/detections/compiler.py b/waftools/detections/compiler.py deleted file mode 100644 index 06baa98ac0..0000000000 --- a/waftools/detections/compiler.py +++ /dev/null @@ -1,92 +0,0 @@ -from waflib import Utils - -def __get_cc_env_vars__(cc): - cmd = cc + ['-dM', '-E', '-'] - try: - p = Utils.subprocess.Popen(cmd, stdin=Utils.subprocess.PIPE, - stdout=Utils.subprocess.PIPE, - stderr=Utils.subprocess.PIPE) - p.stdin.write('\n'.encode()) - return p.communicate()[0] - except Exception: - return "" - -def __test_and_add_flags__(ctx, flags): - for flag in flags: - if ctx.check_cc(cflags='-Werror ' + flag, mandatory=False): - ctx.env.CFLAGS += [flag] - -def __add_generic_flags__(ctx): - ctx.env.CFLAGS += ["-D_ISOC99_SOURCE", "-D_GNU_SOURCE", - "-D_FILE_OFFSET_BITS=64", "-Wall"] - - if ctx.check_cc(cflags="-std=c11", mandatory=False): - ctx.env.CFLAGS += ["-std=c11"] - else: - ctx.env.CFLAGS += ["-std=c99"] - - if ctx.is_optimization(): - ctx.env.CFLAGS += ['-O2'] - - if ctx.is_debug_build(): - ctx.env.CFLAGS += ['-g'] - - __test_and_add_flags__(ctx, ["-Werror=implicit-function-declaration", - "-Wno-error=deprecated-declarations", - "-Wno-error=unused-function", - "-Wempty-body", - "-Wdisabled-optimization", - "-Wstrict-prototypes", - "-Wno-format-zero-length", - "-Werror=format-security", - "-Wno-redundant-decls", - "-Wvla", - "-Wno-format-truncation", - "-Wimplicit-fallthrough", - ]) - __test_and_add_flags__(ctx, ["-fno-math-errno"]) - -def __add_gcc_flags__(ctx): - ctx.env.CFLAGS += ["-Wall", "-Wundef", "-Wmissing-prototypes", "-Wshadow", - "-Wno-switch", "-Wparentheses", "-Wpointer-arith", - "-Wno-pointer-sign", - # GCC bug 66425 - "-Wno-unused-result"] - -def __add_clang_flags__(ctx): - ctx.env.CFLAGS += ["-Wno-logical-op-parentheses", "-fcolor-diagnostics", - "-Wno-tautological-compare", - "-Wno-tautological-constant-out-of-range-compare"] - -def __add_mswin_flags__(ctx): - ctx.env.CFLAGS += ['-D_WIN32_WINNT=0x0602', '-DUNICODE', '-DCOBJMACROS', - '-DINITGUID', '-U__STRICT_ANSI__'] - ctx.env.LAST_LINKFLAGS += ['-Wl,--major-os-version=6,--minor-os-version=0', - '-Wl,--major-subsystem-version=6,--minor-subsystem-version=0'] - -def __add_mingw_flags__(ctx): - __add_mswin_flags__(ctx) - ctx.env.CFLAGS += ['-D__USE_MINGW_ANSI_STDIO=1'] - ctx.env.LAST_LINKFLAGS += ['-mwindows'] - -def __add_cygwin_flags__(ctx): - __add_mswin_flags__(ctx) - ctx.env.CFLAGS += ['-mwin32'] - -__compiler_map__ = { - '__GNUC__': __add_gcc_flags__, - '__clang__': __add_clang_flags__, - '__MINGW32__': __add_mingw_flags__, - '__CYGWIN__': __add_cygwin_flags__, -} - -def __apply_map__(ctx, fnmap): - if not getattr(ctx, 'CC_ENV_VARS', None): - ctx.CC_ENV_VARS = str(__get_cc_env_vars__(ctx.env.CC)) - for k, fn in fnmap.items(): - if ctx.CC_ENV_VARS.find(k) > 0: - fn(ctx) - -def configure(ctx): - __add_generic_flags__(ctx) - __apply_map__(ctx, __compiler_map__) diff --git a/waftools/detections/compiler_swift.py b/waftools/detections/compiler_swift.py deleted file mode 100644 index be66df0fbe..0000000000 --- a/waftools/detections/compiler_swift.py +++ /dev/null @@ -1,203 +0,0 @@ -import re -import string -import os.path -from waflib import Utils -from distutils.version import StrictVersion - - -def __run(cmd): - try: - output = Utils.subprocess.check_output(cmd, stderr=Utils.subprocess.STDOUT, universal_newlines=True) - return output.strip() - except Exception: - return "" - - -def __add_swift_flags(ctx): - ctx.env.SWIFT_FLAGS = [ - "-frontend", "-c", "-sdk", ctx.env.MACOS_SDK, - "-enable-objc-interop", "-emit-objc-header", "-parse-as-library", - ] - - verRe = re.compile("(?i)version\s?([\d.]+)") - ctx.env.SWIFT_VERSION = verRe.search(__run([ctx.env.SWIFT, '-version'])).group(1) - - # prevent possible breakages with future swift versions - if StrictVersion(ctx.env.SWIFT_VERSION) >= StrictVersion("6.0"): - ctx.env.SWIFT_FLAGS.extend(["-swift-version", "5"]) - - if ctx.is_debug_build(): - ctx.env.SWIFT_FLAGS.append("-g") - - if ctx.is_optimization(): - ctx.env.SWIFT_FLAGS.append("-O") - - -def __add_static_swift_library_linking_flags(ctx, swift_library): - ctx.env.append_value('LINKFLAGS', [ - '-L%s' % swift_library, - '-Xlinker', '-force_load_swift_libs', '-lc++', - ]) - - -def __add_dynamic_swift_library_linking_flags(ctx, swift_library): - ctx.env.append_value('LINKFLAGS', ['-L%s' % swift_library]) - - # ABI compatibility - if StrictVersion(ctx.env.SWIFT_VERSION) >= StrictVersion("5.0"): - ctx.env.append_value('LINKFLAGS', [ - '-Xlinker', '-rpath', '-Xlinker', '/usr/lib/swift', - '-L/usr/lib/swift', - ]) - - ctx.env.append_value('LINKFLAGS', [ - '-Xlinker', '-rpath', '-Xlinker', swift_library, - ]) - - -def __find_swift_library(ctx): - swift_libraries = {} - # look for set lib paths in passed environment variables - if 'SWIFT_LIB_DYNAMIC' in ctx.environ: - swift_libraries['SWIFT_LIB_DYNAMIC'] = ctx.environ['SWIFT_LIB_DYNAMIC'] - if 'SWIFT_LIB_STATIC' in ctx.environ: - swift_libraries['SWIFT_LIB_STATIC'] = ctx.environ['SWIFT_LIB_STATIC'] - - # search for swift libs relative to the swift compiler executable - swift_library_relative_paths = { - 'SWIFT_LIB_DYNAMIC': '../../lib/swift/macosx', - 'SWIFT_LIB_STATIC': '../../lib/swift_static/macosx' - } - - for lib_type, path in swift_library_relative_paths.items(): - if lib_type not in swift_libraries: - lib_path = os.path.join(ctx.env.SWIFT, path) - swift_library = ctx.root.find_dir(lib_path) - if swift_library is not None: - swift_libraries[lib_type] = swift_library.abspath() - - # fall back to xcode-select path - swift_library_paths = { - 'SWIFT_LIB_DYNAMIC': [ - 'Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx', - 'usr/lib/swift/macosx' - ], - 'SWIFT_LIB_STATIC': [ - 'Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx', - 'usr/lib/swift_static/macosx' - ] - } - dev_path = __run(['xcode-select', '-p'])[1:] - - for lib_type, paths in swift_library_paths.items(): - for path in paths: - if lib_type not in swift_libraries: - swift_library = ctx.root.find_dir([dev_path, path]) - if swift_library is not None: - swift_libraries[lib_type] = swift_library.abspath() - break - else: - break - - # check if library paths were found - ctx.start_msg('Checking for dynamic Swift Library') - if 'SWIFT_LIB_DYNAMIC' in swift_libraries: - ctx.end_msg(swift_libraries['SWIFT_LIB_DYNAMIC']) - else: - ctx.end_msg(False) - - ctx.start_msg('Checking for static Swift Library') - if 'SWIFT_LIB_STATIC' in swift_libraries: - ctx.end_msg(swift_libraries['SWIFT_LIB_STATIC']) - ctx.env['SWIFT_LIB_STATIC'] = swift_libraries['SWIFT_LIB_STATIC'] - else: - ctx.end_msg(False) - - enableStatic = getattr(ctx.options, 'enable_swift-static') - if (enableStatic) and 'SWIFT_LIB_STATIC' in swift_libraries: - __add_static_swift_library_linking_flags(ctx, swift_libraries['SWIFT_LIB_STATIC']) - else: - __add_dynamic_swift_library_linking_flags(ctx, swift_libraries['SWIFT_LIB_DYNAMIC']) - - -def __find_macos_sdk(ctx): - ctx.start_msg('Checking for macOS SDK') - sdk = None - sdk_build_version = None - sdk_version = None - - # look for set macOS SDK paths and version in passed environment variables - if 'MACOS_SDK' in ctx.environ: - sdk = ctx.environ['MACOS_SDK'] - if 'MACOS_SDK_VERSION' in ctx.environ: - ctx.env.MACOS_SDK_VERSION = ctx.environ['MACOS_SDK_VERSION'] - - # find macOS SDK paths and version - if not sdk: - sdk = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-path']) - if not ctx.env.MACOS_SDK_VERSION: - # show-sdk-build-version: is not available on older command line tools, but return a build version (eg 17A360) - # show-sdk-version: is always available, but on older dev tools it's only the major version - sdk_build_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-build-version']) - sdk_version = __run(['xcrun', '--sdk', 'macosx', '--show-sdk-version']) - - if sdk: - ctx.env.MACOS_SDK = sdk - build_version = '10.10.0' - - if not ctx.env.MACOS_SDK_VERSION: - # convert build version to a version string - # first 2 two digits are the major version, starting with 15 which is 10.11 (offset of 4) - # 1 char is the minor version, A => 0, B => 1 and ongoing - # last digits are bugfix version, which are not relevant for us - # eg 16E185 => 10.12.4, 17A360 => 10.13, 18B71 => 10.14.1 - if sdk_build_version and isinstance(sdk_build_version, str): - verRe = re.compile("(\d+)(\D+)(\d+)") - version_parts = verRe.search(sdk_build_version) - major = int(version_parts.group(1)) - 4 - minor = string.ascii_lowercase.index(version_parts.group(2).lower()) - build_version = '10.' + str(major) + '.' + str(minor) - # from 20 onwards macOS 11.0 starts - if int(version_parts.group(1)) >= 20: - build_version = '11.' + str(minor) - - if not isinstance(sdk_version, str): - sdk_version = '10.10.0' - - # pick the higher version, always pick sdk over build if newer - if StrictVersion(build_version) > StrictVersion(sdk_version): - ctx.env.MACOS_SDK_VERSION = build_version - else: - ctx.env.MACOS_SDK_VERSION = sdk_version - - ctx.end_msg(sdk + ' (version found: ' + ctx.env.MACOS_SDK_VERSION + ')') - else: - ctx.end_msg(False) - - -def __find_swift_compiler(ctx): - ctx.start_msg('Checking for swift (Swift compiler)') - swift = '' - - # look for set swift paths in passed environment variables - if 'SWIFT' in ctx.environ: - swift = ctx.environ['SWIFT'] - - # find swift executable - if not swift: - swift = __run(['xcrun', '-find', 'swift']) - - if swift: - ctx.end_msg(swift) - ctx.env.SWIFT = swift - __add_swift_flags(ctx) - __find_swift_library(ctx) - else: - ctx.end_msg(False) - - -def configure(ctx): - if ctx.env.DEST_OS == "darwin": - __find_macos_sdk(ctx) - if ctx.options.enable_swift is not False: - __find_swift_compiler(ctx) diff --git a/waftools/detections/devices.py b/waftools/detections/devices.py deleted file mode 100644 index 42c4c28171..0000000000 --- a/waftools/detections/devices.py +++ /dev/null @@ -1,31 +0,0 @@ -__cdrom_devices_map__ = { - 'win32': 'D:', - 'cygwin': 'D:', - 'darwin': '/dev/disk1', - 'freebsd': '/dev/cd0', - 'openbsd': '/dev/rcd0c', - 'linux': '/dev/sr0', - 'default': '/dev/cdrom' -} - -__dvd_devices_map__ = { - 'win32': 'D:', - 'cygwin': 'D:', - 'darwin': '/dev/rdiskN', - 'freebsd': '/dev/cd0', - 'openbsd': '/dev/rcd0c', - 'linux': '/dev/sr0', - 'default': '/dev/dvd' -} - -def __default_cdrom_device__(ctx): - default = __cdrom_devices_map__['default'] - return __cdrom_devices_map__.get(ctx.env.DEST_OS, default) - -def __default_dvd_device__(ctx): - default = __dvd_devices_map__['default'] - return __dvd_devices_map__.get(ctx.env.DEST_OS, default) - -def configure(ctx): - ctx.define('DEFAULT_DVD_DEVICE', __default_dvd_device__(ctx)) - ctx.define('DEFAULT_CDROM_DEVICE', __default_cdrom_device__(ctx)) diff --git a/waftools/features.py b/waftools/features.py deleted file mode 100644 index abd29fc1fa..0000000000 --- a/waftools/features.py +++ /dev/null @@ -1,74 +0,0 @@ -from waflib.Options import OptionsContext -import optparse - -class Feature(object): - def __init__(self, group, feature): - self.group = group - self.identifier, self.attributes = feature['name'], feature - - def add_options(self): - [self.add_option(option_rule) for option_rule in self.option_rules()] - - def add_option(self, rule): - self.group.add_option(self.option(rule['state']), - action=rule['action'], - default=rule['default'], - dest=self.storage(), - help=self.help(rule['state'])) - - # private - def option_rules(self): - return { - 'autodetect': [ - {'state': 'disable', 'action': 'store_false', 'default': None}, - {'state': 'enable', 'action': 'store_true', 'default': None}, - ], - 'disable': [ - {'state': 'disable', 'action': 'store_false', 'default': False}, - {'state': 'enable', 'action': 'store_true', 'default': False}, - ], - 'enable': [ - {'state': 'disable', 'action': 'store_false', 'default': True}, - {'state': 'enable', 'action': 'store_true', 'default': True}, - ], - }[self.behaviour()] - - - def behaviour(self): - if 'default' in self.attributes: - return self.attributes['default'] - else: - return 'autodetect' - - - def option(self, state): - return "--{0}-{1}".format(state, self.identifier) - - def help(self, state): - default = self.behaviour() - if (default, state) == ("autodetect", "enable") or default == state: - return optparse.SUPPRESS_HELP - return "{0} {1} [{2}]" \ - .format(state, self.attributes['desc'], default) - - def storage(self): - return "enable_{0}".format(self.identifier) - -def add_feature(group, feature): - Feature(group, feature).add_options() - -def parse_features(opt, group_name, features): - def is_feature(dep): - return dep['name'].find('--') >= 0 - - def strip_feature(dep): - dep['name'] = dep['name'].lstrip('-') - return dep - - features = [strip_feature(dep) for dep in features if is_feature(dep)] - group = opt.get_option_group(group_name) - if not group: - group = opt.add_option_group(group_name) - [add_feature(group, feature) for feature in features] - -OptionsContext.parse_features = parse_features diff --git a/waftools/fragments/audiounit.c b/waftools/fragments/audiounit.c deleted file mode 100644 index e1d3266270..0000000000 --- a/waftools/fragments/audiounit.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -int main(int argc, char **argv) -{ - AudioComponentDescription desc = (AudioComponentDescription) { - .componentType = kAudioUnitType_Output, - .componentSubType = kAudioUnitSubType_RemoteIO, - .componentManufacturer = kAudioUnitManufacturer_Apple, - }; - - AudioComponentFindNext(NULL, &desc); - return 0; -} diff --git a/waftools/fragments/cocoa.m b/waftools/fragments/cocoa.m deleted file mode 100644 index 91b3aaa585..0000000000 --- a/waftools/fragments/cocoa.m +++ /dev/null @@ -1,16 +0,0 @@ -#import -#import -#import - -#include "osdep/macosx_compat.h" - -int main(int argc, char **argv) -{ - @autoreleasepool { - NSArray *ary = @[@1, @2, @3]; - NSLog(@"test subscripting: %@", ary[0]); - NSApplicationLoad(); - CVDisplayLinkRef link; - CVDisplayLinkCreateWithCGDisplay(0, &link); - } -} diff --git a/waftools/fragments/coreaudio.c b/waftools/fragments/coreaudio.c deleted file mode 100644 index c7411311a7..0000000000 --- a/waftools/fragments/coreaudio.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -int main(int argc, char **argv) -{ - AudioComponentDescription desc = (AudioComponentDescription) { - .componentType = kAudioUnitType_Output, - .componentSubType = kAudioUnitSubType_DefaultOutput, - .componentManufacturer = kAudioUnitManufacturer_Apple, - }; - - AudioComponentFindNext(NULL, &desc); - return 0; -} diff --git a/waftools/fragments/gl_x11.c b/waftools/fragments/gl_x11.c deleted file mode 100644 index 7d879b6c0d..0000000000 --- a/waftools/fragments/gl_x11.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -#ifndef GL_VERSION_2_0 -#error "At least GL 2.0 headers needed." -#endif - -int main(int argc, char *argv[]) { - glXCreateContext(NULL, NULL, NULL, True); - glXQueryExtensionsString(NULL, 0); - glXGetProcAddressARB(""); - glXGetCurrentDisplay(); - return 0; -} diff --git a/waftools/fragments/iconv.c b/waftools/fragments/iconv.c deleted file mode 100644 index 78c963b643..0000000000 --- a/waftools/fragments/iconv.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#define INBUFSIZE 1024 -#define OUTBUFSIZE 4096 - -char inbuffer[INBUFSIZE]; -char outbuffer[OUTBUFSIZE]; - -int main(void) { - size_t numread; - iconv_t icdsc; - char *tocode="UTF-8"; - char *fromcode="cp1250"; - if ((icdsc = iconv_open(tocode, fromcode)) != (iconv_t)(-1)) { - while ((numread = read(0, inbuffer, INBUFSIZE))) { - char *iptr=inbuffer; - char *optr=outbuffer; - size_t inleft=numread; - size_t outleft=OUTBUFSIZE; - if (iconv(icdsc, &iptr, &inleft, &optr, &outleft) - != (size_t)(-1)) { - write(1, outbuffer, OUTBUFSIZE - outleft); - } - } - if (iconv_close(icdsc) == -1) - ; - } - return 0; -} diff --git a/waftools/fragments/pthreads.c b/waftools/fragments/pthreads.c deleted file mode 100644 index 84f3d087fb..0000000000 --- a/waftools/fragments/pthreads.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -static void *func(void *arg) { return arg; } -int main(void) { - pthread_t tid; - return pthread_create (&tid, 0, func, 0) != 0; -} diff --git a/waftools/fragments/sse.c b/waftools/fragments/sse.c deleted file mode 100644 index e9689cda17..0000000000 --- a/waftools/fragments/sse.c +++ /dev/null @@ -1,18 +0,0 @@ -#pragma GCC push_options -#pragma GCC target("sse4.1") -#include - -void *a_ptr; - -int main(void) -{ - __m128i xmm0; - __m128i* p = (__m128i*)a_ptr; - - _mm_sfence(); - - xmm0 = _mm_stream_load_si128(p + 1); - _mm_store_si128(p + 2, xmm0); - - return 0; -} diff --git a/waftools/fragments/touchbar.m b/waftools/fragments/touchbar.m deleted file mode 100644 index 3fa4f27aa1..0000000000 --- a/waftools/fragments/touchbar.m +++ /dev/null @@ -1,7 +0,0 @@ -#import - -int main(int argc, char **argv) -{ - [[NSTouchBar alloc] init]; - return 0; -} diff --git a/waftools/fragments/wasapi.c b/waftools/fragments/wasapi.c deleted file mode 100644 index fbd2bb6e1b..0000000000 --- a/waftools/fragments/wasapi.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - const GUID *check1[] = { - &IID_IAudioClient, - &IID_IAudioRenderClient, - &IID_IAudioClient, - &IID_IAudioEndpointVolume, - }; -int main(void) { - return 0; -} diff --git a/waftools/generators/__init__.py b/waftools/generators/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/waftools/generators/headers.py b/waftools/generators/headers.py deleted file mode 100644 index 55db354aab..0000000000 --- a/waftools/generators/headers.py +++ /dev/null @@ -1,45 +0,0 @@ -def __cp_to_variant__(ctx, variant, basename): - src = ctx.bldnode.search_node(basename).read() - node = ctx.bldnode.make_node("{0}/{1}".format(variant, basename)) - node.parent.mkdir() - node.write(src) - -def __write_config_h__(ctx): - ctx.start_msg("Writing configuration header:") - ctx.write_config_header('config.h') - __cp_to_variant__(ctx, ctx.options.variant, 'config.h') - ctx.end_msg("config.h", "PINK") - -def __add_swift_defines__(ctx): - if ctx.dependency_satisfied("swift"): - ctx.start_msg("Adding conditional Swift flags:") - from waflib.Tools.c_config import DEFKEYS, INCKEYS - for define in ctx.env[DEFKEYS]: - if ctx.is_defined(define) and ctx.get_define(define) == "1": - ctx.env.SWIFT_FLAGS.extend(["-D", define]) - ctx.end_msg("yes") - -# Approximately escape the string as C string literal -def __escape_c_string(s): - return s.replace("\"", "\\\"").replace("\n", "\\n") - -def __get_features_string__(ctx): - import inflector - stuff = [] - for dependency_identifier in ctx.satisfied_deps: - defkey = inflector.define_key(dependency_identifier) - if ctx.is_defined(defkey) and ctx.get_define(defkey) == "1": - stuff.append(dependency_identifier) - stuff.sort() - return " ".join(stuff) - -def __add_mpv_defines__(ctx): - from sys import argv - ctx.define("CONFIGURATION", " ".join(argv)) - ctx.define("MPV_CONFDIR", ctx.env.CONFLOADDIR) - ctx.define("FULLCONFIG", __escape_c_string(__get_features_string__(ctx))) - -def configure(ctx): - __add_mpv_defines__(ctx) - __add_swift_defines__(ctx) - __write_config_h__(ctx) diff --git a/waftools/generators/sources.py b/waftools/generators/sources.py deleted file mode 100644 index dae1985e2d..0000000000 --- a/waftools/generators/sources.py +++ /dev/null @@ -1,95 +0,0 @@ -from waflib.Build import BuildContext -from waflib import TaskGen, Utils -from io import StringIO -from TOOLS.matroska import generate_C_header, generate_C_definitions -from TOOLS.file2string import file2string -import os - -def __wayland_scanner_cmd__(ctx, mode, dir, src, vendored_file): - return "${{WAYSCAN}} {0} < {1} > ${{TGT}}".format( - mode, - "${SRC}" if vendored_file else "{}/{}".format(dir, src) - ) - -def __file2string__(ctx, **kwargs): - ctx( - rule = __file2string_cmd__(ctx), - before = ("c",), - name = os.path.basename(kwargs['target']), - **kwargs - ) - -def execf(self, fn): - setattr(self, 'before', ['c']) - setattr(self, 'rule', ' ') # waf doesn't print the task with no rule - target = getattr(self, 'target', None) - out = self.path.find_or_declare(target) - tmp = StringIO() - fn(tmp) - out.write(tmp.getvalue()) - tmp.close() - -@TaskGen.feature('file2string') -def f2s(self): - def fn(out): - source = getattr(self, 'source', None) - src = self.path.find_resource(source) - file2string(source, iter(src.read('rb').splitlines(True)), out) - execf(self, fn) - -@TaskGen.feature('ebml_header') -def ebml_header(self): - execf(self, generate_C_header) - -@TaskGen.feature('ebml_definitions') -def ebml_definitions(self): - execf(self, generate_C_definitions) - -def __wayland_protocol_code__(ctx, **kwargs): - protocol_is_vendored = kwargs.get("vendored_protocol", False) - file_name = kwargs['protocol'] + '.xml' - - if protocol_is_vendored: - del kwargs['vendored_protocol'] - kwargs['source'] = '{}/{}'.format(kwargs['proto_dir'], file_name) - - ctx( - rule = __wayland_scanner_cmd__(ctx, 'private-code', kwargs['proto_dir'], - file_name, - protocol_is_vendored), - name = os.path.basename(kwargs['target']), - **kwargs - ) - -def __wayland_protocol_header__(ctx, **kwargs): - protocol_is_vendored = kwargs.get("vendored_protocol", False) - file_name = kwargs['protocol'] + '.xml' - - if protocol_is_vendored: - del kwargs['vendored_protocol'] - kwargs['source'] = '{}/{}'.format(kwargs['proto_dir'], file_name) - - ctx( - rule = __wayland_scanner_cmd__(ctx, 'client-header', kwargs['proto_dir'], - file_name, - protocol_is_vendored), - before = ('c',), - name = os.path.basename(kwargs['target']), - **kwargs - ) - -@TaskGen.feature('cprogram') -@TaskGen.feature('cshlib') -@TaskGen.feature('cstlib') -@TaskGen.feature('apply_link') -@TaskGen.after_method('process_source', 'process_use', 'apply_link', 'process_uselib_local', 'propagate_uselib_vars', 'do_the_symbol_stuff') -def handle_add_object(tgen): - if getattr(tgen, 'add_objects', None): - for input in tgen.add_objects: - input_node = tgen.path.find_resource(input) - if input_node is not None: - tgen.link_task.inputs.append(input_node) - -BuildContext.file2string = __file2string__ -BuildContext.wayland_protocol_code = __wayland_protocol_code__ -BuildContext.wayland_protocol_header = __wayland_protocol_header__ diff --git a/waftools/inflector.py b/waftools/inflector.py deleted file mode 100644 index 3aa1bc1f99..0000000000 --- a/waftools/inflector.py +++ /dev/null @@ -1,22 +0,0 @@ -import re - -def sanitize_id(word): - """ Converts a word "into_it_s_underscored_version" - Convert any "CamelCased" or "ordinary Word" into an - "underscored_word".""" - - return re.sub('[^A-Z^a-z^0-9]+', '_', \ - re.sub('([a-z\d])([A-Z])', '\\1_\\2', \ - re.sub('([A-Z]+)([A-Z][a-z])', '\\1_\\2', re.sub('::', '/', word)))).lower() - -def storage_key(dep): - return sanitize_id(dep) - -def define_key(dep): - return ("have_" + storage_key(dep)).upper() - -def define_dict(dep): - return {'define_name': define_key(dep)} - -def storage_dict(dep): - return {'uselib_store': storage_key(dep)} diff --git a/waftools/syms.py b/waftools/syms.py deleted file mode 100644 index 3ae69c6640..0000000000 --- a/waftools/syms.py +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/env python -# encoding: utf-8 -# Original source: waflib/extras/syms.py from waf git 610d0d59f (New BSD License) - -""" -set the list of symbols exported from a dynamic library -to use the tool, do something like: - -def build(ctx): - ctx(features='c cshlib syms', source='a.c b.c', export_symbols_def='syms.def', target='testlib') - -only the symbols listed in the file syms.def will be exported. -""" - -from waflib.Context import STDOUT -from waflib.Task import Task -from waflib.Errors import WafError -from waflib.TaskGen import feature, after_method - -class compile_sym(Task): - def run(self): - lsyms = [] - for line in self.inputs[0].read().split(): - lsyms.append(line.strip()) - lsyms.sort() - if self.env.DEST_BINFMT == 'pe': - self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms)) - elif self.env.DEST_BINFMT == 'elf': - self.outputs[0].write('{ global:\n' + ';\n'.join(lsyms) + ";\nlocal: *; };\n") - elif self.env.DEST_BINFMT == 'mac-o': - self.outputs[0].write('\n'.join("_"+sym for sym in lsyms) + '\n') - else: - raise WafError('NotImplemented') - -@feature('syms') -@after_method('process_source', 'process_use', 'apply_link', 'process_uselib_local', 'propagate_uselib_vars') -def do_the_symbol_stuff(self): - tsk = self.create_task('compile_sym', - [self.path.find_node(self.export_symbols_def)], - self.path.find_or_declare(getattr(self, 'sym_filename', self.target + '.def'))) - self.link_task.set_run_after(tsk) - self.link_task.dep_nodes.append(tsk.outputs[0]) - if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME): - self.link_task.env.append_value('LINKFLAGS', ['/def:' + tsk.outputs[0].bldpath()]) - elif self.env.DEST_BINFMT == 'pe': #gcc on windows takes *.def as an additional input - self.link_task.inputs.append(tsk.outputs[0]) - elif self.env.DEST_BINFMT == 'elf': - self.link_task.env.append_value('LINKFLAGS', ['-Wl,-version-script', '-Wl,' + tsk.outputs[0].bldpath()]) - elif self.env.DEST_BINFMT == 'mac-o': - self.link_task.env.append_value('LINKFLAGS', ['-exported_symbols_list', tsk.outputs[0].bldpath()]) - else: - raise WafError('NotImplemented') diff --git a/waftools/waf_customizations.py b/waftools/waf_customizations.py deleted file mode 100644 index f0db04c614..0000000000 --- a/waftools/waf_customizations.py +++ /dev/null @@ -1,60 +0,0 @@ -from waflib.Configure import conf - -@conf -def get_config_header(self, defines=True, headers=False, define_prefix=''): - """ - Only difference is it outputs `#define VAR 0` or `#define VAR value` - instead of `#undef VAR` or `#define VAR val`. - """ - from waflib.Tools.c_config import DEFKEYS, INCKEYS - lst = [] - if headers: - for x in self.env[INCKEYS]: - lst.append('#include <%s>' % x) - - if defines: - for x in self.env[DEFKEYS]: - val = self.is_defined(x) and self.get_define(x) or "0" - lst.append('#define %s %s' % (define_prefix + x, val)) - - return "\n".join(lst) - -from waflib import TaskGen - -@TaskGen.extension('.m') -def m_hook(self, node): - """ - Makes waf call the c compiler for objective-c files - """ - return self.create_compiled_task('c', node) - -def try_last_linkflags(cls): - try: - return cls.orig_run_str + ' ${LAST_LINKFLAGS}' - except AttributeError: - try: - return cls.hcode + ' ${LAST_LINKFLAGS}' - except TypeError: - return cls.hcode.decode('iso8859-1') + ' ${LAST_LINKFLAGS}' - -def build(ctx): - from waflib import Task - - cls = Task.classes['cprogram'] - class cprogram(cls): - run_str = try_last_linkflags(cls) - - cls = Task.classes['cshlib'] - class cshlib(cls): - run_str = try_last_linkflags(cls) - - cls = Task.classes['macplist'] - class macplist(cls): - def run(self): - from waflib import Utils - if getattr(self, 'code', None): - txt = self.code - else: - txt = self.inputs[0].read() - txt = Utils.subst_vars(txt, self.env) - self.outputs[0].write(txt) diff --git a/wscript b/wscript deleted file mode 100644 index 82f65b4afa..0000000000 --- a/wscript +++ /dev/null @@ -1,1152 +0,0 @@ -# vi: ft=python - -import sys, os, re -sys.path.insert(0, os.path.join(os.getcwd(), 'waftools')) -sys.path.insert(0, os.getcwd()) -from shlex import split -from waflib.Configure import conf -from waflib.Tools import c_preproc -from waflib.Tools.compiler_c import c_compiler -from waflib import Utils -from waftools.checks.generic import * -from waftools.checks.custom import * - -c_preproc.go_absolute=True # enable system folders -c_preproc.standard_includes.append('/usr/local/include') - -c_compiler['win32'].remove('msvc') - -APPNAME = 'mpv' - -""" -Dependency identifiers (for win32 vs. Unix): - wscript / C source meaning - -------------------------------------------------------------------------- - posix / HAVE_POSIX: defined on Linux, OSX, Cygwin - (Cygwin emulates POSIX APIs on Windows) - mingw / __MINGW32__: defined if posix is not defined - (Windows without Cygwin) - os-win32 / _WIN32: defined if basic windows.h API is available - win32-desktop / HAVE_WIN32_DESKTOP: defined if desktop windows.h API is available - uwp / HAVE_UWP: defined if building for UWP (basic Windows only) -""" - -build_options = [ - { - 'name': '--lgpl', - 'desc': 'LGPL (version 2.1 or later) build', - 'default': 'disable', - 'func': check_true, - }, { - 'name': 'gpl', - 'desc': 'GPL (version 2 or later) build', - 'deps': '!lgpl', - 'func': check_true, - }, { - 'name': '--cplayer', - 'desc': 'mpv CLI player', - 'default': 'enable', - 'func': check_true - }, { - 'name': '--libmpv-shared', - 'desc': 'shared library', - 'default': 'disable', - 'func': check_true - }, { - 'name': '--libmpv-static', - 'desc': 'static library', - 'default': 'disable', - 'deps': '!libmpv-shared', - 'func': check_true - }, { - 'name': '--static-build', - 'desc': 'static build', - 'default': 'disable', - 'func': check_true - }, { - 'name': '--build-date', - 'desc': 'whether to include binary compile time', - 'default': 'enable', - 'func': check_true - }, { - 'name': '--optimize', - 'desc': 'whether to optimize', - 'default': 'enable', - 'func': check_true - }, { - 'name': '--debug-build', - 'desc': 'whether to compile-in debugging information', - 'default': 'enable', - 'func': check_true - }, { - # Reminder: normally always built, but enabled by MPV_LEAK_REPORT. - # Building it can be disabled only by defining NDEBUG through CFLAGS. - 'name': '--ta-leak-report', - 'desc': 'enable ta leak report by default (development only)', - 'default': 'disable', - 'func': check_true - }, { - 'name': '--manpage-build', - 'desc': 'manpage generation', - 'func': check_ctx_vars('RST2MAN') - }, { - 'name': '--html-build', - 'desc': 'html manual generation', - 'func': check_ctx_vars('RST2HTML'), - 'default': 'disable', - }, { - 'name': '--pdf-build', - 'desc': 'pdf manual generation', - 'func': check_ctx_vars('RST2PDF'), - 'default': 'disable', - }, { - 'name': 'libdl', - 'desc': 'dynamic loader', - 'func': check_libs(['dl'], check_statement('dlfcn.h', 'dlopen("", 0)')) - }, { - 'name': '--cplugins', - 'desc': 'C plugins', - 'deps': 'libdl && !os-win32', - 'func': check_cc(linkflags=['-rdynamic']), - }, { - # does nothing - left for backward and forward compatibility - 'name': '--asm', - 'desc': 'inline assembly (currently without effect)', - 'default': 'enable', - 'func': check_true, - }, { - 'name': '--vector', - 'desc': 'GCC vector instructions', - 'func': check_statement([], 'float v __attribute__((vector_size(32)))'), - }, { - 'name': '--clang-database', - 'desc': 'generate a clang compilation database', - 'func': check_true, - 'default': 'disable', - } , { - 'name': '--swift-static', - 'desc': 'static Swift linking', - 'deps': 'os-darwin', - 'func': check_ctx_vars('SWIFT_LIB_STATIC'), - 'default': 'disable' - } -] - -main_dependencies = [ - { - 'name': 'noexecstack', - 'desc': 'compiler support for noexecstack', - 'func': check_cc(linkflags='-Wl,-z,noexecstack') - }, { - 'name': 'noexecstack', - 'desc': 'linker support for --nxcompat --no-seh --dynamicbase', - 'func': check_cc(linkflags=['-Wl,--nxcompat', '-Wl,--no-seh', '-Wl,--dynamicbase']) - } , { - 'name': 'libm', - 'desc': '-lm', - 'func': check_cc(lib='m') - }, { - 'name': 'mingw', - 'desc': 'MinGW', - 'deps': 'os-win32', - 'func': check_statement('stdlib.h', 'int x = __MINGW32__;' - 'int y = __MINGW64_VERSION_MAJOR'), - }, { - 'name': 'posix', - 'desc': 'POSIX environment', - 'func': check_statement(['unistd.h'], 'long x = _POSIX_VERSION'), - }, { - 'name': 'darwin', - 'desc': 'Darwin environment', - 'deps': 'os-darwin', - 'func': check_true, - }, { - 'name': '--android', - 'desc': 'Android environment', - 'func': check_statement('android/api-level.h', '(void)__ANDROID__'), # arbitrary android-specific header - }, { - 'name': '--android-media-ndk', - 'desc': 'Android Media APIs', - 'deps': 'android', - # header only, library is dynamically loaded - 'func': check_statement('media/NdkImageReader.h', 'int x = AIMAGE_FORMAT_PRIVATE'), - }, { - 'name': '--tvos', - 'desc': 'tvOS environment', - 'func': check_statement( - ['TargetConditionals.h', 'assert.h'], - 'static_assert(TARGET_OS_TV, "TARGET_OS_TV defined to zero!")' - ), - }, { - 'name': '--egl-android', - 'desc': 'Android EGL support', - 'deps': 'android', - 'groups': [ 'gl' ], - 'func': check_cc(lib=['android', 'EGL']), - }, { - 'name': 'posix-or-mingw', - 'desc': 'development environment', - 'deps': 'posix || mingw', - 'func': check_true, - 'req': True, - 'fmsg': 'Unable to find either POSIX or MinGW-w64 environment, ' \ - 'or compiler does not work.', - }, { - 'name': '--swift', - 'desc': 'macOS Swift build tools', - 'deps': 'os-darwin', - 'func': compose_checks(check_swift('4.1'), check_macos_sdk('10.10')), - }, { - 'name': '--uwp', - 'desc': 'Universal Windows Platform', - 'default': 'disable', - 'deps': 'os-win32 && mingw && !cplayer', - 'func': check_cc(lib=['windowsapp']), - }, { - 'name': 'win32-desktop', - 'desc': 'win32 desktop APIs', - 'deps': '(os-win32 || os-cygwin) && !uwp', - 'func': check_cc(lib=['avrt', - 'dwmapi', - 'gdi32', - 'ole32', - 'uuid', - 'uxtheme', - 'version', - 'winmm']), - }, { - 'name': '--win32-internal-pthreads', - 'desc': 'internal pthread wrapper for win32 (Vista+)', - 'deps': 'os-win32 && !posix', - 'func': check_true, - }, { - 'name': 'pthreads', - 'desc': 'POSIX threads', - 'func': check_pthreads, - 'req': True, - 'fmsg': 'Unable to find pthreads support.' - }, { - # NB: this works only if a source file includes osdep/threads.h - # also, technically, triggers undefined behavior (reserved names) - 'name': '--pthread-debug', - 'desc': 'pthread runtime debugging wrappers', - 'default': 'disable', - 'func': check_cc(cflags='-DMP_PTHREAD_DEBUG'), - # The win32 wrapper defines pthreads symbols as macros only. - 'deps_neg': 'win32-internal-pthreads', - }, { - 'name': '--stdatomic', - 'desc': 'C11 stdatomic.h', - 'func': check_libs(['atomic'], - check_statement('stdatomic.h', - 'atomic_int_least64_t test = ATOMIC_VAR_INIT(123);' - 'atomic_fetch_add(&test, 1)')), - 'req': True, - 'fmsg': 'C11 atomics are required; you may need a newer compiler', - }, { - 'name': 'librt', - 'desc': 'linking with -lrt', - 'deps': 'pthreads', - 'func': check_cc(lib='rt') - }, { - 'name': '--iconv', - 'desc': 'iconv', - 'func': check_iconv, - 'req': True, - 'fmsg': "Unable to find iconv which should be part of a standard \ -compilation environment. Aborting. If you really mean to compile without \ -iconv support use --disable-iconv.", - }, { - 'name': 'dos-paths', - 'desc': 'w32/dos paths', - 'deps': 'os-win32 || os-cygwin', - 'func': check_true - }, { - 'name': 'glob-posix', - 'desc': 'glob() POSIX support', - 'deps': '!(os-win32 || os-cygwin)', - 'func': check_statement('glob.h', 'glob("filename", 0, 0, 0)'), - }, { - 'name': 'glob-win32', - 'desc': 'glob() win32 replacement', - 'deps': '!posix && (os-win32 || os-cygwin)', - 'func': check_true - }, { - 'name': 'glob', - 'desc': 'any glob() support', - 'deps': 'glob-posix || glob-win32', - 'func': check_true, - }, { - 'name': 'vt.h', - 'desc': 'vt.h', - 'func': check_statement(['sys/vt.h', 'sys/ioctl.h'], - 'int m; ioctl(0, VT_GETMODE, &m)'), - }, { - 'name': 'consio.h', - 'desc': 'consio.h', - 'deps': '!vt.h', - 'func': check_statement(['sys/consio.h', 'sys/ioctl.h'], - 'int m; ioctl(0, VT_GETMODE, &m)'), - }, { - 'name': 'gbm.h', - 'desc': 'gbm.h', - 'func': check_cc(header_name=['stdio.h', 'gbm.h']), - }, { - 'name': 'glibc-thread-name', - 'desc': 'GLIBC API for setting thread name', - 'func': check_statement('pthread.h', - 'pthread_setname_np(pthread_self(), "ducks")', - use=['pthreads']), - }, { - 'name': 'osx-thread-name', - 'desc': 'OSX API for setting thread name', - 'deps': '!glibc-thread-name', - 'func': check_statement('pthread.h', - 'pthread_setname_np("ducks")', use=['pthreads']), - }, { - 'name': 'bsd-thread-name', - 'desc': 'BSD API for setting thread name', - 'deps': '!(glibc-thread-name || osx-thread-name)', - 'func': check_statement(['pthread.h', 'pthread_np.h'], - 'pthread_set_name_np(pthread_self(), "ducks")', - use=['pthreads']), - }, { - 'name': 'bsd-fstatfs', - 'desc': "BSD's fstatfs()", - 'func': check_statement(['sys/param.h', 'sys/mount.h'], - 'struct statfs fs; fstatfs(0, &fs); fs.f_fstypename') - }, { - 'name': 'linux-fstatfs', - 'desc': "Linux's fstatfs()", - 'deps': 'os-linux', - 'func': check_statement('sys/vfs.h', - 'struct statfs fs; fstatfs(0, &fs); fs.f_namelen') - }, { - 'name': 'linux-input-event-codes', - 'desc': "Linux's input-event-codes.h", - 'func': check_cc(header_name=['linux/input-event-codes.h']), - }, { - 'name' : '--lua', - 'desc' : 'Lua', - 'func': check_lua, - }, { - 'name' : '--javascript', - 'desc' : 'Javascript (MuJS backend)', - 'func': check_pkg_config('mujs', '>= 1.0.0'), - }, { - 'name': 'libass', - 'desc': 'SSA/ASS support', - 'func': check_pkg_config('libass', '>= 0.12.2'), - 'req': True, - 'fmsg': "Unable to find development files for libass, or the version " + - "found is too old. Aborting." - }, { - 'name': '--zlib', - 'desc': 'zlib', - 'func': any_check(check_pkg_config('zlib'), - check_libs(['z'], check_statement('zlib.h', 'inflate(0, Z_NO_FLUSH)'))), - 'req': True, - 'fmsg': 'Unable to find development files for zlib.' - }, { - 'name': '--libbluray', - 'desc': 'Bluray support', - 'func': check_pkg_config('libbluray', '>= 0.3.0'), - #'default': 'disable', - }, { - 'name': '--dvdnav', - 'desc': 'dvdnav support', - 'deps': 'gpl', - 'func': check_pkg_config('dvdnav', '>= 4.2.0', - 'dvdread', '>= 4.1.0'), - 'default': 'disable', - }, { - 'name': '--cdda', - 'desc': 'cdda support (libcdio)', - 'deps': 'gpl', - 'func': check_pkg_config('libcdio_paranoia'), - 'default': 'disable', - }, { - 'name': '--uchardet', - 'desc': 'uchardet support', - 'deps': 'iconv', - 'func': check_pkg_config('uchardet'), - }, { - 'name': '--rubberband', - 'desc': 'librubberband support', - 'func': check_pkg_config('rubberband', '>= 1.8.0'), - }, { - 'name': '--zimg', - 'desc': 'libzimg support (high quality software scaler)', - 'func': check_pkg_config('zimg', '>= 2.9'), - }, { - 'name': '--lcms2', - 'desc': 'LCMS2 support', - 'func': check_pkg_config('lcms2', '>= 2.6'), - }, { - 'name': '--vapoursynth', - 'desc': 'VapourSynth filter bridge', - 'func': check_pkg_config('vapoursynth', '>= 24', - 'vapoursynth-script', '>= 23'), - }, { - 'name': '--libarchive', - 'desc': 'libarchive wrapper for reading zip files and more', - 'func': check_pkg_config('libarchive >= 3.4.0'), - }, { - 'name': '--dvbin', - 'desc': 'DVB input module', - 'deps': 'gpl', - 'func': check_true, - 'default': 'disable', - }, { - 'name': '--sdl2', - 'desc': 'SDL2', - 'func': check_pkg_config('sdl2'), - 'default': 'disable', - }, { - 'name': '--sdl2-gamepad', - 'desc': 'SDL2 gamepad input', - 'deps': 'sdl2', - 'func': check_true, - }, { - 'name': 'jpegxl', - 'desc': 'JPEG XL support via libavcodec', - 'func': check_pkg_config('libavcodec >= 59.27.100'), - }, { - 'name': 'avif_muxer', - 'desc': 'avif support via libavcodec', - 'func': check_pkg_config('libavformat >= 59.24.100'), - }, { - 'name': 'rubberband-3', - 'desc': 'new engine support for librubberband', - 'func': check_pkg_config('rubberband >= 3.0.0'), - }, { - 'name': 'zimg-st428', - 'desc': 'ZIMG support for ZIMG_TRANSFER_ST428', - 'func': check_pkg_config('zimg', '>= 3.0.5'), - } -] - -libav_dependencies = [ - { - 'name': 'ffmpeg', - 'desc': 'FFmpeg library', - 'func': check_pkg_config('libavutil', '>= 56.70.100', - 'libavcodec', '>= 58.134.100', - 'libavformat', '>= 58.76.100', - 'libswscale', '>= 5.9.100', - 'libavfilter', '>= 7.110.100', - 'libswresample', '>= 3.9.100'), - 'req': True, - 'fmsg': "Unable to find development files for some of the required \ -FFmpeg libraries. Git master is recommended." - }, { - 'name': 'av-channel-layout', - 'desc': 'FFmpeg AVChannelLayout API', - 'func': check_pkg_config('libavutil', '>= 57.24.100'), - }, { - 'name': '--libavdevice', - 'desc': 'libavdevice', - 'func': check_pkg_config('libavdevice', '>= 58.13.100'), - } -] - -audio_output_features = [ - { - 'name': '--sdl2-audio', - 'desc': 'SDL2 audio output', - 'deps': 'sdl2', - 'func': check_true, - }, { - 'name': '--oss-audio', - 'desc': 'OSSv4 audio output', - 'func': check_statement(['sys/soundcard.h'], 'int x = SNDCTL_DSP_SETPLAYVOL'), - 'deps': 'posix && gpl', - }, { - 'name': '--pipewire', - 'desc': 'PipeWire audio output', - 'func': check_pkg_config('libpipewire-0.3', '>= 0.3.19') - }, { - 'name': '--sndio', - 'desc': 'sndio audio input/output', - 'func': check_pkg_config('sndio'), - 'default': 'disable' - }, { - 'name': '--pulse', - 'desc': 'PulseAudio audio output', - 'func': check_pkg_config('libpulse', '>= 1.0') - }, { - 'name': '--jack', - 'desc': 'JACK audio output', - 'deps': 'gpl', - 'func': check_pkg_config('jack'), - }, { - 'name': '--openal', - 'desc': 'OpenAL audio output', - 'func': check_pkg_config('openal', '>= 1.13'), - 'default': 'disable' - }, { - 'name': '--opensles', - 'desc': 'OpenSL ES audio output', - 'func': check_statement('SLES/OpenSLES.h', 'slCreateEngine', lib="OpenSLES"), - }, { - 'name': '--alsa', - 'desc': 'ALSA audio output', - 'func': check_pkg_config('alsa', '>= 1.0.18'), - }, { - 'name': '--coreaudio', - 'desc': 'CoreAudio audio output', - 'func': check_cc( - fragment=load_fragment('coreaudio.c'), - framework_name=['CoreFoundation', 'CoreAudio', 'AudioUnit', 'AudioToolbox']) - }, { - 'name': '--audiounit', - 'desc': 'AudioUnit output for iOS', - 'func': check_cc( - fragment=load_fragment('audiounit.c'), - framework_name=['Foundation', 'AudioToolbox']) - }, { - 'name': '--wasapi', - 'desc': 'WASAPI audio output', - 'deps': 'os-win32 || os-cygwin', - 'func': check_cc(fragment=load_fragment('wasapi.c')), - } -] - -video_output_features = [ - { - 'name': '--sdl2-video', - 'desc': 'SDL2 video output', - 'deps': 'sdl2', - 'deps_neg': 'cocoa', - 'func': check_true, - }, { - 'name': '--cocoa', - 'desc': 'Cocoa', - 'func': check_cocoa - }, { - 'name': '--drm', - 'desc': 'DRM', - 'deps': 'vt.h || consio.h', - 'func': check_pkg_config('libdrm', '>= 2.4.75'), - }, { - 'name': '--gbm', - 'desc': 'GBM', - 'deps': 'gbm.h', - 'func': check_pkg_config('gbm', '>= 17.1.0'), - } , { - 'name': 'wayland-scanner', - 'desc': 'wayland-scanner', - 'func': check_program('wayland-scanner', 'WAYSCAN') - } , { - 'name': 'wayland-protocols', - 'desc': 'wayland-protocols', - 'func': check_wl_protocols - } , { - 'name': '--wayland', - 'desc': 'Wayland', - 'deps': 'wayland-protocols && wayland-scanner && linux-input-event-codes', - 'func': check_pkg_config('wayland-client', '>= 1.20.0', - 'wayland-cursor', '>= 1.20.0', - 'xkbcommon', '>= 0.3.0'), - } , { - 'name': 'wayland-protocols-1-27', - 'desc': 'wayland-protocols version 1.27+', - 'deps': 'wayland', - 'func': check_pkg_config('wayland-protocols >= 1.27'), - } , { - 'name': 'wayland-protocols-1-31', - 'desc': 'wayland-protocols version 1.31+', - 'deps': 'wayland', - 'func': check_pkg_config('wayland-protocols >= 1.31'), - } , { - 'name': 'wayland-protocols-1-32', - 'desc': 'wayland-protocols version 1.32+', - 'deps': 'wayland', - 'func': check_pkg_config('wayland-protocols >= 1.32'), - } , { - 'name': 'memfd_create', - 'desc': "Linux's memfd_create()", - 'deps': 'wayland', - 'func': check_statement('sys/mman.h', - 'memfd_create("mpv", MFD_CLOEXEC | MFD_ALLOW_SEALING)') - }, { - 'name': '--dmabuf-wayland', - 'desc': 'dmabuf-wayland video output', - 'deps': 'wayland && memfd_create && drm', - 'func': check_true, - } , { - 'name': '--x11', - 'desc': 'X11', - 'deps': 'gpl', - 'func': check_pkg_config('x11', '>= 1.0.0', - 'xscrnsaver', '>= 1.0.0', - 'xext', '>= 1.0.0', - 'xinerama', '>= 1.0.0', - 'xpresent', '>= 1.0.0', - 'xrandr', '>= 1.2.0'), - } , { - 'name': '--xv', - 'desc': 'Xv video output', - 'deps': 'x11', - 'func': check_pkg_config('xv'), - } , { - 'name': '--gl-cocoa', - 'desc': 'OpenGL Cocoa Backend', - 'deps': 'cocoa', - 'groups': [ 'gl' ], - 'func': check_statement('IOSurface/IOSurface.h', - 'IOSurfaceRef surface;', - framework='IOSurface', - cflags=['-DGL_SILENCE_DEPRECATION']) - } , { - 'name': '--gl-x11', - 'desc': 'OpenGL X11/GLX (deprecated/legacy)', - 'deps': 'x11', - 'groups': [ 'gl' ], - 'func': check_libs(['GL', 'GL Xdamage'], - check_cc(fragment=load_fragment('gl_x11.c'), - use=['x11', 'libdl', 'pthreads'])), - 'default': 'disable', - }, { - 'name': '--rpi', - 'desc': 'Raspberry Pi support', - 'func': check_egl_provider(name='brcmegl', check=any_check( - check_pkg_config('brcmegl'), - check_pkg_config('/opt/vc/lib/pkgconfig/brcmegl.pc') - )), - 'default': 'disable', - } , { - 'name': '--egl', - 'desc': 'EGL 1.4', - 'groups': [ 'gl' ], - 'func': check_egl_provider('1.4') - } , { - 'name': '--egl-x11', - 'desc': 'OpenGL X11 EGL Backend', - 'deps': 'x11 && egl', - 'groups': [ 'gl' ], - 'func': check_true, - } , { - 'name': '--egl-drm', - 'desc': 'OpenGL DRM EGL Backend', - 'deps': 'drm && gbm && egl', - 'groups': [ 'gl' ], - 'func': check_true, - } , { - 'name': '--gl-wayland', - 'desc': 'OpenGL Wayland Backend', - 'deps': 'wayland && egl', - 'groups': [ 'gl' ], - 'func': check_pkg_config('wayland-egl', '>= 9.0.0') - } , { - 'name': '--gl-win32', - 'desc': 'OpenGL Win32 Backend', - 'deps': 'win32-desktop', - 'groups': [ 'gl' ], - 'func': check_statement('windows.h', 'wglCreateContext(0)', - lib='opengl32') - } , { - 'name': '--gl-dxinterop', - 'desc': 'OpenGL/DirectX Interop Backend', - 'deps': 'gl-win32', - 'groups': [ 'gl' ], - 'func': compose_checks( - check_statement(['GL/gl.h', 'GL/wglext.h'], 'int i = WGL_ACCESS_WRITE_DISCARD_NV'), - check_statement('d3d9.h', 'IDirect3D9Ex *d')) - } , { - 'name': '--egl-angle', - 'desc': 'OpenGL ANGLE headers', - 'deps': 'os-win32 || os-cygwin', - 'groups': [ 'gl' ], - 'func': check_statement(['EGL/egl.h', 'EGL/eglext.h', 'EGL/eglext_angle.h'], - 'int x = EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE; ' - 'PFNEGLCREATEDEVICEANGLEPROC y = NULL') - } , { - 'name': '--egl-angle-lib', - 'desc': 'OpenGL Win32 ANGLE Library', - 'deps': 'egl-angle', - 'groups': [ 'gl' ], - 'func': check_statement(['EGL/egl.h'], - 'eglCreateWindowSurface(0, 0, 0, 0)', - lib=['EGL', 'GLESv2', 'dxguid', 'd3d9', - 'gdi32', 'stdc++']) - }, { - 'name': '--egl-angle-win32', - 'desc': 'OpenGL Win32 ANGLE Backend', - 'deps': 'egl-angle && win32-desktop', - 'groups': [ 'gl' ], - 'func': check_true, - } , { - 'name': '--vdpau', - 'desc': 'VDPAU acceleration', - 'deps': 'x11', - 'func': check_pkg_config('vdpau', '>= 0.2'), - } , { - 'name': '--vdpau-gl-x11', - 'desc': 'VDPAU with OpenGL/X11', - 'deps': 'vdpau && gl-x11', - 'func': check_true, - }, { - 'name': '--vaapi', - 'desc': 'VAAPI acceleration', - 'deps': 'libdl && (x11 || wayland || egl-drm)', - 'func': check_pkg_config('libva', '>= 1.1.0'), - }, { - 'name': '--vaapi-x11', - 'desc': 'VAAPI (X11 support)', - 'deps': 'vaapi && x11', - 'func': check_pkg_config('libva-x11', '>= 1.1.0'), - }, { - 'name': '--vaapi-wayland', - 'desc': 'VAAPI (Wayland support)', - 'deps': 'vaapi && gl-wayland', - 'func': check_pkg_config('libva-wayland', '>= 1.1.0'), - }, { - 'name': '--vaapi-drm', - 'desc': 'VAAPI (DRM/EGL support)', - 'deps': 'vaapi && egl-drm', - 'func': check_pkg_config('libva-drm', '>= 1.1.0'), - }, { - 'name': '--vaapi-x-egl', - 'desc': 'VAAPI EGL on X11', - 'deps': 'vaapi-x11 && egl-x11', - 'func': check_true, - }, { - 'name': 'vaapi-egl', - 'desc': 'VAAPI EGL', - 'deps': 'vaapi-x-egl || vaapi-wayland || vaapi-drm', - 'func': check_true, - }, { - 'name': '--caca', - 'desc': 'CACA', - 'deps': 'gpl', - 'func': check_pkg_config('caca', '>= 0.99.beta18'), - }, { - 'name': '--jpeg', - 'desc': 'JPEG support', - 'func': check_cc(header_name=['stdio.h', 'jpeglib.h'], - lib='jpeg', use='libm'), - }, { - 'name': '--direct3d', - 'desc': 'Direct3D support', - 'deps': 'win32-desktop && gpl', - 'func': check_cc(header_name='d3d9.h'), - }, { - 'name': 'shaderc-shared', - 'desc': 'libshaderc SPIR-V compiler (shared library)', - 'deps': '!static-build', - 'groups': ['shaderc'], - 'func': check_pkg_config('shaderc'), - }, { - 'name': 'shaderc-static', - 'desc': 'libshaderc SPIR-V compiler (static library)', - 'deps': '!shaderc-shared', - 'groups': ['shaderc'], - 'func': any_check(check_pkg_config('shaderc_combined'), - check_pkg_config('shaderc_static')), - }, { - 'name': '--shaderc', - 'desc': 'libshaderc SPIR-V compiler', - 'deps': 'shaderc-shared || shaderc-static', - 'func': check_true, - }, { - 'name': 'spirv-cross-shared', - 'desc': 'SPIRV-Cross SPIR-V shader converter (shared library)', - 'deps': '!static-build', - 'groups': ['spirv-cross'], - 'func': check_pkg_config('spirv-cross-c-shared'), - }, { - 'name': 'spirv-cross-static', - 'desc': 'SPIRV-Cross SPIR-V shader converter (static library)', - 'deps': '!spirv-cross-shared', - 'groups': ['spirv-cross'], - 'func': check_pkg_config('spirv-cross'), - }, { - 'name': '--spirv-cross', - 'desc': 'SPIRV-Cross SPIR-V shader converter', - 'deps': 'spirv-cross-shared || spirv-cross-static', - 'func': check_true, - }, { - 'name': '--d3d11', - 'desc': 'Direct3D 11 video output', - 'deps': 'win32-desktop && shaderc && spirv-cross', - 'func': check_cc(header_name=['d3d11_1.h', 'dxgi1_6.h']), - } , { - 'name': '--ios-gl', - 'desc': 'iOS OpenGL ES hardware decoding interop support', - 'func': check_statement('OpenGLES/ES3/glext.h', '(void)GL_RGB32F'), # arbitrary OpenGL ES 3.0 symbol - } , { - 'name': '--plain-gl', - 'desc': 'OpenGL without platform-specific code (e.g. for libmpv)', - 'deps': 'libmpv-shared || libmpv-static', - 'func': check_true, - }, { - 'name': '--gl', - 'desc': 'OpenGL context support', - 'deps': 'gl-cocoa || gl-x11 || egl-x11 || egl-drm || ' - + 'gl-win32 || gl-wayland || rpi || ' - + 'plain-gl', - 'func': check_true, - 'req': True, - 'fmsg': "No OpenGL video output found or enabled. " + - "Aborting. If you really mean to compile without OpenGL " + - "video outputs use --disable-gl.", - }, { - 'name': '--libplacebo', - 'desc': 'libplacebo support', - 'func': check_pkg_config('libplacebo >= 4.157.0'), - }, { - 'name': '--libplacebo-next', - 'desc': 'libplacebo v5.266.0+, needed for vo_gpu_next', - 'deps': 'libplacebo', - 'func': check_preprocessor('libplacebo/config.h', 'PL_API_VER >= 266', - use='libplacebo'), - }, { - 'name': 'libplacebo-decode', - 'desc': 'libplacebo v6.278.0+, needed for Vulkan video decode', - 'deps': 'libplacebo', - 'func': check_preprocessor('libplacebo/config.h', 'PL_API_VER >= 278', - use='libplacebo'), - }, { - 'name': '--vulkan', - 'desc': 'Vulkan context support', - 'deps': 'libplacebo', - 'func': check_pkg_config('vulkan'), - }, { - 'name': 'vk-khr-display', - 'desc': "VK_KHR_display extension", - 'deps': 'vulkan', - 'func': check_statement('vulkan/vulkan_core.h', 'vkCreateDisplayPlaneSurfaceKHR(0, 0, 0, 0)', - use='vulkan') - }, { - 'name': 'vulkan-decode-headers', - 'desc': 'Vulkan headers with decode support', - 'deps': 'vulkan', - 'func': check_pkg_config('vulkan', '>= 1.3.238'), - }, { - 'name': '--vulkan-interop', - 'desc': 'Vulkan graphics interop', - 'deps': 'vulkan-decode-headers && libplacebo-decode', - 'func': check_pkg_config('libavutil', '>= 58.11.100'), - }, { - 'name': 'vaapi-libplacebo', - 'desc': 'VAAPI libplacebo', - 'deps': 'vaapi && libplacebo', - 'func': check_true, - }, { - 'name': 'egl-helpers', - 'desc': 'EGL helper functions', - 'deps': 'egl || rpi || egl-angle-win32 || egl-android', - 'func': check_true - }, { - 'name': '--sixel', - 'desc': 'Sixel', - 'func': check_pkg_config('libsixel', '>= 1.5'), - }, { - 'name': 'dmabuf-interop-gl', - 'desc': 'dmabuf GL Interop', - 'deps': 'egl && drm', - 'func': check_true, - }, { - 'name': 'dmabuf-interop-pl', - 'desc': 'dmabuf libplacebo interop', - 'deps': 'vaapi-libplacebo', - 'func': check_true, - }, { - # This can be removed roughly when Debian 12 is released. - 'name': 'drm-is-kms', - 'desc': 'drmIsKMS() function', - 'deps': 'drm', - 'func': check_pkg_config('libdrm', '>= 2.4.105'), - }, { - 'name': 'posix-shm', - 'desc': "POSIX shared memory API", - 'deps': 'posix', - 'func': check_statement('sys/mman.h', 'shm_open("",0,0)') - } -] - -hwaccel_features = [ - { - 'name': 'videotoolbox-hwaccel', - 'desc': 'libavcodec videotoolbox hwaccel', - 'deps': 'gl-cocoa || ios-gl', - 'func': check_true, - }, { - 'name': '--videotoolbox-gl', - 'desc': 'Videotoolbox with OpenGL', - 'deps': 'gl-cocoa && videotoolbox-hwaccel', - 'func': check_true - }, { - 'name': '--d3d-hwaccel', - 'desc': 'D3D11VA hwaccel', - 'deps': 'os-win32', - 'func': check_true, - }, { - 'name': '--d3d9-hwaccel', - 'desc': 'DXVA2 hwaccel', - 'deps': 'd3d-hwaccel', - 'func': check_true, - }, { - 'name': '--gl-dxinterop-d3d9', - 'desc': 'OpenGL/DirectX Interop Backend DXVA2 interop', - 'deps': 'gl-dxinterop && d3d9-hwaccel', - 'groups': [ 'gl' ], - 'func': check_true, - }, { - 'name': 'ffnvcodec', - 'desc': 'CUDA Headers and dynamic loader', - 'func': check_pkg_config('ffnvcodec >= 11.1.5.1'), - }, { - 'name': '--cuda-hwaccel', - 'desc': 'CUDA acceleration', - 'deps': 'ffnvcodec', - 'func': check_true, - }, { - 'name': '--cuda-interop', - 'desc': 'CUDA with graphics interop', - 'deps': '(gl || vulkan) && cuda-hwaccel', - 'func': check_true, - }, { - 'name': '--rpi-mmal', - 'desc': 'Raspberry Pi MMAL hwaccel', - 'deps': 'rpi', - 'func': any_check(check_pkg_config('mmal'), - check_pkg_config('/opt/vc/lib/pkgconfig/mmal.pc')), - } -] - -standalone_features = [ - { - 'name': 'win32-executable', - 'desc': 'w32 executable', - 'deps': 'os-win32 || !(!(os-cygwin))', - 'func': check_ctx_vars('WINDRES') - }, { - 'name': '--macos-touchbar', - 'desc': 'macOS Touch Bar support', - 'deps': 'cocoa', - 'func': check_cc( - fragment=load_fragment('touchbar.m'), - framework_name=['AppKit'], - compile_filename='test-touchbar.m', - linkflags='-fobjc-arc') - }, { - 'name': '--macos-10-11-features', - 'desc': 'macOS 10.11 SDK Features', - 'deps': 'cocoa', - 'func': check_macos_sdk('10.11') - }, { - 'name': '--macos-10-12-2-features', - 'desc': 'macOS 10.12.2 SDK Features', - 'deps': 'cocoa', - 'func': check_macos_sdk('10.12.2') - }, { - 'name': '--macos-10-14-features', - 'desc': 'macOS 10.14 SDK Features', - 'deps': 'cocoa', - 'func': check_macos_sdk('10.14') - },{ - 'name': '--macos-media-player', - 'desc': 'macOS Media Player support', - 'deps': 'macos-10-12-2-features && swift', - 'func': check_true - }, { - 'name': '--macos-cocoa-cb', - 'desc': 'macOS libmpv backend', - 'deps': 'cocoa && swift', - 'func': check_true - } -] - -_INSTALL_DIRS_LIST = [ - ('confdir', '${SYSCONFDIR}/mpv', 'configuration files'), - ('zshdir', '${DATADIR}/zsh/site-functions', 'zsh completion functions'), - ('confloaddir', '${CONFDIR}', 'configuration files load directory'), - ('bashdir', '${DATADIR}/bash-completion/completions', 'bash completion functions'), -] - -def options(opt): - opt.load('compiler_c') - opt.load('waf_customizations') - opt.load('features') - opt.load('gnu_dirs') - - #remove unused options from gnu_dirs - opt.parser.remove_option("--sbindir") - opt.parser.remove_option("--libexecdir") - opt.parser.remove_option("--sharedstatedir") - opt.parser.remove_option("--localstatedir") - opt.parser.remove_option("--oldincludedir") - opt.parser.remove_option("--infodir") - opt.parser.remove_option("--localedir") - opt.parser.remove_option("--dvidir") - opt.parser.remove_option("--pdfdir") - opt.parser.remove_option("--psdir") - - libdir = opt.parser.get_option('--libdir') - if libdir: - # Replace any mention of lib64 as we keep the default - # for libdir the same as before the waf update. - libdir.help = libdir.help.replace('lib64', 'lib') - - group = opt.get_option_group("Installation directories") - for ident, default, desc in _INSTALL_DIRS_LIST: - group.add_option('--{0}'.format(ident), - type = 'string', - dest = ident, - default = default, - help = 'directory for installing {0} [{1}]' \ - .format(desc, default.replace('${','').replace('}',''))) - - group = opt.get_option_group("build and install options") - group.add_option('--variant', - default = '', - help = 'variant name for saving configuration and build results') - - opt.parse_features('build and install options', build_options) - optional_features = main_dependencies + libav_dependencies - opt.parse_features('optional features', optional_features) - opt.parse_features('audio outputs', audio_output_features) - opt.parse_features('video outputs', video_output_features) - opt.parse_features('hwaccels', hwaccel_features) - opt.parse_features('standalone app', standalone_features) - - group = opt.get_option_group("optional features") - group.add_option('--lua', - type = 'string', - dest = 'LUA_VER', - help = "select Lua package to autodetect. Choices (x is 1 or 2): luadef5x, lua5x, lua5.x, lua-5.x, luajit (luadef5x is for pkg-config name 'lua', the rest are exact pkg-config names)") - group.add_option('--swift-flags', - type = 'string', - dest = 'SWIFT_FLAGS', - help = "Optional Swift compiler flags") - -@conf -def is_optimization(ctx): - return getattr(ctx.options, 'enable_optimize') - -@conf -def is_debug_build(ctx): - return getattr(ctx.options, 'enable_debug-build') - -def configure(ctx): - from waflib import Options - ctx.resetenv(ctx.options.variant) - ctx.check_waf_version(mini='1.8.4') - target = os.environ.get('TARGET') - (cc, pkg_config, ar, windres) = ('cc', 'pkg-config', 'ar', 'windres') - - if target: - cc = '-'.join([target, 'gcc']) - pkg_config = '-'.join([target, pkg_config]) - ar = '-'.join([target, ar]) - windres = '-'.join([target, windres]) - - ctx.find_program(cc, var='CC') - ctx.find_program(pkg_config, var='PKG_CONFIG') - ctx.find_program(ar, var='AR') - ctx.find_program('rst2html', var='RST2HTML', mandatory=False) - ctx.find_program('rst2man', var='RST2MAN', mandatory=False) - ctx.find_program('rst2pdf', var='RST2PDF', mandatory=False) - ctx.find_program(windres, var='WINDRES', mandatory=False) - ctx.find_program('perl', var='BIN_PERL', mandatory=False) - - ctx.add_os_flags('LIBRARY_PATH') - - ctx.load('compiler_c python') - ctx.load('waf_customizations') - ctx.load('dependencies') - ctx.load('detections.compiler_swift') - ctx.load('detections.compiler') - ctx.load('detections.devices') - ctx.load('gnu_dirs') - - # if libdir is not set in command line options, - # override the gnu_dirs default in order to - # always have `lib/` as the library directory. - if not getattr(Options.options, 'LIBDIR', None): - ctx.env['LIBDIR'] = Utils.subst_vars(os.path.join('${EXEC_PREFIX}', 'lib'), ctx.env) - - for ident, _, _ in _INSTALL_DIRS_LIST: - varname = ident.upper() - ctx.env[varname] = getattr(ctx.options, ident) - - # keep substituting vars, until the paths are fully expanded - while re.match('\$\{([^}]+)\}', ctx.env[varname]): - ctx.env[varname] = Utils.subst_vars(ctx.env[varname], ctx.env) - - if ctx.options.LUA_VER: - ctx.options.enable_lua = True - - ctx.parse_dependencies(build_options) - ctx.parse_dependencies(main_dependencies) - ctx.parse_dependencies(libav_dependencies) - ctx.parse_dependencies(audio_output_features) - ctx.parse_dependencies(video_output_features) - ctx.parse_dependencies(hwaccel_features) - - ctx.define('PLATFORM', check_platform(ctx)) - - if ctx.options.SWIFT_FLAGS: - ctx.env.SWIFT_FLAGS.extend(split(ctx.options.SWIFT_FLAGS)) - - ctx.parse_dependencies(standalone_features) - - ctx.load('generators.headers') - - if not ctx.dependency_satisfied('build-date'): - ctx.env.CFLAGS += ['-DNO_BUILD_TIMESTAMPS'] - - if ctx.dependency_satisfied('clang-database'): - ctx.load('clang_compilation_database') - - if ctx.dependency_satisfied('cplugins'): - # We need to export the libmpv symbols, since the mpv binary itself is - # not linked against libmpv. The C plugin needs to be able to pick - # up the libmpv symbols from the binary. We still restrict the set - # of exported symbols via mpv.def. - ctx.env.LINKFLAGS += ['-rdynamic'] - - ctx.store_dependencies_lists() - from waflib import Logs - Logs.error("WARNING: Building mpv with waf is deprecated and will be removed the future! It is recommended to switch to meson as soon as possible.") - -def __write_version__(ctx): - ctx( - source = 'version.py', - target = 'generated/version.h', - rule = '${PYTHON} ${SRC} ${TGT}', - always = True) - -def build(ctx): - if ctx.options.variant not in ctx.all_envs: - from waflib import Errors - raise Errors.WafError( - 'The project was not configured: run "waf --variant={0} configure" first!' - .format(ctx.options.variant)) - ctx.unpack_dependencies_lists() - ctx.add_group('versionh') - ctx.add_group('sources') - - ctx.set_group('versionh') - __write_version__(ctx) - ctx.set_group('sources') - ctx.load('wscript_build') - -def init(ctx): - from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext - for y in (BuildContext, CleanContext, InstallContext, UninstallContext): - class tmp(y): - variant = ctx.options.variant - - # This is needed because waf initializes the ConfigurationContext with - # an arbitrary setenv('') which would rewrite the previous configuration - # cache for the default variant if the configure step finishes. - # Ideally ConfigurationContext should just let us override this at class - # level like the other Context subclasses do with variant - from waflib.Configure import ConfigurationContext - class cctx(ConfigurationContext): - def resetenv(self, name): - self.all_envs = {} - self.setenv(name) diff --git a/wscript_build.py b/wscript_build.py deleted file mode 100644 index a470808ae5..0000000000 --- a/wscript_build.py +++ /dev/null @@ -1,826 +0,0 @@ -import re -import os - -def _add_rst_manual_dependencies(ctx): - manpage_sources_basenames = """ - options.rst ao.rst vo.rst af.rst vf.rst encode.rst - input.rst osc.rst stats.rst lua.rst ipc.rst changes.rst""".split() - - manpage_sources = ['DOCS/man/'+x for x in manpage_sources_basenames] - - for manpage_source in manpage_sources: - ctx.add_manual_dependency( - ctx.path.find_node('DOCS/man/mpv.rst'), - ctx.path.find_node(manpage_source)) - -def _build_html(ctx): - ctx( - name = 'rst2html', - target = 'DOCS/man/mpv.html', - source = 'DOCS/man/mpv.rst', - rule = '${RST2HTML} ${SRC} ${TGT}', - install_path = ctx.env.HTMLDIR) - - _add_rst_manual_dependencies(ctx) - -def _build_man(ctx): - ctx( - name = 'rst2man', - target = 'DOCS/man/mpv.1', - source = 'DOCS/man/mpv.rst', - rule = '${RST2MAN} --strip-elements-with-class=contents ${SRC} ${TGT}', - install_path = ctx.env.MANDIR + '/man1') - - _add_rst_manual_dependencies(ctx) - -def _build_pdf(ctx): - ctx( - name = 'rst2pdf', - target = 'DOCS/man/mpv.pdf', - source = 'DOCS/man/mpv.rst', - rule = '${RST2PDF} -c -b 1 --repeat-table-rows ${SRC} -o ${TGT}', - install_path = ctx.env.DOCDIR) - - _add_rst_manual_dependencies(ctx) - -def _all_includes(ctx): - return [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \ - ctx.dependencies_includes() - -def build(ctx): - ctx.load('waf_customizations') - ctx.load('generators.sources') - - ctx( - features = "file2string", - source = "TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns", - target = "generated/TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns.inc", - ) - - icons = [16, 32, 64, 128] - for size in icons: - name = "etc/mpv-icon-8bit-%dx%d.png" % (size, size) - ctx( - features = "file2string", - source = name, - target = "generated/%s.inc" % name, - ) - - ctx( - features = "file2string", - source = "etc/input.conf", - target = "generated/etc/input.conf.inc", - ) - - ctx( - features = "file2string", - source = "etc/builtin.conf", - target = "generated/etc/builtin.conf.inc", - ) - - ctx( - features = "file2string", - source = "sub/osd_font.otf", - target = "generated/sub/osd_font.otf.inc", - ) - - lua_files = ["defaults.lua", "assdraw.lua", "options.lua", "osc.lua", - "ytdl_hook.lua", "stats.lua", "console.lua", - "auto_profiles.lua"] - - for fn in lua_files: - fn = "player/lua/" + fn - ctx( - features = "file2string", - source = fn, - target = "generated/%s.inc" % fn, - ) - - ctx( - features = "file2string", - source = "player/javascript/defaults.js", - target = "generated/player/javascript/defaults.js.inc", - ) - - if ctx.dependency_satisfied('wayland'): - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "stable/xdg-shell/xdg-shell", - target = "generated/wayland/xdg-shell.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "stable/xdg-shell/xdg-shell", - target = "generated/wayland/xdg-shell.h") - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "unstable/idle-inhibit/idle-inhibit-unstable-v1", - target = "generated/wayland/idle-inhibit-unstable-v1.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "unstable/idle-inhibit/idle-inhibit-unstable-v1", - target = "generated/wayland/idle-inhibit-unstable-v1.h") - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "stable/presentation-time/presentation-time", - target = "generated/wayland/presentation-time.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "stable/presentation-time/presentation-time", - target = "generated/wayland/presentation-time.h") - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "unstable/xdg-decoration/xdg-decoration-unstable-v1", - target = "generated/wayland/xdg-decoration-unstable-v1.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "unstable/xdg-decoration/xdg-decoration-unstable-v1", - target = "generated/wayland/xdg-decoration-unstable-v1.h") - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "unstable/linux-dmabuf/linux-dmabuf-unstable-v1", - target = "generated/wayland/linux-dmabuf-unstable-v1.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "unstable/linux-dmabuf/linux-dmabuf-unstable-v1", - target = "generated/wayland/linux-dmabuf-unstable-v1.h") - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "stable/viewporter/viewporter", - target = "generated/wayland/viewporter.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "stable/viewporter/viewporter", - target = "generated/wayland/viewporter.h") - - if ctx.dependency_satisfied('wayland-protocols-1-27'): - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "staging/content-type/content-type-v1", - target = "generated/wayland/content-type-v1.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "staging/content-type/content-type-v1", - target = "generated/wayland/content-type-v1.h") - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "staging/single-pixel-buffer/single-pixel-buffer-v1", - target = "generated/wayland/single-pixel-buffer-v1.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "staging/single-pixel-buffer/single-pixel-buffer-v1", - target = "generated/wayland/single-pixel-buffer-v1.h") - - - if ctx.dependency_satisfied('wayland-protocols-1-31'): - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "staging/fractional-scale/fractional-scale-v1", - target = "generated/wayland/fractional-scale-v1.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "staging/fractional-scale/fractional-scale-v1", - target = "generated/wayland/fractional-scale-v1.h") - - if ctx.dependency_satisfied('wayland-protocols-1-32'): - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "staging/cursor-shape/cursor-shape-v1", - target = "generated/wayland/cursor-shape-v1.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "staging/cursor-shape/cursor-shape-v1", - target = "generated/wayland/cursor-shape-v1.h") - ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "unstable/tablet/tablet-unstable-v2", - target = "generated/wayland/tablet-unstable-v2.c") - ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR, - protocol = "unstable/tablet/tablet-unstable-v2", - target = "generated/wayland/tablet-unstable-v2.h") - - ctx(features = "ebml_header", target = "generated/ebml_types.h") - ctx(features = "ebml_definitions", target = "generated/ebml_defs.inc") - - def swift(task): - src = [x.abspath() for x in task.inputs] - bridge = ctx.path.find_node("osdep/macOS_swift_bridge.h").abspath() - tgt = task.outputs[0].abspath() - header = task.outputs[1].abspath() - module = task.outputs[2].abspath() - module_name = os.path.basename(module).rsplit(".", 1)[0] - - cmd = [ ctx.env.SWIFT ] - cmd.extend(ctx.env.SWIFT_FLAGS) - cmd.extend([ - "-module-name", module_name, - "-emit-module-path", module, - "-import-objc-header", bridge, - "-emit-objc-header-path", header, - "-o", tgt, - ]) - cmd.extend(src) - cmd.extend([ "-I.", "-I%s" % ctx.srcnode.abspath() ]) - - return task.exec_command(cmd) - - if ctx.dependency_satisfied('cocoa') and ctx.dependency_satisfied('swift'): - swift_source = [ - ( "osdep/macos/log_helper.swift" ), - ( "osdep/macos/libmpv_helper.swift" ), - ( "osdep/macos/mpv_helper.swift" ), - ( "osdep/macos/swift_extensions.swift" ), - ( "osdep/macos/swift_compat.swift" ), - ( "osdep/macos/remote_command_center.swift", "macos-media-player" ), - ( "video/out/mac/common.swift" ), - ( "video/out/mac/view.swift" ), - ( "video/out/mac/window.swift" ), - ( "video/out/mac/title_bar.swift" ), - ( "video/out/cocoa_cb_common.swift", "macos-cocoa-cb" ), - ( "video/out/mac/gl_layer.swift", "macos-cocoa-cb" ), - ] - - ctx( - rule = swift, - source = ctx.filtered_sources(swift_source), - target = [ "osdep/macOS_swift.o", - "osdep/macOS_swift.h", - "osdep/macOS_swift.swiftmodule" ], - before = 'c', - ) - - ctx.env.append_value('LINKFLAGS', [ - '-Xlinker', '-add_ast_path', - '-Xlinker', ctx.path.find_or_declare("osdep/macOS_swift.swiftmodule").abspath() - ]) - - if ctx.dependency_satisfied('cplayer'): - main_fn_c = ctx.pick_first_matching_dep([ - ( "osdep/main-fn-cocoa.c", "cocoa" ), - ( "osdep/main-fn-unix.c", "posix" ), - ( "osdep/main-fn-win.c", "win32-desktop" ), - ]) - - getch2_c = ctx.pick_first_matching_dep([ - ( "osdep/terminal-unix.c", "posix" ), - ( "osdep/terminal-win.c", "win32-desktop" ), - ( "osdep/terminal-dummy.c" ), - ]) - - timer_c = ctx.pick_first_matching_dep([ - ( "osdep/timer-win2.c", "os-win32" ), - ( "osdep/timer-darwin.c", "os-darwin" ), - ( "osdep/timer-linux.c", "posix" ), - ]) - - ipc_c = ctx.pick_first_matching_dep([ - ( "input/ipc-unix.c", "posix" ), - ( "input/ipc-win.c", "win32-desktop" ), - ( "input/ipc-dummy.c" ), - ]) - - subprocess_c = ctx.pick_first_matching_dep([ - ( "osdep/subprocess-posix.c", "posix" ), - ( "osdep/subprocess-win.c", "win32-desktop" ), - ( "osdep/subprocess-dummy.c" ), - ]) - - language_c = ctx.pick_first_matching_dep([ - ( "osdep/language-apple.c", "cocoa" ), - ( "osdep/language-win.c", "win32-desktop" ), - ( "osdep/language-posix.c" ), - ]) - - sources = [ - ## Audio - ( "audio/aframe.c" ), - ( "audio/chmap.c" ), - ( "audio/chmap_avchannel.c", "av-channel-layout" ), - ( "audio/chmap_sel.c" ), - ( "audio/decode/ad_lavc.c" ), - ( "audio/decode/ad_spdif.c" ), - ( "audio/filter/af_drop.c" ), - ( "audio/filter/af_format.c" ), - ( "audio/filter/af_lavcac3enc.c" ), - ( "audio/filter/af_rubberband.c", "rubberband" ), - ( "audio/filter/af_scaletempo.c" ), - ( "audio/filter/af_scaletempo2.c" ), - ( "audio/filter/af_scaletempo2_internals.c" ), - ( "audio/fmt-conversion.c" ), - ( "audio/format.c" ), - ( "audio/out/ao.c" ), - ( "audio/out/ao_alsa.c", "alsa" ), - ( "audio/out/ao_audiotrack.c", "android" ), - ( "audio/out/ao_audiounit.m", "audiounit" ), - ( "audio/out/ao_coreaudio.c", "coreaudio" ), - ( "audio/out/ao_coreaudio_chmap.c", "coreaudio || audiounit" ), - ( "audio/out/ao_coreaudio_exclusive.c", "coreaudio" ), - ( "audio/out/ao_coreaudio_properties.c", "coreaudio" ), - ( "audio/out/ao_coreaudio_utils.c", "coreaudio || audiounit" ), - ( "audio/out/ao_jack.c", "jack" ), - ( "audio/out/ao_lavc.c" ), - ( "audio/out/ao_null.c" ), - ( "audio/out/ao_openal.c", "openal" ), - ( "audio/out/ao_opensles.c", "opensles" ), - ( "audio/out/ao_oss.c", "oss-audio" ), - ( "audio/out/ao_pcm.c" ), - ( "audio/out/ao_pipewire.c", "pipewire" ), - ( "audio/out/ao_pulse.c", "pulse" ), - ( "audio/out/ao_sdl.c", "sdl2-audio" ), - ( "audio/out/ao_sndio.c", "sndio" ), - ( "audio/out/ao_wasapi.c", "wasapi" ), - ( "audio/out/ao_wasapi_changenotify.c", "wasapi" ), - ( "audio/out/ao_wasapi_utils.c", "wasapi" ), - ( "audio/out/buffer.c" ), - - ## Core - ( "common/av_common.c" ), - ( "common/av_log.c" ), - ( "common/codecs.c" ), - ( "common/common.c" ), - ( "common/encode_lavc.c" ), - ( "common/msg.c" ), - ( "common/playlist.c" ), - ( "common/recorder.c" ), - ( "common/stats.c" ), - ( "common/tags.c" ), - ( "common/version.c" ), - - ## Demuxers - ( "demux/codec_tags.c" ), - ( "demux/cue.c" ), - ( "demux/cache.c" ), - ( "demux/demux.c" ), - ( "demux/demux_cue.c" ), - ( "demux/demux_disc.c" ), - ( "demux/demux_edl.c" ), - ( "demux/demux_lavf.c" ), - ( "demux/demux_libarchive.c", "libarchive" ), - ( "demux/demux_mf.c" ), - ( "demux/demux_mkv.c" ), - ( "demux/demux_mkv_timeline.c" ), - ( "demux/demux_null.c" ), - ( "demux/demux_playlist.c" ), - ( "demux/demux_raw.c" ), - ( "demux/demux_timeline.c" ), - ( "demux/ebml.c" ), - ( "demux/packet.c" ), - ( "demux/timeline.c" ), - - ( "filters/f_async_queue.c" ), - ( "filters/f_autoconvert.c" ), - ( "filters/f_auto_filters.c" ), - ( "filters/f_decoder_wrapper.c" ), - ( "filters/f_demux_in.c" ), - ( "filters/f_hwtransfer.c" ), - ( "filters/f_lavfi.c" ), - ( "filters/f_output_chain.c" ), - ( "filters/f_swresample.c" ), - ( "filters/f_swscale.c" ), - ( "filters/f_utils.c" ), - ( "filters/filter.c" ), - ( "filters/frame.c" ), - ( "filters/user_filters.c" ), - - ## Input - ( "input/cmd.c" ), - ( "input/event.c" ), - ( "input/input.c" ), - ( "input/ipc.c" ), - ( ipc_c ), - ( "input/keycodes.c" ), - ( "input/sdl_gamepad.c", "sdl2-gamepad" ), - - ## Misc - ( "misc/bstr.c" ), - ( "misc/charset_conv.c" ), - ( "misc/dispatch.c" ), - ( "misc/jni.c", "android" ), - ( "misc/json.c" ), - ( "misc/language.c" ), - ( "misc/natural_sort.c" ), - ( "misc/node.c" ), - ( "misc/rendezvous.c" ), - ( "misc/random.c" ), - ( "misc/thread_pool.c" ), - ( "misc/thread_tools.c" ), - - ## Options - ( "options/m_config_core.c" ), - ( "options/m_config_frontend.c" ), - ( "options/m_option.c" ), - ( "options/m_property.c" ), - ( "options/options.c" ), - ( "options/parse_commandline.c" ), - ( "options/parse_configfile.c" ), - ( "options/path.c" ), - - ## Player - ( "player/audio.c" ), - ( "player/client.c" ), - ( "player/command.c" ), - ( "player/configfiles.c" ), - ( "player/external_files.c" ), - ( "player/javascript.c", "javascript" ), - ( "player/loadfile.c" ), - ( "player/lua.c", "lua" ), - ( "player/main.c" ), - ( "player/misc.c" ), - ( "player/osd.c" ), - ( "player/playloop.c" ), - ( "player/screenshot.c" ), - ( "player/scripting.c" ), - ( "player/sub.c" ), - ( "player/video.c" ), - - ## Streams - ( "stream/cookies.c" ), - ( "stream/dvb_tune.c", "dvbin" ), - ( "stream/stream.c" ), - ( "stream/stream_avdevice.c" ), - ( "stream/stream_bluray.c", "libbluray" ), - ( "stream/stream_cb.c" ), - ( "stream/stream_cdda.c", "cdda" ), - ( "stream/stream_concat.c" ), - ( "stream/stream_slice.c" ), - ( "stream/stream_dvb.c", "dvbin" ), - ( "stream/stream_dvdnav.c", "dvdnav" ), - ( "stream/stream_edl.c" ), - ( "stream/stream_file.c" ), - ( "stream/stream_lavf.c" ), - ( "stream/stream_libarchive.c", "libarchive" ), - ( "stream/stream_memory.c" ), - ( "stream/stream_mf.c" ), - ( "stream/stream_null.c" ), - - ## Subtitles - ( "sub/ass_mp.c" ), - ( "sub/dec_sub.c" ), - ( "sub/draw_bmp.c" ), - ( "sub/filter_regex.c", "posix" ), - ( "sub/filter_jsre.c", "javascript" ), - ( "sub/filter_sdh.c" ), - ( "sub/img_convert.c" ), - ( "sub/lavc_conv.c" ), - ( "sub/osd.c" ), - ( "sub/osd_libass.c" ), - ( "sub/sd_ass.c" ), - ( "sub/sd_lavc.c" ), - - ## Video - ( "video/csputils.c" ), - ( "video/cuda.c", "cuda-hwaccel" ), - ( "video/d3d.c", "d3d-hwaccel" ), - ( "video/drmprime.c", "drm" ), - ( "video/decode/vd_lavc.c" ), - ( "video/filter/refqueue.c" ), - ( "video/filter/vf_d3d11vpp.c", "d3d-hwaccel" ), - ( "video/filter/vf_fingerprint.c", "zimg" ), - ( "video/filter/vf_format.c" ), - ( "video/filter/vf_gpu.c", "egl-helpers && gl && egl" ), - ( "video/filter/vf_sub.c" ), - ( "video/filter/vf_vapoursynth.c", "vapoursynth" ), - ( "video/filter/vf_vavpp.c", "vaapi" ), - ( "video/filter/vf_vdpaupp.c", "vdpau" ), - ( "video/fmt-conversion.c" ), - ( "video/hwdec.c" ), - ( "video/image_loader.c" ), - ( "video/image_writer.c" ), - ( "video/img_format.c" ), - ( "video/mp_image.c" ), - ( "video/mp_image_pool.c" ), - ( "video/out/android_common.c", "android" ), - ( "video/out/aspect.c" ), - ( "video/out/bitmap_packer.c" ), - ( "video/out/cocoa/events_view.m", "cocoa" ), - ( "video/out/cocoa/video_view.m", "cocoa" ), - ( "video/out/cocoa/window.m", "cocoa" ), - ( "video/out/cocoa_common.m", "cocoa" ), - ( "video/out/d3d11/context.c", "d3d11" ), - ( "video/out/d3d11/hwdec_d3d11va.c", "d3d11 && d3d-hwaccel" ), - ( "video/out/d3d11/hwdec_dxva2dxgi.c", "d3d11 && d3d9-hwaccel" ), - ( "video/out/d3d11/ra_d3d11.c", "d3d11" ), - ( "video/out/dither.c" ), - ( "video/out/dr_helper.c" ), - ( "video/out/drm_atomic.c", "drm" ), - ( "video/out/drm_common.c", "drm" ), - ( "video/out/drm_prime.c", "drm" ), - ( "video/out/filter_kernels.c" ), - ( "video/out/gpu/context.c" ), - ( "video/out/gpu/d3d11_helpers.c", "d3d11 || egl-angle-win32" ), - ( "video/out/gpu/error_diffusion.c" ), - ( "video/out/gpu/hwdec.c" ), - ( "video/out/gpu/lcms.c" ), - ( "video/out/gpu/libmpv_gpu.c" ), - ( "video/out/gpu/osd.c" ), - ( "video/out/gpu/ra.c" ), - ( "video/out/gpu/shader_cache.c" ), - ( "video/out/gpu/spirv.c" ), - ( "video/out/gpu/spirv_shaderc.c", "shaderc" ), - ( "video/out/gpu/user_shaders.c" ), - ( "video/out/gpu/utils.c" ), - ( "video/out/gpu/video.c" ), - ( "video/out/gpu/video_shaders.c" ), - ( "video/out/gpu_next/context.c", "libplacebo-next" ), - ( "video/out/hwdec/hwdec_aimagereader.c", "android-media-ndk" ), - ( "video/out/hwdec/hwdec_cuda.c", "cuda-interop" ), - ( "video/out/hwdec/hwdec_cuda_gl.c", "cuda-interop && gl" ), - ( "video/out/hwdec/hwdec_cuda_vk.c", "cuda-interop && vulkan" ), - ( "video/out/hwdec/hwdec_drmprime.c", "drm" ), - ( "video/out/hwdec/hwdec_drmprime_overlay.c","drm" ), - ( "video/out/hwdec/hwdec_vaapi.c", "vaapi-egl || vaapi-libplacebo" ), - ( "video/out/hwdec/hwdec_vulkan.c", "vulkan-interop" ), - ( "video/out/hwdec/dmabuf_interop_gl.c", "dmabuf-interop-gl" ), - ( "video/out/hwdec/dmabuf_interop_pl.c", "dmabuf-interop-pl" ), - ( "video/out/hwdec/dmabuf_interop_wl.c", "dmabuf-wayland" ), - ( "video/out/libmpv_sw.c" ), - ( "video/out/placebo/ra_pl.c", "libplacebo" ), - ( "video/out/placebo/utils.c", "libplacebo" ), - ( "video/out/opengl/angle_dynamic.c", "egl-angle" ), - ( "video/out/opengl/common.c", "gl" ), - ( "video/out/opengl/context.c", "gl" ), - ( "video/out/opengl/context_android.c", "egl-android" ), - ( "video/out/opengl/context_angle.c", "egl-angle-win32" ), - ( "video/out/opengl/context_cocoa.c", "gl-cocoa" ), - ( "video/out/opengl/context_drm_egl.c", "egl-drm" ), - ( "video/out/opengl/context_dxinterop.c","gl-dxinterop" ), - ( "video/out/opengl/context_glx.c", "gl-x11" ), - ( "video/out/opengl/context_rpi.c", "rpi" ), - ( "video/out/opengl/context_wayland.c", "gl-wayland" ), - ( "video/out/opengl/context_win.c", "gl-win32" ), - ( "video/out/opengl/context_x11egl.c", "egl-x11" ), - ( "video/out/opengl/egl_helpers.c", "egl-helpers" ), - ( "video/out/opengl/formats.c", "gl" ), - ( "video/out/opengl/hwdec_d3d11egl.c", "d3d-hwaccel && egl-angle" ), - ( "video/out/opengl/hwdec_dxva2egl.c", "d3d9-hwaccel && egl-angle" ), - ( "video/out/opengl/hwdec_dxva2gldx.c", "gl-dxinterop-d3d9" ), - ( "video/out/opengl/hwdec_ios.m", "ios-gl" ), - ( "video/out/opengl/hwdec_osx.c", "videotoolbox-gl" ), - ( "video/out/opengl/hwdec_rpi.c", "rpi-mmal" ), - ( "video/out/opengl/hwdec_vdpau.c", "vdpau-gl-x11" ), - ( "video/out/opengl/libmpv_gl.c", "gl" ), - ( "video/out/opengl/ra_gl.c", "gl" ), - ( "video/out/opengl/utils.c", "gl" ), - ( "video/out/present_sync.c", "wayland || x11" ), - ( "video/out/wldmabuf/context_wldmabuf.c", "dmabuf-wayland" ), - ( "video/out/wldmabuf/ra_wldmabuf.c", "dmabuf-wayland" ), - ( "video/out/vo.c" ), - ( "video/out/vo_caca.c", "caca" ), - ( "video/out/vo_direct3d.c", "direct3d" ), - ( "video/out/vo_drm.c", "drm" ), - ( "video/out/vo_gpu.c" ), - ( "video/out/vo_gpu_next.c", "libplacebo-next" ), - ( "video/out/vo_image.c" ), - ( "video/out/vo_lavc.c" ), - ( "video/out/vo_libmpv.c" ), - ( "video/out/vo_mediacodec_embed.c", "android" ), - ( "video/out/vo_null.c" ), - ( "video/out/vo_rpi.c", "rpi-mmal" ), - ( "video/out/vo_sdl.c", "sdl2-video" ), - ( "video/out/vo_sixel.c", "sixel" ), - ( "video/out/vo_kitty.c" ), - ( "video/out/vo_tct.c" ), - ( "video/out/vo_vaapi.c", "vaapi-x11 && gpl" ), - ( "video/out/vo_dmabuf_wayland.c", "dmabuf-wayland" ), - ( "video/out/vo_vdpau.c", "vdpau" ), - ( "video/out/vo_wlshm.c", "wayland && memfd_create" ), - ( "video/out/vo_x11.c" , "x11" ), - ( "video/out/vo_xv.c", "xv" ), - ( "video/out/vulkan/context.c", "vulkan" ), - ( "video/out/vulkan/context_display.c", "vulkan && vk-khr-display" ), - ( "video/out/vulkan/context_android.c", "vulkan && android" ), - ( "video/out/vulkan/context_wayland.c", "vulkan && wayland" ), - ( "video/out/vulkan/context_win.c", "vulkan && win32-desktop" ), - ( "video/out/vulkan/context_xlib.c", "vulkan && x11" ), - ( "video/out/vulkan/utils.c", "vulkan" ), - ( "video/out/w32_common.c", "win32-desktop" ), - ( "generated/wayland/single-pixel-buffer-v1.c", "wayland-protocols-1-27" ), - ( "generated/wayland/content-type-v1.c", "wayland-protocols-1-27" ), - ( "generated/wayland/fractional-scale-v1.c", "wayland-protocols-1-31"), - ( "generated/wayland/cursor-shape-v1.c", "wayland-protocols-1-32"), - ( "generated/wayland/tablet-unstable-v2.c", "wayland-protocols-1-32"), - ( "generated/wayland/idle-inhibit-unstable-v1.c", "wayland" ), - ( "generated/wayland/presentation-time.c", "wayland" ), - ( "generated/wayland/xdg-decoration-unstable-v1.c", "wayland" ), - ( "generated/wayland/xdg-shell.c", "wayland" ), - ( "generated/wayland/linux-dmabuf-unstable-v1.c", "wayland" ), - ( "generated/wayland/viewporter.c", "wayland" ), - ( "video/out/wayland_common.c", "wayland" ), - ( "video/out/win32/displayconfig.c", "win32-desktop" ), - ( "video/out/win32/droptarget.c", "win32-desktop" ), - ( "video/out/win_state.c"), - ( "video/out/x11_common.c", "x11" ), - ( "video/repack.c" ), - ( "video/sws_utils.c" ), - ( "video/zimg.c", "zimg" ), - ( "video/vaapi.c", "vaapi" ), - ( "video/vdpau.c", "vdpau" ), - ( "video/vdpau_mixer.c", "vdpau" ), - - ## osdep - ( getch2_c ), - ( "osdep/io.c" ), - ( "osdep/threads.c" ), - ( "osdep/timer.c" ), - ( timer_c ), - ( "osdep/polldev.c", "posix" ), - - ( language_c ), - - ( "osdep/android/strnlen.c", "android"), - ( "osdep/apple_utils.c", "cocoa" ), - ( "osdep/glob-win.c", "glob-win32" ), - ( "osdep/macosx_application.m", "cocoa" ), - ( "osdep/macosx_events.m", "cocoa" ), - ( "osdep/macosx_menubar.m", "cocoa" ), - ( "osdep/macosx_touchbar.m", "macos-touchbar" ), - ( "osdep/mpv.rc", "win32-executable" ), - ( "osdep/path-darwin.c", "os-darwin"), - ( "osdep/path-macosx.m", "cocoa" ), - ( "osdep/path-unix.c", "posix && !os-darwin" ), - ( "osdep/path-uwp.c", "uwp" ), - ( "osdep/path-win.c", "win32-desktop" ), - ( "osdep/semaphore_osx.c" ), - ( "osdep/subprocess.c" ), - ( subprocess_c ), - ( "osdep/w32_keyboard.c", "os-cygwin" ), - ( "osdep/w32_keyboard.c", "os-win32" ), - ( "osdep/win32/pthread.c", "win32-internal-pthreads"), - ( "osdep/windows_utils.c", "os-cygwin" ), - ( "osdep/windows_utils.c", "os-win32" ), - - ## tree_allocator - "ta/ta.c", "ta/ta_talloc.c", "ta/ta_utils.c" - ] - - if ctx.dependency_satisfied('win32-executable'): - from waflib import TaskGen - - TaskGen.declare_chain( - name = 'windres', - rule = '${WINDRES} ${WINDRES_FLAGS} ${SRC} ${TGT}', - ext_in = '.rc', - ext_out = '-rc.o', - color = 'PINK') - - ctx.env.WINDRES_FLAGS = [ - '--include-dir={0}'.format(ctx.bldnode.abspath()), - '--include-dir={0}'.format(ctx.srcnode.abspath()), - '--codepage=65001' # Unicode codepage - ] - - for node in 'osdep/mpv.exe.manifest etc/mpv-icon.ico'.split(): - ctx.add_manual_dependency( - ctx.path.find_node('osdep/mpv.rc'), - ctx.path.find_node(node)) - - version = ctx.bldnode.find_node('generated/version.h') - if version: - ctx.add_manual_dependency( - ctx.path.find_node('osdep/mpv.rc'), - version) - - if ctx.dependency_satisfied('cplayer'): - ctx( - target = "objects", - source = ctx.filtered_sources(sources), - use = ctx.dependencies_use(), - includes = _all_includes(ctx), - features = "c", - ) - - syms = False - if ctx.dependency_satisfied('cplugins'): - syms = True - ctx.load("syms") - - additional_objects = [] - if ctx.dependency_satisfied('swift'): - additional_objects.append("osdep/macOS_swift.o") - - if ctx.dependency_satisfied('cplayer'): - ctx( - target = "mpv", - source = main_fn_c, - use = ctx.dependencies_use() + ['objects'], - add_objects = additional_objects, - includes = _all_includes(ctx), - features = "c cprogram" + (" syms" if syms else ""), - export_symbols_def = "libmpv/mpv.def", # for syms=True - install_path = ctx.env.BINDIR - ) - for f in ['mpv.conf', 'input.conf', 'mplayer-input.conf', \ - 'restore-old-bindings.conf']: - ctx.install_as(os.path.join(ctx.env.DOCDIR, f), - os.path.join('etc/', f)) - - if ctx.env.DEST_OS == 'win32': - wrapctx = ctx( - target = "mpv", - source = ['osdep/win32-console-wrapper.c'], - features = "c cprogram", - install_path = ctx.env.BINDIR - ) - - wrapctx.env.cprogram_PATTERN = "%s.com" - wrapflags = ['-municode', '-Wl,--subsystem,console'] - wrapctx.env.CFLAGS = ctx.env.CFLAGS + wrapflags - wrapctx.env.LAST_LINKFLAGS = ctx.env.LAST_LINKFLAGS + wrapflags - - build_shared = ctx.dependency_satisfied('libmpv-shared') - build_static = ctx.dependency_satisfied('libmpv-static') - if build_shared or build_static: - if build_shared: - waftoolsdir = os.path.join(os.path.dirname(__file__), "waftools") - ctx.load("syms", tooldir=waftoolsdir) - vre = '#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION\((.*), (.*)\)' - libmpv_header = ctx.path.find_node("libmpv/client.h").read() - major, minor = re.search(vre, libmpv_header).groups() - libversion = major + '.' + minor + '.0' - - def _build_libmpv(shared): - features = "c " - if shared: - features += "cshlib syms" - else: - features += "cstlib" - - libmpv_kwargs = { - "target": "mpv", - "source": ctx.filtered_sources(sources), - "use": ctx.dependencies_use(), - "add_objects": additional_objects, - "includes": [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \ - ctx.dependencies_includes(), - "features": features, - "export_symbols_def": "libmpv/mpv.def", - "install_path": ctx.env.LIBDIR, - "install_path_implib": ctx.env.LIBDIR, - } - - if shared and ctx.dependency_satisfied('android'): - # for Android we just add the linker flag without version - # as we still need the SONAME for proper linkage. - # (LINKFLAGS logic taken from waf's apply_vnum in ccroot.py) - v=ctx.env.SONAME_ST%'libmpv.so' - ctx.env.append_value('LINKFLAGS',v.split()) - else: - # for all other configurations we want SONAME to be used - libmpv_kwargs["vnum"] = libversion - - if shared and ctx.env.DEST_OS == 'win32': - libmpv_kwargs["install_path"] = ctx.env.BINDIR - - ctx(**libmpv_kwargs) - - if build_shared: - _build_libmpv(True) - if build_static: - _build_libmpv(False) - - def get_deps(): - res = [] - for k in ctx.env.keys(): - if (k.startswith("LIB_") and k != "LIB_ST") \ - or (k.startswith("STLIB_") and k != "STLIB_ST" and k != "STLIB_MARKER"): - for l in ctx.env[k]: - if l in res: - res.remove(l) - res.append(l) - return " ".join(["-l" + l for l in res]) - - ctx( - target = 'libmpv/mpv.pc', - source = 'libmpv/mpv.pc.in', - features = 'subst', - PREFIX = ctx.env.PREFIX, - LIBDIR = ctx.env.LIBDIR, - INCDIR = ctx.env.INCLUDEDIR, - VERSION = libversion, - PRIV_LIBS = get_deps(), - ) - - headers = ["client.h", "render.h", - "render_gl.h", "stream_cb.h"] - for f in headers: - ctx.install_as(ctx.env.INCLUDEDIR + '/mpv/' + f, 'libmpv/' + f) - - ctx.install_as(ctx.env.LIBDIR + '/pkgconfig/mpv.pc', 'libmpv/mpv.pc') - - if ctx.dependency_satisfied('html-build'): - _build_html(ctx) - - if ctx.dependency_satisfied('manpage-build'): - _build_man(ctx) - - if ctx.dependency_satisfied('pdf-build'): - _build_pdf(ctx) - - if ctx.dependency_satisfied('cplayer'): - - if ctx.env.ZSHDIR: - ctx.install_as(ctx.env.ZSHDIR + '/_mpv', 'etc/_mpv.zsh') - - if ctx.env.BASHDIR: - ctx.install_as(ctx.env.BASHDIR + '/mpv', 'etc/mpv.bash-completion') - - ctx.install_files( - ctx.env.DATADIR + '/applications', - ['etc/mpv.desktop'] ) - - ctx.install_files( - ctx.env.DATADIR + '/metainfo', - ['etc/mpv.metainfo.xml'] ) - - ctx.install_files(ctx.env.CONFDIR, ['etc/encoding-profiles.conf'] ) - - for size in '16x16 32x32 64x64 128x128'.split(): - ctx.install_as( - ctx.env.DATADIR + '/icons/hicolor/' + size + '/apps/mpv.png', - 'etc/mpv-icon-8bit-' + size + '.png') - - ctx.install_as( - ctx.env.DATADIR + '/icons/hicolor/scalable/apps/mpv.svg', - 'etc/mpv-gradient.svg') - - ctx.install_files( - ctx.env.DATADIR + '/icons/hicolor/symbolic/apps', - ['etc/mpv-symbolic.svg'])