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.
This commit is contained in:
LaserEyess 2022-11-12 09:27:07 -05:00 committed by Dudemanguy
parent 60a263246e
commit f2cce5f38f
44 changed files with 61 additions and 4336 deletions

View File

@ -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

39
.gitignore vendored
View File

@ -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

View File

@ -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.

View File

@ -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 <https://waf.io/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.

View File

@ -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

View File

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -26,7 +26,6 @@
#include <stddef.h>
#include <stdint.h>
/* New symbols must still be added to libmpv/mpv.def. */
#ifdef _WIN32
#define MPV_EXPORT __declspec(dllexport)
#elif defined(__GNUC__) || defined(__clang__)

View File

@ -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

View File

@ -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")

View File

@ -1,2 +0,0 @@
#!/usr/bin/env python
# encoding: utf-8

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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__)

View File

@ -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)

View File

@ -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))

View File

@ -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

View File

@ -1,15 +0,0 @@
#include <AudioToolbox/AudioToolbox.h>
#include <AudioUnit/AudioUnit.h>
#include <CoreAudio/CoreAudioTypes.h>
int main(int argc, char **argv)
{
AudioComponentDescription desc = (AudioComponentDescription) {
.componentType = kAudioUnitType_Output,
.componentSubType = kAudioUnitSubType_RemoteIO,
.componentManufacturer = kAudioUnitManufacturer_Apple,
};
AudioComponentFindNext(NULL, &desc);
return 0;
}

View File

@ -1,16 +0,0 @@
#import <CoreServices/CoreServices.h>
#import <OpenGL/OpenGL.h>
#import <Cocoa/Cocoa.h>
#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);
}
}

View File

@ -1,15 +0,0 @@
#include <CoreAudio/CoreAudio.h>
#include <AudioToolbox/AudioToolbox.h>
#include <AudioUnit/AudioUnit.h>
int main(int argc, char **argv)
{
AudioComponentDescription desc = (AudioComponentDescription) {
.componentType = kAudioUnitType_Output,
.componentSubType = kAudioUnitSubType_DefaultOutput,
.componentManufacturer = kAudioUnitManufacturer_Apple,
};
AudioComponentFindNext(NULL, &desc);
return 0;
}

View File

@ -1,15 +0,0 @@
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <stddef.h>
#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;
}

View File

@ -1,30 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <iconv.h>
#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;
}

View File

@ -1,6 +0,0 @@
#include <pthread.h>
static void *func(void *arg) { return arg; }
int main(void) {
pthread_t tid;
return pthread_create (&tid, 0, func, 0) != 0;
}

View File

@ -1,18 +0,0 @@
#pragma GCC push_options
#pragma GCC target("sse4.1")
#include <smmintrin.h>
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;
}

View File

@ -1,7 +0,0 @@
#import <AppKit/AppKit.h>
int main(int argc, char **argv)
{
[[NSTouchBar alloc] init];
return 0;
}

View File

@ -1,16 +0,0 @@
#include <malloc.h>
#include <stdlib.h>
#include <process.h>
#include <audioclient.h>
#include <endpointvolume.h>
#include <mmdeviceapi.h>
#include <avrt.h>
const GUID *check1[] = {
&IID_IAudioClient,
&IID_IAudioRenderClient,
&IID_IAudioClient,
&IID_IAudioEndpointVolume,
};
int main(void) {
return 0;
}

View File

@ -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)

View File

@ -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__

View File

@ -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)}

View File

@ -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')

View File

@ -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)

1152
wscript

File diff suppressed because it is too large Load Diff

View File

@ -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'])