From 55dd521b4f7fac1bf963ddf54491ee4318eef4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20V=C3=A1zquez=20Blanco?= Date: Wed, 4 Jun 2025 20:37:09 +0200 Subject: [PATCH] libserialport: Add version 0.1.2-1. --- releases.json | 8 + subprojects/libserialport.wrap | 9 + .../packagefiles/libserialport/meson.build | 176 ++++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 subprojects/libserialport.wrap create mode 100644 subprojects/packagefiles/libserialport/meson.build diff --git a/releases.json b/releases.json index 5921005a2..a128b542d 100644 --- a/releases.json +++ b/releases.json @@ -2281,6 +2281,14 @@ "3.6.4-1" ] }, + "libserialport": { + "dependency_names": [ + "libserialport" + ], + "versions": [ + "0.1.2-1" + ] + }, "libsigcplusplus-3": { "dependency_names": [ "sigc++-3.0" diff --git a/subprojects/libserialport.wrap b/subprojects/libserialport.wrap new file mode 100644 index 000000000..4a10238eb --- /dev/null +++ b/subprojects/libserialport.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = libserialport-0.1.2 +source_url = https://sigrok.org/download/source/libserialport/libserialport-0.1.2.tar.gz +source_filename = libserialport-0.1.2.tar.gz +source_hash = 5deb92b5ca72c0347b07b786848350deca2dcfd975ce613b8e0e1d947a4b4ca9 +patch_directory = libserialport + +[provide] +dependency_names = libserialport diff --git a/subprojects/packagefiles/libserialport/meson.build b/subprojects/packagefiles/libserialport/meson.build new file mode 100644 index 000000000..59d7d4f8d --- /dev/null +++ b/subprojects/packagefiles/libserialport/meson.build @@ -0,0 +1,176 @@ +project( + 'libserialport', + 'c', + version: '0.1.2', + license: 'LGPL-3.0-or-later', + meson_version: '>= 0.49.0', +) + +libserialport_includes = include_directories(['.']) + +libserialport_headers = files('libserialport.h') + +libserialport_sources = files('serialport.c', 'timing.c') + +libserialport_cflags = [] +libserialport_ldflags = [] + +cc = meson.get_compiler('c') + +# Check for visibility control +if cc.compiles( + 'void foo(void) __attribute__((visibility("hidden")));', + name: 'visibility attribute check', +) + sp_api = '__attribute__((visibility("default")))' + sp_priv = '__attribute__((visibility("hidden")))' +elif cc.get_id() == 'msvc' or cc.compiles( + '__declspec(dllexport) void foo(void);', + name: 'declspec check', +) + sp_api = '__declspec(dllexport)' + sp_priv = '' +else + sp_api = '' + sp_priv = '' +endif + +cdata = configuration_data( + { + 'SP_API': sp_api, + 'SP_PRIV': sp_priv, + }, +) + +# Function checks +cdata.set('HAVE_REALPATH', cc.has_function('realpath')) +cdata.set('HAVE_FLOCK', cc.has_function('flock')) +cdata.set('HAVE_CLOCK_GETTIME', cc.has_function('clock_gettime')) + +# Header checks +cdata.set('HAVE_SYS_FILE_H', cc.has_header('sys/file.h')) + +# Type checks +cdata.set( + 'HAVE_STRUCT_TERMIOS2', + cc.has_type( + 'struct termios2', + prefix: '#include ', + ), +) +cdata.set( + 'HAVE_STRUCT_SERIAL_STRUCT', + cc.has_type( + 'struct serial_struct', + prefix: '#include ', + ), +) +cdata.set( + 'HAVE_STRUCT_TERMIOX', + cc.has_type( + 'struct termiox', + prefix: '#include ', + ), +) + +# Member checks +cdata.set( + 'HAVE_STRUCT_TERMIOS_C_ISPEED', + cc.has_member( + 'struct termios', + 'c_ispeed', + prefix: '#include ', + ), +) +cdata.set( + 'HAVE_STRUCT_TERMIOS_C_OSPEED', + cc.has_member( + 'struct termios', + 'c_ospeed', + prefix: '#include ', + ), +) +cdata.set( + 'HAVE_STRUCT_TERMIOS2_C_ISPEED', + cc.has_member( + 'struct termios2', + 'c_ispeed', + prefix: '#include ', + ), +) +cdata.set( + 'HAVE_STRUCT_TERMIOS2_C_OSPEED', + cc.has_member( + 'struct termios2', + 'c_ospeed', + prefix: '#include ', + ), +) + +# Header symbol check +cdata.set10( + 'HAVE_DECL_BOTHER', + cc.has_header_symbol('linux/termios.h', 'BOTHER'), +) + +# Derived defines +if cdata.get('HAVE_STRUCT_TERMIOS_C_ISPEED') and cdata.get( + 'HAVE_STRUCT_TERMIOS_C_OSPEED', +) + cdata.set('HAVE_TERMIOS_SPEED', 1) +endif +if cdata.get('HAVE_STRUCT_TERMIOS2_C_ISPEED') and cdata.get( + 'HAVE_STRUCT_TERMIOS2_C_OSPEED', +) + cdata.set('HAVE_TERMIOS2_SPEED', 1) +endif + +if host_machine.system() == 'linux' + libserialport_sources += files('linux.c', 'linux_termios.c') + libserialport_cflags += '-DLIBSERIALPORT_ATBUILD' +elif host_machine.system() == 'windows' + libserialport_sources += files('windows.c') + libserialport_cflags += '-DLIBSERIALPORT_MSBUILD' + libserialport_ldflags += '-lsetupapi' +elif host_machine.system() == 'darwin' + libserialport_sources += files('macosx.c') + libserialport_cflags += '-DLIBSERIALPORT_ATBUILD' + libserialport_ldflags += [ + '-framework', + 'IOKit', + '-framework', + 'CoreFoundation', + ] +elif host_machine.system() == 'freebsd' + libserialport_sources += files('freebsd.c') + libserialport_cflags += '-DLIBSERIALPORT_ATBUILD' +endif + +configure_file( + output: 'config.h', + configuration: cdata, +) + +libserialport_lib = library( + 'libserialport', + libserialport_sources, + c_args: libserialport_cflags, + link_args: libserialport_ldflags, + include_directories: libserialport_includes, + version: '0.1.0', + install: true, +) + +pkg = import('pkgconfig') +pkg.generate(libserialport_lib) + +install_headers(libserialport_headers) + +libserialport_dep = declare_dependency( + include_directories: libserialport_includes, + link_with: libserialport_lib, +) + +if meson.version().version_compare('>=0.54.0') + meson.override_dependency('libserialport', libserialport_dep) +endif