You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
6.5 KiB

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