ec4cd62fa7d31944afc6ee1677d0f3f069289dd1
[feed/packages.git] / libs / spice / patches / 020-no-code-generation.patch
1 From 713a3e09fbd5948823ac0c396249537329b878e4 Mon Sep 17 00:00:00 2001
2 From: Frediano Ziglio <fziglio@redhat.com>
3 Date: Thu, 12 Mar 2020 03:45:54 +0000
4 Subject: [PATCH] build: Allow to build disabling code generation
5
6 Reduce dependencies if used by agents which do not need
7 marshallers/demarshallers code.
8
9 Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
10 ---
11 common/meson.build | 28 +++++++++++++++-------------
12 meson.build | 24 +++++++++++++-----------
13 meson_options.txt | 2 +-
14 tests/meson.build | 34 ++++++++++++++++++----------------
15 4 files changed, 47 insertions(+), 41 deletions(-)
16
17 diff --git a/common/meson.build b/common/meson.build
18 index 7356cc0..14bf242 100644
19 --- a/subprojects/spice-common/common/meson.build
20 +++ b/subprojects/spice-common/common/meson.build
21 @@ -67,19 +67,21 @@ spice_common_dep = declare_dependency(link_with : spice_common_lib,
22
23
24 # client_demarshallers
25 -codegen_cmd = [python, spice_codegen]
26 -codegen_args = ['--generate-demarshallers',
27 - '--client',
28 - '--include', 'common/messages.h',
29 - '--generated-declaration-file', '@OUTPUT1@',
30 - '@INPUT@', '@OUTPUT0@']
31 -
32 -client_demarshallers = custom_target('client_demarshallers',
33 - input : [spice_proto],
34 - output : ['generated_client_demarshallers.c', 'generated_messages.h'],
35 - install : false,
36 - command : [codegen_cmd, codegen_args],
37 - depend_files : [spice_codegen_files, 'messages.h'])
38 +if spice_common_generate_client_code or spice_common_generate_server_code
39 + codegen_cmd = [python, spice_codegen]
40 + codegen_args = ['--generate-demarshallers',
41 + '--client',
42 + '--include', 'common/messages.h',
43 + '--generated-declaration-file', '@OUTPUT1@',
44 + '@INPUT@', '@OUTPUT0@']
45 +
46 + client_demarshallers = custom_target('client_demarshallers',
47 + input : [spice_proto],
48 + output : ['generated_client_demarshallers.c', 'generated_messages.h'],
49 + install : false,
50 + command : [codegen_cmd, codegen_args],
51 + depend_files : [spice_codegen_files, 'messages.h'])
52 +endif
53
54 #
55 # libspice-common-client
56 diff --git a/meson.build b/meson.build
57 index 41a9419..b60a9fe 100644
58 --- a/subprojects/spice-common/meson.build
59 +++ b/subprojects/spice-common/meson.build
60 @@ -119,17 +119,19 @@ foreach dep, version : optional_deps
61 endforeach
62
63 # Python
64 -py_module = import('python')
65 -python = py_module.find_installation()
66 -
67 -if get_option('python-checks')
68 - foreach module : ['six', 'pyparsing']
69 - message('Checking for python module @0@'.format(module))
70 - cmd = run_command(python, '-m', module)
71 - if cmd.returncode() != 0
72 - error('Python module @0@ not found'.format(module))
73 - endif
74 - endforeach
75 +if spice_common_generate_client_code or spice_common_generate_server_code
76 + py_module = import('python')
77 + python = py_module.find_installation()
78 +
79 + if get_option('python-checks')
80 + foreach module : ['six', 'pyparsing']
81 + message('Checking for python module @0@'.format(module))
82 + cmd = run_command(python, '-m', module)
83 + if cmd.returncode() != 0
84 + error('Python module @0@ not found'.format(module))
85 + endif
86 + endforeach
87 + endif
88 endif
89
90 # smartcard check
91 diff --git a/meson_options.txt b/meson_options.txt
92 index d30858f..d93d74b 100644
93 --- a/subprojects/spice-common/meson_options.txt
94 +++ b/subprojects/spice-common/meson_options.txt
95 @@ -39,7 +39,7 @@ option('manual',
96
97 option('generate-code',
98 type : 'combo',
99 - choices : ['all', 'server', 'client'],
100 + choices : ['all', 'server', 'client', 'none'],
101 description : 'Which code should be built')
102
103 option('tests',
104 diff --git a/tests/meson.build b/tests/meson.build
105 index d315056..1ad5bc5 100644
106 --- a/subprojects/spice-common/tests/meson.build
107 +++ b/subprojects/spice-common/tests/meson.build
108 @@ -20,26 +20,28 @@ endforeach
109 #
110 # test_marshallers
111 #
112 -test_proto = files('test-marshallers.proto')
113 +if spice_common_generate_client_code or spice_common_generate_server_code
114 + test_proto = files('test-marshallers.proto')
115
116 -test_marshallers_sources = ['test-marshallers.c', 'test-marshallers.h']
117 + test_marshallers_sources = ['test-marshallers.c', 'test-marshallers.h']
118
119 -targets = [
120 - ['test_marshallers', test_proto, 'generated_test_marshallers.c', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']],
121 - ['test_marshallers_h', test_proto, 'generated_test_marshallers.h', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '-H', '@INPUT@', '@OUTPUT@']],
122 - ['test_demarshallers', test_proto, 'generated_test_demarshallers.c', ['--generate-demarshallers', '--client', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']],
123 - ['test_enums_h', test_proto, 'generated_test_enums.h', ['-e', '@INPUT@', '@OUTPUT@']],
124 -]
125 + targets = [
126 + ['test_marshallers', test_proto, 'generated_test_marshallers.c', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']],
127 + ['test_marshallers_h', test_proto, 'generated_test_marshallers.h', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '-H', '@INPUT@', '@OUTPUT@']],
128 + ['test_demarshallers', test_proto, 'generated_test_demarshallers.c', ['--generate-demarshallers', '--client', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']],
129 + ['test_enums_h', test_proto, 'generated_test_enums.h', ['-e', '@INPUT@', '@OUTPUT@']],
130 + ]
131
132 -foreach t : targets
133 - cmd = [python, spice_codegen] + t[3]
134 - test_marshallers_sources += custom_target(t[0], input: t[1], output : t[2], command: cmd, depend_files : spice_codegen_files)
135 -endforeach
136 + foreach t : targets
137 + cmd = [python, spice_codegen] + t[3]
138 + test_marshallers_sources += custom_target(t[0], input: t[1], output : t[2], command: cmd, depend_files : spice_codegen_files)
139 + endforeach
140
141 -test('test_marshallers',
142 - executable('test_marshallers', test_marshallers_sources,
143 - dependencies : spice_common_dep,
144 - install : false))
145 + test('test_marshallers',
146 + executable('test_marshallers', test_marshallers_sources,
147 + dependencies : spice_common_dep,
148 + install : false))
149 +endif
150
151 #
152 # test_quic
153 --
154 GitLab
155