qt: playlist: use item title if available
[vlc.git] / contrib / src / gen-meson-crossfile.py
blob26e0faafb6881e6809c9789c758908f23412410e
1 #!/usr/bin/env python3
2 import os
3 import argparse
4 import shlex
6 # Argument parsing
7 parser = argparse.ArgumentParser(
8 description="Generate a meson crossfile based on environment variables")
9 parser.add_argument('file', type=argparse.FileType('w', encoding='UTF-8'),
10 help="output file")
11 args = parser.parse_args()
13 # Helper to add env variable value to crossfile
14 def _add_environ_val(meson_key, env_key):
15 env_value = os.environ.get(env_key, '')
16 args.file.write("{} = '{}'\n".format(meson_key, env_value))
18 # Helper to add env variable array to crossfile
19 def _add_environ_arr(meson_key, env_key):
20 env_values = shlex.split(os.environ.get(env_key, ''))
21 arr_string = (', '.join("'" + item + "'" for item in env_values))
22 args.file.write("{} = [{}]\n".format(meson_key, arr_string))
24 # Generate meson crossfile
25 args.file.write("# Automatically generated by contrib makefile\n")
27 # Binaries section
28 args.file.write("\n[binaries]\n")
29 _add_environ_val('c', 'CC')
30 _add_environ_val('cpp', 'CXX')
31 _add_environ_val('ar', 'AR')
32 _add_environ_val('strip', 'STRIP')
33 _add_environ_val('pkgconfig', 'PKG_CONFIG')
34 _add_environ_val('windres', 'WINDRES')
36 # Properties section
37 args.file.write("\n[properties]\n")
38 args.file.write("needs_exe_wrapper = true\n")
39 _add_environ_arr('c_args', 'CFLAGS')
40 _add_environ_arr('c_link_args', 'LDFLAGS')
41 _add_environ_arr('cpp_args', 'CXXFLAGS')
42 _add_environ_arr('cpp_link_args', 'LDFLAGS')
44 # Host machine section
45 args.file.write("\n[host_machine]\n")
46 _add_environ_val('system', 'HOST_SYSTEM')
47 _add_environ_val('cpu_family', 'HOST_ARCH')
48 args.file.write("endian = 'little'\n")
50 # Get first part of triplet
51 cpu = os.environ.get('HOST', '').split('-')[0]
52 args.file.write("cpu = '{}'\n".format(cpu))