From 1136d76fd38d6b916f286419c152fed207d93e3f Mon Sep 17 00:00:00 2001 From: Christian Seiler Date: Sat, 31 Aug 2024 22:27:23 +0200 Subject: [PATCH 01/70] Windows: don't fail if WaitCommEvent was aborted due to thread exit This is a partial fix for #1603. --- libserialport_internal.h | 1 + serialport.c | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/libserialport_internal.h b/libserialport_internal.h index f1d0d85..57346d6 100644 --- a/libserialport_internal.h +++ b/libserialport_internal.h @@ -158,6 +158,7 @@ struct sp_port { DWORD write_buf_size; BOOL writing; BOOL wait_running; + BOOL last_wait_thread_exited; #else int fd; #endif diff --git a/serialport.c b/serialport.c index 1135c36..b3b9249 100644 --- a/serialport.c +++ b/serialport.c @@ -420,19 +420,35 @@ SP_API void sp_free_port_list(struct sp_port **list) /** To be called after port receive buffer is emptied. */ static enum sp_return restart_wait(struct sp_port *port) { - DWORD wait_result, last_error_code; + DWORD wait_result; if (port->wait_running) { /* Check status of running wait operation. */ if (GetOverlappedResult(port->hdl, &port->wait_ovl, &wait_result, FALSE)) { DEBUG("Previous wait completed"); + port->last_wait_thread_exited = FALSE; port->wait_running = FALSE; - } else if ((last_error_code = GetLastError()) == ERROR_OPERATION_ABORTED) { - DEBUG("Previous wait aborted"); + } else if (GetLastError() == ERROR_OPERATION_ABORTED) { + /* This error is returned if the last thread that called + * restart_wait() has exited while WaitCommEvent() was + * still active. In that case we don't consider that to + * be an error. Just restart the wait procedure instead. + */ + DEBUG("Previous wait ended due to previous thread exiting"); + /* We need to record that the wait thread exited before + * we called WaitCommEvent(). This is because the exit of + * the previous thread always generates a spurious wakeup, + * and if no data has been received in the mean time, the + * WaitCommEvent() wouldn't be restarted a second time by + * restart_wait_if_needed() after a read call after the + * spurious wakeup. + */ + port->last_wait_thread_exited = TRUE; port->wait_running = FALSE; - } else if (last_error_code == ERROR_IO_INCOMPLETE) { + } else if (GetLastError() == ERROR_IO_INCOMPLETE) { DEBUG("Previous wait still running"); + port->last_wait_thread_exited = FALSE; RETURN_OK(); } else { RETURN_FAIL("GetOverlappedResult() failed"); @@ -1029,7 +1045,11 @@ static enum sp_return restart_wait_if_needed(struct sp_port *port, unsigned int DWORD errors; COMSTAT comstat; - if (bytes_read == 0) + /* Only skip restarting the wait operation if we didn't have a + * wakeup immediately following the exit of the last thread that + * re-initiated the wait loop. + */ + if (!port->last_wait_thread_exited && bytes_read == 0) RETURN_OK(); if (ClearCommError(port->hdl, &errors, &comstat) == 0) From f5e4821c62d26c2548a3c87d7b29bd8a8575f521 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 16:09:34 +0100 Subject: [PATCH 02/70] Add libserialport.h to dist tarball --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9b017eb..2c708c3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,7 +51,7 @@ if MACOSX libserialport_la_LDFLAGS += -framework IOKit -framework CoreFoundation endif -nodist_include_HEADERS = libserialport.h +include_HEADERS = libserialport.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libserialport.pc @@ -79,5 +79,5 @@ ChangeLog: dist-hook: ChangeLog -doc: $(nodist_include_HEADERS) $(top_srcdir)/Doxyfile +doc: $(include_HEADERS) $(top_srcdir)/Doxyfile doxygen $(top_srcdir)/Doxyfile From ebfcf0275d582fd7605cbb9b11575fd8e695c34e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 17:41:13 +0100 Subject: [PATCH 03/70] Fix distcheck target (distclean generated ChangeLog) To allow the "make distcheck" target recipe to succeed, add the generated ChangeLog file to the DISTCLEANFILES variable. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 2c708c3..f9f1d34 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,7 +70,7 @@ EXTRA_DIST = Doxyfile \ examples/await_events.c \ examples/handle_errors.c -MAINTAINERCLEANFILES = ChangeLog +DISTCLEANFILES = ChangeLog .PHONY: ChangeLog doc From 40bb49d2d46dbdcbea0675af5a72c99f5991d7b4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 17:52:32 +0100 Subject: [PATCH 04/70] Group generating and cleaning up ChangeLog file --- Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index f9f1d34..6d747f1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,13 +70,12 @@ EXTRA_DIST = Doxyfile \ examples/await_events.c \ examples/handle_errors.c -DISTCLEANFILES = ChangeLog - .PHONY: ChangeLog doc ChangeLog: git --git-dir '$(top_srcdir)/.git' log >$@ || touch $@ +DISTCLEANFILES = ChangeLog dist-hook: ChangeLog doc: $(include_HEADERS) $(top_srcdir)/Doxyfile From 3f571001f8d0e63d85a53dabc782aa019068aaaf Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 17:49:01 +0100 Subject: [PATCH 05/70] XXX Detect git, doxygen before using it --- Makefile.am | 12 +++++++++++- configure.ac | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 6d747f1..209b86e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,10 +73,20 @@ EXTRA_DIST = Doxyfile \ .PHONY: ChangeLog doc ChangeLog: - git --git-dir '$(top_srcdir)/.git' log >$@ || touch $@ +if HAVE_PROG_GIT + if test -d '$(top_srcdir)/.git'; then \ + $(GIT) --git-dir '$(top_srcdir)/.git' log > ChangeLog; \ + else \ + echo "Generated dummy ChangeLog file (no .git directory)" > ChangeLog; \ + fi +else + echo "Generated dummy ChangeLog file (no git tool)" > ChangeLog +endif DISTCLEANFILES = ChangeLog dist-hook: ChangeLog +if HAVE_PROG_DOXYGEN doc: $(include_HEADERS) $(top_srcdir)/Doxyfile doxygen $(top_srcdir)/Doxyfile +endif diff --git a/configure.ac b/configure.ac index a26b851..db8a92a 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,19 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S +AC_DEFUN([SP_PROG], [dnl + m4_assert([$# >= 2])[]dnl + AC_ARG_VAR(m4_toupper($1), [$2]) + AS_VAR_IF(m4_toupper($1), [], [dnl + AC_PATH_PROG(m4_toupper($1), [$1], [no]) + ]) + AM_CONDITIONAL([HAVE_PROG_]m4_toupper($1), [test "x$m4_toupper($1)" != xno]) +])dnl + +SP_PROG([doxygen], [doxygen documentation system]) +SP_PROG([git], [git revision control system]) + + ## SP_PROG_VERSION(program, sh-var) ## Obtain the version of and store it in . AC_DEFUN([SP_PROG_VERSION], From 3edbada4f66bd768fba05377647821271adf1a32 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 17:14:55 +0100 Subject: [PATCH 06/70] XXX Add more files to dist tarball --- Makefile.am | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Makefile.am b/Makefile.am index 209b86e..8b0f202 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,6 +70,51 @@ EXTRA_DIST = Doxyfile \ examples/await_events.c \ examples/handle_errors.c +EXTRA_DIST += AUTHORS +EXTRA_DIST += COPYING +EXTRA_DIST += NEWS +EXTRA_DIST += README + +EXTRA_DIST += autogen.sh +EXTRA_DIST += config-header.py +EXTRA_DIST += config-pattern + +EXTRA_DIST += common.props +EXTRA_DIST += debug.props +EXTRA_DIST += release.props + +EXTRA_DIST += libserialport.sln +EXTRA_DIST += libserialport.vcxproj +EXTRA_DIST += libserialport.vcxproj.filters + +EXTRA_DIST += examples/Makefile +EXTRA_DIST += examples/README +EXTRA_DIST += examples/examples.sln + +EXTRA_DIST += examples/await_events.c +EXTRA_DIST += examples/projects/await_events.vcxproj +EXTRA_DIST += examples/projects/await_events.vcxproj.filters + +EXTRA_DIST += examples/handle_errors.c +EXTRA_DIST += examples/projects/handle_errors.vcxproj +EXTRA_DIST += examples/projects/handle_errors.vcxproj.filters + +EXTRA_DIST += examples/list_ports.c +EXTRA_DIST += examples/projects/list_ports.vcxproj +EXTRA_DIST += examples/projects/list_ports.vcxproj.filters + +EXTRA_DIST += examples/port_config.c +EXTRA_DIST += examples/projects/port_config.vcxproj +EXTRA_DIST += examples/projects/port_config.vcxproj.filters + +EXTRA_DIST += examples/port_info.c +EXTRA_DIST += examples/projects/port_info.vcxproj +EXTRA_DIST += examples/projects/port_info.vcxproj.filters + +EXTRA_DIST += examples/send_receive.c +EXTRA_DIST += examples/projects/send_receive.vcxproj +EXTRA_DIST += examples/projects/send_receive.vcxproj.filters + .PHONY: ChangeLog doc ChangeLog: From 458120e55c1c42437a1aa2cdd2308503d9b7af3b Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 15:51:32 +0100 Subject: [PATCH 07/70] configure.ac: AC_DEFINE_UNQUOTED for SP_PACKAGE_VERSION_STRING --- configure.ac | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index db8a92a..55ec318 100644 --- a/configure.ac +++ b/configure.ac @@ -79,10 +79,10 @@ SP_PROG_VERSION([$CC], [sp_cc_version]) # Initialize libtool. LT_INIT -AC_DEFINE([SP_PACKAGE_VERSION_MAJOR], [sp_package_version_major], [.]) -AC_DEFINE([SP_PACKAGE_VERSION_MINOR], [sp_package_version_minor], [.]) -AC_DEFINE([SP_PACKAGE_VERSION_MICRO], [sp_package_version_micro], [.]) -AC_DEFINE([SP_PACKAGE_VERSION_STRING], ["sp_package_version"], [.]) +AC_DEFINE_UNQUOTED([SP_PACKAGE_VERSION_MAJOR], [sp_package_version_major], [.]) +AC_DEFINE_UNQUOTED([SP_PACKAGE_VERSION_MINOR], [sp_package_version_minor], [.]) +AC_DEFINE_UNQUOTED([SP_PACKAGE_VERSION_MICRO], [sp_package_version_micro], [.]) +AC_DEFINE_UNQUOTED([SP_PACKAGE_VERSION_STRING], ["sp_package_version"], [.]) AC_SUBST([SP_PACKAGE_VERSION], [sp_package_version]) # Library version for libserialport (NOT the same as the package version). From 5eb4785ae15950b6262c5d1d5972a6666aba37cb Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 00:05:28 +0100 Subject: [PATCH 08/70] configure.ac: one AC_INIT argument per line for better overview --- configure.ac | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 55ec318..35fcafc 100644 --- a/configure.ac +++ b/configure.ac @@ -27,8 +27,11 @@ m4_define([sp_package_version_minor], [1]) m4_define([sp_package_version_micro], [1]) m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro]) -AC_INIT([libserialport], [sp_package_version], [martin-libserialport@earth.li], - [libserialport], [http://sigrok.org/wiki/Libserialport]) +AC_INIT([libserialport], + [sp_package_version], + [martin-libserialport@earth.li], + [libserialport], + [http://sigrok.org/wiki/Libserialport]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([autostuff]) AC_CONFIG_AUX_DIR([autostuff]) From f4c96b2832e650d2631ebdcdb50daff086af4977 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 00:13:22 +0100 Subject: [PATCH 09/70] configure.ac: add safety net for sp_package_* macros Add m4_pattern_forbid safety net for sp_package_* macros. --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 35fcafc..d54c1f7 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,7 @@ AC_PREREQ([2.63]) # libserialport package version number (NOT the same as shared lib version!). +m4_pattern_forbid([sp_package_]) m4_define([sp_package_version_major], [0]) m4_define([sp_package_version_minor], [1]) m4_define([sp_package_version_micro], [1]) From 5a79fe4acf52913de9f92db42d5bd551917abc3c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 03:04:30 +0100 Subject: [PATCH 10/70] configure.ac: Change package name, bugreport and url for avrdudes fork --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index d54c1f7..6d60e59 100644 --- a/configure.ac +++ b/configure.ac @@ -28,11 +28,11 @@ m4_define([sp_package_version_minor], [1]) m4_define([sp_package_version_micro], [1]) m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro]) -AC_INIT([libserialport], +AC_INIT([avrdudes bugfix fork of sigrok libserialport], [sp_package_version], - [martin-libserialport@earth.li], + [https://github.com/avrdudes/libserialport/issues], [libserialport], - [http://sigrok.org/wiki/Libserialport]) + [https://github.com/avrdudes/libserialport]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([autostuff]) AC_CONFIG_AUX_DIR([autostuff]) From 9250937c37cfb3d8bcd66ffa07dfadc21f2ced1a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sun, 25 Feb 2024 00:10:15 +0100 Subject: [PATCH 11/70] RRR Update libserialport.h version info when necessary Starting with commit f6e32b2dfa322aa4bd4a279a46d588e0e73ea238, libserialport.h has become a static file which needs manual updates of some of its content whenever some content in configure.ac changes. This updates the libserialport.h file if it should be changed, and suggests committing the changed file and aborts autoreconf. This gives a human user an opportunity to react, and aborts automatic processes which had the unnoticed inconsistent state. As the updating code runs at autoreconf time, it should be run automatically every time configure.ac has changed and therefore when the relevant information might have been changed. The C preprocessor macros in libserialport.h which this updates SP_PACKAGE_VERSION_MAJOR SP_PACKAGE_VERSION_MINOR SP_PACKAGE_VERSION_MICRO SP_PACKAGE_VERSION_STRING SP_LIB_VERSION_CURRENT SP_LIB_VERSION_REVISION SP_LIB_VERSION_AGE SP_LIB_VERSION_STRING --- buildstuff/sed-update-source-file | 43 +++++++++++++++++++++++++++++ configure.ac | 46 ++++++++++++++++++++++++------- 2 files changed, 79 insertions(+), 10 deletions(-) create mode 100755 buildstuff/sed-update-source-file diff --git a/buildstuff/sed-update-source-file b/buildstuff/sed-update-source-file new file mode 100755 index 0000000..981bb88 --- /dev/null +++ b/buildstuff/sed-update-source-file @@ -0,0 +1,43 @@ +#! /bin/sh +# +# Usage: +# sed-update-source-file sed-arguments... +# +# This will take the given source file , run sed with the given sed arguments on it, and if the sed output differs from the input, will update and not + +set -e + +prog="$(basename "$0")" + +fname="$1" +test -n "$fname" || { + echo "$prog: error: no source file given" >&2 + exit 2 +} +shift +test -f "$fname" || { + echo "$prog: error: source file is no file: $fname" >&2 + exit 2 +} + +tname="$fname.tmp.$$" + + +${SED-sed} "$@" < "$fname" > "$tname" || { + s="$?" + echo "$prog: Error running sed, exit code $s." + rm -f "$tname" + exit 2 +} + +if ${CMP-cmp} "$fname" "$tname" > /dev/null; then + # echo "$prog: source file up to date: $fname" >&2 + rm -f "$tname" + exit 0 +else + ${DIFF-diff} -u "$fname" "$tname" >&2 ||: + mv -f "$tname" "$fname" + echo "$prog: source file has been updated: $fname" >&2 + echo "$prog: commit the file, and then re-run autoreconf." >&2 + exit 1 +fi diff --git a/configure.ac b/configure.ac index 6d60e59..4dc5707 100644 --- a/configure.ac +++ b/configure.ac @@ -93,16 +93,42 @@ AC_SUBST([SP_PACKAGE_VERSION], [sp_package_version]) # Carefully read the libtool docs before updating these numbers! # The algorithm for determining which number to change (and how) is nontrivial! # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info -SP_LIB_VERSION_CURRENT=1 -SP_LIB_VERSION_REVISION=0 -SP_LIB_VERSION_AGE=1 -AC_SUBST([SP_LIB_VERSION], - ["$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"]) - -AC_DEFINE_UNQUOTED([SP_LIB_VERSION_CURRENT], [$SP_LIB_VERSION_CURRENT], [.]) -AC_DEFINE_UNQUOTED([SP_LIB_VERSION_REVISION], [$SP_LIB_VERSION_REVISION], [.]) -AC_DEFINE_UNQUOTED([SP_LIB_VERSION_AGE], [$SP_LIB_VERSION_AGE], [.]) -AC_DEFINE_UNQUOTED([SP_LIB_VERSION_STRING], ["$SP_LIB_VERSION"], [.]) +m4_define([sp_lib_version_current], [1])dnl +m4_define([sp_lib_version_revision], [0])dnl +m4_define([sp_lib_version_age], [1])dnl +m4_define([sp_lib_version], [sp_lib_version_current:sp_lib_version_revision:sp_lib_version_age])dnl +AC_SUBST([SP_LIB_VERSION], ["sp_lib_version"]) + +AC_DEFINE_UNQUOTED([SP_LIB_VERSION_CURRENT], [sp_lib_version_current], [.]) +AC_DEFINE_UNQUOTED([SP_LIB_VERSION_REVISION], [sp_lib_version_revision], [.]) +AC_DEFINE_UNQUOTED([SP_LIB_VERSION_AGE], [sp_lib_version_age], [.]) +AC_DEFINE_UNQUOTED([SP_LIB_VERSION_STRING], ["sp_lib_version"], [.]) + +dnl ------------------------------------------------------------------------ +dnl When necessary, update the libserialport.h source file according +dnl to changed above sp_package_version* and sp_lib_version* values. +dnl ------------------------------------------------------------------------ +m4_define([sp_sed_command_args], [])dnl +m4_define([sp_sed_command_add], [dnl + m4_append([sp_sed_command_args], + [ -e 's|^\([[:punct:]]define $1\)[[:space:]].*|\1 ]$2[|g'])dnl +])dnl +dnl +sp_sed_command_add([SP_PACKAGE_VERSION_MAJOR], [sp_package_version_major])dnl +sp_sed_command_add([SP_PACKAGE_VERSION_MINOR], [sp_package_version_minor])dnl +sp_sed_command_add([SP_PACKAGE_VERSION_MICRO], [sp_package_version_micro])dnl +sp_sed_command_add([SP_PACKAGE_VERSION_STRING], ["sp_package_version"])dnl +dnl +sp_sed_command_add([SP_LIB_VERSION_CURRENT], [sp_lib_version_current])dnl +sp_sed_command_add([SP_LIB_VERSION_REVISION], [sp_lib_version_revision])dnl +sp_sed_command_add([SP_LIB_VERSION_AGE], [sp_lib_version_age])dnl +sp_sed_command_add([SP_LIB_VERSION_STRING], ["sp_lib_version"])dnl +dnl +m4_esyscmd([./buildstuff/sed-update-source-file libserialport.h]m4_defn([sp_sed_command_args]))dnl +m4_case(m4_sysval, [0], [], [dnl + m4_fatal([sed-update-source-file script returned non-0]) +])dnl + AM_CONDITIONAL([LINUX], [test -z "${host_os##linux*}" || test -z "${host_os##uclinux*}"]) AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}"]) From 9fb9d8d0bb7a44be5e87d0c1118001a0698cf380 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 03:05:21 +0100 Subject: [PATCH 12/70] configure.ac: Add tweak number Adding such a suffix lets the upstream versions compare higher than the avrdude fork versioning. This also means that the NEWS must mention the new version. Unfortunately, the 0.1.2-avrdude tag does still claim to be the 0.1.1 version. --- NEWS | 5 +++++ configure.ac | 3 ++- libserialport.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 7afa688..3ed1fd8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +0.1.1.23 (2024-02-20) +--------------------- + + * Fix some devices on OSX (make buffer large enough for OSX class string) + 0.1.1 (2016-01-27) ------------------ diff --git a/configure.ac b/configure.ac index 4dc5707..2698174 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,8 @@ m4_pattern_forbid([sp_package_]) m4_define([sp_package_version_major], [0]) m4_define([sp_package_version_minor], [1]) m4_define([sp_package_version_micro], [1]) -m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro]) +m4_define([sp_package_version_tweak], [23]) +m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro]m4_ifdef([sp_package_version_tweak], [.][sp_package_version_tweak])) AC_INIT([avrdudes bugfix fork of sigrok libserialport], [sp_package_version], diff --git a/libserialport.h b/libserialport.h index 7467f74..8e8a585 100644 --- a/libserialport.h +++ b/libserialport.h @@ -1717,7 +1717,7 @@ SP_API void sp_default_debug_handler(const char *format, ...); #define SP_PACKAGE_VERSION_MICRO 1 /** The libserialport package version ("major.minor.micro") as string. */ -#define SP_PACKAGE_VERSION_STRING "0.1.1" +#define SP_PACKAGE_VERSION_STRING "0.1.1.23" /* * Library/libtool version macros (can be used for conditional compilation). From 98b82f37669e7165aefb537b06a01751db6878fb Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sun, 25 Feb 2024 01:01:25 +0100 Subject: [PATCH 13/70] Group all m4 version definitions at the top Move the m4 lib version definitions to the top close to the m4 package version definitions to have them all in one place. --- configure.ac | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 2698174..c2784e2 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,15 @@ m4_define([sp_package_version_micro], [1]) m4_define([sp_package_version_tweak], [23]) m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro]m4_ifdef([sp_package_version_tweak], [.][sp_package_version_tweak])) +# Library version for libserialport (NOT the same as the package version). +# Carefully read the libtool docs before updating these numbers! +# The algorithm for determining which number to change (and how) is nontrivial! +# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info +m4_define([sp_lib_version_current], [1]) +m4_define([sp_lib_version_revision], [0]) +m4_define([sp_lib_version_age], [1]) +m4_define([sp_lib_version], [sp_lib_version_current:sp_lib_version_revision:sp_lib_version_age]) + AC_INIT([avrdudes bugfix fork of sigrok libserialport], [sp_package_version], [https://github.com/avrdudes/libserialport/issues], @@ -90,14 +99,6 @@ AC_DEFINE_UNQUOTED([SP_PACKAGE_VERSION_MICRO], [sp_package_version_micro], [.]) AC_DEFINE_UNQUOTED([SP_PACKAGE_VERSION_STRING], ["sp_package_version"], [.]) AC_SUBST([SP_PACKAGE_VERSION], [sp_package_version]) -# Library version for libserialport (NOT the same as the package version). -# Carefully read the libtool docs before updating these numbers! -# The algorithm for determining which number to change (and how) is nontrivial! -# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info -m4_define([sp_lib_version_current], [1])dnl -m4_define([sp_lib_version_revision], [0])dnl -m4_define([sp_lib_version_age], [1])dnl -m4_define([sp_lib_version], [sp_lib_version_current:sp_lib_version_revision:sp_lib_version_age])dnl AC_SUBST([SP_LIB_VERSION], ["sp_lib_version"]) AC_DEFINE_UNQUOTED([SP_LIB_VERSION_CURRENT], [sp_lib_version_current], [.]) From 31b78ead69226497ade2cf3e7734129631c448d4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Feb 2024 20:16:14 +0100 Subject: [PATCH 14/70] XXX CMakeLists.txt --- CMakeLists.txt | 61 +++++++++++++++++++++++ CMakeLists.txt.in | 61 +++++++++++++++++++++++ Makefile.am | 18 +++++++ buildstuff/sed-substitute | 81 +++++++++++++++++++++++++++++++ buildstuff/sed-update-source-file | 4 +- cmake-config.h.in | 11 +++++ configure.ac | 32 ++++++++++++ linux.c | 2 +- 8 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 CMakeLists.txt.in create mode 100755 buildstuff/sed-substitute create mode 100644 cmake-config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..092ceac --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,61 @@ +# @configure_input@ + +cmake_minimum_required(VERSION 3.14) + +project(libserialport + VERSION "@PACKAGE_VERSION@" + DESCRIPTION "@PACKAGE_NAME@" + HOMEPAGE_URL "@PACKAGE_URL@" + LANGUAGES C +) + +include(GNUInstallDirs) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED True) + +configure_file(cmake-config.h.in config.h) +configure_file(libserialport.pc.in libserialport.pc) + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(LSP_SOURCES "macosx.c") +elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(LSP_SOURCES "freebsd.c") +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(LSP_SOURCES "linux.c") +elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(LSP_SOURCES "windows.c") +else() + message(FATAL_ERROR + config.h + "${CMAKE_PROJECT_NAME} does not support this system: ${CMAKE_SYSTEM_NAME}") +endif() + +add_library(libserialport SHARED + ${LSP_SOURCES} +) + +target_include_directories(libserialport + PUBLIC + "${PROJECT_SOURCE_DIR}" + "${PROJECT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}" +) + +set_target_properties(libserialport PROPERTIES + PREFIX "" + PUBLIC_HEADER "libserialport.h" + VERSION @CMAKE_LIB_VERSION@ + SOVERSION @CMAKE_LIB_SOVERSION@ +) + +install(TARGETS libserialport + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + PUBLIC_HEADER DESTINATION include COMPONENT dev +) + +install(FILES "libserialport.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" +) diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in new file mode 100644 index 0000000..163d978 --- /dev/null +++ b/CMakeLists.txt.in @@ -0,0 +1,61 @@ +# @configure_input@ + +cmake_minimum_required(VERSION 3.14) + +project(@PACKAGE_TARNAME@ + VERSION "@PACKAGE_VERSION@" + DESCRIPTION "@PACKAGE_NAME@" + HOMEPAGE_URL "@PACKAGE_URL@" + LANGUAGES C +) + +include(GNUInstallDirs) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED True) + +configure_file(cmake-config.h.in config.h) +configure_file(libserialport.pc.in libserialport.pc) + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(LSP_SOURCES "macosx.c") +elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(LSP_SOURCES "freebsd.c") +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(LSP_SOURCES "linux.c") +elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(LSP_SOURCES "windows.c") +else() + message(FATAL_ERROR + config.h + "${CMAKE_PROJECT_NAME} does not support this system: ${CMAKE_SYSTEM_NAME}") +endif() + +add_library(libserialport SHARED + ${LSP_SOURCES} +) + +target_include_directories(libserialport + PUBLIC + "${PROJECT_SOURCE_DIR}" + "${PROJECT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}" +) + +set_target_properties(libserialport PROPERTIES + PREFIX "" + PUBLIC_HEADER "libserialport.h" + VERSION @CMAKE_LIB_VERSION@ + SOVERSION @CMAKE_LIB_SOVERSION@ +) + +install(TARGETS libserialport + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + PUBLIC_HEADER DESTINATION include COMPONENT dev +) + +install(FILES "libserialport.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" +) diff --git a/Makefile.am b/Makefile.am index 8b0f202..f476eb1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,8 @@ AM_CFLAGS = -std=c99 -Wall -Wextra -pedantic -Wmissing-prototypes -Wshadow # using autotools. AM_CFLAGS += -DLIBSERIALPORT_ATBUILD +noinst_DATA = + lib_LTLIBRARIES = libserialport.la libserialport_la_SOURCES = serialport.c timing.c libserialport_internal.h @@ -115,6 +117,22 @@ EXTRA_DIST += examples/send_receive.c EXTRA_DIST += examples/projects/send_receive.vcxproj EXTRA_DIST += examples/projects/send_receive.vcxproj.filters +SED_CMDS = +SED_CMDS += -e 's|[@]PACKAGE_TARNAME[@]|$(PACKAGE_TARNAME)|g' +SED_CMDS += -e 's|[@]PACKAGE_TARNAME[@]|$(PACKAGE_TARNAME)|g' + +EXTRA_DIST += CMakeLists.txt.in +EXTRA_DIST += $(srcdir)/CMakeLists.txt +noinst_DATA += $(srcdir)/CMakeLists.txt +$(srcdir)/CMakeLists.txt: CMakeLists.txt.in + if $(SED) $(SED_CMDS) $< > $@.tmp.$$$$; then \ + mv -f "$@.tmp.$$$$" "$@"; \ + else \ + s="$?"; \ + rm -f "$@.tmp.$$$$"; \ + exit "$s"; \ + fi + .PHONY: ChangeLog doc ChangeLog: diff --git a/buildstuff/sed-substitute b/buildstuff/sed-substitute new file mode 100755 index 0000000..74b45a3 --- /dev/null +++ b/buildstuff/sed-substitute @@ -0,0 +1,81 @@ +#! /bin/sh +# +# Usage: +# sed-substitute sed-arguments... +# +# This will take the given source file (must end with +# ".in"), run sed with the given sed arguments on it, and checks if +# the result is different from the without the trailing +# ".in". +# +# If this changes the content of , it updates the +# file and fails the autoreconf run to allow the user to commit the +# generated file. + +set -e + +prog="$(basename "$0")" + +inname="$1" +test -n "$inname" || { + echo "$prog: error: no source file given" >&2 + exit 2 +} +shift +case "$inname" in + *.in) + : + ;; + *) + echo "$prog: error: source file name does not end with \".in\": $inname" >&2 + exit 2 + ;; +esac +test -f "$inname" || { + echo "$prog: error: source file is no file: $inname" >&2 + exit 2 +} + +case "$outname" in + */*) + outname="$(dirname "$inname")/$(basename "$inname" .in)" + ;; + *) + outname="$(basename "$inname" .in)" + ;; +esac + +tmpname="$outname.tmp.$$" + + +${SED-sed} -e "s|[@]configure_input[@]|$outname. Generated from $inname by configure.ac.|g" "$@" < "$inname" > "$tmpname" || { + s="$?" + echo "$prog: Error running sed, exit code $s." + rm -f "$tmpname" + exit 2 +} + +if grep '[@][A-Za-z0-9_-]\{1,\}@' "$tmpname" >&2; then + echo "$prog: Unsubstituted values found while substituting $inname" >&2 + rm -f "$tmpname" + exit 2 +fi + +if test -f "$outname"; then + if ${CMP-cmp} "$outname" "$tmpname" > /dev/null; then + # echo "$prog: source file up to date: $outname" >&2 + rm -f "$tmpname" + exit 0 + else + ${DIFF-diff} -u "$outname" "$tmpname" >&2 ||: + mv -f "$tmpname" "$outname" + echo "$prog: source file has been updated: $outname" >&2 + echo "$prog: commit the file, and then re-run autoreconf." >&2 + exit 1 + fi +else + mv -f "$tmpname" "$outname" + echo "$prog: created new source file: $outname" >&2 + echo "$prog: commit the file, and then re-run autoreconf." >&2 + exit 1 +fi diff --git a/buildstuff/sed-update-source-file b/buildstuff/sed-update-source-file index 981bb88..eadfce3 100755 --- a/buildstuff/sed-update-source-file +++ b/buildstuff/sed-update-source-file @@ -3,7 +3,9 @@ # Usage: # sed-update-source-file sed-arguments... # -# This will take the given source file , run sed with the given sed arguments on it, and if the sed output differs from the input, will update and not +# This will take the given source file , run sed with the +# given sed commands on it, and if the sed output differs from the +# input, will update and abort the autoreconf process. set -e diff --git a/cmake-config.h.in b/cmake-config.h.in new file mode 100644 index 0000000..ba40a81 --- /dev/null +++ b/cmake-config.h.in @@ -0,0 +1,11 @@ +/* cmake-config.h.in. Manually generated from config.h.in */ + +#cmakedefine SP_PACKAGE_VERSION_MAJOR +#cmakedefine SP_PACKAGE_VERSION_MINOR +#cmakedefine SP_PACKAGE_VERSION_MICRO +#cmakedefine SP_PACKAGE_VERSION_STRING + +#cmakedefine SP_LIB_VERSION_CURRENT +#cmakedefine SP_LIB_VERSION_AGE +#cmakedefine SP_LIB_VERSION_REVISION +#cmakedefine SP_LIB_VERSION_STRING diff --git a/configure.ac b/configure.ac index c2784e2..178508e 100644 --- a/configure.ac +++ b/configure.ac @@ -61,6 +61,7 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) # Checks for programs. AC_PROG_CC +AC_PROG_SED AC_PROG_INSTALL AC_PROG_LN_S @@ -131,6 +132,37 @@ m4_case(m4_sysval, [0], [], [dnl m4_fatal([sed-update-source-file script returned non-0]) ])dnl +dnl ------------------------------------------------------------------------ +dnl Generate the CMakeLists.txt file from CMakeLists.txt.in according +dnl to the above sp_package_version* and sp_lib_version* values. +dnl ------------------------------------------------------------------------ +m4_define([sp_sed_command_args], [])dnl +m4_define([sp_sed_command_add], [dnl + m4_append([sp_sed_command_args], + [ -e 's|[@]]$1[@|]$2[|g'])dnl +])dnl +dnl +sp_sed_command_add([PACKAGE_TARNAME], [AC_PACKAGE_TARNAME])dnl +sp_sed_command_add([PACKAGE_NAME], [AC_PACKAGE_NAME])dnl +sp_sed_command_add([PACKAGE_VERSION], [AC_PACKAGE_VERSION])dnl +sp_sed_command_add([PACKAGE_URL], [AC_PACKAGE_URL])dnl +dnl +dnl TODO: Make sure the _minor and _micro values are calculcated correctly. +m4_define([cmake_lib_version_major], [m4_eval(sp_lib_version_current, sp_lib_version_age)])dnl +m4_define([cmake_lib_version_minor], [sp_lib_version_age])dnl +m4_define([cmake_lib_version_micro], [sp_lib_version_revision])dnl +m4_define([cmake_lib_version], sp_lib_version_major.sp_lib_version_minor.sp_lib_version_micro)dnl +sp_sed_command_add([CMAKE_LIB_SOVERSION], [cmake_lib_version_major])dnl +sp_sed_command_add([CMAKE_LIB_VERSION], [cmake_lib_version])dnl +dnl +AC_SUBST([LIBGPHOTO2_CURRENT_MIN], + [`expr $LIBGPHOTO2_CURRENT - $LIBGPHOTO2_AGE`]) + +m4_esyscmd([./buildstuff/sed-substitute CMakeLists.txt.in]m4_defn([sp_sed_command_args]))dnl +m4_case(m4_sysval, [0], [], [dnl + m4_fatal([sed-substitute script returned non-0]) +])dnl + AM_CONDITIONAL([LINUX], [test -z "${host_os##linux*}" || test -z "${host_os##uclinux*}"]) AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}"]) diff --git a/linux.c b/linux.c index 8f32085..5b3b1d0 100644 --- a/linux.c +++ b/linux.c @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -#include +#include "config.h" #include "libserialport.h" #include "libserialport_internal.h" From 672b35c662e2f31a4b2930657f57840339480cc3 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 03:43:39 +0100 Subject: [PATCH 15/70] XXX First shot at CI builds --- .github/workflows/build.yml | 81 +++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 12 +++--- 2 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4cbefa7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,81 @@ +# +# build.yml - GitHub build action for libserialport adapted from AVRDUDE +# Copyright (C) 2021 Marius Greuel +# Copyright (C) 2024 Hans Ulrich Niedermann +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +name: Build + +on: + push: + branches-ignore: + - 'onlinedocs' + pull_request: + branches-ignore: + - 'onlinedocs' + workflow_call: + +jobs: + linux-x86_64-autotools: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install prerequisites + run: >- + sudo apt-get update + + sudo apt-get install -y + build-essential + automake + libtool + - name: Configure + run: >- + ./autogen.sh + + mkdir _atbuild && cd _atbuild + + ../configure + --prefix=$PWD/../_amprefix + - name: Build + run: make -C _atbuild -j$(nproc) + - name: Install + run: sudo make -C _atbuild install + - name: distcheck + run: make -C _atbuild -j$(nproc) distcheck + - name: List installed files + run: find _amprefix | env LC_ALL=C sort + + linux-x86_64-cmake: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install prerequisites + run: >- + sudo apt-get update + + sudo apt-get install -y + build-essential + cmake -D CMAKE_INSTALL_PREFIX:PATH=$PWD/_cmprefix + - name: Configure + run: >- + cmake + -B build + - name: Build + run: cmake --build build + - name: Install + run: sudo cmake --build build --target install + - name: List installed files + run: find _cmprefix | env LC_ALL=C sort diff --git a/CMakeLists.txt b/CMakeLists.txt index 092ceac..49eb3a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ -# @configure_input@ +# CMakeLists.txt. Generated from CMakeLists.txt.in by configure.ac. cmake_minimum_required(VERSION 3.14) project(libserialport - VERSION "@PACKAGE_VERSION@" - DESCRIPTION "@PACKAGE_NAME@" - HOMEPAGE_URL "@PACKAGE_URL@" + VERSION "0.1.1.23" + DESCRIPTION "avrdudes bugfix fork of sigrok libserialport" + HOMEPAGE_URL "https://github.com/avrdudes/libserialport" LANGUAGES C ) @@ -46,8 +46,8 @@ target_include_directories(libserialport set_target_properties(libserialport PROPERTIES PREFIX "" PUBLIC_HEADER "libserialport.h" - VERSION @CMAKE_LIB_VERSION@ - SOVERSION @CMAKE_LIB_SOVERSION@ + VERSION sp_lib_version_major.sp_lib_version_minor.sp_lib_version_micro + SOVERSION 1 ) install(TARGETS libserialport From 77ef34560f34e4922a00cd53590601a750bbd701 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 03:50:27 +0100 Subject: [PATCH 16/70] XXX CI --- .github/workflows/build.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4cbefa7..5dc366d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,15 +48,15 @@ jobs: mkdir _atbuild && cd _atbuild ../configure - --prefix=$PWD/../_amprefix + --prefix=/usr - name: Build run: make -C _atbuild -j$(nproc) - name: Install - run: sudo make -C _atbuild install + run: sudo make -C _atbuild install DESTDIR=$PWD/_d + - name: List installed files + run: find _d | env LC_ALL=C sort | sed 's|^_d||' - name: distcheck run: make -C _atbuild -j$(nproc) distcheck - - name: List installed files - run: find _amprefix | env LC_ALL=C sort linux-x86_64-cmake: runs-on: ubuntu-latest @@ -68,14 +68,15 @@ jobs: sudo apt-get install -y build-essential - cmake -D CMAKE_INSTALL_PREFIX:PATH=$PWD/_cmprefix + cmake - name: Configure run: >- cmake -B build + -D CMAKE_INSTALL_PREFIX:PATH=/usr - name: Build run: cmake --build build - name: Install - run: sudo cmake --build build --target install + run: sudo cmake --build build --target install DESTDIR=$PWD/_d - name: List installed files - run: find _cmprefix | env LC_ALL=C sort + run: find _d | env LC_ALL=C sort | sed 's|^_d||' From d6e319e29bd9c0ee541a30e8f4bce4f43febbb82 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 04:48:07 +0100 Subject: [PATCH 17/70] XXX cmake checkpoint --- CMakeLists.txt | 43 +++++++++++++++++++++++++++------------ CMakeLists.txt.in | 38 ++++++++++++++++++++++++---------- buildstuff/sed-substitute | 5 ++++- cmake-config.h.in | 23 +++++++++++++-------- configure.ac | 6 ++---- 5 files changed, 78 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49eb3a3..96ec99d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ +# ====================================================================== # CMakeLists.txt. Generated from CMakeLists.txt.in by configure.ac. +# DO NOT MODIFY THIS FILE. EDIT CMakeLists.txt.in INSTEAD. +# ====================================================================== cmake_minimum_required(VERSION 3.14) @@ -11,11 +14,13 @@ project(libserialport include(GNUInstallDirs) -set(CMAKE_C_STANDARD 99) -set(CMAKE_C_STANDARD_REQUIRED True) - -configure_file(cmake-config.h.in config.h) -configure_file(libserialport.pc.in libserialport.pc) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/libserialport.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/libserialport.pc" +) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libserialport.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" +) if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(LSP_SOURCES "macosx.c") @@ -31,23 +36,39 @@ else() "${CMAKE_PROJECT_NAME} does not support this system: ${CMAKE_SYSTEM_NAME}") endif() +set(SP_API "__attribute__\(\(visibility\(\"default\"\)\)\)") +set(SP_PRIV "__attribute__\(\(visibility\(\"hidden\"\)\)\)") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/config.h" +) + add_library(libserialport SHARED ${LSP_SOURCES} + "${CMAKE_CURRENT_BINARY_DIR}/config.h" +) + +target_compile_features(libserialport PRIVATE c_std_99) +set_target_properties(libserialport PROPERTIES C_EXTENSIONS OFF) + +target_compile_definitions(libserialport + PRIVATE LIBSERIALPORT_ATBUILD ) target_include_directories(libserialport PUBLIC - "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}" + "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" ) set_target_properties(libserialport PROPERTIES PREFIX "" PUBLIC_HEADER "libserialport.h" - VERSION sp_lib_version_major.sp_lib_version_minor.sp_lib_version_micro - SOVERSION 1 + VERSION 0.1.0 + SOVERSION 0 ) install(TARGETS libserialport @@ -55,7 +76,3 @@ install(TARGETS libserialport ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" PUBLIC_HEADER DESTINATION include COMPONENT dev ) - -install(FILES "libserialport.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" -) diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 163d978..09f4f5f 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -1,4 +1,6 @@ +# ====================================================================== # @configure_input@ +# ====================================================================== cmake_minimum_required(VERSION 3.14) @@ -11,11 +13,13 @@ project(@PACKAGE_TARNAME@ include(GNUInstallDirs) -set(CMAKE_C_STANDARD 99) -set(CMAKE_C_STANDARD_REQUIRED True) - -configure_file(cmake-config.h.in config.h) -configure_file(libserialport.pc.in libserialport.pc) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/libserialport.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/libserialport.pc" +) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libserialport.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" +) if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(LSP_SOURCES "macosx.c") @@ -31,16 +35,32 @@ else() "${CMAKE_PROJECT_NAME} does not support this system: ${CMAKE_SYSTEM_NAME}") endif() +set(SP_API "__attribute__\(\(visibility\(\"default\"\)\)\)") +set(SP_PRIV "__attribute__\(\(visibility\(\"hidden\"\)\)\)") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/config.h" +) + add_library(libserialport SHARED ${LSP_SOURCES} + "${CMAKE_CURRENT_BINARY_DIR}/config.h" +) + +target_compile_features(libserialport PRIVATE c_std_99) +set_target_properties(libserialport PROPERTIES C_EXTENSIONS OFF) + +target_compile_definitions(libserialport + PRIVATE LIBSERIALPORT_ATBUILD ) target_include_directories(libserialport PUBLIC - "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}" + "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" ) set_target_properties(libserialport PROPERTIES @@ -55,7 +75,3 @@ install(TARGETS libserialport ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" PUBLIC_HEADER DESTINATION include COMPONENT dev ) - -install(FILES "libserialport.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" -) diff --git a/buildstuff/sed-substitute b/buildstuff/sed-substitute index 74b45a3..a30d620 100755 --- a/buildstuff/sed-substitute +++ b/buildstuff/sed-substitute @@ -48,7 +48,7 @@ esac tmpname="$outname.tmp.$$" -${SED-sed} -e "s|[@]configure_input[@]|$outname. Generated from $inname by configure.ac.|g" "$@" < "$inname" > "$tmpname" || { +${SED-sed} -e "s|^\(.*\)[@]configure_input[@]|\1$outname. Generated from $inname by configure.ac.\n\1DO NOT MODIFY THIS FILE. EDIT $inname INSTEAD.|g" "$@" < "$inname" > "$tmpname" || { s="$?" echo "$prog: Error running sed, exit code $s." rm -f "$tmpname" @@ -68,13 +68,16 @@ if test -f "$outname"; then exit 0 else ${DIFF-diff} -u "$outname" "$tmpname" >&2 ||: + chmod +w "$outname" mv -f "$tmpname" "$outname" + chmod -w "$outname" echo "$prog: source file has been updated: $outname" >&2 echo "$prog: commit the file, and then re-run autoreconf." >&2 exit 1 fi else mv -f "$tmpname" "$outname" + chmod -w "$outname" echo "$prog: created new source file: $outname" >&2 echo "$prog: commit the file, and then re-run autoreconf." >&2 exit 1 diff --git a/cmake-config.h.in b/cmake-config.h.in index ba40a81..3974528 100644 --- a/cmake-config.h.in +++ b/cmake-config.h.in @@ -1,11 +1,18 @@ /* cmake-config.h.in. Manually generated from config.h.in */ -#cmakedefine SP_PACKAGE_VERSION_MAJOR -#cmakedefine SP_PACKAGE_VERSION_MINOR -#cmakedefine SP_PACKAGE_VERSION_MICRO -#cmakedefine SP_PACKAGE_VERSION_STRING +#if 0 +# define SP_PACKAGE_VERSION_MAJOR @SP_PACKAGE_VERSION_MAJOR@ +# define SP_PACKAGE_VERSION_MINOR @SP_PACKAGE_VERSION_MINOR@ +# define SP_PACKAGE_VERSION_MICRO @SP_PACKAGE_VERSION_MICRO@ +# define SP_PACKAGE_VERSION_STRING "@SP_PACKAGE_VERSION_STRING@" +#endif -#cmakedefine SP_LIB_VERSION_CURRENT -#cmakedefine SP_LIB_VERSION_AGE -#cmakedefine SP_LIB_VERSION_REVISION -#cmakedefine SP_LIB_VERSION_STRING +#if 0 +# define SP_LIB_VERSION_CURRENT @SP_LIB_VERSION_CURRENT@ +# define SP_LIB_VERSION_AGE @SP_LIB_VERSION_AGE@ +# define SP_LIB_VERSION_REVISION @SP_LIB_VERSION_REVISION@ +# define SP_LIB_VERSION_STRING "@SP_LIB_VERSION_STRING@" +#endif + +#define SP_API @SP_API@ +#define SP_PRIV @SP_PRIV@ diff --git a/configure.ac b/configure.ac index 178508e..95a5b4f 100644 --- a/configure.ac +++ b/configure.ac @@ -148,15 +148,13 @@ sp_sed_command_add([PACKAGE_VERSION], [AC_PACKAGE_VERSION])dnl sp_sed_command_add([PACKAGE_URL], [AC_PACKAGE_URL])dnl dnl dnl TODO: Make sure the _minor and _micro values are calculcated correctly. -m4_define([cmake_lib_version_major], [m4_eval(sp_lib_version_current, sp_lib_version_age)])dnl +m4_define([cmake_lib_version_major], [m4_eval(sp_lib_version_current - sp_lib_version_age)])dnl m4_define([cmake_lib_version_minor], [sp_lib_version_age])dnl m4_define([cmake_lib_version_micro], [sp_lib_version_revision])dnl -m4_define([cmake_lib_version], sp_lib_version_major.sp_lib_version_minor.sp_lib_version_micro)dnl +m4_define([cmake_lib_version], m4_defn([cmake_lib_version_major]).m4_defn([cmake_lib_version_minor]).m4_defn([cmake_lib_version_micro]))dnl sp_sed_command_add([CMAKE_LIB_SOVERSION], [cmake_lib_version_major])dnl sp_sed_command_add([CMAKE_LIB_VERSION], [cmake_lib_version])dnl dnl -AC_SUBST([LIBGPHOTO2_CURRENT_MIN], - [`expr $LIBGPHOTO2_CURRENT - $LIBGPHOTO2_AGE`]) m4_esyscmd([./buildstuff/sed-substitute CMakeLists.txt.in]m4_defn([sp_sed_command_args]))dnl m4_case(m4_sysval, [0], [], [dnl From 9f07979184380e861447cb6b05375b0aba420408 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 04:57:37 +0100 Subject: [PATCH 18/70] XXX fix include dir search sequence for config.h --- linux.c | 2 +- test_timing.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/linux.c b/linux.c index 5b3b1d0..8f32085 100644 --- a/linux.c +++ b/linux.c @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -#include "config.h" +#include #include "libserialport.h" #include "libserialport_internal.h" diff --git a/test_timing.c b/test_timing.c index a24de5e..dc047e8 100644 --- a/test_timing.c +++ b/test_timing.c @@ -1,4 +1,4 @@ -#include "config.h" +#include #include "libserialport.h" #include "libserialport_internal.h" #include From 049af6bc6a1a821f518219d1083a3bc3eafdd38e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 04:58:02 +0100 Subject: [PATCH 19/70] XXX --- CMakeLists.txt | 4 ++++ CMakeLists.txt.in | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96ec99d..5f12c26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,10 @@ endif() set(SP_API "__attribute__\(\(visibility\(\"default\"\)\)\)") set(SP_PRIV "__attribute__\(\(visibility\(\"hidden\"\)\)\)") +set(SP_API "__declspec(dllexport)") +set(SP_PRIV "") +set(SP_API "") +set(SP_PRIV "") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 09f4f5f..4c191c0 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -37,6 +37,10 @@ endif() set(SP_API "__attribute__\(\(visibility\(\"default\"\)\)\)") set(SP_PRIV "__attribute__\(\(visibility\(\"hidden\"\)\)\)") +set(SP_API "__declspec(dllexport)") +set(SP_PRIV "") +set(SP_API "") +set(SP_PRIV "") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" From 420b6ca3e34c80ed4dc99c506ff287259bff7dd4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 05:06:25 +0100 Subject: [PATCH 20/70] CI: Change to /usr/local to prevent weird libdir Change prefix to /usr/local to prevent weird libdir /usr/lib/x86_64-linux-gnu/ on Debian/Ubuntu. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5dc366d..d3a583b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,7 +48,7 @@ jobs: mkdir _atbuild && cd _atbuild ../configure - --prefix=/usr + --prefix=/usr/local - name: Build run: make -C _atbuild -j$(nproc) - name: Install @@ -73,7 +73,7 @@ jobs: run: >- cmake -B build - -D CMAKE_INSTALL_PREFIX:PATH=/usr + -D CMAKE_INSTALL_PREFIX:PATH=/usr/local - name: Build run: cmake --build build - name: Install From f86a28be299468b332f4e0120c90d3b899b648e6 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 05:15:49 +0100 Subject: [PATCH 21/70] test-builds.sh --- .gitignore | 5 +++++ test-builds.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 test-builds.sh diff --git a/.gitignore b/.gitignore index 353d778..e0d88cf 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,8 @@ Debug/ Release/ x64/ *.vcxproj.user + +/_amb/ +/_amd/ +/_cmb/ +/_cmd/ diff --git a/test-builds.sh b/test-builds.sh new file mode 100755 index 0000000..d569fd0 --- /dev/null +++ b/test-builds.sh @@ -0,0 +1,27 @@ +#! /bin/sh + +set -ex + +cd "$(dirname "$0")" + +rm -rf autom4te.cache +autoreconf -vis + +rm -rf _cmb +cmake -S . -B _cmb -D CMAKE_INSTALL_PREFIX:PATH=/usr/local +cmake --build _cmb --verbose +cmake --build _cmb --target install DESTDIR="$PWD/_cmd" + +mkdir _amb +cd _amb +../configure --prefix=/usr/local +make -j$(nproc) +make install DESTDIR="$PWD/../_amd" + +cd .. + +diff -u \ + <(find _amd | env LC_ALL=C sort | sed 's|^_amd||') \ + <(find _cmd | env LC_ALL=C sort | sed 's|^_cmd||') + +diff -u _{am,cm}d/lib/pkgconfig/libserialport.pc From beece5f9f8c54a4f7274b8eb3412ae9d2f5986aa Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 05:45:01 +0100 Subject: [PATCH 22/70] XXX Make "doc" target work with out of tree builds --- Doxyfile => Doxyfile.in | 2 +- Makefile.am | 4 ++-- configure.ac | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename Doxyfile => Doxyfile.in (99%) diff --git a/Doxyfile b/Doxyfile.in similarity index 99% rename from Doxyfile rename to Doxyfile.in index 0ac1014..58349ee 100644 --- a/Doxyfile +++ b/Doxyfile.in @@ -819,7 +819,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = libserialport.h +INPUT = @abs_srcdir@/libserialport.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/Makefile.am b/Makefile.am index f476eb1..43d14d8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -150,6 +150,6 @@ DISTCLEANFILES = ChangeLog dist-hook: ChangeLog if HAVE_PROG_DOXYGEN -doc: $(include_HEADERS) $(top_srcdir)/Doxyfile - doxygen $(top_srcdir)/Doxyfile +doc: $(srcdir)/libserialport.h Doxyfile + doxygen `test -f Doxyfile || echo '$(srcdir)/'`Doxyfile endif diff --git a/configure.ac b/configure.ac index 95a5b4f..4b8d747 100644 --- a/configure.ac +++ b/configure.ac @@ -232,7 +232,7 @@ AS_CASE([$sp_cv_visibility_control], AC_DEFINE_UNQUOTED([SP_API], [$SP_API], [Macro preceding public API functions]) AC_DEFINE_UNQUOTED([SP_PRIV], [$SP_PRIV], [Macro preceding private functions]) -AC_CONFIG_FILES([Makefile libserialport.pc]) +AC_CONFIG_FILES([Doxyfile Makefile libserialport.pc]) AC_OUTPUT From cb77bf1f671a94a62fb2283736e5abad5e1c9292 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 05:45:30 +0100 Subject: [PATCH 23/70] Add note about avrdude fork to README and libserialport.h --- README | 6 ++++++ libserialport.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/README b/README index 817dff7..9f0b05d 100644 --- a/README +++ b/README @@ -2,6 +2,12 @@ libserialport: cross-platform library for accessing serial ports ------------------------------------------------------------------------------- + /---------------------------------\ + | THIS IS A FORK OF libserialport | + | FOR THE avrdude PROJECT TO HELP | + | COLLECT FIXES TO FEED UPSTREAM. | + \---------------------------------/ + libserialport is a minimal library written in C that is intended to take care of the OS-specific details when writing software that uses serial ports. diff --git a/libserialport.h b/libserialport.h index 8e8a585..0c3acf4 100644 --- a/libserialport.h +++ b/libserialport.h @@ -33,6 +33,9 @@ * * libserialport is an open source project released under the LGPL3+ license. * + * **This is a fork of upstream libserialport for integration with avrdude + * and fixing bugs and collecting patches to feed back to upstream.** + * * The library is maintained by the [sigrok](http://sigrok.org/) project. See * the [libserialport homepage](http://sigrok.org/wiki/Libserialport) for the * latest information. From c27ef1175e02a8c84b9e9117a8675da0e8f5909f Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 05:45:37 +0100 Subject: [PATCH 24/70] XXX test-builds.sh --- test-builds.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test-builds.sh b/test-builds.sh index d569fd0..04485db 100755 --- a/test-builds.sh +++ b/test-builds.sh @@ -7,16 +7,28 @@ cd "$(dirname "$0")" rm -rf autom4te.cache autoreconf -vis -rm -rf _cmb +for d in _{am,cm}{b,d} +do + test -d "$d" || continue + chmod -R +w "$d" + rm -rf "$d" +done + cmake -S . -B _cmb -D CMAKE_INSTALL_PREFIX:PATH=/usr/local cmake --build _cmb --verbose cmake --build _cmb --target install DESTDIR="$PWD/_cmd" mkdir _amb cd _amb -../configure --prefix=/usr/local -make -j$(nproc) +configure_args="" +if test -d /usr/lib64; then + configure_args="$configure_args --libdir=\${exec_prefix}/lib64" +fi +../configure --prefix=/usr/local ${configure_args} +make -j$(nproc) V=1 make install DESTDIR="$PWD/../_amd" +make -j$(nproc) doc +make -j$(nproc) distcheck cd .. From eca8fec52f1a9fb2486494fb4484343978a35400 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 05:47:16 +0100 Subject: [PATCH 25/70] XXX substitution --- CMakeLists.txt | 3 ++- buildstuff/sed-substitute | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f12c26..5f5bad9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ # ====================================================================== # CMakeLists.txt. Generated from CMakeLists.txt.in by configure.ac. -# DO NOT MODIFY THIS FILE. EDIT CMakeLists.txt.in INSTEAD. +# !!!!!!! DO NOT MODIFY THIS FILE !!!!!!!! +# EDIT CMakeLists.txt.in INSTEAD AND RE-RUN autoreconf. # ====================================================================== cmake_minimum_required(VERSION 3.14) diff --git a/buildstuff/sed-substitute b/buildstuff/sed-substitute index a30d620..81024d4 100755 --- a/buildstuff/sed-substitute +++ b/buildstuff/sed-substitute @@ -48,7 +48,7 @@ esac tmpname="$outname.tmp.$$" -${SED-sed} -e "s|^\(.*\)[@]configure_input[@]|\1$outname. Generated from $inname by configure.ac.\n\1DO NOT MODIFY THIS FILE. EDIT $inname INSTEAD.|g" "$@" < "$inname" > "$tmpname" || { +${SED-sed} -e "s|^\(.*\)[@]configure_input[@]|\1$outname. Generated from $inname by configure.ac.\n\1!!!!!!! DO NOT MODIFY THIS FILE !!!!!!!!\n\1EDIT $inname INSTEAD AND RE-RUN autoreconf.|g" "$@" < "$inname" > "$tmpname" || { s="$?" echo "$prog: Error running sed, exit code $s." rm -f "$tmpname" From a4d4dbf30d72419997f2f062e831675ba4a9b40c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 06:10:43 +0100 Subject: [PATCH 26/70] test-builds.sh: mingw cross build --- .gitignore | 2 ++ test-builds.sh | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e0d88cf..48110dd 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,8 @@ Release/ x64/ *.vcxproj.user +/_amb-w64/ +/_amd-w64/ /_amb/ /_amd/ /_cmb/ diff --git a/test-builds.sh b/test-builds.sh index 04485db..7878fd4 100755 --- a/test-builds.sh +++ b/test-builds.sh @@ -7,7 +7,25 @@ cd "$(dirname "$0")" rm -rf autom4te.cache autoreconf -vis -for d in _{am,cm}{b,d} +find_in_path() { + local d + local saved_IFS + saved_IFS="$IFS" + IFS=":" + for d in $PATH + do + IFS="$saved_IFS" + if test -x "$d/$1" + then + echo "$d/$1" + return 0 + fi + done + IFS="$saved_IFS" + return 1 +} + +for d in _{am,cm}{b,d}{,-w64} do test -d "$d" || continue chmod -R +w "$d" @@ -27,13 +45,33 @@ fi ../configure --prefix=/usr/local ${configure_args} make -j$(nproc) V=1 make install DESTDIR="$PWD/../_amd" +cd .. + +if find_in_path mingw64-configure && find_in_path mingw64-make +then + mkdir _amb-w64 + cd _amb-w64 + mingw64-configure + mingw64-make -j$(nproc) V=1 + mingw64-make install DESTDIR="$PWD/../_amd-w64" + cd .. +fi + +cd _amb make -j$(nproc) doc make -j$(nproc) distcheck - cd .. diff -u \ <(find _amd | env LC_ALL=C sort | sed 's|^_amd||') \ - <(find _cmd | env LC_ALL=C sort | sed 's|^_cmd||') + <(find _cmd | env LC_ALL=C sort | sed 's|^_cmd||') \ +||: + +diff -u _{am,cm}d/lib/pkgconfig/libserialport.pc \ +||: + +diff -u \ + <(find _amd -not -type d | env LC_ALL=C sort | sed 's|^_amd||' | sed 's|^/usr/local||' | sed 's|^/lib64/|/lib/|') \ + <(find _amd-w64 -not -type d | env LC_ALL=C sort | sed 's|^_amd-w64||' | sed 's|^/usr/x86_64-w64-mingw32/sys-root/mingw||') \ +||: -diff -u _{am,cm}d/lib/pkgconfig/libserialport.pc From f22b1ccc04efc7df83a8e6f3d40122b61b0fb2b9 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 06:38:28 +0100 Subject: [PATCH 27/70] CI: Debian for i386, armhf, arm64 --- .github/workflows/build.yml | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3a583b..0b9e2ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,9 @@ on: - 'onlinedocs' workflow_call: +env: + BUILD_TYPE: RelWithDebInfo + jobs: linux-x86_64-autotools: runs-on: ubuntu-latest @@ -73,6 +76,7 @@ jobs: run: >- cmake -B build + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D CMAKE_INSTALL_PREFIX:PATH=/usr/local - name: Build run: cmake --build build @@ -80,3 +84,41 @@ jobs: run: sudo cmake --build build --target install DESTDIR=$PWD/_d - name: List installed files run: find _d | env LC_ALL=C sort | sed 's|^_d||' + + linux: + runs-on: ubuntu-latest + container: debian:11 + strategy: + matrix: + include: + - { arch: i386, processor: i686, prefix: i686-linux-gnu, inc-lib: i386-linux-gnu } + - { arch: armhf, processor: armhf, prefix: arm-linux-gnueabihf, inc-lib: arm-linux-gnueabihf } + - { arch: arm64, processor: aarch64, prefix: aarch64-linux-gnu, inc-lib: aarch64-linux-gnu } + steps: + - uses: actions/checkout@v3 + - name: Add architecture + run: | + dpkg --add-architecture ${{matrix.arch}} + apt-get update + - name: Install prerequisites + run: >- + apt-get update + + apt-get install -y + git + cmake + crossbuild-essential-${{matrix.arch}} + - name: Configure + run: >- + cmake + -D DEBUG_CMAKE=1 + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + -D CMAKE_SYSTEM_NAME=Linux + -D CMAKE_SYSTEM_PROCESSOR=${{matrix.processor}} + -D CMAKE_C_COMPILER=${{matrix.prefix}}-gcc + -D CMAKE_FIND_ROOT_PATH=/usr/${{matrix.prefix}} + -D CMAKE_INCLUDE_PATH=/usr/include/${{matrix.inc-lib}} + -D CMAKE_LIBRARY_PATH=/usr/lib/${{matrix.inc-lib}} + -B build + - name: Build + run: cmake --build build From 592ae79af1f44b5e10ddf213f5397cbd3ff13139 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 06:54:40 +0100 Subject: [PATCH 28/70] CI: add macos --- .github/workflows/build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b9e2ee..f6d1ad5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -122,3 +122,24 @@ jobs: -B build - name: Build run: cmake --build build + + macos-x86_64: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Install prerequisites + run: >- + # brew update + + brew install + cmake + - name: Configure + run: >- + cmake + -D CMAKE_C_FLAGS=-I/usr/local/include + -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar + -D DEBUG_CMAKE=1 + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + -B build + - name: Build + run: cmake --build build From 9d96733aac3fe7311e0544184081ed7d04c7e47c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 06:44:08 +0100 Subject: [PATCH 29/70] CI: add msvc and mingw builds for windows --- .github/workflows/build.yml | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6d1ad5..b4e8a9f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,3 +143,57 @@ jobs: -B build - name: Build run: cmake --build build + + msvc: + runs-on: windows-latest + strategy: + matrix: + include: + - { arch: x86, platform: Win32 } + - { arch: x64, platform: x64 } + - { arch: arm64, platform: ARM64 } + steps: + - uses: actions/checkout@v3 + - name: Configure + run: >- + cmake + -A ${{matrix.platform}} + -D DEBUG_CMAKE=1 + -D CMAKE_SYSTEM_VERSION=11 + -D CMAKE_C_FLAGS_RELWITHDEBINFO="/MT /GL /Zi /O2 /Ob1 /DNDEBUG" + -D CMAKE_CXX_FLAGS_RELWITHDEBINFO="/MT /GL /Zi /O2 /Ob1 /DNDEBUG" + -D CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="/DEBUG /INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF" + -B build + - name: Build + run: cmake --build build --config ${{env.BUILD_TYPE}} + + mingw: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + strategy: + matrix: + include: + - { sys: mingw64, env: x86_64 } + - { sys: ucrt64, env: ucrt-x86_64 } + - { sys: clang64, env: clang-x86_64 } + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + update: true + install: >- + base-devel + mingw-w64-${{matrix.env}}-gcc + mingw-w64-${{matrix.env}}-cmake + - name: Configure + run: >- + cmake + -G"MSYS Makefiles" + -D DEBUG_CMAKE=1 + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + -B build + - name: Build + run: cmake --build build From 6e9a6e9c879b08e1ac64b001aec4f9f48a670e21 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 07:21:29 +0100 Subject: [PATCH 30/70] XXX Add default/hidden attrs and __declspec(dllexport) --- CMakeLists.txt | 25 +++++++++++++++++++------ CMakeLists.txt.in | 25 +++++++++++++++++++------ test-visibility-control-attribute.c | 1 + test-visibility-control-declspec.c | 1 + 4 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 test-visibility-control-attribute.c create mode 100644 test-visibility-control-declspec.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f5bad9..c0c2246 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,12 +37,25 @@ else() "${CMAKE_PROJECT_NAME} does not support this system: ${CMAKE_SYSTEM_NAME}") endif() -set(SP_API "__attribute__\(\(visibility\(\"default\"\)\)\)") -set(SP_PRIV "__attribute__\(\(visibility\(\"hidden\"\)\)\)") -set(SP_API "__declspec(dllexport)") -set(SP_PRIV "") -set(SP_API "") -set(SP_PRIV "") +set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE) +try_compile(VISIBILITY_CONTROL_ATTRIBUTE + "${PROJECT_BINARY_DIR}/bindir1" + "${CMAKE_CURRENT_SOURCE_DIR}/test-visibility-control-attribute.c" +) +try_compile(VISIBILITY_CONTROL_DECLSPEC + "${PROJECT_BINARY_DIR}/bindir2" + "${CMAKE_CURRENT_SOURCE_DIR}/test-visibility-control-declspec.c" +) +if(VISIBILITY_CONTROL_ATTRIBUTE) + set(SP_API "__attribute__((visibility(\"default\")))") + set(SP_PRIV "__attribute__((visibility(\"hidden\")))") +elseif(VISIBILITY_CONTROL_DECLSPEC) + set(SP_API "__declspec(dllexport)") + set(SP_PRIV "") +else() + set(SP_API "") + set(SP_PRIV "") +endif() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 4c191c0..39fa584 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -35,12 +35,25 @@ else() "${CMAKE_PROJECT_NAME} does not support this system: ${CMAKE_SYSTEM_NAME}") endif() -set(SP_API "__attribute__\(\(visibility\(\"default\"\)\)\)") -set(SP_PRIV "__attribute__\(\(visibility\(\"hidden\"\)\)\)") -set(SP_API "__declspec(dllexport)") -set(SP_PRIV "") -set(SP_API "") -set(SP_PRIV "") +set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE) +try_compile(VISIBILITY_CONTROL_ATTRIBUTE + "${PROJECT_BINARY_DIR}/bindir1" + "${CMAKE_CURRENT_SOURCE_DIR}/test-visibility-control-attribute.c" +) +try_compile(VISIBILITY_CONTROL_DECLSPEC + "${PROJECT_BINARY_DIR}/bindir2" + "${CMAKE_CURRENT_SOURCE_DIR}/test-visibility-control-declspec.c" +) +if(VISIBILITY_CONTROL_ATTRIBUTE) + set(SP_API "__attribute__((visibility(\"default\")))") + set(SP_PRIV "__attribute__((visibility(\"hidden\")))") +elseif(VISIBILITY_CONTROL_DECLSPEC) + set(SP_API "__declspec(dllexport)") + set(SP_PRIV "") +else() + set(SP_API "") + set(SP_PRIV "") +endif() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" diff --git a/test-visibility-control-attribute.c b/test-visibility-control-attribute.c new file mode 100644 index 0000000..a8b3414 --- /dev/null +++ b/test-visibility-control-attribute.c @@ -0,0 +1 @@ +__attribute__((visibility("hidden"))) void foo(void) {} diff --git a/test-visibility-control-declspec.c b/test-visibility-control-declspec.c new file mode 100644 index 0000000..e21aafb --- /dev/null +++ b/test-visibility-control-declspec.c @@ -0,0 +1 @@ +__declspec(dllexport) void foo(void) {} From dc840b7d2d032641f5cb8efe4e291cf64b830ce2 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 07:34:01 +0100 Subject: [PATCH 31/70] CI: combine workflow stuff --- .github/workflows/build.yml | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b4e8a9f..14df03b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,8 @@ env: BUILD_TYPE: RelWithDebInfo jobs: - linux-x86_64-autotools: + + linux-x86_64: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -42,48 +43,39 @@ jobs: sudo apt-get install -y build-essential + cmake automake libtool - - name: Configure + - name: at: configure run: >- ./autogen.sh - mkdir _atbuild && cd _atbuild + mkdir _build-at && cd _build-at ../configure --prefix=/usr/local - - name: Build - run: make -C _atbuild -j$(nproc) - - name: Install - run: sudo make -C _atbuild install DESTDIR=$PWD/_d - - name: List installed files - run: find _d | env LC_ALL=C sort | sed 's|^_d||' + - name: at: build + run: make -C _build-at -j$(nproc) + - name: at: install + run: sudo make -C _build-at install DESTDIR=$PWD/_d + - name: at: list installed files + run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' - name: distcheck run: make -C _atbuild -j$(nproc) distcheck - - linux-x86_64-cmake: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install prerequisites + - name: cm: configure run: >- - sudo apt-get update + cd .. - sudo apt-get install -y - build-essential - cmake - - name: Configure - run: >- cmake - -B build + -B _build-cm -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D CMAKE_INSTALL_PREFIX:PATH=/usr/local - - name: Build - run: cmake --build build - - name: Install - run: sudo cmake --build build --target install DESTDIR=$PWD/_d - - name: List installed files - run: find _d | env LC_ALL=C sort | sed 's|^_d||' + - name: cm: build + run: cmake --build _build-cm + - name: cm: install + run: sudo cmake --build _cmbuild --target install DESTDIR=$PWD/_dest-cm + - name: cm: list installed files + run: find _dest-cm | env LC_ALL=C sort | sed 's|^__dest-cm||' linux: runs-on: ubuntu-latest @@ -107,8 +99,10 @@ jobs: apt-get install -y git cmake + automake + libtool crossbuild-essential-${{matrix.arch}} - - name: Configure + - name: cm: configure run: >- cmake -D DEBUG_CMAKE=1 @@ -120,8 +114,22 @@ jobs: -D CMAKE_INCLUDE_PATH=/usr/include/${{matrix.inc-lib}} -D CMAKE_LIBRARY_PATH=/usr/lib/${{matrix.inc-lib}} -B build - - name: Build + - name: cm: build run: cmake --build build + - name: at: configure + run: >- + ./autogen.sh + + mkdir _build-at && cd _build-at + + ../configure + --prefix=/usr/local + - name: at: build + run: make -C _build-at -j$(nproc) + - name: at: install + run: sudo make -C _build-at install DESTDIR=$PWD/_d + - name: at: list installed files + run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' macos-x86_64: runs-on: macos-latest @@ -188,6 +196,8 @@ jobs: base-devel mingw-w64-${{matrix.env}}-gcc mingw-w64-${{matrix.env}}-cmake + mingw-w64-${{matrix.env}}-automake + mingw-w64-${{matrix.env}}-libtool - name: Configure run: >- cmake From 386afcfcfa38ad0bd5ccba5324264e96de7cab2a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 07:41:59 +0100 Subject: [PATCH 32/70] CI: workflow step name quoting --- .github/workflows/build.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14df03b..b2dc98f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ jobs: cmake automake libtool - - name: at: configure + - name: "at: configure" run: >- ./autogen.sh @@ -54,15 +54,15 @@ jobs: ../configure --prefix=/usr/local - - name: at: build + - name: "at: build" run: make -C _build-at -j$(nproc) - - name: at: install + - name: "at: install" run: sudo make -C _build-at install DESTDIR=$PWD/_d - - name: at: list installed files + - name: "at: list installed files" run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' - - name: distcheck + - name: "at: distcheck" run: make -C _atbuild -j$(nproc) distcheck - - name: cm: configure + - name: "cm: configure" run: >- cd .. @@ -70,11 +70,11 @@ jobs: -B _build-cm -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D CMAKE_INSTALL_PREFIX:PATH=/usr/local - - name: cm: build + - name: "cm: build" run: cmake --build _build-cm - - name: cm: install + - name: "cm: install" run: sudo cmake --build _cmbuild --target install DESTDIR=$PWD/_dest-cm - - name: cm: list installed files + - name: "cm: list installed files" run: find _dest-cm | env LC_ALL=C sort | sed 's|^__dest-cm||' linux: @@ -102,7 +102,7 @@ jobs: automake libtool crossbuild-essential-${{matrix.arch}} - - name: cm: configure + - name: "cm: configure" run: >- cmake -D DEBUG_CMAKE=1 @@ -114,9 +114,9 @@ jobs: -D CMAKE_INCLUDE_PATH=/usr/include/${{matrix.inc-lib}} -D CMAKE_LIBRARY_PATH=/usr/lib/${{matrix.inc-lib}} -B build - - name: cm: build + - name: "cm: build" run: cmake --build build - - name: at: configure + - name: "at: configure" run: >- ./autogen.sh @@ -124,11 +124,11 @@ jobs: ../configure --prefix=/usr/local - - name: at: build + - name: "at: build" run: make -C _build-at -j$(nproc) - - name: at: install + - name: "at: install" run: sudo make -C _build-at install DESTDIR=$PWD/_d - - name: at: list installed files + - name: "at: list installed files" run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' macos-x86_64: From 98b1bcdf3f7639e5180adddfafdc70dd9d890a7b Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 07:56:07 +0100 Subject: [PATCH 33/70] CI: blindly throwing bits at CI --- .github/workflows/build.yml | 2 +- CMakeLists.txt | 25 +++++++++++++++++++++++++ CMakeLists.txt.in | 25 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2dc98f..2918313 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,7 +61,7 @@ jobs: - name: "at: list installed files" run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' - name: "at: distcheck" - run: make -C _atbuild -j$(nproc) distcheck + run: make -C _build-at -j$(nproc) distcheck - name: "cm: configure" run: >- cd .. diff --git a/CMakeLists.txt b/CMakeLists.txt index c0c2246..e3bab20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,25 @@ else() set(SP_PRIV "") endif() +set(EXTRA_WINDOWS_SOURCES) +set(EXTRA_WINDOWS_INCLUDES) +set(EXTRA_WINDOWS_RESOURCES) +set(EXTRA_WINDOWS_LIBRARIES) + +if(WIN32 OR MINGW) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/windows.rc.in" + "${CMAKE_CURRENT_BINARY_DIR}/windows.rc" + ) + list(APPEND EXTRA_WINDOWS_RESOURCES "${CMAKE_CURRENT_BINARY_DIR}/windows.rc") + list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32) +endif() + +if(MSVC) +else() + add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror) +endif() + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @@ -65,9 +84,15 @@ configure_file( add_library(libserialport SHARED ${LSP_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/config.h" + ${EXTRA_WINDOWS_SOURCES} + ${EXTRA_WINDOWS_RESOURCES} ) target_compile_features(libserialport PRIVATE c_std_99) +target_link_libraries(libserialport + PUBLIC + ${EXTRA_WINDOWS_LIBRARIES} +) set_target_properties(libserialport PROPERTIES C_EXTENSIONS OFF) target_compile_definitions(libserialport diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 39fa584..8d23b72 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -55,6 +55,25 @@ else() set(SP_PRIV "") endif() +set(EXTRA_WINDOWS_SOURCES) +set(EXTRA_WINDOWS_INCLUDES) +set(EXTRA_WINDOWS_RESOURCES) +set(EXTRA_WINDOWS_LIBRARIES) + +if(WIN32 OR MINGW) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/windows.rc.in" + "${CMAKE_CURRENT_BINARY_DIR}/windows.rc" + ) + list(APPEND EXTRA_WINDOWS_RESOURCES "${CMAKE_CURRENT_BINARY_DIR}/windows.rc") + list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32) +endif() + +if(MSVC) +else() + add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror) +endif() + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @@ -63,9 +82,15 @@ configure_file( add_library(libserialport SHARED ${LSP_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/config.h" + ${EXTRA_WINDOWS_SOURCES} + ${EXTRA_WINDOWS_RESOURCES} ) target_compile_features(libserialport PRIVATE c_std_99) +target_link_libraries(libserialport + PUBLIC + ${EXTRA_WINDOWS_LIBRARIES} +) set_target_properties(libserialport PROPERTIES C_EXTENSIONS OFF) target_compile_definitions(libserialport From f43a62c48b9189a9a014d20a8c1ab237cdf1fba2 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 08:10:58 +0100 Subject: [PATCH 34/70] ci: tryp macos frameworks --- CMakeLists.txt | 10 ++++++++++ CMakeLists.txt.in | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3bab20..dd9bda8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,10 +88,20 @@ add_library(libserialport SHARED ${EXTRA_WINDOWS_RESOURCES} ) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(EXTRA_MACOS_LIBRARIES + "-framework IOKit" + "-framework CoreFoundation" + ) +else() + set(EXTRA_MACOS_LIBRARIES) +endif() + target_compile_features(libserialport PRIVATE c_std_99) target_link_libraries(libserialport PUBLIC ${EXTRA_WINDOWS_LIBRARIES} + ${EXTRA_MACOS_LIBRARIES} ) set_target_properties(libserialport PROPERTIES C_EXTENSIONS OFF) diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 8d23b72..fe8ccaf 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -86,10 +86,20 @@ add_library(libserialport SHARED ${EXTRA_WINDOWS_RESOURCES} ) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(EXTRA_MACOS_LIBRARIES + "-framework IOKit" + "-framework CoreFoundation" + ) +else() + set(EXTRA_MACOS_LIBRARIES) +endif() + target_compile_features(libserialport PRIVATE c_std_99) target_link_libraries(libserialport PUBLIC ${EXTRA_WINDOWS_LIBRARIES} + ${EXTRA_MACOS_LIBRARIES} ) set_target_properties(libserialport PROPERTIES C_EXTENSIONS OFF) From fef4f211dfc0a20a22bd3e4335bc6093d4860504 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 08:19:46 +0100 Subject: [PATCH 35/70] CI: stop using sudo for installing to DESTDIR --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2918313..8466036 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ jobs: - name: "at: build" run: make -C _build-at -j$(nproc) - name: "at: install" - run: sudo make -C _build-at install DESTDIR=$PWD/_d + run: make -C _build-at install DESTDIR=$PWD/_d - name: "at: list installed files" run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' - name: "at: distcheck" @@ -73,7 +73,7 @@ jobs: - name: "cm: build" run: cmake --build _build-cm - name: "cm: install" - run: sudo cmake --build _cmbuild --target install DESTDIR=$PWD/_dest-cm + run: cmake --build _cmbuild --target install DESTDIR=$PWD/_dest-cm - name: "cm: list installed files" run: find _dest-cm | env LC_ALL=C sort | sed 's|^__dest-cm||' @@ -127,7 +127,7 @@ jobs: - name: "at: build" run: make -C _build-at -j$(nproc) - name: "at: install" - run: sudo make -C _build-at install DESTDIR=$PWD/_d + run: make -C _build-at install DESTDIR=$PWD/_d - name: "at: list installed files" run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' From 84e5e34400f627c0e08ddcd005bfdb07ee60e032 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 08:27:47 +0100 Subject: [PATCH 36/70] CI: misc fixes --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8466036..d651609 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,15 +57,19 @@ jobs: - name: "at: build" run: make -C _build-at -j$(nproc) - name: "at: install" - run: make -C _build-at install DESTDIR=$PWD/_d + run: make -C _build-at install DESTDIR=$PWD/_dest-at - name: "at: list installed files" - run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' + run: find _dest-at | env LC_ALL=C sort | sed 's|^_dest-at||' - name: "at: distcheck" run: make -C _build-at -j$(nproc) distcheck - name: "cm: configure" run: >- cd .. + pwd + + ls + cmake -B _build-cm -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} From fb458b22cecd199bbb81c2f8fe45756db78b1fab Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 08:30:14 +0100 Subject: [PATCH 37/70] CI foo --- .github/workflows/build.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d651609..4eca354 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,12 +64,6 @@ jobs: run: make -C _build-at -j$(nproc) distcheck - name: "cm: configure" run: >- - cd .. - - pwd - - ls - cmake -B _build-cm -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} From 160f5324cb0f34b0238a6942a487745b22d79303 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 08:41:24 +0100 Subject: [PATCH 38/70] XXX test-builds.sh --- test-builds.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test-builds.sh b/test-builds.sh index 7878fd4..6e6ba15 100755 --- a/test-builds.sh +++ b/test-builds.sh @@ -57,6 +57,13 @@ then cd .. fi +if find_in_path mingw64-cmake +then + mingw64-cmake -S . -B _cmb-w64 + make -C _cmb-w64 -j$(nproc) + make -C _cmb-w64 install DESTDIR="$PWD/_cmd-w64" +fi + cd _amb make -j$(nproc) doc make -j$(nproc) distcheck @@ -75,3 +82,12 @@ diff -u \ <(find _amd-w64 -not -type d | env LC_ALL=C sort | sed 's|^_amd-w64||' | sed 's|^/usr/x86_64-w64-mingw32/sys-root/mingw||') \ ||: +diff -u \ + <(find _amd-w64 | env LC_ALL=C sort | sed 's|^_amd-w64||') \ + <(find _cmd-w64 | env LC_ALL=C sort | sed 's|^_cmd-w64||') \ +||: + +diff -u _{am,cm}d-w64/lib/pkgconfig/libserialport.pc \ +||: + +# End of file. From 05d8b4ff67493a68d6d3c7c3974e305699dbf43c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 08:41:38 +0100 Subject: [PATCH 39/70] Actually add windows.h.in --- Makefile.am | 2 + configure.ac | 2 +- windows.rc.in | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 windows.rc.in diff --git a/Makefile.am b/Makefile.am index 43d14d8..ac9f597 100644 --- a/Makefile.am +++ b/Makefile.am @@ -153,3 +153,5 @@ if HAVE_PROG_DOXYGEN doc: $(srcdir)/libserialport.h Doxyfile doxygen `test -f Doxyfile || echo '$(srcdir)/'`Doxyfile endif + +EXTRA_DIST += windows.rc.in diff --git a/configure.ac b/configure.ac index 4b8d747..55cc25f 100644 --- a/configure.ac +++ b/configure.ac @@ -232,7 +232,7 @@ AS_CASE([$sp_cv_visibility_control], AC_DEFINE_UNQUOTED([SP_API], [$SP_API], [Macro preceding public API functions]) AC_DEFINE_UNQUOTED([SP_PRIV], [$SP_PRIV], [Macro preceding private functions]) -AC_CONFIG_FILES([Doxyfile Makefile libserialport.pc]) +AC_CONFIG_FILES([Doxyfile Makefile libserialport.pc windows.rc]) AC_OUTPUT diff --git a/windows.rc.in b/windows.rc.in new file mode 100644 index 0000000..47b0e86 --- /dev/null +++ b/windows.rc.in @@ -0,0 +1,122 @@ +// +// avrdude - A Downloader / Uploader for AVR device programmers +// Copyright(C) 2021 Marius Greuel +// +// This program is free software; you can redistribute itand /or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program.If not, see < http://www.gnu.org/licenses/>. +// + +#include "winres.h" + +#pragma code_page(1252) + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +STRINGTABLE +BEGIN + 100 "LIBSERIALPORT" +END + +#cmakedefine PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#ifdef PROJECT_VERSION_MAJOR +#define VER_MAJOR PROJECT_VERSION_MAJOR +#else +#define VER_MAJOR 0 +#endif + +#cmakedefine PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#ifdef PROJECT_VERSION_MINOR +#define VER_MINOR PROJECT_VERSION_MINOR +#else +#define VER_MINOR 0 +#endif + +#cmakedefine PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#ifdef PROJECT_VERSION_PATCH +#define VER_BUILD PROJECT_VERSION_PATCH +#else +#define VER_BUILD 0 +#endif + +#cmakedefine PROJECT_VERSION_TWEAK @PROJECT_VERSION_TWEAK@ +#ifdef PROJECT_VERSION_TWEAK +#define VER_REVISION PROJECT_VERSION_TWEAK +#else +#define VER_REVISION 0 +#endif + +#cmakedefine GIT_COMMIT_YEAR "@GIT_COMMIT_YEAR@" +#ifdef GIT_COMMIT_YEAR +#define VER_COMMIT_YEAR GIT_COMMIT_YEAR +#else +#define VER_COMMIT_YEAR "" +#endif + +#define _STR(s) #s +#define _VER_STR(a, b, c, d) _STR(a) "." _STR(b) "." _STR(c) "." _STR(d) + +#define VER_FILEVERSION VER_MAJOR,VER_MINOR,VER_BUILD,VER_REVISION +#define VER_FILEVERSION_STR _VER_STR(VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION) +#define VER_PRODUCTVERSION VER_FILEVERSION +#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR +#define VER_COMPANYNAME_STR "The AVRDUDE authors" +#define VER_FILEDESCRIPTION_STR "AVRDUDE" +#define VER_PRODUCTNAME_STR "AVRDUDE" +#define VER_INTERNALNAME_STR "avrdude.exe" +#define VER_LEGALCOPYRIGHT_STR "\251 " VER_COMMIT_YEAR " The AVRDUDE authors" +#define VER_ORIGINALFILENAME_STR VER_INTERNALNAME_STR +#define VER_COMMENTS_STR "@PACKAGE_URL@" +#define VER_FILETYPE VFT_APP +#define VER_FILESUBTYPE 0 + +#ifdef DEBUG +#define VER_DEBUG VS_FF_DEBUG +#else +#define VER_DEBUG 0 +#endif + +#define VER_FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#define VER_FILEOS VOS__WINDOWS32 +#define VER_FILEFLAGS (VER_DEBUG) + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +PRODUCTVERSION VER_PRODUCTVERSION +FILEFLAGSMASK VER_FILEFLAGSMASK +FILEFLAGS VER_FILEFLAGS +FILEOS VER_FILEOS +FILETYPE VER_FILETYPE +FILESUBTYPE VER_FILESUBTYPE +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" // LANG_ENGLISH/SUBLANG_ENGLISH_US, Unicode CP + BEGIN +#ifdef VER_COMMENTS_STR + VALUE "Comments", VER_COMMENTS_STR +#endif + VALUE "CompanyName", VER_COMPANYNAME_STR + VALUE "FileDescription", VER_FILEDESCRIPTION_STR + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", VER_INTERNALNAME_STR + VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR + VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR + VALUE "ProductName", VER_PRODUCTNAME_STR + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1200 //LANG_ENGLISH/SUBLANG_ENGLISH_US, Unicode CP + END +END From a9c30c6dc4dd6f93942daae8761a9c7568511e6f Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 08:49:12 +0100 Subject: [PATCH 40/70] CI: one fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4eca354..f41aa37 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,7 @@ jobs: - name: "cm: build" run: cmake --build _build-cm - name: "cm: install" - run: cmake --build _cmbuild --target install DESTDIR=$PWD/_dest-cm + run: cmake --build _build-cm --target install DESTDIR=$PWD/_dest-cm - name: "cm: list installed files" run: find _dest-cm | env LC_ALL=C sort | sed 's|^__dest-cm||' From db72d3e762311e35133885a79f478e308d51d9c2 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 08:58:07 +0100 Subject: [PATCH 41/70] ci: mingw package names --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f41aa37..9b2868f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -194,7 +194,7 @@ jobs: base-devel mingw-w64-${{matrix.env}}-gcc mingw-w64-${{matrix.env}}-cmake - mingw-w64-${{matrix.env}}-automake + automake1.16 mingw-w64-${{matrix.env}}-libtool - name: Configure run: >- From 8db31c3677ea4c91e2bf54b2e48422c04a058512 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 23:54:12 +0100 Subject: [PATCH 42/70] remove unused CMakeLists.txt substitutions from Makefile.am --- Makefile.am | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index ac9f597..84ceada 100644 --- a/Makefile.am +++ b/Makefile.am @@ -117,21 +117,8 @@ EXTRA_DIST += examples/send_receive.c EXTRA_DIST += examples/projects/send_receive.vcxproj EXTRA_DIST += examples/projects/send_receive.vcxproj.filters -SED_CMDS = -SED_CMDS += -e 's|[@]PACKAGE_TARNAME[@]|$(PACKAGE_TARNAME)|g' -SED_CMDS += -e 's|[@]PACKAGE_TARNAME[@]|$(PACKAGE_TARNAME)|g' - EXTRA_DIST += CMakeLists.txt.in EXTRA_DIST += $(srcdir)/CMakeLists.txt -noinst_DATA += $(srcdir)/CMakeLists.txt -$(srcdir)/CMakeLists.txt: CMakeLists.txt.in - if $(SED) $(SED_CMDS) $< > $@.tmp.$$$$; then \ - mv -f "$@.tmp.$$$$" "$@"; \ - else \ - s="$?"; \ - rm -f "$@.tmp.$$$$"; \ - exit "$s"; \ - fi .PHONY: ChangeLog doc From b56880470b5dabd625e33e89e256651cb34dcbc7 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 26 Feb 2024 23:54:47 +0100 Subject: [PATCH 43/70] chmod -w for git clones --- buildstuff/sed-substitute | 1 + 1 file changed, 1 insertion(+) diff --git a/buildstuff/sed-substitute b/buildstuff/sed-substitute index 81024d4..141d699 100755 --- a/buildstuff/sed-substitute +++ b/buildstuff/sed-substitute @@ -65,6 +65,7 @@ if test -f "$outname"; then if ${CMP-cmp} "$outname" "$tmpname" > /dev/null; then # echo "$prog: source file up to date: $outname" >&2 rm -f "$tmpname" + chmod -w "$outname" exit 0 else ${DIFF-diff} -u "$outname" "$tmpname" >&2 ||: From 677b75fc89da0751551310849a836345436014fe Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:03:27 +0100 Subject: [PATCH 44/70] clean up test-builds.sh to work on FreeBSD --- test-builds.sh | 115 ++++++++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/test-builds.sh b/test-builds.sh index 6e6ba15..47734d4 100755 --- a/test-builds.sh +++ b/test-builds.sh @@ -1,28 +1,39 @@ -#! /bin/sh +#! /usr/bin/env bash +# +# Bash features used: +# - process substitution: <() +# - arrays: declare -a +# - brace globs: {foo,bar} set -ex cd "$(dirname "$0")" rm -rf autom4te.cache -autoreconf -vis +${AUTORECONF-autoreconf} -vis find_in_path() { - local d - local saved_IFS - saved_IFS="$IFS" - IFS=":" - for d in $PATH - do + case "$1" in + /*) + echo "$1" + return 0 + ;; + esac + local d + local saved_IFS + saved_IFS="$IFS" + IFS=":" + for d in $PATH + do + IFS="$saved_IFS" + if test -x "$d/$1" + then + echo "$d/$1" + return 0 + fi + done IFS="$saved_IFS" - if test -x "$d/$1" - then - echo "$d/$1" - return 0 - fi - done - IFS="$saved_IFS" - return 1 + return 1 } for d in _{am,cm}{b,d}{,-w64} @@ -32,62 +43,70 @@ do rm -rf "$d" done -cmake -S . -B _cmb -D CMAKE_INSTALL_PREFIX:PATH=/usr/local -cmake --build _cmb --verbose -cmake --build _cmb --target install DESTDIR="$PWD/_cmd" +${CMAKE-cmake} -S . -B _cmb -D CMAKE_INSTALL_PREFIX:PATH=/usr/local +${CMAKE-cmake} --build _cmb --verbose +${CMAKE-cmake} --build _cmb --target install DESTDIR="$PWD/_cmd" mkdir _amb cd _amb -configure_args="" +declare -a configure_args=() if test -d /usr/lib64; then - configure_args="$configure_args --libdir=\${exec_prefix}/lib64" + configure_args+=("--libdir=\${exec_prefix}/lib64") fi -../configure --prefix=/usr/local ${configure_args} -make -j$(nproc) V=1 -make install DESTDIR="$PWD/../_amd" +../configure --prefix=/usr/local "${configure_args[@]}" +${MAKE-make} -j$(nproc) V=1 +${MAKE-make} install DESTDIR="$PWD/../_amd" cd .. if find_in_path mingw64-configure && find_in_path mingw64-make then - mkdir _amb-w64 - cd _amb-w64 - mingw64-configure - mingw64-make -j$(nproc) V=1 - mingw64-make install DESTDIR="$PWD/../_amd-w64" - cd .. + mkdir _amb-w64 + cd _amb-w64 + mingw64-configure + mingw64-make -j$(nproc) V=1 + mingw64-make install DESTDIR="$PWD/../_amd-w64" + cd .. fi +have_mingw64=no if find_in_path mingw64-cmake then + have_mingw64=yes mingw64-cmake -S . -B _cmb-w64 - make -C _cmb-w64 -j$(nproc) - make -C _cmb-w64 install DESTDIR="$PWD/_cmd-w64" + ${MAKE-make} -C _cmb-w64 -j$(nproc) + ${MAKE-make} -C _cmb-w64 install DESTDIR="$PWD/_cmd-w64" fi cd _amb -make -j$(nproc) doc -make -j$(nproc) distcheck +if find_in_path ${DOXYGEN-doxygen} +then + ${MAKE-make} -j$(nproc) doc +fi +${MAKE-make} -j$(nproc) distcheck cd .. -diff -u \ +${DIFF-diff} -u \ <(find _amd | env LC_ALL=C sort | sed 's|^_amd||') \ <(find _cmd | env LC_ALL=C sort | sed 's|^_cmd||') \ ||: -diff -u _{am,cm}d/lib/pkgconfig/libserialport.pc \ +${DIFF-diff} -u _{am,cm}d/lib/pkgconfig/libserialport.pc \ ||: -diff -u \ - <(find _amd -not -type d | env LC_ALL=C sort | sed 's|^_amd||' | sed 's|^/usr/local||' | sed 's|^/lib64/|/lib/|') \ - <(find _amd-w64 -not -type d | env LC_ALL=C sort | sed 's|^_amd-w64||' | sed 's|^/usr/x86_64-w64-mingw32/sys-root/mingw||') \ -||: - -diff -u \ - <(find _amd-w64 | env LC_ALL=C sort | sed 's|^_amd-w64||') \ - <(find _cmd-w64 | env LC_ALL=C sort | sed 's|^_cmd-w64||') \ -||: - -diff -u _{am,cm}d-w64/lib/pkgconfig/libserialport.pc \ -||: +if test "x$have_mingw64" = xyes +then + ${DIFF-diff} -u \ + <(find _amd -not -type d | env LC_ALL=C sort | sed 's|^_amd||' | sed 's|^/usr/local||' | sed 's|^/lib64/|/lib/|') \ + <(find _amd-w64 -not -type d | env LC_ALL=C sort | sed 's|^_amd-w64||' | sed 's|^/usr/x86_64-w64-mingw32/sys-root/mingw||') \ + ||: + + ${DIFF-diff} -u \ + <(find _amd-w64 | env LC_ALL=C sort | sed 's|^_amd-w64||') \ + <(find _cmd-w64 | env LC_ALL=C sort | sed 's|^_cmd-w64||') \ + ||: + + ${DIFF-diff} -u _{am,cm}d-w64/lib/pkgconfig/libserialport.pc \ + ||: +fi # End of file. From 41bb3a033384283c43c1cefdeb08824b04cbb2c4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:05:51 +0100 Subject: [PATCH 45/70] HACK test_timing.c: enlarge the valid time interval a bit My VM with FreeBSD takes a bit more than 1050ms for the 1s sleep, namely about 1072ms. No idea what kind of problem this indicates. --- test_timing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_timing.c b/test_timing.c index dc047e8..febf000 100644 --- a/test_timing.c +++ b/test_timing.c @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) time_sub(&b, &a, &c); printf("Measured: %ums\n", time_as_ms(&c)); assert(time_as_ms(&c) >= 950); - assert(time_as_ms(&c) <= 1050); + assert(time_as_ms(&c) <= 1080); printf("Starting 3s timeout\n"); timeout_start(&to, 3000); printf("Time to wait: %dms\n", timeout_remaining_ms(&to)); From df8d308c67cbf7e4bf9542f0ec0ce727566bb761 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:24:17 +0100 Subject: [PATCH 46/70] sed-subst: chmod a-w, chmod +w --- buildstuff/sed-substitute | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildstuff/sed-substitute b/buildstuff/sed-substitute index 141d699..81328da 100755 --- a/buildstuff/sed-substitute +++ b/buildstuff/sed-substitute @@ -65,20 +65,20 @@ if test -f "$outname"; then if ${CMP-cmp} "$outname" "$tmpname" > /dev/null; then # echo "$prog: source file up to date: $outname" >&2 rm -f "$tmpname" - chmod -w "$outname" + ${CHMOD-chmod} a-w "$outname" exit 0 else ${DIFF-diff} -u "$outname" "$tmpname" >&2 ||: - chmod +w "$outname" + ${CHMOD-chmod} +w "$outname" mv -f "$tmpname" "$outname" - chmod -w "$outname" + ${CHMOD-chmod} a-w "$outname" echo "$prog: source file has been updated: $outname" >&2 echo "$prog: commit the file, and then re-run autoreconf." >&2 exit 1 fi else mv -f "$tmpname" "$outname" - chmod -w "$outname" + ${CHMOD-chmod} a-w "$outname" echo "$prog: created new source file: $outname" >&2 echo "$prog: commit the file, and then re-run autoreconf." >&2 exit 1 From f9658c81b8fcdfc1e4dd14c29fffc50f3d7ce43a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:24:35 +0100 Subject: [PATCH 47/70] gitignore: dirs generated by test-builds.sh --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 48110dd..6f73534 100644 --- a/.gitignore +++ b/.gitignore @@ -21,9 +21,11 @@ Release/ x64/ *.vcxproj.user -/_amb-w64/ -/_amd-w64/ /_amb/ +/_amb-*/ /_amd/ +/_amd-*/ /_cmb/ +/_cmb-*/ /_cmd/ +/_cmd-*/ From bd65842f6bfa77951f0815e59665e2acb551d02f Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:27:04 +0100 Subject: [PATCH 48/70] ci: separate job for autoreconf --- .github/workflows/build.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b2868f..e255239 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,10 +46,11 @@ jobs: cmake automake libtool - - name: "at: configure" + - name: "at: autoreconf" run: >- ./autogen.sh - + - name: "at: configure" + run: >- mkdir _build-at && cd _build-at ../configure @@ -114,10 +115,11 @@ jobs: -B build - name: "cm: build" run: cmake --build build - - name: "at: configure" + - name: "at: autoreconf" run: >- ./autogen.sh - + - name: "at: configure" + run: >- mkdir _build-at && cd _build-at ../configure From 2ebe1895b1063cc23b4b667ccc17b05526068357 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:30:57 +0100 Subject: [PATCH 49/70] ci: consistent step labels across jobs --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e255239..a16e2fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -141,7 +141,7 @@ jobs: brew install cmake - - name: Configure + - name: "cm: configure" run: >- cmake -D CMAKE_C_FLAGS=-I/usr/local/include @@ -149,7 +149,7 @@ jobs: -D DEBUG_CMAKE=1 -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -B build - - name: Build + - name: "cm: build" run: cmake --build build msvc: @@ -162,7 +162,7 @@ jobs: - { arch: arm64, platform: ARM64 } steps: - uses: actions/checkout@v3 - - name: Configure + - name: "cm: configure" run: >- cmake -A ${{matrix.platform}} @@ -172,7 +172,7 @@ jobs: -D CMAKE_CXX_FLAGS_RELWITHDEBINFO="/MT /GL /Zi /O2 /Ob1 /DNDEBUG" -D CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="/DEBUG /INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF" -B build - - name: Build + - name: "cm: build" run: cmake --build build --config ${{env.BUILD_TYPE}} mingw: @@ -198,12 +198,12 @@ jobs: mingw-w64-${{matrix.env}}-cmake automake1.16 mingw-w64-${{matrix.env}}-libtool - - name: Configure + - name: "cm: configure" run: >- cmake -G"MSYS Makefiles" -D DEBUG_CMAKE=1 -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -B build - - name: Build + - name: "cm: build" run: cmake --build build From f4cf24c22675d88ca3b532cd90c0bbd66c3d1852 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:42:04 +0100 Subject: [PATCH 50/70] probably not needing hid on windows (this is not avrdude) --- CMakeLists.txt | 2 +- CMakeLists.txt.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd9bda8..344e5d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,7 @@ if(WIN32 OR MINGW) "${CMAKE_CURRENT_BINARY_DIR}/windows.rc" ) list(APPEND EXTRA_WINDOWS_RESOURCES "${CMAKE_CURRENT_BINARY_DIR}/windows.rc") - list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32) + list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi ws2_32) endif() if(MSVC) diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index fe8ccaf..fa3aa96 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -66,7 +66,7 @@ if(WIN32 OR MINGW) "${CMAKE_CURRENT_BINARY_DIR}/windows.rc" ) list(APPEND EXTRA_WINDOWS_RESOURCES "${CMAKE_CURRENT_BINARY_DIR}/windows.rc") - list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32) + list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi ws2_32) endif() if(MSVC) From 026ee4bcd20bc33f46cac0b06f9ccf83ea56c7c8 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:38:39 +0100 Subject: [PATCH 51/70] HACK windows string length thing This might address the following build warning/error: ``` D:/a/libserialport/libserialport/windows.c: In function 'get_port_details': D:/a/libserialport/libserialport/windows.c:457:83: error: '%s' directive output may be truncated writing up to 31 bytes into a region of size between 20 and 31 [-Werror=format-truncation=] 457 | snprintf(usb_path, sizeof(usb_path), "%d%s%s", | ^~ 458 | (int)address, *tmp ? "." : "", tmp); | ~~~ D:/a/libserialport/libserialport/windows.c:457:41: note: 'snprintf' output between 2 and 44 bytes into a destination of size 32 457 | snprintf(usb_path, sizeof(usb_path), "%d%s%s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 458 | (int)address, *tmp ? "." : "", tmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1.exe: all warnings being treated as errors make[2]: *** [CMakeFiles/libserialport.dir/build.make:76: CMakeFiles/libserialport.dir/windows.c.obj] Error 1 make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/libserialport.dir/all] Error 2 make: *** [Makefile:136: all] Error 2 ``` --- windows.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/windows.c b/windows.c index 2825a92..f894ec5 100644 --- a/windows.c +++ b/windows.c @@ -454,8 +454,9 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port) if (CM_Get_DevNode_Registry_PropertyA(dev_inst, CM_DRP_ADDRESS, 0, &address, &size, 0) == CR_SUCCESS) { strcpy(tmp, usb_path); - snprintf(usb_path, sizeof(usb_path), "%d%s%s", - (int)address, *tmp ? "." : "", tmp); + /* FIXME: string length, address value range, etc. */ + snprintf(usb_path, sizeof(usb_path), "%u%s%s", + (BYTE)(0xff & address), *tmp ? "." : "", tmp); } } while (CM_Get_Parent(&dev_inst, dev_inst, 0) == CR_SUCCESS); From f6dc1ef8a35f1611024297ca3899c8bad547ca6c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 00:50:05 +0100 Subject: [PATCH 52/70] ci: fix dir names --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a16e2fd..d20db98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,7 +74,7 @@ jobs: - name: "cm: install" run: cmake --build _build-cm --target install DESTDIR=$PWD/_dest-cm - name: "cm: list installed files" - run: find _dest-cm | env LC_ALL=C sort | sed 's|^__dest-cm||' + run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' linux: runs-on: ubuntu-latest @@ -127,9 +127,9 @@ jobs: - name: "at: build" run: make -C _build-at -j$(nproc) - name: "at: install" - run: make -C _build-at install DESTDIR=$PWD/_d + run: make -C _build-at install DESTDIR=$PWD/_dest-at - name: "at: list installed files" - run: find _dest-at | env LC_ALL=C sort | sed 's|^__dest-at||' + run: find _dest-at | env LC_ALL=C sort | sed 's|^_dest-at||' macos-x86_64: runs-on: macos-latest From 055ba9c2a34889202ed09605444b2199455ce22e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 01:17:18 +0100 Subject: [PATCH 53/70] make cmake --build also --verbose --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d20db98..d50ef49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -150,7 +150,7 @@ jobs: -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -B build - name: "cm: build" - run: cmake --build build + run: cmake --build build --verbose msvc: runs-on: windows-latest @@ -173,7 +173,7 @@ jobs: -D CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="/DEBUG /INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF" -B build - name: "cm: build" - run: cmake --build build --config ${{env.BUILD_TYPE}} + run: cmake --build build --config ${{env.BUILD_TYPE}} --verbose mingw: runs-on: windows-latest @@ -206,4 +206,4 @@ jobs: -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -B build - name: "cm: build" - run: cmake --build build + run: cmake --build build --verbose From 1225d8e1c4c4c25a5038806345a5c43a66c25b9c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 01:22:20 +0100 Subject: [PATCH 54/70] Add source files in CMakeLists.txt I had forgotten --- CMakeLists.txt | 4 +++- CMakeLists.txt.in | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 344e5d8..2e89926 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") set(LSP_SOURCES "freebsd.c") elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(LSP_SOURCES "linux.c") + set(LSP_SOURCES linux.c linux_termios.c linux_termios.h) elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") set(LSP_SOURCES "windows.c") else() @@ -82,6 +82,8 @@ configure_file( ) add_library(libserialport SHARED + serialport.c + timing.c ${LSP_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/config.h" ${EXTRA_WINDOWS_SOURCES} diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index fa3aa96..78c3e67 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -26,7 +26,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") set(LSP_SOURCES "freebsd.c") elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(LSP_SOURCES "linux.c") + set(LSP_SOURCES linux.c linux_termios.c linux_termios.h) elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") set(LSP_SOURCES "windows.c") else() @@ -80,6 +80,8 @@ configure_file( ) add_library(libserialport SHARED + serialport.c + timing.c ${LSP_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/config.h" ${EXTRA_WINDOWS_SOURCES} From 273b8ef99bb360cce6b725bd8bd9144d65b6bfa1 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 01:31:55 +0100 Subject: [PATCH 55/70] ci/cmake stuff --- .github/workflows/build.yml | 47 ++++++++++++++++++++++++++++++------- CMakeLists.txt | 2 ++ CMakeLists.txt.in | 2 ++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d50ef49..32dc4ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -112,9 +112,13 @@ jobs: -D CMAKE_FIND_ROOT_PATH=/usr/${{matrix.prefix}} -D CMAKE_INCLUDE_PATH=/usr/include/${{matrix.inc-lib}} -D CMAKE_LIBRARY_PATH=/usr/lib/${{matrix.inc-lib}} - -B build + -B _build-cm - name: "cm: build" - run: cmake --build build + run: cmake --build _build-cm + - name: "cm: install" + run: cmake --build _build-cm --target install DESTDIR=$PWD/_dest-cm + - name: "cm: list installed files" + run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' - name: "at: autoreconf" run: >- ./autogen.sh @@ -148,9 +152,13 @@ jobs: -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar -D DEBUG_CMAKE=1 -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -B build + -B _build-cm - name: "cm: build" - run: cmake --build build --verbose + run: cmake --build _build-cm --verbose + - name: "cm: install" + run: cmake --build _build-cm --target install DESTDIR=$PWD/_dest-cm + - name: "cm: list installed files" + run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' msvc: runs-on: windows-latest @@ -171,9 +179,13 @@ jobs: -D CMAKE_C_FLAGS_RELWITHDEBINFO="/MT /GL /Zi /O2 /Ob1 /DNDEBUG" -D CMAKE_CXX_FLAGS_RELWITHDEBINFO="/MT /GL /Zi /O2 /Ob1 /DNDEBUG" -D CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="/DEBUG /INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF" - -B build + -B _build-cm - name: "cm: build" - run: cmake --build build --config ${{env.BUILD_TYPE}} --verbose + run: cmake --build _build-cm --config ${{env.BUILD_TYPE}} --verbose + - name: "cm: install" + run: cmake --build _build-cm --target install DESTDIR=$PWD/_dest-cm + - name: "cm: list installed files" + run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' mingw: runs-on: windows-latest @@ -204,6 +216,25 @@ jobs: -G"MSYS Makefiles" -D DEBUG_CMAKE=1 -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -B build + -B _build-cm - name: "cm: build" - run: cmake --build build --verbose + run: cmake --build _build-cm --verbose + - name: "cm: install" + run: cmake --build _build-cm --target install DESTDIR=$PWD/_dest-cm + - name: "cm: list installed files" + run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' + - name: "at: autoreconf" + run: >- + ./autogen.sh + - name: "at: configure" + run: >- + mkdir _build-at && cd _build-at + + ../configure + --prefix=/usr/local + - name: "at: build" + run: make -C _build-at -j$(nproc) + - name: "at: install" + run: make -C _build-at install DESTDIR=$PWD/_dest-at + - name: "at: list installed files" + run: find _dest-at | env LC_ALL=C sort | sed 's|^_dest-at||' diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e89926..befb825 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,8 @@ else() add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror) endif() +# FIXME: -no-undefined for Linux + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 78c3e67..10e70bb 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -74,6 +74,8 @@ else() add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror) endif() +# FIXME: -no-undefined for Linux + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" From ca43a42f3ed07ceeaf50199e25164a3d87e989d9 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 01:40:20 +0100 Subject: [PATCH 56/70] mingw: add autoconf --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32dc4ce..ad3eaa2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -209,6 +209,7 @@ jobs: mingw-w64-${{matrix.env}}-gcc mingw-w64-${{matrix.env}}-cmake automake1.16 + autoconf mingw-w64-${{matrix.env}}-libtool - name: "cm: configure" run: >- From f53240a9fe7dff8e4b3d6042b2998c728c96b6b1 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 01:44:24 +0100 Subject: [PATCH 57/70] try actions/checkout@v4 --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad3eaa2..a603d02 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: linux-x86_64: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install prerequisites run: >- sudo apt-get update @@ -86,7 +86,7 @@ jobs: - { arch: armhf, processor: armhf, prefix: arm-linux-gnueabihf, inc-lib: arm-linux-gnueabihf } - { arch: arm64, processor: aarch64, prefix: aarch64-linux-gnu, inc-lib: aarch64-linux-gnu } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Add architecture run: | dpkg --add-architecture ${{matrix.arch}} @@ -138,7 +138,7 @@ jobs: macos-x86_64: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install prerequisites run: >- # brew update @@ -169,7 +169,7 @@ jobs: - { arch: x64, platform: x64 } - { arch: arm64, platform: ARM64 } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "cm: configure" run: >- cmake @@ -199,7 +199,7 @@ jobs: - { sys: ucrt64, env: ucrt-x86_64 } - { sys: clang64, env: clang-x86_64 } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: msys2/setup-msys2@v2 with: msystem: ${{matrix.sys}} From 956a56bd9104ce9fa89424fe02e15b390844a542 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 01:47:45 +0100 Subject: [PATCH 58/70] mingw autoconf2.72 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a603d02..9f6e0c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -209,7 +209,7 @@ jobs: mingw-w64-${{matrix.env}}-gcc mingw-w64-${{matrix.env}}-cmake automake1.16 - autoconf + autoconf2.72 mingw-w64-${{matrix.env}}-libtool - name: "cm: configure" run: >- From 65c6f28d869a07c417050dc2a052af80c236306f Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 01:53:01 +0100 Subject: [PATCH 59/70] setting ACLOCAL for mingw --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f6e0c8..ff2536d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -226,7 +226,7 @@ jobs: run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' - name: "at: autoreconf" run: >- - ./autogen.sh + env ACLOCAL=aclocal1.16 ./autogen.sh - name: "at: configure" run: >- mkdir _build-at && cd _build-at From 05bae21e82ca91cc1973233439565e725244a2dd Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 02:02:50 +0100 Subject: [PATCH 60/70] Trying to work with tool versions for AUTO* for mingw --- .github/workflows/build.yml | 6 +++++- autogen.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff2536d..cf618ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -226,7 +226,11 @@ jobs: run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' - name: "at: autoreconf" run: >- - env ACLOCAL=aclocal1.16 ./autogen.sh + ACV=-2.72 + + AMC=-1.16 + + env ACLOCAL=aclocal$AMV AUTOMAKE=automake$AMV AUTORECONF=autoreconf$ACV AUTOCONF=autoconf$ACV AUTOM4TE=autom4te$ACV AUTOHEADER=autoheader$ACV ./autogen.sh - name: "at: configure" run: >- mkdir _build-at && cd _build-at diff --git a/autogen.sh b/autogen.sh index 5e10887..5073921 100755 --- a/autogen.sh +++ b/autogen.sh @@ -23,4 +23,4 @@ test -n "$srcdir" || srcdir=`dirname "$0"` test -n "$srcdir" || srcdir=. test -d "$srcdir/autostuff" || mkdir "$srcdir/autostuff" -autoreconf --force --install --verbose "$srcdir" +${AUTORECONF-autoreconf} --force --install --verbose "$srcdir" From 30a9a4b39b48a9b28c4cb0b84f3407ff775c152a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 02:10:57 +0100 Subject: [PATCH 61/70] See whether mingw ucrt64 build might succeed without -Werror --- CMakeLists.txt | 2 +- CMakeLists.txt.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index befb825..1678258 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,7 @@ endif() if(MSVC) else() - add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror) + add_compile_options(-Wall -Wextra -Wno-unused-parameter) # -Werror) endif() # FIXME: -no-undefined for Linux diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 10e70bb..b470a8c 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -71,7 +71,7 @@ endif() if(MSVC) else() - add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror) + add_compile_options(-Wall -Wextra -Wno-unused-parameter) # -Werror) endif() # FIXME: -no-undefined for Linux From 1209b4188356159960a808ff3aa60d0e7077a288 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 02:18:54 +0100 Subject: [PATCH 62/70] ci typo fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf618ee..f0e4ce4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -228,7 +228,7 @@ jobs: run: >- ACV=-2.72 - AMC=-1.16 + AMV=-1.16 env ACLOCAL=aclocal$AMV AUTOMAKE=automake$AMV AUTORECONF=autoreconf$ACV AUTOCONF=autoconf$ACV AUTOM4TE=autom4te$ACV AUTOHEADER=autoheader$ACV ./autogen.sh - name: "at: configure" From 3b7ccab91ded62e45cd1d74b9e62ada72fd30513 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 02:33:53 +0100 Subject: [PATCH 63/70] update script tuning --- buildstuff/sed-update-source-file | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/buildstuff/sed-update-source-file b/buildstuff/sed-update-source-file index eadfce3..3ac125a 100755 --- a/buildstuff/sed-update-source-file +++ b/buildstuff/sed-update-source-file @@ -27,11 +27,16 @@ tname="$fname.tmp.$$" ${SED-sed} "$@" < "$fname" > "$tname" || { s="$?" - echo "$prog: Error running sed, exit code $s." + echo "$prog: Error running sed, exit code $s." >&2 rm -f "$tname" exit 2 } +test -s "$tname" || { + echo "$prog: sed has produced an empty file" >&2 + exit 2 +} + if ${CMP-cmp} "$fname" "$tname" > /dev/null; then # echo "$prog: source file up to date: $fname" >&2 rm -f "$tname" From 8d598db90159aa68e67206444a2470bb8617a6c6 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 02:37:17 +0100 Subject: [PATCH 64/70] add autotools build on macos --- .github/workflows/build.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0e4ce4..3ae9cc3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,6 +145,9 @@ jobs: brew install cmake + automake + autoconf + libtool - name: "cm: configure" run: >- cmake @@ -159,6 +162,21 @@ jobs: run: cmake --build _build-cm --target install DESTDIR=$PWD/_dest-cm - name: "cm: list installed files" run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' + - name: "at: autoreconf" + run: >- + ./autogen.sh + - name: "at: configure" + run: >- + mkdir _build-at && cd _build-at + + ../configure + --prefix=/usr/local + - name: "at: build" + run: make -C _build-at -j$(nproc) + - name: "at: install" + run: make -C _build-at install DESTDIR=$PWD/_dest-at + - name: "at: list installed files" + run: find _dest-at | env LC_ALL=C sort | sed 's|^_dest-at||' msvc: runs-on: windows-latest From d6452e8adb26866288d5244ebfc082ab92135110 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 17:47:33 +0100 Subject: [PATCH 65/70] try MSVC and MINGW with LIBSERIALPORT_MSBUILD --- CMakeLists.txt | 6 ++++++ CMakeLists.txt.in | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1678258..484602b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,12 @@ target_compile_definitions(libserialport PRIVATE LIBSERIALPORT_ATBUILD ) +if(MSVC OR MINGW) + target_compile_definitions(libserialport + PRIVATE LIBSERIALPORT_MSBUILD + ) +endif() + target_include_directories(libserialport PUBLIC "${PROJECT_BINARY_DIR}" diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index b470a8c..41d26ca 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -111,6 +111,12 @@ target_compile_definitions(libserialport PRIVATE LIBSERIALPORT_ATBUILD ) +if(MSVC OR MINGW) + target_compile_definitions(libserialport + PRIVATE LIBSERIALPORT_MSBUILD + ) +endif() + target_include_directories(libserialport PUBLIC "${PROJECT_BINARY_DIR}" From 0e447e08fda320390c7ec4d8634ec9b2ed7137be Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 17:52:35 +0100 Subject: [PATCH 66/70] Choose either one of LIBSERIALPORT_(AT|MS)BUILD --- CMakeLists.txt | 8 ++++---- CMakeLists.txt.in | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 484602b..4d35936 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,14 +109,14 @@ target_link_libraries(libserialport ) set_target_properties(libserialport PROPERTIES C_EXTENSIONS OFF) -target_compile_definitions(libserialport - PRIVATE LIBSERIALPORT_ATBUILD -) - if(MSVC OR MINGW) target_compile_definitions(libserialport PRIVATE LIBSERIALPORT_MSBUILD ) +else() + target_compile_definitions(libserialport + PRIVATE LIBSERIALPORT_ATBUILD + ) endif() target_include_directories(libserialport diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 41d26ca..590cf0c 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -107,14 +107,14 @@ target_link_libraries(libserialport ) set_target_properties(libserialport PROPERTIES C_EXTENSIONS OFF) -target_compile_definitions(libserialport - PRIVATE LIBSERIALPORT_ATBUILD -) - if(MSVC OR MINGW) target_compile_definitions(libserialport PRIVATE LIBSERIALPORT_MSBUILD ) +else() + target_compile_definitions(libserialport + PRIVATE LIBSERIALPORT_ATBUILD + ) endif() target_include_directories(libserialport From fec338d9d82af282ae4c659f95bb86db333d4cf3 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 18:15:27 +0100 Subject: [PATCH 67/70] XXX line endings, .gitattributes, etc --- .gitattributes | 4 ++++ buildstuff/sed-substitute | 23 ++++++++++++++++------- buildstuff/sed-update-source-file | 14 +++++++++++--- 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..39d8667 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +* text=auto eol=lf +*.sln text eol=crlf +*.vcxproj text eol=crlf +*.vcxproj.filters text eol=crlf diff --git a/buildstuff/sed-substitute b/buildstuff/sed-substitute index 81328da..1d074c8 100755 --- a/buildstuff/sed-substitute +++ b/buildstuff/sed-substitute @@ -45,22 +45,31 @@ case "$outname" in ;; esac -tmpname="$outname.tmp.$$" - +tmqname="$outname.tmq.$$" -${SED-sed} -e "s|^\(.*\)[@]configure_input[@]|\1$outname. Generated from $inname by configure.ac.\n\1!!!!!!! DO NOT MODIFY THIS FILE !!!!!!!!\n\1EDIT $inname INSTEAD AND RE-RUN autoreconf.|g" "$@" < "$inname" > "$tmpname" || { +${SED-sed} -e "s|^\(.*\)[@]configure_input[@]|\1$outname. Generated from $inname by configure.ac.\n\1!!!!!!! DO NOT MODIFY THIS FILE !!!!!!!!\n\1EDIT $inname INSTEAD AND RE-RUN autoreconf.|g" "$@" < "$inname" > "$tmqname" || { s="$?" - echo "$prog: Error running sed, exit code $s." - rm -f "$tmpname" + echo "$prog: Error running sed, exit code $s." >&2 + rm -f "$tmqname" exit 2 } -if grep '[@][A-Za-z0-9_-]\{1,\}@' "$tmpname" >&2; then +if grep '[@][A-Za-z0-9_-]\{1,\}@' "$tmqname" >&2; then echo "$prog: Unsubstituted values found while substituting $inname" >&2 - rm -f "$tmpname" + rm -f "$tmqname" exit 2 fi +tmpname="$outname.tmp.$$" + +${TR-tr} -d '\015' < "$tmqname" > "$tmpname" || { + s="$?" + echo "$prog: Error running tr, exit code $s" >&2 + rm -f "$tmqname" + exit 2 +} +rm -f "$tmqname" + if test -f "$outname"; then if ${CMP-cmp} "$outname" "$tmpname" > /dev/null; then # echo "$prog: source file up to date: $outname" >&2 diff --git a/buildstuff/sed-update-source-file b/buildstuff/sed-update-source-file index 3ac125a..4835f0d 100755 --- a/buildstuff/sed-update-source-file +++ b/buildstuff/sed-update-source-file @@ -23,14 +23,22 @@ test -f "$fname" || { } tname="$fname.tmp.$$" +qname="$fname.tmq.$$" +${SED-sed} "$@" < "$fname" > "$qname" || { + s="$?" + echo "$prog: Error running sed, exit code $s" >&2 + rm -f "$qname" + exit 2 +} -${SED-sed} "$@" < "$fname" > "$tname" || { +${TR-tr} -d '\015' < "$qname" > "$tname" || { s="$?" - echo "$prog: Error running sed, exit code $s." >&2 - rm -f "$tname" + echo "$prog: Error running tr, exit code $s" >&2 + rm -f "$qname" "$tname" exit 2 } +rm -f "$qname" test -s "$tname" || { echo "$prog: sed has produced an empty file" >&2 From 077891a38eb460e57543e8ae329a138eaabfc23e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 18:28:20 +0100 Subject: [PATCH 68/70] ci: msvc install stuff --- .github/workflows/build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ae9cc3..ce7a95a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -201,9 +201,10 @@ jobs: - name: "cm: build" run: cmake --build _build-cm --config ${{env.BUILD_TYPE}} --verbose - name: "cm: install" - run: cmake --build _build-cm --target install DESTDIR=$PWD/_dest-cm - - name: "cm: list installed files" - run: find _dest-cm | env LC_ALL=C sort | sed 's|^_dest-cm||' + run: cmake --build _build-cm --target install + + # This is running in powershell, not sh. Therefore find, env, + # sort do not work as usual. mingw: runs-on: windows-latest From d8b35d4ddc1458b211e3bfbc80f5eb24d135bf47 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 27 Feb 2024 19:41:35 +0100 Subject: [PATCH 69/70] Try windows builds without TR CRLF cleanups .gitattributes file might already work --- buildstuff/sed-substitute | 2 +- buildstuff/sed-update-source-file | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildstuff/sed-substitute b/buildstuff/sed-substitute index 1d074c8..737bf26 100755 --- a/buildstuff/sed-substitute +++ b/buildstuff/sed-substitute @@ -62,7 +62,7 @@ fi tmpname="$outname.tmp.$$" -${TR-tr} -d '\015' < "$tmqname" > "$tmpname" || { +cat < "$tmqname" > "$tmpname" || { s="$?" echo "$prog: Error running tr, exit code $s" >&2 rm -f "$tmqname" diff --git a/buildstuff/sed-update-source-file b/buildstuff/sed-update-source-file index 4835f0d..c076dd3 100755 --- a/buildstuff/sed-update-source-file +++ b/buildstuff/sed-update-source-file @@ -32,7 +32,7 @@ ${SED-sed} "$@" < "$fname" > "$qname" || { exit 2 } -${TR-tr} -d '\015' < "$qname" > "$tname" || { +cat < "$qname" > "$tname" || { s="$?" echo "$prog: Error running tr, exit code $s" >&2 rm -f "$qname" "$tname" From 34a8286d6675fab27f61838b1415f7b69349dff4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 28 Feb 2024 00:15:19 +0100 Subject: [PATCH 70/70] more CMakeLists.txt header --- CMakeLists.txt | 4 +++- CMakeLists.txt.in | 2 -- buildstuff/sed-substitute | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d35936..a948ec1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,9 @@ # ====================================================================== # CMakeLists.txt. Generated from CMakeLists.txt.in by configure.ac. +# ====================================================================== # !!!!!!! DO NOT MODIFY THIS FILE !!!!!!!! -# EDIT CMakeLists.txt.in INSTEAD AND RE-RUN autoreconf. +# ====================================================================== +# EDIT CMakeLists.txt.in INSTEAD AND RE-RUN autoreconf/autogen.sh # ====================================================================== cmake_minimum_required(VERSION 3.14) diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 590cf0c..9bcb925 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -1,6 +1,4 @@ -# ====================================================================== # @configure_input@ -# ====================================================================== cmake_minimum_required(VERSION 3.14) diff --git a/buildstuff/sed-substitute b/buildstuff/sed-substitute index 737bf26..e17bab5 100755 --- a/buildstuff/sed-substitute +++ b/buildstuff/sed-substitute @@ -47,7 +47,7 @@ esac tmqname="$outname.tmq.$$" -${SED-sed} -e "s|^\(.*\)[@]configure_input[@]|\1$outname. Generated from $inname by configure.ac.\n\1!!!!!!! DO NOT MODIFY THIS FILE !!!!!!!!\n\1EDIT $inname INSTEAD AND RE-RUN autoreconf.|g" "$@" < "$inname" > "$tmqname" || { +${SED-sed} -e "s|^\(.*\)[@]configure_input[@]|\1======================================================================\n\1$outname. Generated from $inname by configure.ac.\n\1======================================================================\n\1!!!!!!! DO NOT MODIFY THIS FILE !!!!!!!!\n\1======================================================================\n\1EDIT $inname INSTEAD AND RE-RUN autoreconf/autogen.sh\n\1======================================================================|g" "$@" < "$inname" > "$tmqname" || { s="$?" echo "$prog: Error running sed, exit code $s." >&2 rm -f "$tmqname"