Skip to content

Commit 8a02710

Browse files
committed
rust/language.rs: add full BCP 47 compliant pipeline
- Removes custom, incomplete language mapping tables - Adds validation for the BCP 47-defined format - Compares all components separately instead of treating them as the same entity - Adds canonicalization support for ISO 639-{1,2t,2b,3} It is not overly strict in validation to preserve compatibility with "custom" tags. If the language can be parsed and normalized, this will be used; otherwise, it falls back to direct string comparison. For BCP 47 components, all mismatches are penalized equally, with 1000 points deducted per mismatch. This value can be adjusted if needed. This commit should greatly improve support for matching language tags consisting of more than just the primary language and region.
1 parent f25525a commit 8a02710

20 files changed

+486
-385
lines changed

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ repos:
1919
hooks:
2020
- id: codespell
2121
args: ["--ignore-words-list", "datas,DNE,enew,HDA,numer,ontop,optionA,Paeth,pathc,inout"]
22-
exclude: ^misc/language.c$

meson.build

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ project('mpv',
1111
'cpp_std=c++20',
1212
'cpp_eh=default',
1313
'warning_level=2',
14+
'rust_std=2021',
15+
'build.rust_std=2021',
1416
]
1517
)
1618

@@ -140,7 +142,6 @@ sources = files(
140142
'misc/dispatch.c',
141143
'misc/io_utils.c',
142144
'misc/json.c',
143-
'misc/language.c',
144145
'misc/natural_sort.c',
145146
'misc/node.c',
146147
'misc/path_utils.c',
@@ -1763,6 +1764,8 @@ major = client_h_define.split('|')[0].split('<<')[0].strip('() ')
17631764
minor = client_h_define.split('|')[1].strip('() ')
17641765
client_api_version = major + '.' + minor + '.0'
17651766

1767+
subdir('rust')
1768+
17661769
libmpv = library('mpv', sources, dependencies: dependencies, gnu_symbol_visibility: 'hidden',
17671770
include_directories: incdir_public,
17681771
link_args: cc.get_supported_link_arguments(['-Wl,-Bsymbolic']),
@@ -1780,7 +1783,7 @@ if get_option('libmpv')
17801783
install_headers(headers, subdir: 'mpv')
17811784

17821785
# Allow projects to build with libmpv by cloning into ./subprojects/mpv
1783-
libmpv_dep = declare_dependency(include_directories: incdir_public, link_with: libmpv)
1786+
libmpv_dep = declare_dependency(include_directories: incdir_public, link_with: [libmpv, libmpv_rs])
17841787
meson.override_dependency('mpv', libmpv_dep)
17851788
endif
17861789

@@ -1815,8 +1818,8 @@ if get_option('cplayer')
18151818
rename: 'mpv.svg')
18161819
install_data('etc/mpv-symbolic.svg', install_dir: join_paths(hicolor_dir, 'symbolic', 'apps'))
18171820

1818-
mpv = executable('mpv', main_fn_source, objects: libmpv.extract_all_objects(recursive: true), dependencies: dependencies,
1819-
win_subsystem: get_option('win32-subsystem'), install: true)
1821+
mpv = executable('mpv', main_fn_source, objects: libmpv.extract_all_objects(recursive: true),
1822+
dependencies: dependencies + libmpv_rs_dep, win_subsystem: get_option('win32-subsystem'), install: true)
18201823

18211824
if win32 and get_option('win32-subsystem') != 'console'
18221825
wrapper_sources= 'osdep/win32-console-wrapper.c'

0 commit comments

Comments
 (0)