Signed-off-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx> --- common/meson.build | 120 +++++++++++++++++++++++++++++++++++ docs/meson.build | 11 ++++ meson.build | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 37 +++++++++++ tests/meson.build | 34 ++++++++++ 5 files changed, 381 insertions(+) create mode 100644 common/meson.build create mode 100644 docs/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 tests/meson.build diff --git a/common/meson.build b/common/meson.build new file mode 100644 index 0000000..8979947 --- /dev/null +++ b/common/meson.build @@ -0,0 +1,120 @@ +# +# libspice-common +# +spice_common_sources = [ + 'backtrace.c', + 'backtrace.h', + 'bitops.h', + 'canvas_utils.c', + 'canvas_utils.h', + 'client_demarshallers.h', + 'client_marshallers.h', + 'draw.h', + 'lines.c', + 'lines.h', + 'log.c', + 'log.h', + 'lz.c', + 'lz.h', + 'lz_common.h', + 'lz_config.h', + 'macros.h', + 'marshaller.c', + 'marshaller.h', + 'mem.c', + 'mem.h', + 'messages.h', + 'pixman_utils.c', + 'pixman_utils.h', + 'quic.c', + 'quic.h', + 'quic_config.h', + 'rect.h', + 'region.c', + 'region.h', + 'ring.h', + 'rop3.c', + 'rop3.h', + 'snd_codec.c', + 'snd_codec.h', + 'spice_common.h', + 'ssl_verify.c', + 'ssl_verify.h', + 'verify.h' +] + +spice_common_lib = static_library('spice-common', spice_common_sources, + install : false, + include_directories: spice_common_include, + dependencies: spice_common_deps) + +spice_common_generate_code = get_option('generate-code') +# +# libspice-common-client +# +if spice_common_generate_code == 'all' or spice_common_generate_code == 'client' + targets = [ + ['client_demarshallers', spice_proto, 'generated_client_demarshallers.c', ['--generate-demarshallers', '--client', '--include', 'common/messages.h', '@INPUT@', '@OUTPUT@']], + ['client_demarshallers1', spice1_proto, 'generated_client_demarshallers1.c', ['--generate-demarshallers', '--client', '--include', 'common/messages.h', '--prefix', '1', '--ptrsize', '8', '@INPUT@', '@OUTPUT@']], + ['client_marshallers_h', spice_proto, 'generated_client_marshallers.h', ['--generate-marshallers', '-P', '--client', '--include', 'common/messages.h', '-H', '@INPUT@', '@OUTPUT@']], + ['client_marshalers', spice_proto, 'generated_client_marshallers.c', ['--generate-marshallers', '-P', '--client', '--include', 'client_marshallers.h', '@INPUT@', '@OUTPUT@']], + ['client_marshallers1', spice1_proto, 'generated_client_marshallers1.c', ['--generate-marshallers', '-P', '--client', '--include', 'common/messages.h', '--include', 'client_marshallers.h', '--prefix', '1', '--ptrsize', '8', '@INPUT@', '@OUTPUT@']], + ] + + spice_common_client_sources = [] + + foreach t : targets + cmd = [spice_codegen] + t[3] + spice_common_client_sources += custom_target(t[0], input : t[1], output : t[2], install : false, command : cmd) + endforeach + + spice_common_client_lib = static_library('spice-common-client', spice_common_client_sources, + install : false, + include_directories: spice_common_include, + dependencies: spice_common_deps) + spice_common_client_dep = declare_dependency(sources : spice_common_client_sources) +endif + +# +# libspice-common-server +# +if spice_common_generate_code == 'all' or spice_common_generate_code == 'server' + structs_args = [ + '-M', 'String', + '-M', 'Rect', + '-M', 'Point', + '-M', 'DisplayBase', + '-M', 'Fill', + '-M', 'Opaque', + '-M', 'Copy', + '-M', 'Blend', + '-M', 'Blackness', + '-M', 'Whiteness', + '-M', 'Invers', + '-M', 'Rop3', + '-M', 'Stroke', + '-M', 'Text', + '-M', 'Transparent', + '-M', 'AlphaBlend', + '-M', 'Composite', + ] + + targets = [ + ['server_demarshallers', spice_proto, 'generated_server_demarshallers.c', ['--generate-demarshallers', '--server', '--include', 'common/messages.h', '@INPUT@', '@OUTPUT@']], + ['server_marshallers_h', spice_proto, 'generated_server_marshallers.h', ['--generate-marshallers', '--server'] + structs_args + ['--include', 'common/messages.h', '-H', '@INPUT@', '@OUTPUT@']], + ['server_marshallers', spice_proto, 'generated_server_marshallers.c', ['--generate-marshallers', '--server'] + structs_args + ['--include', 'common/messages.h', '@INPUT@', '@OUTPUT@']], + ] + + spice_common_server_sources = [] + + foreach t : targets + cmd = [python.path(), spice_codegen] + t[3] + spice_common_server_sources += custom_target(t[0], input : t[1], output : t[2], install : false, command : cmd) + endforeach + + spice_common_server_lib = static_library('spice-common-server', spice_common_server_sources, + install : false, + include_directories: spice_common_include, + dependencies: spice_common_deps) + spice_common_server_dep = declare_dependency(sources : spice_common_server_sources) +endif diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 0000000..7abb54c --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,11 @@ +if get_option('manual') + asciidoc = find_program('asciidoc', required : false) + if asciidoc.found() + custom_target('spice_protocol.html', + input : files('spice_protocol.txt'), + output : 'spice_protocol.html', + command : [asciidoc, '-n', '-a', 'icons', '-a', 'toc', '-o', '@OUTPUT@', '@INPUT@'], + install_dir : meson.current_build_dir(), # FIXME: used to force the build of the documentation, + install : true) # if install is false, it will not be done. + endif +endif diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..ba1fa0d --- /dev/null +++ b/meson.build @@ -0,0 +1,179 @@ +# +# project definition +# +project('spice-common', 'c', + meson_version : '>= 0.45.0', + license : 'LGPLv2.1') + +# some global vars +spice_common_global_cflags = [#'-std=c99', # fails compiling bitops.h + '-static', + '-DHAVE_CONFIG_H', + '-DG_LOG_DOMAIN="Spice"', + '-Wall', + '-Wextra', + '-Werror'] + +if get_option('alignment-checks') + spice_common_global_cflags += ['-DSPICE_DEBUG_ALIGNMENT'] +endif + +spice_common_deps = [] +spice_common_include = include_directories('.') + +spice_proto = files('spice.proto') +spice1_proto = files('spice1.proto') +spice_codegen = files('spice_codegen.py') + +compiler = meson.get_compiler('c') +spice_common_config_data = configuration_data() +if get_option('extra-checks') + spice_common_config_data.set('ENABLE_EXTRA_CHECKS', '1') +endif + +# +# check for system headers +# +headers = [['alloca.h', 'HAVE_ALLOCA_H'], + ['arpa/inet.h', 'HAVE_ARPA_INET_H'], + ['dlfcn.h', 'HAVE_DLFCN_H'], + ['inttypes.h', 'HAVE_INTTYPES_H'], + ['malloc.h', 'HAVE_MALLOC_H'], + ['memory.h', 'HAVE_MEMORY_H'], + ['netinet/in.h', 'HAVE_NETINET_IN_H'], + ['stddef.h', 'HAVE_STDDEF_H'], + ['stdint.h', 'HAVE_STDINT_H'], + ['stdlib.h', 'HAVE_STDLIB_H'], + ['strings.h', 'HAVE_STRINGS_H'], + ['string.h', 'HAVE_STRING_H'], + ['sys/socket.h', 'HAVE_SYS_SOCKET_H'], + ['sys/stat.h', 'HAVE_SYS_STAT_H'], + ['sys/types.h', 'HAVE_SYS_TYPES_H'], + ['unistd.h', 'HAVE_UNISTD_H'], + ['vfork.h', 'HAVE_VFORK_H']] + +foreach h : headers + if compiler.has_header(h[0]) + spice_common_config_data.set(h[1], '1') + endif +endforeach + +# +# check for system functions +# +functions = [['alloca', 'HAVE_ALLOCA'], + ['dup2', 'HAVE_DUP2'], + ['floor', 'HAVE_FLOOR'], + ['fork', 'HAVE_FORK'], + ['inet_ntoa', 'HAVE_INET_NTOA'], + ['memmove', 'HAVE_MEMMOVE'], + ['memset', 'HAVE_MEMSET'], + ['pow', 'HAVE_POW'], + ['sqrt', 'HAVE_SQRT'], + ['vfork', 'HAVE_VFORK']] + +foreach f : functions + if compiler.has_function(f[0]) + spice_common_config_data.set(f[1], '1') + endif +endforeach + + +# +# check for mandatory dependencies +# +glib_version_info = '>= 2.38' +glib_encoded_version = 'GLIB_VERSION_2_38' +spice_protocol_version = '>= @0@'.format(get_option('protocol-version')) + +deps = [['spice-protocol', spice_protocol_version], + ['glib-2.0', glib_version_info], + ['gio-2.0', glib_version_info], + ['gthread-2.0', glib_version_info], + ['pixman-1', '>= 0.17.7'], + ['openssl', '>= 1.0.0']] + +foreach dep : deps + spice_common_deps += dependency(dep[0], version : dep[1]) +endforeach + +spice_common_glib_cflags = ['-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_encoded_version), + '-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_encoded_version)] + +spice_common_global_cflags += spice_common_glib_cflags + +# +# Non-mandatory/optional dependencies +# +deps = [['opus', '>= 0.9.14', 'HAVE_OPUS'],] +optional_deps = [['celt051', '>= 0.5.1.1', 'HAVE_CELT051'],] + +foreach dep : optional_deps + if get_option(dep[0]) + deps += [dep] + endif +endforeach + +foreach dep : deps + d = dependency(dep[0], required : false, version : dep[1]) + if d.found() + spice_common_deps += d + spice_common_config_data.set(dep[2], '1') + endif +endforeach + +# Python +if get_option('python-checks') + dependency('python3') + py_module = import('python3') + python = py_module.find_python() + foreach module : ['six', 'pyparsing'] + cmd = run_command(python, '-m', module) + if cmd.returncode() != 0 + error('Python module @0@ not found'.format(module)) + endif + endforeach +endif + +# smartcard check +smartcard_dep = dependency('libcacard', required : false, version : '>= 2.5.1') +if smartcard_dep.found() + spice_common_deps += smartcard_dep + spice_common_config_data.set('USE_SMARTCARD', '1') +else + smartcard012_dep = dependency('libcacard', required : false, version : '>= 0.1.2') + if smartcard012_dep.found() + spice_common_deps += smartcard012_dep + spice_common_config_data.set('USE_SMARTCARD_012', '1') + endif +endif + +spice_common_has_smartcard = smartcard_dep.found() or smartcard012_dep.found() + +# +# global C defines +# +if not meson.is_subproject() + warning('This project is only intended to be used as a subproject!') + foreach arg : spice_common_global_cflags + add_global_arguments(arg, language : 'c') + endforeach +else + foreach arg : spice_common_global_cflags + add_project_arguments(arg, language : 'c') + endforeach +endif + +# +# Subdirectories +# +subdir('common') +subdir('tests') +subdir('docs') + +# +# write config.h +# +configure_file(output : 'config.h', + install : false, + configuration : spice_common_config_data) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..8e27cbf --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,37 @@ +option('alignment-checks', + type : 'boolean', + value : false, + yield : true, + description : 'Enable runtime checks for cast alignment (default=false)') + +option('extra-checks', + type : 'boolean', + value : false, + yield : true, + description : 'Enable extra checks on code (default=false)') + +option('celt051', + type : 'boolean', + value : true, + description: 'Enable celt051 audio codec (default=true)') + +option('python-checks', + type : 'boolean', + value : true, + description : 'Enable checks for Python modules needed to build from git (default=true)') + +option('manual', + type : 'boolean', + value : true, + yield : true, + description : 'Build SPICE manual (default=true)') + +option('protocol-version', + type : 'string', + value : '0.12.12', + description : 'SPICE protocol version required (default=0.12.12)') + +option('generate-code', + type : 'combo', + choices : ['all', 'server', 'client'], + description : 'Which code should be built (default=all)') diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..7616011 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,34 @@ +# +# test_logging +# +test ('test-logging', + executable('test_logging', 'test-logging.c', + include_directories: spice_common_include, + dependencies: spice_common_deps, + link_with: spice_common_lib, + install : false)) + +# +# test_marshallers +# +test_proto = files('test-marshallers.proto') + +test_marshallers_sources = ['test-marshallers.c', 'test-marshallers.h'] + +targets = [ + ['test_marshallers', test_proto, 'generated_test_marshallers.c', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']], + ['test_marshallers_h', test_proto, 'generated_test_marshallers.h', ['--generate-marshallers', '--server', '--include', 'test-marshallers.h', '-H', '@INPUT@', '@OUTPUT@']], + ['test_demarshallers', test_proto, 'generated_test_demarshallers.c', ['--generate-demarshallers', '--client', '--include', 'test-marshallers.h', '@INPUT@', '@OUTPUT@']], +] + +foreach t : targets + cmd = [spice_codegen] + t[3] + test_marshallers_sources += custom_target(t[0], input: t[1], output : t[2], command: cmd) +endforeach + +test('test_marshallers', + executable('test_marshallers', test_marshallers_sources, + include_directories: spice_common_include, + dependencies: spice_common_deps, + link_with: spice_common_lib, + install : false)) -- 2.14.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel