-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for the meson build system as well as a bit of documentation. Compatibility with the existing waf build is maintained.
- Loading branch information
1 parent
f610fe1
commit ff32286
Showing
19 changed files
with
2,240 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,5 @@ | |
|
||
/old_build | ||
/Makefile | ||
|
||
/subprojects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# 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+. | ||
|
||
### 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
generated/TOOLS/osxbundle/mpv.app/Contents/Resources/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
input = join_paths(source_root, 'TOOLS', 'osxbundle', | ||
'mpv.app', 'Contents', 'Resources', 'icon.icns') | ||
osxbundle = custom_target('osxbundle', | ||
input: input, | ||
output: 'icon.icns.inc', | ||
command: [file2string, '@INPUT@', '@OUTPUT@'], | ||
) | ||
sources += osxbundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
icons = ['16', '32', '64', '128'] | ||
foreach size: icons | ||
name = 'mpv-icon-8bit-'+size+'x'+size+'.png' | ||
icon = custom_target(name, | ||
input: join_paths(source_root, 'etc', name), | ||
output: name + '.inc', | ||
command: [file2string, '@INPUT@', '@OUTPUT@'], | ||
) | ||
sources += icon | ||
endforeach | ||
|
||
etc_files = ['input.conf', 'builtin.conf'] | ||
foreach file: etc_files | ||
etc_file = custom_target(file, | ||
input: join_paths(source_root, 'etc', file), | ||
output: file + '.inc', | ||
command: [file2string, '@INPUT@', '@OUTPUT@'], | ||
) | ||
sources += etc_file | ||
endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ebml_defs = custom_target('ebml_defs', | ||
output: 'ebml_defs.inc', | ||
command: [matroska, '--generate-definitions', '@OUTPUT@'], | ||
) | ||
|
||
ebml_types = custom_target('ebml_types', | ||
output: 'ebml_types.h', | ||
command: [matroska, '--generate-header', '@OUTPUT@'], | ||
) | ||
|
||
version_h = custom_target('version.h', | ||
output: 'version.h', | ||
command: [version_py, '@OUTPUT@'], | ||
build_always_stale: true, | ||
) | ||
|
||
sources += [ebml_defs, ebml_types, version_h] | ||
|
||
# Meson doesn't allow having multiple build targets with the same name in the same file. | ||
# Just generate the com in here for windows builds. | ||
if win32 and get_option('cplayer') | ||
features += 'win32-executable' | ||
wrapper_flags = ['-municode', '-Wl,--subsystem,console'] | ||
wrapper_sources= '../osdep/win32-console-wrapper.c' | ||
executable('mpv', wrapper_sources, c_args: wrapper_flags, link_args: wrapper_flags, | ||
name_suffix: 'com', install: true) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# custom swift targets | ||
bridge = join_paths(source_root, 'osdep/macOS_swift_bridge.h') | ||
header = join_paths(build_root, 'osdep/macOS_swift.h') | ||
module = join_paths(build_root, 'osdep/macOS_swift.swiftmodule') | ||
target = join_paths(build_root, 'osdep/macOS_swift.o') | ||
|
||
swift_flags = ['-frontend', '-c', '-sdk', macos_sdk_path, | ||
'-enable-objc-interop', '-emit-objc-header', '-parse-as-library'] | ||
|
||
if swift_ver.version_compare('>=6.0') | ||
swift_flags += ['-swift-version', '5'] | ||
endif | ||
|
||
if get_option('debug') | ||
swift_flags += '-g' | ||
endif | ||
|
||
if get_option('optimization') != '0' | ||
swift_flags += '-O' | ||
endif | ||
|
||
if macos_10_11_features.allowed() | ||
swift_flags += ['-D', 'HAVE_MACOS_10_11_FEATURES'] | ||
endif | ||
|
||
if macos_10_14_features.allowed() | ||
swift_flags += ['-D', 'HAVE_MACOS_10_14_FEATURES'] | ||
endif | ||
|
||
extra_flags = get_option('swift-flags').split() | ||
swift_flags += extra_flags | ||
|
||
swift_compile = [swift_prog, swift_flags, '-module-name', 'macOS_swift', | ||
'-emit-module-path', '@OUTPUT0@', '-import-objc-header', bridge, | ||
'-emit-objc-header-path', '@OUTPUT1@', '-o', '@OUTPUT2@', | ||
'@INPUT@', '-I.', '-I' + source_root] | ||
|
||
swift_targets = custom_target('swift_targets', | ||
input: swift_sources, | ||
output: ['macOS_swift.swiftmodule', 'macOS_swift.h', 'macOS_swift.o'], | ||
command: swift_compile, | ||
) | ||
sources += swift_targets | ||
|
||
swift_lib_dir_py = find_program(join_paths(tools_directory, 'macos-swift-lib-directory.py')) | ||
swift_lib_dir = run_command(swift_lib_dir_py, swift_prog.full_path(), check: true).stdout() | ||
message('Detected Swift library directory: ' + swift_lib_dir) | ||
|
||
# linker flags | ||
swift_link_flags = ['-L' + swift_lib_dir, '-Xlinker', '-rpath', | ||
'-Xlinker', swift_lib_dir, '-rdynamic', '-Xlinker', | ||
'-add_ast_path', '-Xlinker', module] | ||
if swift_ver.version_compare('>=5.0') | ||
swift_link_flags += ['-Xlinker', '-rpath', '-Xlinker', | ||
'/usr/lib/swift', '-L/usr/lib/swift'] | ||
endif | ||
add_project_link_arguments(swift_link_flags, language: ['c', 'objc']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
defaults_js = custom_target('defaults.js', | ||
input: join_paths(source_root, 'player', 'javascript', 'defaults.js'), | ||
output: 'defaults.js.inc', | ||
command: [file2string, '@INPUT@', '@OUTPUT@'], | ||
) | ||
sources += defaults_js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
lua_files = ['defaults.lua', 'assdraw.lua', 'options.lua', 'osc.lua', | ||
'ytdl_hook.lua', 'stats.lua', 'console.lua', 'auto_profiles.lua'] | ||
foreach file: lua_files | ||
lua_file = custom_target(file, | ||
input: join_paths(source_root, 'player', 'lua', file), | ||
output: file + '.inc', | ||
command: [file2string, '@INPUT@', '@OUTPUT@'], | ||
) | ||
sources += lua_file | ||
endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
osd_font = custom_target('osd_font.otf', | ||
input: join_paths(source_root, 'sub', 'osd_font.otf'), | ||
output: 'osd_font.otf.inc', | ||
command: [file2string, '@INPUT@', '@OUTPUT@'], | ||
) | ||
sources += osd_font |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
wl_protocol_dir = wayland['deps'][2].get_variable(pkgconfig: 'pkgdatadir') | ||
protocols = [[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], | ||
[wl_protocol_dir, 'stable/presentation-time/presentation-time.xml'], | ||
[wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'], | ||
[wl_protocol_dir, 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml']] | ||
wl_protocols_source = [] | ||
wl_protocols_headers = [] | ||
|
||
foreach p: protocols | ||
xml = join_paths(p) | ||
wl_protocols_source += custom_target(xml.underscorify() + '_c', | ||
input: xml, | ||
output: '@BASENAME@.c', | ||
command: [wayland['scanner'], 'private-code', '@INPUT@', '@OUTPUT@'], | ||
) | ||
wl_protocols_headers += custom_target(xml.underscorify() + '_h', | ||
input: xml, | ||
output: '@BASENAME@.h', | ||
command: [wayland['scanner'], 'client-header', '@INPUT@', '@OUTPUT@'], | ||
) | ||
endforeach | ||
|
||
lib_client_protocols = static_library('protocols', | ||
wl_protocols_source + wl_protocols_headers, | ||
dependencies: wayland['deps'][0]) | ||
|
||
client_protocols = declare_dependency(link_with: lib_client_protocols, | ||
sources: wl_protocols_headers) | ||
|
||
dependencies += [client_protocols, wayland['deps']] | ||
|
||
sources += ['video/out/wayland_common.c'] |
Oops, something went wrong.