build: introduce meson build recipes
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Daniel P. Berrangé
3 years ago
0 | #!/usr/bin/python3 | |
1 | ||
2 | import subprocess | |
3 | ||
4 | rpms = subprocess.check_output(["rpm", "-qa"]) | |
5 | rpms = rpms.decode("utf-8").split("\n") | |
6 | rpms.sort() | |
7 | ||
8 | for rpm in rpms: | |
9 | if rpm == "": | |
10 | continue | |
11 | print(rpm, end="\r\n") |
0 | #!/usr/bin/env python3 | |
1 | ||
2 | import os | |
3 | import sys | |
4 | ||
5 | meson_build_root = sys.argv[1] | |
6 | file_name = sys.argv[2] | |
7 | ||
8 | meson_dist_root = os.environ['MESON_DIST_ROOT'] | |
9 | ||
10 | os.system('cp {0} {1}'.format( | |
11 | os.path.join(meson_build_root, file_name), | |
12 | os.path.join(meson_dist_root, file_name) | |
13 | )) |
0 | #!/usr/bin/env python3 | |
1 | ||
2 | import os | |
3 | ||
4 | meson_source_root = os.environ['MESON_SOURCE_ROOT'] | |
5 | ||
6 | os.chdir(meson_source_root) | |
7 | os.system('git log --pretty=format:"* %aN <%aE>" | sort -u') |
0 | #!/usr/bin/python3 | |
1 | ||
2 | import os | |
3 | import subprocess | |
4 | import sys | |
5 | import tempfile | |
6 | ||
7 | if len(sys.argv) != 13: | |
8 | print("syntax: %s BUILD-DIR PREFIX WIXL-ARCH MSIFILE WXS " | |
9 | "BUILDENV WIXL-HEAT-PATH WIXL-PATH " | |
10 | "HAVE_SPICE HAVE_VNC HAVE_LIBVIRT HAVE_OVIRT" % sys.argv[0]) | |
11 | sys.exit(1) | |
12 | ||
13 | builddir = sys.argv[1] | |
14 | prefix = sys.argv[2] | |
15 | arch = sys.argv[3] | |
16 | msifile = sys.argv[4] | |
17 | wxs = sys.argv[5] | |
18 | buildenv = sys.argv[6] | |
19 | ||
20 | wixl_heat = sys.argv[7] | |
21 | wixl = sys.argv[8] | |
22 | ||
23 | have_spice = sys.argv[9] | |
24 | have_vnc = sys.argv[10] | |
25 | have_libvirt = sys.argv[11] | |
26 | have_ovirt = sys.argv[12] | |
27 | ||
28 | def build_msi(): | |
29 | if "DESTDIR" not in os.environ: | |
30 | print("$DESTDIR environment variable missing. " | |
31 | "Please run 'ninja install' before attempting to " | |
32 | "build the MSI binary, and set DESTDIR to point " | |
33 | "to the installation virtual root.", file=sys.stderr) | |
34 | sys.exit(1) | |
35 | vroot = os.environ["DESTDIR"] | |
36 | ||
37 | manifest = [] | |
38 | for root, subFolder, files in os.walk(vroot): | |
39 | for item in files: | |
40 | path = str(os.path.join(root,item)) | |
41 | manifest.append(path) | |
42 | ||
43 | wxsfiles = subprocess.run( | |
44 | [ | |
45 | wixl_heat, | |
46 | "-p", vroot + prefix + "/", | |
47 | "--component-group", "CG.virt-viewer", | |
48 | "--var", "var.DESTDIR", | |
49 | "--directory-ref", "INSTALLDIR", | |
50 | ], | |
51 | input="\n".join(manifest), | |
52 | encoding="utf8", | |
53 | check=True, | |
54 | capture_output=True) | |
55 | ||
56 | wxsfilelist = os.path.join(builddir, "data", "virt-viewer-files.wxs") | |
57 | with open(wxsfilelist, "w") as fh: | |
58 | print(wxsfiles.stdout, file=fh) | |
59 | ||
60 | wixlenv = os.environ | |
61 | wixlenv["MANUFACTURER"] = "Virt Viewer Project" | |
62 | ||
63 | subprocess.run( | |
64 | [ | |
65 | wixl, | |
66 | "-D", "SourceDir=" + prefix, | |
67 | "-D", "DESTDIR=" + vroot + prefix, | |
68 | "-D", "HaveSpiceGtk=" + have_spice, | |
69 | "-D", "HaveGtkVnc=" + have_vnc, | |
70 | "-D", "HaveLibvirt=" + have_libvirt, | |
71 | "-D", "HaveOvirt=" + have_ovirt, | |
72 | "--arch", arch, | |
73 | "-o", msifile, | |
74 | wxs, wxsfilelist, | |
75 | ], | |
76 | check=True, | |
77 | env=wixlenv) | |
78 | ||
79 | build_msi() |
0 | #!/usr/bin/env python3 | |
1 | ||
2 | import os | |
3 | import os.path | |
4 | import subprocess | |
5 | import sys | |
6 | ||
7 | if "MESON_INSTALL_PREFIX" not in os.environ: | |
8 | print("This is meant to be run from Meson only", file=sys.stderr) | |
9 | sys.exit(1) | |
10 | ||
11 | # If installing into a DESTDIR we assume | |
12 | # this is a distro packaging build, so skip actions | |
13 | if os.environ.get("DESTDIR", "") != "": | |
14 | sys.exit(0) | |
15 | ||
16 | if len(sys.argv) != 4: | |
17 | print("%s UPDATE-MIME-DATABASE UPDATE-ICON-CACHE UPDATE-DESKTOP-DATABASE") | |
18 | sys.exit(1) | |
19 | ||
20 | prefix = os.environ["MESON_INSTALL_PREFIX"] | |
21 | ||
22 | update_mime_database = sys.argv[1] | |
23 | update_icon_cache = sys.argv[2] | |
24 | update_desktop_database = sys.argv[3] | |
25 | ||
26 | if update_mime_database != "": | |
27 | print("Updating mime database") | |
28 | subprocess.run([update_mime_database, | |
29 | os.path.join(prefix, "share", "mime")], | |
30 | check=True) | |
31 | else: | |
32 | print("Skipping mime database update") | |
33 | ||
34 | if update_icon_cache != "": | |
35 | print("Updating icon cache") | |
36 | subprocess.run([update_icon_cache, "-qtf", | |
37 | os.path.join(prefix, "share", "icons", "hicolor")], | |
38 | check=True) | |
39 | else: | |
40 | print("Skipping icon cache update") | |
41 | ||
42 | if update_desktop_database != "": | |
43 | print("Updating desktop database") | |
44 | subprocess.run([update_desktop_database, "-q", | |
45 | os.path.join(prefix, "share", "applications")], | |
46 | check=True) | |
47 | else: | |
48 | print("Skipping desktop database update") |
0 | #!/usr/bin/python3 | |
1 | ||
2 | import sys | |
3 | import subprocess | |
4 | ||
5 | windres = sys.argv[1] | |
6 | icondir = sys.argv[2] | |
7 | manifestdir = sys.argv[3] | |
8 | rcfile = sys.argv[4] | |
9 | objfile = sys.argv[5] | |
10 | ||
11 | subprocess.check_call([ | |
12 | windres, | |
13 | "-DICONDIR=\\\"" + icondir + "\\\"", | |
14 | "-DMANIFESTDIR=\\\"" + manifestdir + "\\\"", | |
15 | "-i", rcfile, | |
16 | "-o", objfile, | |
17 | ]) |
0 | /* Enable compile-time and run-time bounds-checking, and some warnings. */ | |
1 | #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ | |
2 | # define _FORTIFY_SOURCE 2 | |
3 | #endif | |
4 | ||
5 | /* Name of package */ | |
6 | #define PACKAGE "virt-viewer" | |
7 | ||
8 | /* GETTEXT package name */ | |
9 | #define GETTEXT_PACKAGE "virt-viewer" | |
10 | ||
11 | /* GLib logging domain */ | |
12 | #define G_LOG_DOMAIN "virt-viewer" | |
13 | ||
14 | /* Enable GNU extensions */ | |
15 | #define _GNU_SOURCE | |
16 | ||
17 | /* Build version details */ | |
18 | #define BUILDID "-@BUILDID@" | |
19 | ||
20 | /* Define to the full name and version of this package. */ | |
21 | #define PACKAGE_STRING "virt-viewer @VERSION@" | |
22 | ||
23 | /* Define to the version of this package. */ | |
24 | #define PACKAGE_VERSION "@VERSION@" | |
25 | ||
26 | /* OS ID for this build */ | |
27 | #define REMOTE_VIEWER_OS_ID "@OS_ID@" | |
28 | ||
29 | /* Version number of package */ | |
30 | #define VERSION "@VERSION@" | |
31 | ||
32 | /* Have gtk-vnc? */ | |
33 | #mesondefine HAVE_GTK_VNC | |
34 | ||
35 | /* Have libvirt? */ | |
36 | #mesondefine HAVE_LIBVIRT | |
37 | ||
38 | /* Have libgovirt? */ | |
39 | #mesondefine HAVE_OVIRT | |
40 | ||
41 | /* Define to 1 if you have the `ovirt_api_search_vms' function. */ | |
42 | #undef HAVE_OVIRT_API_SEARCH_VMS | |
43 | ||
44 | /* Define to 1 if you have the `ovirt_cluster_get_data_center' function. */ | |
45 | #undef HAVE_OVIRT_CLUSTER_GET_DATA_CENTER | |
46 | ||
47 | /* Have support for data center */ | |
48 | #undef HAVE_OVIRT_DATA_CENTER | |
49 | ||
50 | /* Define to 1 if you have the `ovirt_host_get_cluster' function. */ | |
51 | #undef HAVE_OVIRT_HOST_GET_CLUSTER | |
52 | ||
53 | /* Define to 1 if you have the `ovirt_storage_domain_get_disks' function. */ | |
54 | #undef HAVE_OVIRT_STORAGE_DOMAIN_GET_DISKS | |
55 | ||
56 | /* Define to 1 if you have the `ovirt_vm_get_host' function. */ | |
57 | #undef HAVE_OVIRT_VM_GET_HOST | |
58 | ||
59 | /* Have spice-gtk? */ | |
60 | #mesondefine HAVE_SPICE_GTK | |
61 | ||
62 | /* Have vte? */ | |
63 | #mesondefine HAVE_VTE |
0 | if host_machine.system() != 'windows' | |
1 | desktop = 'remote-viewer.desktop' | |
2 | ||
3 | i18n.merge_file ( | |
4 | desktop, | |
5 | type: 'desktop', | |
6 | input: desktop + '.in', | |
7 | output: desktop, | |
8 | po_dir: po_dir, | |
9 | install: true, | |
10 | install_dir: join_paths(datadir, 'applications') | |
11 | ) | |
12 | ||
13 | mimetypes = 'virt-viewer-mime.xml' | |
14 | ||
15 | i18n.merge_file ( | |
16 | mimetypes, | |
17 | type: 'xml', | |
18 | input: mimetypes + '.in', | |
19 | output: mimetypes, | |
20 | data_dirs: i18n_itsdir, | |
21 | po_dir: po_dir, | |
22 | install: true, | |
23 | install_dir: join_paths(datadir, 'mime', 'packages') | |
24 | ) | |
25 | ||
26 | metainfo = 'remote-viewer.appdata.xml' | |
27 | ||
28 | i18n.merge_file ( | |
29 | metainfo, | |
30 | type: 'xml', | |
31 | input: metainfo + '.in', | |
32 | output: metainfo, | |
33 | po_dir: po_dir, | |
34 | install: true, | |
35 | install_dir: join_paths(datadir, 'metainfo') | |
36 | ) | |
37 | endif | |
38 | ||
39 | with_msi=false | |
40 | if host_machine.system() == 'windows' | |
41 | wixl = find_program('wixl', required: false) | |
42 | wixl_heat = find_program('wixl-heat', required: false) | |
43 | ||
44 | if wixl.found() and wixl_heat.found() | |
45 | with_msi=true | |
46 | endif | |
47 | endif | |
48 | ||
49 | if with_msi | |
50 | buildenv = custom_target( | |
51 | 'buildenv.txt', | |
52 | output: ['buildenv.txt'], | |
53 | command: [ | |
54 | python3, | |
55 | join_paths(meson.source_root(), 'build-aux', 'buildenv.py') | |
56 | ], | |
57 | capture: true) | |
58 | ||
59 | msi_filename = 'virt-viewer-@0@-@1@.msi'.format(wixl_arch, meson.project_version()) | |
60 | ||
61 | if libvirt_dep.found() | |
62 | wixl_libvirt_arg = 'True' | |
63 | else | |
64 | wixl_libvirt_arg = 'False' | |
65 | endif | |
66 | ||
67 | if spice_gtk_dep.found() | |
68 | wixl_spice_gtk_arg = 'True' | |
69 | else | |
70 | wixl_spice_gtk_arg = 'False' | |
71 | endif | |
72 | ||
73 | if gtk_vnc_dep.found() | |
74 | wixl_gtk_vnc_arg = 'True' | |
75 | else | |
76 | wixl_gtk_vnc_arg = 'False' | |
77 | endif | |
78 | ||
79 | if govirt_dep.found() | |
80 | wixl_govirt_arg = 'True' | |
81 | else | |
82 | wixl_govirt_arg = 'False' | |
83 | endif | |
84 | ||
85 | wxsfile = configure_file( | |
86 | input: 'virt-viewer.wxs.in', | |
87 | output: 'virt-viewer.wxs', | |
88 | configuration: conf_data | |
89 | ) | |
90 | ||
91 | msi = custom_target( | |
92 | msi_filename, | |
93 | input: [wxsfile, buildenv], | |
94 | output: [msi_filename], | |
95 | build_by_default: false, | |
96 | command: [ | |
97 | python3, | |
98 | join_paths(meson.source_root(), 'build-aux', 'msitool.py'), | |
99 | meson.build_root(), | |
100 | prefix, | |
101 | wixl_arch, | |
102 | join_paths(meson.build_root(), 'data', msi_filename), | |
103 | wxsfile, | |
104 | buildenv, | |
105 | wixl_heat, | |
106 | wixl, | |
107 | wixl_spice_gtk_arg, | |
108 | wixl_gtk_vnc_arg, | |
109 | wixl_libvirt_arg, | |
110 | wixl_govirt_arg, | |
111 | ], | |
112 | ) | |
113 | ||
114 | endif |
0 | logo_icon_sizes = [ | |
1 | '16x16', | |
2 | '22x22', | |
3 | '24x24', | |
4 | '32x32', | |
5 | '48x48', | |
6 | '256x256', | |
7 | 'scalable', | |
8 | ] | |
9 | ||
10 | misc_icon_sizes = [ | |
11 | '24x24', | |
12 | 'scalable', | |
13 | ] | |
14 | ||
15 | misc_icon_names = [ | |
16 | 'usb', | |
17 | ] | |
18 | ||
19 | foreach icon_size: logo_icon_sizes | |
20 | if icon_size == 'scalable' | |
21 | src_icon = 'virt-viewer.svg' | |
22 | else | |
23 | src_icon = 'virt-viewer.png' | |
24 | endif | |
25 | install_data( | |
26 | join_paths(icon_size, src_icon), | |
27 | install_dir: join_paths(datadir, 'icons', 'hicolor', icon_size, 'apps') | |
28 | ) | |
29 | endforeach | |
30 | ||
31 | foreach icon_size: misc_icon_sizes | |
32 | foreach icon_name: misc_icon_names | |
33 | if icon_size == 'scalable' | |
34 | src_icon = 'virt-viewer-' + icon_name + '.svg' | |
35 | else | |
36 | src_icon = 'virt-viewer-' + icon_name + '.png' | |
37 | endif | |
38 | install_data( | |
39 | join_paths(icon_size, src_icon), | |
40 | install_dir: join_paths(datadir, 'icons', 'hicolor', icon_size, 'devices') | |
41 | ) | |
42 | endforeach | |
43 | endforeach | |
44 | ||
45 | ||
46 | if host_machine.system() == 'windows' | |
47 | icotool = find_program('icotool') | |
48 | ||
49 | infiles = [] | |
50 | foreach size: ['16', '32', '48', '256'] | |
51 | infiles += [join_paths('@0@x@0@'.format(size), 'virt-viewer.png')] | |
52 | endforeach | |
53 | ||
54 | outfile = 'virt-viewer.ico' | |
55 | ||
56 | icofile = custom_target( | |
57 | outfile, | |
58 | output : outfile, | |
59 | input : infiles, | |
60 | command : [icotool, '-c', '-o', '@OUTPUT@', '@INPUT@']) | |
61 | endif |
0 | custom_target( | |
1 | 'viewer-viewer-man', | |
2 | output : 'virt-viewer.1', | |
3 | input : 'virt-viewer.pod', | |
4 | command : [ | |
5 | pod2man, | |
6 | '--section=1', | |
7 | '--center=Virtualization Support', | |
8 | '--name=Virt-Viewer', | |
9 | '--release=Virt-Viewer @0@'.format(meson.project_version()), | |
10 | '@INPUT@', '@OUTPUT@' | |
11 | ], | |
12 | install : true, | |
13 | install_dir : join_paths(mandir, 'man1') | |
14 | ) | |
15 | ||
16 | custom_target( | |
17 | 'remote-viewer-man', | |
18 | output : 'remote-viewer.1', | |
19 | input : 'remote-viewer.pod', | |
20 | command : [ | |
21 | pod2man, | |
22 | '--section=1', | |
23 | '--center=Virtualization Support', | |
24 | '--name=Remote-Viewer', | |
25 | '--release=Virt-Viewer @0@'.format(meson.project_version()), | |
26 | '@INPUT@', '@OUTPUT@' | |
27 | ], | |
28 | install : true, | |
29 | install_dir : join_paths(mandir, 'man1') | |
30 | ) |
0 | project( | |
1 | 'virt-viewer','c', | |
2 | version: '3.0', | |
3 | license: 'GPLv3+', | |
4 | default_options: [ | |
5 | 'buildtype=debugoptimized', | |
6 | 'b_pie=true', | |
7 | 'c_std=gnu99', | |
8 | 'warning_level=1', | |
9 | ], | |
10 | meson_version: '>= 0.54.0' | |
11 | ) | |
12 | ||
13 | pod2man = find_program('pod2man') | |
14 | ||
15 | cc = meson.get_compiler('c') | |
16 | python3 = find_program('python3', required: true) | |
17 | # Python3 < 3.7 treats the C locale as 7-bit only. We must force env vars so | |
18 | # it treats it as UTF-8 regardless of the user's locale. | |
19 | runutf8 = [ 'LC_ALL=', 'LANG=C', 'LC_CTYPE=en_US.UTF-8' ] | |
20 | git = run_command('test', '-d', '.git').returncode() == 0 | |
21 | ||
22 | conf_data = configuration_data() | |
23 | conf_data.set('VERSION', meson.project_version()) | |
24 | conf_data.set('PACKAGE_STRING', 'virt-viewer ' + meson.project_version()) | |
25 | ||
26 | # Keep these two definitions in agreement. | |
27 | glib_min_version='>=2.40' | |
28 | glib_min_version_symbol='GLIB_VERSION_2_40' | |
29 | ||
30 | # Keep these two definitions in agreement. | |
31 | gtk_min_version='>=3.12' | |
32 | gtk_min_version_symbol='GDK_VERSION_3_12' | |
33 | ||
34 | libxml_min_version='>=2.6.0' | |
35 | libvirt_min_version='>=1.2.8' | |
36 | libvirt_glib_min_version='>=0.1.8' | |
37 | gtk_vnc_min_version='>=0.4.0' | |
38 | spice_gtk_min_version='>=0.35' | |
39 | spice_protocol_min_version='>=0.12.7' | |
40 | govirt_min_version='>=0.3.3' | |
41 | rest_min_version='>=0.8' | |
42 | vte_min_version='>=0.46.0' | |
43 | bash_completion_version='2.0' | |
44 | ||
45 | add_global_arguments('-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_min_version_symbol), language: 'c') | |
46 | add_global_arguments('-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_min_version_symbol), language: 'c') | |
47 | ||
48 | add_global_arguments('-DGDK_VERSION_MIN_REQUIRED=@0@'.format(gtk_min_version_symbol), language: 'c') | |
49 | add_global_arguments('-DGDK_VERSION_MAX_ALLOWED=@0@'.format(gtk_min_version_symbol), language: 'c') | |
50 | ||
51 | cc_flags = [] | |
52 | ||
53 | git_werror = get_option('git_werror') | |
54 | if git_werror.enabled() or git_werror.auto() and git | |
55 | cc_flags += [ '-Werror' ] | |
56 | endif | |
57 | ||
58 | cc_flags += [ | |
59 | '-fno-common', | |
60 | '-W', | |
61 | '-Wabsolute-value', | |
62 | '-Waddress', | |
63 | '-Waddress-of-packed-member', | |
64 | '-Waggressive-loop-optimizations', | |
65 | '-Wall', | |
66 | '-Wattribute-warning', | |
67 | '-Wattributes', | |
68 | '-Wbool-compare', | |
69 | '-Wbool-operation', | |
70 | '-Wbuiltin-declaration-mismatch', | |
71 | '-Wbuiltin-macro-redefined', | |
72 | '-Wcannot-profile', | |
73 | '-Wcast-align', | |
74 | '-Wcast-align=strict', | |
75 | '-Wcast-function-type', | |
76 | '-Wchar-subscripts', | |
77 | '-Wclobbered', | |
78 | '-Wcomment', | |
79 | '-Wcomments', | |
80 | '-Wcoverage-mismatch', | |
81 | '-Wcpp', | |
82 | '-Wdangling-else', | |
83 | '-Wdate-time', | |
84 | '-Wdeprecated-declarations', | |
85 | '-Wdesignated-init', | |
86 | '-Wdouble-promotion', | |
87 | '-Wdiscarded-array-qualifiers', | |
88 | '-Wdiscarded-qualifiers', | |
89 | '-Wdiv-by-zero', | |
90 | '-Wduplicated-cond', | |
91 | '-Wduplicate-decl-specifier', | |
92 | '-Wempty-body', | |
93 | '-Wendif-labels', | |
94 | '-Wexpansion-to-defined', | |
95 | '-Wextra', | |
96 | '-Wformat-contains-nul', | |
97 | '-Wformat-extra-args', | |
98 | '-Wformat-nonliteral', | |
99 | '-Wformat-security', | |
100 | '-Wformat-y2k', | |
101 | '-Wformat-zero-length', | |
102 | '-Wframe-address', | |
103 | '-Wfree-nonheap-object', | |
104 | '-Whsa', | |
105 | '-Wif-not-aligned', | |
106 | '-Wignored-attributes', | |
107 | '-Wignored-qualifiers', | |
108 | '-Wimplicit', | |
109 | '-Wimplicit-function-declaration', | |
110 | '-Wimplicit-int', | |
111 | '-Wincompatible-pointer-types', | |
112 | '-Winit-self', | |
113 | '-Winline', | |
114 | '-Wint-conversion', | |
115 | '-Wint-in-bool-context', | |
116 | '-Wint-to-pointer-cast', | |
117 | '-Winvalid-memory-model', | |
118 | '-Winvalid-pch', | |
119 | '-Wlogical-not-parentheses', | |
120 | '-Wlogical-op', | |
121 | '-Wmain', | |
122 | '-Wmaybe-uninitialized', | |
123 | '-Wmemset-elt-size', | |
124 | '-Wmemset-transposed-args', | |
125 | '-Wmisleading-indentation', | |
126 | '-Wmissing-attributes', | |
127 | '-Wmissing-braces', | |
128 | '-Wmissing-declarations', | |
129 | '-Wmissing-field-initializers', | |
130 | '-Wmissing-include-dirs', | |
131 | '-Wmissing-parameter-type', | |
132 | '-Wmissing-profile', | |
133 | '-Wmissing-prototypes', | |
134 | '-Wmultichar', | |
135 | '-Wmultistatement-macros', | |
136 | '-Wnarrowing', | |
137 | '-Wnested-externs', | |
138 | '-Wnonnull', | |
139 | '-Wnonnull-compare', | |
140 | '-Wnull-dereference', | |
141 | '-Wodr', | |
142 | '-Wold-style-declaration', | |
143 | '-Wold-style-definition', | |
144 | '-Wopenmp-simd', | |
145 | '-Woverflow', | |
146 | '-Woverride-init', | |
147 | '-Wpacked-bitfield-compat', | |
148 | '-Wpacked-not-aligned', | |
149 | '-Wparentheses', | |
150 | '-Wpointer-arith', | |
151 | '-Wpointer-compare', | |
152 | '-Wpointer-sign', | |
153 | '-Wpointer-to-int-cast', | |
154 | '-Wpragmas', | |
155 | '-Wpsabi', | |
156 | '-Wrestrict', | |
157 | '-Wreturn-local-addr', | |
158 | '-Wreturn-type', | |
159 | '-Wscalar-storage-order', | |
160 | '-Wsequence-point', | |
161 | '-Wshadow', | |
162 | '-Wshift-count-negative', | |
163 | '-Wshift-count-overflow', | |
164 | '-Wshift-negative-value', | |
165 | '-Wsizeof-array-argument', | |
166 | '-Wsizeof-pointer-div', | |
167 | '-Wsizeof-pointer-memaccess', | |
168 | '-Wstrict-aliasing', | |
169 | '-Wstrict-prototypes', | |
170 | '-Wstringop-truncation', | |
171 | '-Wsuggest-attribute=cold', | |
172 | '-Wsuggest-attribute=const', | |
173 | '-Wsuggest-attribute=format', | |
174 | '-Wsuggest-attribute=noreturn', | |
175 | '-Wsuggest-attribute=pure', | |
176 | '-Wsuggest-final-methods', | |
177 | '-Wsuggest-final-types', | |
178 | '-Wswitch', | |
179 | '-Wswitch-bool', | |
180 | '-Wswitch-unreachable', | |
181 | '-Wsync-nand', | |
182 | '-Wtautological-compare', | |
183 | '-Wtrampolines', | |
184 | '-Wtrigraphs', | |
185 | '-Wtype-limits', | |
186 | '-Wuninitialized', | |
187 | '-Wunknown-pragmas', | |
188 | '-Wunused', | |
189 | '-Wunused-but-set-parameter', | |
190 | '-Wunused-but-set-variable', | |
191 | '-Wunused-function', | |
192 | '-Wunused-label', | |
193 | '-Wunused-local-typedefs', | |
194 | '-Wunused-parameter', | |
195 | '-Wunused-result', | |
196 | '-Wunused-value', | |
197 | '-Wunused-variable', | |
198 | '-Wvarargs', | |
199 | '-Wvariadic-macros', | |
200 | '-Wvector-operation-performance', | |
201 | '-Wvla', | |
202 | '-Wvolatile-register-var', | |
203 | '-Wwrite-strings', | |
204 | ] | |
205 | ||
206 | # gcc --help=warnings outputs | |
207 | ptrdiff_max = cc.sizeof('ptrdiff_t', prefix: '#include <stddef.h>') | |
208 | size_max = cc.sizeof('size_t', prefix: '#include <stdint.h>') | |
209 | # Compute max safe object size by checking ptrdiff_t and size_t sizes. | |
210 | # Ideally we would get PTRDIFF_MAX and SIZE_MAX values but it would | |
211 | # give us (2147483647L) and we would have to remove the () and the suffix | |
212 | # in order to convert it to numbers to be able to pick the smaller one. | |
213 | alloc_max = run_command( | |
214 | 'python3', '-c', | |
215 | 'print(min(2**(@0@ * 8 - 1) - 1, 2**(@1@ * 8) - 1))'.format(ptrdiff_max, size_max), | |
216 | ) | |
217 | cc_flags += [ | |
218 | '-Walloc-size-larger-than=@0@'.format(alloc_max.stdout().strip()), | |
219 | '-Warray-bounds=2', | |
220 | '-Wattribute-alias=2', | |
221 | '-Wformat-overflow=2', | |
222 | '-Wformat-truncation=2', | |
223 | '-Wimplicit-fallthrough=5', | |
224 | '-Wnormalized=nfc', | |
225 | '-Wshift-overflow=2', | |
226 | '-Wstringop-overflow=2', | |
227 | '-Wunused-const-variable=2', | |
228 | '-Wvla-larger-then=4031', | |
229 | ] | |
230 | ||
231 | cc_flags += [ | |
232 | # So we have -W enabled, and then have to explicitly turn off... | |
233 | '-Wno-sign-compare', | |
234 | ||
235 | # We do "bad" function casts all the time for event callbacks | |
236 | '-Wno-cast-function-type', | |
237 | ||
238 | # Clang incorrectly complains about dup typedefs win gnu99 mode | |
239 | # so use this Clang-specific arg to keep it quiet | |
240 | '-Wno-typedef-redefinition', | |
241 | ||
242 | # We don't use -Wc++-compat so we have to enable it explicitly | |
243 | '-Wjump-misses-init', | |
244 | ||
245 | # -Wswitch is enabled but that doesn't report missing enums if a default: | |
246 | # is present | |
247 | '-Wswitch-enum', | |
248 | ||
249 | # -Wformat=2 implies -Wformat-nonliteral so we need to manually exclude it | |
250 | '-Wno-format-nonliteral', | |
251 | ||
252 | # -Wformat enables this by default, and we should keep it, | |
253 | # but need to rewrite various areas of code first | |
254 | '-Wno-format-truncation', | |
255 | ||
256 | # This should be < 256 really. Currently we're down to 4096, | |
257 | # but using 1024 bytes sized buffers (mostly for virStrerror) | |
258 | # stops us from going down further | |
259 | '-Wframe-larger-than=4096', | |
260 | ||
261 | # extra special flags | |
262 | '-fexceptions', | |
263 | '-fasynchronous-unwind-tables', | |
264 | ||
265 | # Need -fipa-pure-const in order to make -Wsuggest-attribute=pure | |
266 | # fire even without -O. | |
267 | '-fipa-pure-const', | |
268 | ||
269 | # We should eventually enable this, but right now there are at | |
270 | # least 75 functions triggering warnings. | |
271 | '-Wno-suggest-attribute=pure', | |
272 | '-Wno-suggest-attribute=const', | |
273 | ] | |
274 | ||
275 | # on aarch64 error: -fstack-protector not supported for this target | |
276 | if host_machine.cpu_family() != 'aarch64' | |
277 | if host_machine.system() in [ 'linux', 'freebsd', 'windows' ] | |
278 | # we prefer -fstack-protector-strong but fallback to -fstack-protector-all | |
279 | fstack_cflags = cc.first_supported_argument([ | |
280 | '-fstack-protector-strong', | |
281 | '-fstack-protector-all', | |
282 | ]) | |
283 | cc_flags += fstack_cflags | |
284 | ||
285 | # When building with mingw using -fstack-protector requires libssp library | |
286 | # which is included by using -fstack-protector with linker. | |
287 | if fstack_cflags.length() == 1 and host_machine.system() == 'windows' | |
288 | add_project_link_arguments(fstack_cflags, language: 'c') | |
289 | endif | |
290 | endif | |
291 | endif | |
292 | ||
293 | # Clang complains about unused static inline functions which are common | |
294 | # with G_DEFINE_AUTOPTR_CLEANUP_FUNC. | |
295 | w_unused_function_args = ['-Wunused-function', '-Werror'] | |
296 | w_unused_function_code = ''' | |
297 | static inline void foo(void) {} | |
298 | ||
299 | int main(void) { return 0; } | |
300 | ''' | |
301 | # -Wunused-function is implied by -Wall, we must turn it off explicitly. | |
302 | if not cc.compiles(w_unused_function_code, args: w_unused_function_args) | |
303 | cc_flags += ['-Wno-unused-function'] | |
304 | endif | |
305 | ||
306 | cc_flags_disabled = [ | |
307 | # In meson this is specified using 'c_std=gnu99' in project() function. | |
308 | '-std=gnu99', | |
309 | ||
310 | # don't care about C++ compiler compat | |
311 | '-Wc++-compat', | |
312 | '-Wabi', | |
313 | '-Wdeprecated', | |
314 | ||
315 | # Don't care about ancient C standard compat | |
316 | '-Wtraditional', | |
317 | '-Wtraditional-conversion', | |
318 | ||
319 | # Ignore warnings in /usr/include | |
320 | '-Wsystem-headers', | |
321 | ||
322 | # Happy for compiler to add struct padding | |
323 | '-Wpadded', | |
324 | ||
325 | # GCC very confused with -O2 | |
326 | '-Wunreachable-code', | |
327 | ||
328 | # Too many to deal with | |
329 | '-Wconversion', | |
330 | '-Wsign-conversion', | |
331 | ||
332 | # Need to allow bad cast for execve() | |
333 | '-Wcast-qual', | |
334 | ||
335 | # We need to use long long in many places | |
336 | '-Wlong-long', | |
337 | ||
338 | # We allow manual list of all enum cases without default | |
339 | '-Wswitch-default', | |
340 | ||
341 | # Not a problem since we don't use -fstrict-overflow | |
342 | '-Wstrict-overflow', | |
343 | ||
344 | # Not a problem since we don't use -funsafe-loop-optimizations | |
345 | '-Wunsafe-loop-optimizations', | |
346 | ||
347 | # gcc 4.4.6 complains this is C++ only; gcc 4.7.0 implies this from -Wall | |
348 | '-Wenum-compare', | |
349 | ||
350 | # gcc 5.1 -Wformat-signedness mishandles enums, not ready for prime time | |
351 | '-Wformat-signedness', | |
352 | ||
353 | # Several conditionals expand the same on both branches depending on the | |
354 | # particular platform/architecture | |
355 | '-Wduplicated-branches', | |
356 | ||
357 | # > This warning does not generally indicate that there is anything wrong | |
358 | # > with your code; it merely indicates that GCC's optimizers are unable | |
359 | # > to handle the code effectively. | |
360 | # Source: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html | |
361 | '-Wdisabled-optimization', | |
362 | ||
363 | # Various valid glib APIs/macros trigger this warning | |
364 | '-Wbad-function-cast', | |
365 | ||
366 | # We might fundamentally need some of these disabled forever, but | |
367 | # ideally we'd turn many of them on | |
368 | '-Wfloat-equal', | |
369 | '-Wpacked', | |
370 | '-Wunused-macros', | |
371 | '-Woverlength-strings', | |
372 | '-Wstack-protector', | |
373 | '-Wsuggest-attribute=malloc', | |
374 | ||
375 | # g_return_val_if_fail usage violates this often | |
376 | '-Wdeclaration-after-statement', | |
377 | ] | |
378 | ||
379 | foreach flag : cc_flags_disabled | |
380 | if cc_flags.contains(flag) | |
381 | error('@0@ is disabled but listed in cc_flags'.format(flag)) | |
382 | endif | |
383 | endforeach | |
384 | ||
385 | supported_cc_flags = cc.get_supported_arguments(cc_flags) | |
386 | add_project_arguments(supported_cc_flags, language: 'c') | |
387 | ||
388 | ||
389 | prefix = get_option('prefix') | |
390 | localedir = join_paths(prefix, get_option('localedir')) | |
391 | datadir = join_paths(prefix, get_option('datadir')) | |
392 | mandir = join_paths(prefix, get_option('mandir')) | |
393 | ||
394 | add_global_arguments('-DLOCALE_DIR="@0@"'.format(localedir), language: 'c') | |
395 | ||
396 | libm_dep = cc.find_library('m', required : true) | |
397 | ||
398 | glib_dep = dependency('glib-2.0', version: glib_min_version) | |
399 | gmodule_dep = dependency('gmodule-2.0', version: glib_min_version) | |
400 | gtk_dep = dependency('gtk+-3.0', version: gtk_min_version) | |
401 | ||
402 | libxml_dep = dependency('libxml-2.0', version: libxml_min_version) | |
403 | ||
404 | libvirt_dep = dependency('libvirt', version: libvirt_min_version, required: get_option('libvirt')) | |
405 | libvirt_glib_dep = dependency('libvirt-glib-1.0', version: libvirt_glib_min_version, required: get_option('libvirt')) | |
406 | if get_option('libvirt').auto() | |
407 | if libvirt_dep.found() and not libvirt_glib_dep.found() | |
408 | libvirt_dep = dependency('', required: false) | |
409 | endif | |
410 | if not libvirt_dep.found() and libvirt_glib_dep.found() | |
411 | libvirt_glib_dep = dependency('', required: false) | |
412 | endif | |
413 | endif | |
414 | if libvirt_dep.found() | |
415 | conf_data.set('HAVE_LIBVIRT', '1') | |
416 | endif | |
417 | ||
418 | gtk_vnc_dep = dependency('gtk-vnc-2.0', version: gtk_vnc_min_version, required: get_option('vnc')) | |
419 | if gtk_vnc_dep.found() | |
420 | conf_data.set('HAVE_GTK_VNC', '1') | |
421 | endif | |
422 | ||
423 | spice_glib_dep = dependency('spice-client-glib-2.0', version: spice_gtk_min_version, required: get_option('spice')) | |
424 | spice_gtk_dep = dependency('spice-client-gtk-3.0', version: spice_gtk_min_version, required: get_option('spice')) | |
425 | spice_protocol_dep = dependency('spice-protocol', version: spice_protocol_min_version, required: get_option('spice')) | |
426 | if get_option('spice').auto() | |
427 | if not spice_protocol_dep.found() or not spice_gtk_dep.found() or not spice_glib_dep.found() | |
428 | spice_protocol_dep = dependency('', required: false) | |
429 | spice_glib_dep = dependency('', required: false) | |
430 | spice_gtk_dep = dependency('', required: false) | |
431 | endif | |
432 | endif | |
433 | if spice_gtk_dep.found() | |
434 | conf_data.set('HAVE_SPICE_GTK', '1') | |
435 | endif | |
436 | ||
437 | govirt_dep = dependency('govirt-1.0', version: govirt_min_version, required: get_option('ovirt')) | |
438 | rest_dep = dependency('rest-0.7', version: rest_min_version, required: get_option('ovirt')) | |
439 | if get_option('ovirt').auto() | |
440 | if govirt_dep.found() and not rest_dep.found() | |
441 | govirt_dep = dependency('', required: false) | |
442 | endif | |
443 | if not govirt_dep.found() and rest_dep.found() | |
444 | rest_dep = dependency('', required: false) | |
445 | endif | |
446 | endif | |
447 | if govirt_dep.found() | |
448 | conf_data.set('HAVE_OVIRT', '1') | |
449 | endif | |
450 | ||
451 | vte_dep = dependency('vte-2.91', version: vte_min_version, required: get_option('vte')) | |
452 | if vte_dep.found() | |
453 | conf_data.set('HAVE_VTE', '1') | |
454 | endif | |
455 | ||
456 | bash_completion_dep = dependency('bash-completion', version: '>=' + bash_completion_version, required: get_option('bash_completion')) | |
457 | ||
458 | if bash_completion_dep.found() | |
459 | bash_completion_dir = get_option('bash_completion_dir') | |
460 | if bash_completion_dir == '' | |
461 | bash_completion_dir = bash_completion_dep.get_pkgconfig_variable('completionsdir') | |
462 | bash_completion_prefix = bash_completion_dep.get_pkgconfig_variable('prefix') | |
463 | rc = run_command( | |
464 | 'python3', '-c', | |
465 | 'print("@0@".replace("@1@", "@2@"))'.format( | |
466 | bash_completion_dir, bash_completion_prefix, prefix, | |
467 | ), | |
468 | check: true, | |
469 | ) | |
470 | bash_completion_dir = rc.stdout().strip() | |
471 | endif | |
472 | endif | |
473 | ||
474 | conf_data.set('BUILDID', get_option('build-id')) | |
475 | conf_data.set('OS_ID', get_option('os-id')) | |
476 | ||
477 | arr_version = meson.project_version().split('.') | |
478 | ||
479 | conf_data.set('WINDOWS_PRODUCTVERSION', '@0@.@1@.@2@'.format( | |
480 | arr_version[0], | |
481 | arr_version[1], | |
482 | get_option('build-id'))) | |
483 | ||
484 | if host_machine.system() == 'windows' | |
485 | if host_machine.cpu() != 'x86_64' | |
486 | wixl_arch = 'x86' | |
487 | else | |
488 | wixl_arch = 'x64' | |
489 | endif | |
490 | conf_data.set('WIXL_ARCH', wixl_arch) | |
491 | endif | |
492 | ||
493 | configure_file( | |
494 | input: 'config.h.in', | |
495 | output: 'config.h', | |
496 | configuration: conf_data | |
497 | ) | |
498 | ||
499 | if git | |
500 | authors_helper = join_paths(meson.source_root(), 'build-aux', 'gen-authors.py') | |
501 | authors = run_command(python3.path(), authors_helper, env: runutf8) | |
502 | authors_file = 'AUTHORS.in' | |
503 | ||
504 | authors_conf = configuration_data() | |
505 | authors_conf.set('authorslist', authors.stdout()) | |
506 | ||
507 | configure_file( | |
508 | input: authors_file, | |
509 | output: '@BASENAME@', | |
510 | configuration: authors_conf, | |
511 | ) | |
512 | ||
513 | configure_file( | |
514 | input: 'virt-viewer.spec.in', | |
515 | output: 'virt-viewer.spec', | |
516 | configuration: conf_data | |
517 | ) | |
518 | ||
519 | configure_file( | |
520 | input: 'mingw-virt-viewer.spec.in', | |
521 | output: 'mingw-virt-viewer.spec', | |
522 | configuration: conf_data | |
523 | ) | |
524 | ||
525 | dist_helper = join_paths(meson.source_root(), 'build-aux', 'dist.py') | |
526 | meson.add_dist_script(python3.path(), dist_helper, meson.build_root(), 'AUTHORS') | |
527 | meson.add_dist_script(python3.path(), dist_helper, meson.build_root(), 'virt-viewer.spec') | |
528 | endif | |
529 | ||
530 | gnome = import('gnome') | |
531 | i18n = import('i18n') | |
532 | ||
533 | i18n_itsdir = join_paths(meson.source_root(), 'data', 'gettext') | |
534 | top_include_dir = [include_directories('.')] | |
535 | ||
536 | update_mime_database = find_program('update-mime-database', required: false) | |
537 | update_icon_cache = find_program('gtk-update-icon-cache', required: false) | |
538 | update_desktop_database = find_program('update-desktop-database', required: false) | |
539 | ||
540 | update_mime_database_path = '' | |
541 | if update_mime_database.found() | |
542 | update_mime_database_path = update_mime_database.path() | |
543 | endif | |
544 | ||
545 | update_icon_cache_path = '' | |
546 | if update_icon_cache.found() | |
547 | update_icon_cache_path = update_icon_cache.path() | |
548 | endif | |
549 | ||
550 | update_desktop_database_path = '' | |
551 | if update_desktop_database.found() | |
552 | update_desktop_database_path = update_desktop_database.path() | |
553 | endif | |
554 | ||
555 | meson.add_install_script('build-aux/post_install.py', | |
556 | update_mime_database_path, | |
557 | update_icon_cache_path, | |
558 | update_desktop_database_path) | |
559 | ||
560 | subdir('icons') | |
561 | subdir('src') | |
562 | subdir('po') | |
563 | subdir('man') | |
564 | subdir('tests') | |
565 | if bash_completion_dep.found() | |
566 | subdir('bash-completion') | |
567 | endif | |
568 | subdir('data') |
0 | option('git_werror', type: 'feature', value: 'auto', description: 'use -Werror if building from GIT') | |
1 | ||
2 | option('libvirt', type: 'feature', value: 'auto', description: 'libvirt support') | |
3 | option('vnc', type: 'feature', value: 'auto', description: 'VNC support') | |
4 | option('spice', type: 'feature', value: 'auto', description: 'SPICE support') | |
5 | option('ovirt', type: 'feature', value: 'auto', description: 'oVirt support') | |
6 | option('vte', type: 'feature', value: 'auto', description: 'VTE support') | |
7 | ||
8 | option('build-id', type: 'string', value: '', description: 'Extra build ID string') | |
9 | option('os-id', type: 'string', value: '', description: 'Remote viewer OS-ID string') | |
10 | ||
11 | option('bash_completion', type: 'feature', value: 'auto', description: 'bash-completion support') | |
12 | option('bash_completion_dir', type: 'string', value: '', description: 'directory containing bash completion scripts') |
0 | po_dir = meson.current_source_dir() | |
1 | ||
2 | i18n.gettext(meson.project_name(), | |
3 | args: ['--sort-output'], | |
4 | data_dirs: i18n_itsdir, | |
5 | preset: 'glib') |
0 | src_include_dir = [include_directories('.')] | |
1 | ||
2 | enum_sources = [ | |
3 | 'virt-viewer-display.h', | |
4 | ] | |
5 | ||
6 | common_enum_headers = gnome.mkenums( | |
7 | 'virt-viewer-enums.h', | |
8 | sources: enum_sources, | |
9 | symbol_prefix: 'virt_viewer', | |
10 | identifier_prefix: 'VirtViewer', | |
11 | h_template: 'virt-viewer-enums.h.etemplate', | |
12 | ) | |
13 | ||
14 | common_enum_sources = gnome.mkenums( | |
15 | 'virt-viewer-enums.c', | |
16 | sources: enum_sources, | |
17 | symbol_prefix: 'virt_viewer', | |
18 | identifier_prefix: 'VirtViewer', | |
19 | c_template: 'virt-viewer-enums.c.etemplate', | |
20 | ) | |
21 | ||
22 | ui_resources = gnome.compile_resources( | |
23 | 'virt-viewer-resources', | |
24 | 'resources/virt-viewer.gresource.xml', | |
25 | source_dir: 'resources', | |
26 | ) | |
27 | ||
28 | util_sources = [ | |
29 | 'virt-viewer-util.c' | |
30 | ] | |
31 | ||
32 | util_deps = [ | |
33 | libxml_dep, | |
34 | glib_dep, gmodule_dep, gtk_dep, | |
35 | ] | |
36 | ||
37 | ||
38 | util_lib = static_library( | |
39 | 'virt-viewer-util', | |
40 | util_sources, | |
41 | dependencies: util_deps, | |
42 | include_directories: top_include_dir, | |
43 | ) | |
44 | ||
45 | ||
46 | common_sources = [ | |
47 | common_enum_headers, | |
48 | common_enum_sources, | |
49 | ui_resources, | |
50 | 'glib-compat.c', | |
51 | 'virt-viewer-auth.c', | |
52 | 'virt-viewer-app.c', | |
53 | 'virt-viewer-file.c', | |
54 | 'virt-viewer-session.c', | |
55 | 'virt-viewer-display.c', | |
56 | 'virt-viewer-notebook.c', | |
57 | 'virt-viewer-window.c', | |
58 | 'virt-viewer-vm-connection.c', | |
59 | 'virt-viewer-display-vte.c', | |
60 | 'virt-viewer-timed-revealer.c', | |
61 | ] | |
62 | ||
63 | if gtk_vnc_dep.found() | |
64 | common_sources += [ | |
65 | 'virt-viewer-session-vnc.c', | |
66 | 'virt-viewer-display-vnc.c', | |
67 | ] | |
68 | endif | |
69 | ||
70 | if spice_gtk_dep.found() | |
71 | common_sources += [ | |
72 | 'virt-viewer-session-spice.c', | |
73 | 'virt-viewer-display-spice.c', | |
74 | 'virt-viewer-file-transfer-dialog.c', | |
75 | ] | |
76 | endif | |
77 | ||
78 | if govirt_dep.found() | |
79 | common_sources += [ | |
80 | 'ovirt-foreign-menu.c', | |
81 | 'remote-viewer-iso-list-dialog.c', | |
82 | ] | |
83 | endif | |
84 | ||
85 | common_deps = [ | |
86 | libm_dep, | |
87 | libxml_dep, | |
88 | glib_dep, gmodule_dep, gtk_dep, | |
89 | gtk_vnc_dep, | |
90 | spice_glib_dep, spice_gtk_dep, spice_protocol_dep, | |
91 | govirt_dep, rest_dep, | |
92 | vte_dep, | |
93 | ] | |
94 | ||
95 | ||
96 | common_lib = static_library( | |
97 | 'virt-viewer-common', | |
98 | common_sources, | |
99 | dependencies: common_deps, | |
100 | link_with: [util_lib], | |
101 | include_directories: top_include_dir, | |
102 | ) | |
103 | ||
104 | virt_viewer_sources = [ | |
105 | common_enum_headers, | |
106 | 'virt-viewer.c', | |
107 | 'virt-viewer-main.c' | |
108 | ] | |
109 | ||
110 | virt_viewer_deps = common_deps + [ | |
111 | libvirt_dep, libvirt_glib_dep, | |
112 | ] | |
113 | ||
114 | remote_viewer_sources = [ | |
115 | common_enum_headers, | |
116 | 'remote-viewer.c', | |
117 | 'remote-viewer-connect.c', | |
118 | 'remote-viewer-main.c', | |
119 | ] | |
120 | ||
121 | remote_viewer_deps = common_deps | |
122 | ||
123 | gui_security_link_args = [] | |
124 | cui_security_link_args = [] | |
125 | if host_machine.system() == 'windows' | |
126 | # binutils does not take into account entry point when | |
127 | # -pie is used so we need to provide it manually | |
128 | # The prefix is empty for x86_64, underscore ("_") otherwise | |
129 | entry_prefix = '' | |
130 | if host_machine.cpu() != 'x86_64' | |
131 | entry_prefix = '_' | |
132 | endif | |
133 | ||
134 | # --dynamicbase to enable ASLR protection | |
135 | # --nxcompat is to enable NX protection | |
136 | # -pie as --dynamicbase requires relocations | |
137 | gui_security_link_args += [ | |
138 | '-Wl,--dynamicbase,-pie,--nxcompat', | |
139 | '-Wl,-e,@0@WinMainCRTStartup'.format(entry_prefix), | |
140 | '-mwindows', | |
141 | ] | |
142 | cui_security_link_args += [ | |
143 | '-Wl,--dynamicbase,-pie,--nxcompat', | |
144 | '-Wl,-e,@0@WinMainCRTStartup'.format(entry_prefix), | |
145 | '-mconsole', | |
146 | ] | |
147 | endif | |
148 | ||
149 | if libvirt_dep.found() | |
150 | executable( | |
151 | 'virt-viewer', | |
152 | virt_viewer_sources, | |
153 | dependencies: virt_viewer_deps, | |
154 | link_with: common_lib, | |
155 | link_args: gui_security_link_args, | |
156 | include_directories: top_include_dir, | |
157 | install: true, | |
158 | ) | |
159 | endif | |
160 | ||
161 | executable( | |
162 | 'remote-viewer', | |
163 | remote_viewer_sources, | |
164 | dependencies: remote_viewer_deps, | |
165 | link_with: common_lib, | |
166 | link_args: gui_security_link_args, | |
167 | include_directories: top_include_dir, | |
168 | install: true, | |
169 | ) | |
170 | ||
171 | if host_machine.system() == 'windows' | |
172 | windres = find_program('windres') | |
173 | runwindres = join_paths(meson.source_root(), 'build-aux', 'run-windres.py') | |
174 | ||
175 | rcfile = configure_file( | |
176 | input: 'virt-viewer.rc.in', | |
177 | output: 'virt-viewer.rc', | |
178 | configuration: conf_data | |
179 | ) | |
180 | ||
181 | rcobj = custom_target( | |
182 | 'virt-viewer-rc.o', | |
183 | input: [rcfile, icofile, 'virt-viewer.manifest'], | |
184 | output: ['virt-viewer-rc.o'], | |
185 | command : [ | |
186 | python3, | |
187 | runwindres, | |
188 | windres, | |
189 | join_paths(meson.build_root(), 'icons'), | |
190 | meson.current_source_dir(), | |
191 | rcfile, | |
192 | '@OUTPUT@' | |
193 | ]) | |
194 | ||
195 | wrapper_sources = [ | |
196 | 'windows-cmdline-wrapper.c', | |
197 | rcobj, | |
198 | ] | |
199 | ||
200 | executable( | |
201 | 'windows-cmdline-wrapper', | |
202 | wrapper_sources, | |
203 | link_args: ['-lpsapi'] + cui_security_link_args, | |
204 | include_directories: top_include_dir, | |
205 | install: true, | |
206 | ) | |
207 | endif |
0 | version_compare_bin = executable( | |
1 | 'test-version-compare', | |
2 | sources: ['test-version-compare.c'], | |
3 | dependencies: [glib_dep, gtk_dep], | |
4 | include_directories: top_include_dir + src_include_dir, | |
5 | link_with: [util_lib], | |
6 | ) | |
7 | ||
8 | test('test-version-compare', version_compare_bin) | |
9 | ||
10 | ||
11 | monitor_mapping_bin = executable( | |
12 | 'test-monitor-mapping', | |
13 | sources: ['test-monitor-mapping.c'], | |
14 | dependencies: [glib_dep, gtk_dep], | |
15 | include_directories: top_include_dir + src_include_dir, | |
16 | link_with: [util_lib], | |
17 | ) | |
18 | ||
19 | test('test-monitor-mapping', monitor_mapping_bin) | |
20 | ||
21 | ||
22 | hotkeys_bin = executable( | |
23 | 'test-hotkeys', | |
24 | sources: ['test-hotkeys.c', common_enum_headers], | |
25 | dependencies: [glib_dep, gtk_dep], | |
26 | include_directories: top_include_dir + src_include_dir, | |
27 | link_with: [common_lib], | |
28 | ) | |
29 | ||
30 | test('test-hotkeys', hotkeys_bin) | |
31 | ||
32 | ||
33 | monitor_alignment_bin = executable( | |
34 | 'test-monitor-alignment', | |
35 | sources: ['test-monitor-alignment.c'], | |
36 | dependencies: [glib_dep, gtk_dep], | |
37 | include_directories: top_include_dir + src_include_dir, | |
38 | link_with: [util_lib], | |
39 | ) | |
40 | ||
41 | test('test-monitor-alignment', monitor_alignment_bin) | |
42 | ||
43 | ||
44 | if host_machine.system() == 'windows' | |
45 | redirect_bin = executable( | |
46 | 'test-redirect', | |
47 | sources: ['redirect-test.c'], | |
48 | dependencies: [glib_dep, gtk_dep], | |
49 | link_with: [util_lib], | |
50 | link_args: ['-Wl,--subsystem,windows'], | |
51 | include_directories: top_include_dir + src_include_dir, | |
52 | ) | |
53 | ||
54 | test('test-redirect', redirect_bin) | |
55 | endif |