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.

142 lines
6.1 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. --- a/subprojects/spice-common/common/meson.build
  15. +++ b/subprojects/spice-common/common/meson.build
  16. @@ -67,19 +67,21 @@ spice_common_dep = declare_dependency(li
  17. # client_demarshallers
  18. -codegen_cmd = [python, spice_codegen]
  19. -codegen_args = ['--generate-demarshallers',
  20. - '--client',
  21. - '--include', 'common/messages.h',
  22. - '--generated-declaration-file', '@OUTPUT1@',
  23. - '@INPUT@', '@OUTPUT0@']
  24. +if spice_common_generate_client_code or spice_common_generate_server_code
  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. -client_demarshallers = custom_target('client_demarshallers',
  32. - input : [spice_proto],
  33. - output : ['generated_client_demarshallers.c', 'generated_messages.h'],
  34. - install : false,
  35. - command : [codegen_cmd, codegen_args],
  36. - depend_files : [spice_codegen_files, 'messages.h'])
  37. + client_demarshallers = custom_target('client_demarshallers',
  38. + input : [spice_proto],
  39. + output : ['generated_client_demarshallers.c', 'generated_messages.h'],
  40. + install : false,
  41. + command : [codegen_cmd, codegen_args],
  42. + depend_files : [spice_codegen_files, 'messages.h'])
  43. +endif
  44. #
  45. # libspice-common-client
  46. --- a/subprojects/spice-common/meson.build
  47. +++ b/subprojects/spice-common/meson.build
  48. @@ -131,17 +131,19 @@ foreach dep, version : optional_deps
  49. endforeach
  50. # Python
  51. -py_module = import('python')
  52. -python = py_module.find_installation()
  53. +if spice_common_generate_client_code or spice_common_generate_server_code
  54. + py_module = import('python')
  55. + python = py_module.find_installation()
  56. -if get_option('python-checks')
  57. - foreach module : ['six', 'pyparsing']
  58. - message('Checking for python module @0@'.format(module))
  59. - cmd = run_command(python, '-m', module)
  60. - if cmd.returncode() != 0
  61. - error('Python module @0@ not found'.format(module))
  62. - endif
  63. - endforeach
  64. + if get_option('python-checks')
  65. + foreach module : ['six', 'pyparsing']
  66. + message('Checking for python module @0@'.format(module))
  67. + cmd = run_command(python, '-m', module)
  68. + if cmd.returncode() != 0
  69. + error('Python module @0@ not found'.format(module))
  70. + endif
  71. + endforeach
  72. + endif
  73. endif
  74. # smartcard check
  75. --- a/subprojects/spice-common/meson_options.txt
  76. +++ b/subprojects/spice-common/meson_options.txt
  77. @@ -45,7 +45,7 @@ option('manual',
  78. option('generate-code',
  79. type : 'combo',
  80. - choices : ['all', 'server', 'client'],
  81. + choices : ['all', 'server', 'client', 'none'],
  82. description : 'Which code should be built')
  83. option('tests',
  84. --- a/subprojects/spice-common/tests/meson.build
  85. +++ b/subprojects/spice-common/tests/meson.build
  86. @@ -15,26 +15,28 @@ endforeach
  87. #
  88. # test_marshallers
  89. #
  90. -test_proto = files('test-marshallers.proto')
  91. +if spice_common_generate_client_code or spice_common_generate_server_code
  92. + test_proto = files('test-marshallers.proto')
  93. -test_marshallers_sources = ['test-marshallers.c', 'test-marshallers.h']
  94. + test_marshallers_sources = ['test-marshallers.c', 'test-marshallers.h']
  95. -targets = [
  96. - ['test_marshallers', test_proto, 'generated_test_marshallers.c', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']],
  97. - ['test_marshallers_h', test_proto, 'generated_test_marshallers.h', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '-H', '@INPUT@', '@OUTPUT@']],
  98. - ['test_demarshallers', test_proto, 'generated_test_demarshallers.c', ['--generate-demarshallers', '--client', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']],
  99. - ['test_enums_h', test_proto, 'generated_test_enums.h', ['-e', '@INPUT@', '@OUTPUT@']],
  100. -]
  101. + targets = [
  102. + ['test_marshallers', test_proto, 'generated_test_marshallers.c', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']],
  103. + ['test_marshallers_h', test_proto, 'generated_test_marshallers.h', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '-H', '@INPUT@', '@OUTPUT@']],
  104. + ['test_demarshallers', test_proto, 'generated_test_demarshallers.c', ['--generate-demarshallers', '--client', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']],
  105. + ['test_enums_h', test_proto, 'generated_test_enums.h', ['-e', '@INPUT@', '@OUTPUT@']],
  106. + ]
  107. -foreach t : targets
  108. - cmd = [python, spice_codegen] + t[3]
  109. - test_marshallers_sources += custom_target(t[0], input: t[1], output : t[2], command: cmd, depend_files : spice_codegen_files)
  110. -endforeach
  111. + foreach t : targets
  112. + cmd = [python, spice_codegen] + t[3]
  113. + test_marshallers_sources += custom_target(t[0], input: t[1], output : t[2], command: cmd, depend_files : spice_codegen_files)
  114. + endforeach
  115. -test('test_marshallers',
  116. - executable('test_marshallers', test_marshallers_sources,
  117. - dependencies : spice_common_dep,
  118. - install : false))
  119. + test('test_marshallers',
  120. + executable('test_marshallers', test_marshallers_sources,
  121. + dependencies : spice_common_dep,
  122. + install : false))
  123. +endif
  124. #
  125. # test_quic