diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index bff74cd16c..785a39b1e7 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -57,6 +57,7 @@ Interface changes - add `--tone-mapping-visualize` - change type of `--brightness`, `--saturation`, `--contrast`, `--hue` and `--gamma` to float. + - add `platform` property --- mpv 0.35.0 --- - add the `--vo=gpu-next` video output driver, as well as the options `--allow-delayed-peak-detect`, `--builtin-scalers`, diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index ea305af615..4f9e68d567 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -3341,6 +3341,12 @@ Property list somewhat weird form (apparently "hex BCD"), indicating the release version of the libass library linked to mpv. +``platform`` + Returns a string describing what target platform mpv was built for. The value + of this is dependent on what the underlying build system detects. Some of the + most common values are: ``windows``, ``darwin`` (macos or ios), ``linux``, + ``android``, and ``freebsd``. Note that this is not a complete listing. + ``options/`` (RW) The value of option ``--``. Most options can be changed at runtime by writing to this property. Note that many options require reloading the file diff --git a/meson.build b/meson.build index 527ac58bb1..8f90aa9137 100644 --- a/meson.build +++ b/meson.build @@ -1652,6 +1652,7 @@ sys.stdout.write(features) feature_str = run_command(python, '-c', feature_sort, feature_keys, check: true).stdout() conf_data.set_quoted('FULLCONFIG', feature_str) conf_data.set_quoted('MPV_CONFDIR', join_paths(get_option('prefix'), get_option('sysconfdir'), 'mpv')) +conf_data.set_quoted('PLATFORM', host_machine.system()) configure_file(output : 'config.h', configuration : conf_data) message('List of enabled features: ' + feature_str) diff --git a/player/command.c b/player/command.c index 2ad83cb703..a284a4c047 100644 --- a/player/command.c +++ b/player/command.c @@ -3293,6 +3293,12 @@ static int mp_property_libass_version(void *ctx, struct m_property *prop, return m_property_int64_ro(action, arg, ass_library_version()); } +static int mp_property_platform(void *ctx, struct m_property *prop, + int action, void *arg) +{ + return m_property_strdup_ro(action, arg, PLATFORM); +} + static int mp_property_alias(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3916,6 +3922,7 @@ static const struct m_property mp_properties_base[] = { {"mpv-configuration", mp_property_configuration}, {"ffmpeg-version", mp_property_ffmpeg}, {"libass-version", mp_property_libass_version}, + {"platform", mp_property_platform}, {"options", mp_property_options}, {"file-local-options", mp_property_local_options}, diff --git a/waftools/checks/custom.py b/waftools/checks/custom.py index 79bfcf2ade..9e060c522d 100644 --- a/waftools/checks/custom.py +++ b/waftools/checks/custom.py @@ -6,7 +6,7 @@ import os __all__ = ["check_pthreads", "check_iconv", "check_lua", "check_cocoa", "check_wl_protocols", "check_swift", - "check_egl_provider"] + "check_egl_provider", "check_platform"] pthreads_program = load_fragment('pthreads.c') @@ -168,3 +168,13 @@ def check_egl_provider(minVersion=None, name='egl', check=None): else: return False return fn + +# Strictly for matching the platform names to what +# the meson build calls them. +def check_platform(ctx): + if ctx.env.DEST_OS == "win32": + return "windows" + elif ctx.dependency_satisfied("android"): + return "android" + else: + return ctx.env.DEST_OS diff --git a/wscript b/wscript index 567fc67ff0..da90c97253 100644 --- a/wscript +++ b/wscript @@ -1054,6 +1054,8 @@ def configure(ctx): ctx.parse_dependencies(video_output_features) ctx.parse_dependencies(hwaccel_features) + ctx.define('PLATFORM', check_platform(ctx)) + if ctx.options.SWIFT_FLAGS: ctx.env.SWIFT_FLAGS.extend(split(ctx.options.SWIFT_FLAGS))